#ABMPC-TEST import streamlit as st import pandas as pd import plotly.graph_objects as go # Must be called first. st.set_page_config( layout="wide", # 'centered' or 'wide' page_title='ABMPC-TEST', menu_items={ 'About': "A shareable data application. https://www.giltedged.systems" } ) header = st.container() dataset = st.container() body = st.container() footer = st.container() with header: # st.title("Agent-Based Model Portfolio Choice: Test Ouput") col1, col2 = st.columns(2) with col1: st.title("Agent-Based Model Portfolio Choice") st.subheader("Test Ouput") with col2: st.info("[GiltEdged.systems/early-models/abmpc](https://www.giltedged.systems/early-models/abmpc)") with dataset: data_url = ('https://www.data-reports.net/model-output/abmpc-test/abmpc-test-01.csv') # @st.cache_data def load_data(steps): data = pd.read_csv(data_url, nrows=steps) return data with body: with st.expander("See The Puzzling Impact of Interest Rates"): st.write("'.. It follows, in contrast to what most students of principles of economics are taught, that higher interest rates generate more economic activity, not less. Unless high interest rates have a detrimental impact on some components of aggregate demand.' G&L, Chapter 4, p.114") st.write("**G&L continue:** '.. The fall in bond prices induces an immediate reduction in wealth. Interest rates have a big effect on asset prices and this is one of the main conduits for monetary policy - working in the conventional way. A rise in interest rates reduces demand for a time in model LP this is achieved by a reduction in consumption expenditures, with a lag, through the reduction in the wealth term that appears in the consumption function. And this puts the earlier unconventional result of Chapter 4 into a proper perspective. Model LP shows that interest rate increases do have a negative effect on real demand, but this negative effect is only a temporary one (which may still last for quite a long time). In a longer period, the effect of higher interest rates is positive as we have said before.' G&L, Chapter 5, p.151") st.caption("G&L: Godley, W & Lavoie, M, Monetary Economics: An Integrated Approach to Credit, Money, Income, Production and Wealth.") # st.divider() col1, col2, col3, col4 = st.columns(4) col1.metric("Model Steps", "170") col2.metric("Expenditure", "20 Units", "Every Step", delta_color="off") col3.metric("Interest Rate Environment", "0% to 1.25%") col4.metric("Taxation", "20%", "Flat Rate", delta_color="off") colA, colB = st.columns([2,3], gap="large") with colA: stepsDefault = 170 # Default number of steps to show. steps = st.slider("Model Steps", min_value=1, max_value=170, value=stepsDefault, step=2) with colB: option = st.selectbox( 'Model Interest Rate:', ('0% Interest-Bearing Bills', '0.75% Interest-Bearing Bills', '0.75% to 1.25% Interest-Bearing Bills (@Step 90)', '1.25% to 0.75% Interest-Bearing Bills (@Step 90)', '0.75% Interest-Bearing Bills (Multiple Agents: 1 Producer, 3 Households)')) if option == "0% Interest-Bearing Bills": data_url = "https://www.data-reports.net/model-output/abmpc-test/abmpc-test-run-01.csv" elif option == "0.75% Interest-Bearing Bills": data_url = "https://www.data-reports.net/model-output/abmpc-test/abmpc-test-run-02.csv" elif option == "0.75% to 1.25% Interest-Bearing Bills (@Step 90)": data_url = "https://www.data-reports.net/model-output/abmpc-test/abmpc-test-run-03.csv" elif option == "1.25% to 0.75% Interest-Bearing Bills (@Step 90)": data_url = "https://www.data-reports.net/model-output/abmpc-test/abmpc-test-run-04.csv" elif option == "0.75% Interest-Bearing Bills (Multiple Agents: 1 Producer, 3 Households)": data_url = "https://www.data-reports.net/model-output/abmpc-test/abmpc-test-run-05.csv" # Load data. df = load_data(steps) def display_chart(): dff = df goFig = go.Figure() goFig.add_trace(go.Scatter(x=dff.Step, y=dff.national_income, mode='lines', name='National Income' )) goFig.add_trace(go.Scatter(x=dff.Step, y=dff.disposable_income, mode='lines', name='Disposable Income' )) goFig.add_trace(go.Scatter(x=dff.Step, y=dff.consumption, mode='lines', name='Consumption' )) goFig.add_trace(go.Scatter(x=dff.Step, y=dff.bills_issued, mode='lines', name='Bills Issued' )) goFig.add_trace(go.Scatter(x=dff.Step, y=dff.fiscal_balance, mode='lines', name='Fiscal Balance' )) goFig.update_layout( margin=dict(l=50,r=40,b=40,t=40), height=700, template="plotly_dark", xaxis_title="Model Steps", xaxis_tickfont_size=14, yaxis=dict( title='Monetary Units', ), showlegend=True, legend_title="Macro Indicators", title=go.layout.Title( text="Model Run: " + option, xref="paper", x=0 ) ) st.plotly_chart(goFig, use_container_width=True) display_chart() with footer: st.markdown("---") st.caption("Visit the [GiltEdged.systems](https://www.www.giltedged.systems) website.")