File size: 5,556 Bytes
fb04818
 
 
 
 
 
 
 
 
 
49917e9
fb04818
 
 
 
 
 
 
 
 
928b2f0
fb04818
 
 
928b2f0
 
fb04818
 
49917e9
fb04818
 
48a8ddb
fb04818
 
 
 
 
 
 
928b2f0
 
 
 
 
fb04818
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
456fd7e
fb04818
456fd7e
fb04818
456fd7e
fb04818
456fd7e
fb04818
456fd7e
fb04818
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f435de8
fb04818
 
 
 
 
49917e9
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
#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.")