Created
February 28, 2025 14:22
-
-
Save Magnus167/37bd9f0e4eee082fb0e60a895729a990 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# Create sample dataframes for demonstration | |
DF_CALC = pd.DataFrame( | |
{ | |
"Name": ["USD_EQXR", "GBP_EQXR", "EUR_CDS", "JPY_CDS", "GOLD_PRICE"], | |
"Status": [ | |
"Calc-Error", | |
"Late-Collection", | |
"GOOD", | |
"GOOD", | |
"Collect-Error", | |
], | |
"Error": [ | |
"Cannot div by zero", | |
"Data delayed, recalc to proceed", | |
"", | |
"", | |
"Series redacted", | |
], | |
} | |
) | |
DF_CALC_2 = pd.DataFrame( | |
{ | |
"Name": ["USD_EQXR", "GBP_EQXR", "EUR_CDS", "JPY_CDS", "GOLD_PRICE"], | |
"Status": ["GOOD", "GOOD", "GOOD", "GOOD", "Collect-Error"], | |
"Error": ["", "", "", "", "Series redacted"], | |
} | |
) | |
DF_COLLECT = pd.DataFrame( | |
{ | |
"Product": ["GBP_EQXR", "GOLD_PRICE"], | |
"Status": ["Collect-Error", "Collect-Error"], | |
"Provider": ["MB", "DS"], | |
"Underlying Series": ["gbp_usd_eqxr", "comex_gold_price"], | |
"Error": ["Source did not provide data", "Data not available"], | |
} | |
) | |
DF_COLLECT_2 = pd.DataFrame( | |
{ | |
"Product": [ "GOLD_PRICE"], | |
"Status": ["Collect-Error"], | |
"Provider": ["DS"], | |
"Underlying Series": ["comex_gold_price"], | |
"Error": [ "Data not available"], | |
} | |
) | |
def chart_page(): | |
st.title("Chart Page") | |
st.write("Here is a simple chart.") | |
data = pd.DataFrame(np.random.randn(20, 2), columns=["X", "Y"]) | |
st.line_chart(data) | |
def table_page(): | |
st.title("Table Page") | |
st.write("Multiple dataframes displayed in separate tabs.") | |
# Create sample dataframes for demonstration | |
df_calc, df_collect = DF_CALC, DF_COLLECT | |
# Create tabs for each dataframe | |
tab1, tab2 = st.tabs(["Calc-Errors", "Collect-Errors"]) | |
with tab1: | |
st.subheader("Calc-Errors") | |
st.dataframe(df_calc) | |
with tab2: | |
st.subheader("Products Data") | |
st.dataframe(df_collect) | |
def buttons_page(): | |
st.title("Buttons Page") | |
st.write("Here are some buttons with links.") | |
st.button( | |
"Macrosynergy Academy", | |
on_click=lambda: st.write( | |
"[Macrosynergy Academy](https://academy.macrosynergy.com)" | |
), | |
) | |
st.button( | |
"JPMaQS on JPMM", | |
on_click=lambda: st.write("[JPMaQS on JPMM](https://www.jpmm.com/#jpmaqs)"), | |
) | |
st.button( | |
"Macrosynergy Package docs", | |
on_click=lambda: st.write( | |
"[Macrosynergy Package docs](https://docs.macrosynergy.com)" | |
), | |
) | |
def multi_charts_page(): | |
st.title("Multi-Chart Page") | |
st.write("Select a chart type from the dropdown.") | |
chart_type = st.selectbox( | |
"Select Chart Type", ["Line Chart", "Bar Chart", "Scatter Plot"] | |
) | |
data = pd.DataFrame(np.random.randn(20, 2), columns=["X", "Y"]) | |
if chart_type == "Line Chart": | |
st.line_chart(data) | |
elif chart_type == "Bar Chart": | |
st.bar_chart(data) | |
elif chart_type == "Scatter Plot": | |
# fig, ax = plt.subplots() | |
# ax.scatter(data["X"], data["Y"]) | |
# st.pyplot(fig) | |
st.scatter_chart(data) | |
def main(): | |
st.set_page_config(page_title="Multi-Page App", layout="wide") | |
st.sidebar.title("Navigation") | |
page = st.sidebar.radio("Go to", ["Chart", "Table", "Buttons", "Multi-Charts"]) | |
if page == "Chart": | |
chart_page() | |
elif page == "Table": | |
table_page() | |
elif page == "Buttons": | |
buttons_page() | |
elif page == "Multi-Charts": | |
multi_charts_page() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment