Spaces:
Configuration error
Configuration error
File size: 4,020 Bytes
025632f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
#!/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) |