| import streamlit as st |
| import requests |
| import pandas as pd |
| from bs4 import BeautifulSoup |
| import urllib3 |
|
|
| |
| st.set_page_config(page_title="Monitor Cambiario", page_icon="馃搱", layout="centered") |
|
|
| |
| urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) |
|
|
| def get_data(): |
| |
| try: |
| url_crypto = "https://criptoya.com/api/USDT/VES/0.1" |
| res_crypto = requests.get(url_crypto) |
| data_crypto = res_crypto.json() |
| usdt_price = data_crypto['binancep2p']['totalAsk'] |
| except: |
| usdt_price = 0 |
|
|
| |
| try: |
| url_bcv = "https://www.bcv.org.ve" |
| |
| headers = {'User-Agent': 'Mozilla/5.0'} |
| res_bcv = requests.get(url_bcv, headers=headers, verify=False) |
| soup = BeautifulSoup(res_bcv.text, 'html.parser') |
| |
| |
| dolar = float(soup.find(id="dolar").find("strong").text.strip().replace(',', '.')) |
| euro = float(soup.find(id="euro").find("strong").text.strip().replace(',', '.')) |
| except: |
| dolar, euro = 0, 0 |
|
|
| return usdt_price, dolar, euro |
|
|
| |
| st.title("馃搳 Monitor de Divisas") |
| st.markdown(f"**脷ltima actualizaci贸n:** {pd.Timestamp.now().strftime('%d/%m/%Y %H:%M:%S')}") |
|
|
| usdt, usd_bcv, eur_bcv = get_data() |
|
|
| |
| col1, col2, col3 = st.columns(3) |
|
|
| with col1: |
| st.metric(label="USDT (Binance)", value=f"{usdt:.2f} VES") |
|
|
| with col2: |
| st.metric(label="D贸lar BCV", value=f"{usd_bcv:.2f} VES") |
|
|
| with col3: |
| st.metric(label="Euro BCV", value=f"{eur_bcv:.2f} VES") |
|
|
| st.divider() |
|
|
| |
| st.subheader("馃挕 An谩lisis de Compra") |
|
|
| |
| compra_sugerida = usdt - (usdt * 0.10) |
|
|
| c1, c2 = st.columns(2) |
| with c1: |
| st.info(f"**Precio USDT:** {usdt:.2f}") |
| st.success(f"**Sugerencia de compra (-10%):** {compra_sugerida:.2f} VES") |
|
|
| with c2: |
| |
| brecha = ((usdt / usd_bcv) - 1) * 100 if usd_bcv > 0 else 0 |
| st.warning(f"**Brecha Cambiaria:** {brecha:.2f}%") |
|
|
| |
| st.subheader("馃摑 Resumen de Datos") |
| df_mostrar = pd.DataFrame({ |
| "Moneda": ["USDT", "BCV $", "BCV Euro"], |
| "Monto (VES)": [usdt, usd_bcv, eur_bcv] |
| }) |
| st.table(df_mostrar) |
|
|
| if st.button('馃攧 Actualizar Precios'): |
| st.rerun() |
|
|