Spaces:
				
			
			
	
			
			
		Configuration error
		
	
	
	
			
			
	
	
	
	
		
		
		Configuration error
		
	| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| """ | |
| Created on Tue Nov 2 10:06:46 2021 | |
| @author: benjaminull | |
| """ | |
| import pybase64 as base64 | |
| import io | |
| import streamlit as st | |
| from plotly import graph_objs as go | |
| def formatnum_0(numero): | |
| ''' | |
| Esta función permite dar formato a los montos de saldo y valor cuota en | |
| las cartolas. | |
| ''' | |
| return '{:,.0f}'.format(numero).replace(",", "@").replace(".", ",").replace("@", ".") | |
| def formatnum_2(numero): | |
| return '{:,.2f}'.format(numero).replace(",", "@").replace(".", ",").replace("@", ".") | |
| def macro_plot(col, data, color, prefijo, ancho, largo): | |
| fig = go.Figure() | |
| close_ = go.Scatter(x=data.index, y=data['Close'], name="stock_close", | |
| line=dict(color=color), fill='tonexty') | |
| fig.add_trace(close_) | |
| fig.layout.update(title_text="", xaxis_rangeslider_visible=True, | |
| width=ancho, height=largo, margin_b=0, margin_t=0, | |
| margin_r=0, margin_l=0) | |
| fig.update_yaxes(range=[min(data['Close'])/1.05, | |
| max(data['Close'])*1.05], tickprefix=prefijo) | |
| col.plotly_chart(fig, use_container_width=True) | |
| def get_table_excel_link(df, name): | |
| towrite = io.BytesIO() | |
| downloaded_file = df.to_excel(towrite, encoding='utf-8', index=False, | |
| header=True) | |
| towrite.seek(0) # reset pointer | |
| file_name = 'Data' + name + '.xlsx' | |
| style = 'style="color:black;text-decoration: none; font-size:18px;"' | |
| name_mark = "Descargar " + name + ".xlsx" | |
| b64 = base64.b64encode(towrite.read()).decode() # some strings | |
| linko= f'<center><a href="data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,{b64}" '+style+'download="'+file_name+'"><button>'+name_mark+'</button></a></center>' | |
| return linko | |
| def selectbox_larra(label, options): | |
| var = st.selectbox(label, sorted(list(set(options)))) | |
| return var | |
| def style_table(): | |
| style_table = """ | |
| <style> | |
| tbody tr:hover { | |
| color:#BB1114;} | |
| thead { | |
| background-color:#BB1114 ; | |
| color: #E8E8E8; | |
| } | |
| tbody tr:nth-child(odd) { | |
| background-color: #fff; | |
| } | |
| tbody tr:nth-child(even) { | |
| background-color: #eee; | |
| } | |
| tbody tr:nth-child(odd) | |
| stTable { | |
| border-collapse: collapse; | |
| margin: 25px 0; | |
| font-size: 0.9em; | |
| min-width: 400px; | |
| box-shadow: 0 0 20px rgba(0, 0, 0, 0.15); | |
| } | |
| </style> | |
| """ | |
| st.markdown(style_table, unsafe_allow_html=True) | |
| def button_style(): | |
| style_button = """ | |
| <style> | |
| button { | |
| display: inline-block; | |
| background-color: #e8e8e8; | |
| border-radius: 15px; | |
| border: 4px #cccccc; | |
| color: #4a4a4a; | |
| text-align: center; | |
| font-size: 18px; | |
| padding: 2px; | |
| width: 300px; | |
| transition: all 0.5s; | |
| cursor: pointer; | |
| margin: 5px; | |
| } | |
| button span { | |
| cursor: pointer; | |
| display: inline-block; | |
| position: relative; | |
| transition: 0.5s; | |
| } | |
| button span:after { | |
| content: '\00bb'; | |
| position: absolute; | |
| opacity: 0; | |
| top: 0; | |
| right: -20px; | |
| transition: 0.5s; | |
| } | |
| button:hover { | |
| background-color: #bb1114; | |
| color:#e8e8e8; | |
| } | |
| button:hover span { | |
| padding-right: 25px; | |
| } | |
| button:hover span:after { | |
| opacity: 1; | |
| right: 0; | |
| } | |
| </style> | |
| """ | |
| st.markdown(style_button, unsafe_allow_html=True) |