-
-
Notifications
You must be signed in to change notification settings - Fork 367
/
dashboard.py
178 lines (146 loc) Β· 8.88 KB
/
dashboard.py
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
"""Dashboard Module"""
import streamlit as st
from app import helpers, initalization_model, metrics_view, socials_model
st.set_page_config(page_title="Finance Toolkit Dashboard", page_icon="π οΈ", layout="wide")
st.session_state = initalization_model.initalize_session_state(st.session_state)
if "is_expanded" not in st.session_state:
st.session_state["is_expanded"] = True
if st.session_state["invalid_api_key"]:
helpers.load_css("app/assets/style.css")
st.session_state["welcome_msg"].markdown(
body="""
## Welcome to the Finance Toolkit Dashboard! π
This dashboard is powered by the Finance Toolkit, an open-source toolkit in which 200+ relevant financial ratios,
indicators and performance measurements are written down in the most simplistic way allowing for complete
transparency of the method of calculation. Once you've entered you're API key you are ready to go!
The key features of this dashboard are as follows:
- π’ Compare a small or large selection of tickers for any period (10+ years for Premium users, max 5 years for
Free users).
- π Plot any item from the Financial Statements, e.g. Shareholder's Equity from the Balance Sheet, Revenue from
the Income Statement and Operating Cash Flow from the Cash Flow Statement.
- πΈ Compare 150+ financial ratios, technical indicators, performance metrics and risk metrics.
- π Show quarterly results, growth rates, trailing twelve months (TTM) as well as tables (with the option
to download the data)
Find below a demonstration of what is possible once you have entered your API key.
"""
)
st.session_state["intro_video"].video(
"app/assets/financetoolkit-dashboard.mov",
autoplay=True,
muted=True,
start_time=3,
end_time=66,
)
st.session_state["mobile_user"].markdown(
"""
<div class="mobile-only"><h3>π± Mobile Users</h3><b>Given that you are viewing this page on mobile,
please open the sidebar (arrow in the top left) to get started! Once you've entered your API key it
should automatically proceed.</b></div>
""",
unsafe_allow_html=True,
)
st.session_state = initalization_model.create_api_key_sidebar(st.session_state)
if "perform_initalization" not in st.session_state:
st.session_state["perform_initalization"] = False
if not st.session_state["invalid_api_key"]:
st.session_state["welcome_msg"].empty()
st.session_state["intro_video"].empty()
st.session_state["mobile_user"].empty()
st.title("π οΈ Finance Toolkit")
st.markdown(
"""
The Finance Toolkit is an open-source toolkit in which 200+ relevant financial ratios, indicators and
performance measurements are written down
in the most simplistic way allowing for complete transparency of the method of calculation. This enables
you to avoid dependence on metrics
from other providers that do not provide their methods. With a large selection of financial statements
in hand, it facilitates
streamlined calculations, promoting the adoption of a consistent and universally understood methods and formulas.
**See the explanation section for more information how to use this dashboard and look at the configurations
section to get started!**
"""
)
with st.expander("Explanation", expanded=False):
st.markdown(
unsafe_allow_html=True,
body="""
Within the configurations sections you have the following options:
- **Stock Ticker**: you can select out over 30.000 companies. You can select any amount
of tickers here to collect data from. These tickers will be plotted together in a graph once you press the button.
If you are looking for foreign exchanges (outside of the US) you can enable the toggle to show these. Note
that this only applies for Premium users.
- **Start Date & End Date**: you can select the start and end date for the data you want to collect, when you have
a Premium plan this defaults to 10 years, for the Free plan this defaults to 5 years (maximum period).
- **Metrics:** this includes a wide variety of metrics from the Finance Toolkit. You can select any amount
of metrics here which will be plotted in individual graphs.
- **Quarterly Toggle**: this toggle allows you to switch between quarterly and annual data.
- **Twelve Trailing Months (TTM)**: this toggle allows you to calculate the Twelve Trailing Months values,
available when using quarterly data.
- **Growth Rates**: this toggle allows you to calculate the growth rates (percentage change) of the data.
- **Include Table**: this toggle allows you to include a table with the plotted data, this also allows
you to download the data to a CSV file.
The list below features all available metrics from the Finance Toolkit. In brackets, you will find the
abbreviation to identify the respective type of metric.
- **BS** (Balance Sheet Statement) includes all assets, liabilities, and equity items of a company.
- **IS** (Income Statement) includes all revenue, expenses, and profit items of a company.
- **CF** (Cash Flow Statement) includes all cash inflows and outflows of a company.
- **FR** (Financial Ratios) includes all financial ratios that can be calculated from the financial statements.
- **MD** (Market Data) includes all market data such as adjusted close, cumulative return, and more.
- **PF** (Performance Metrics) includes all performance metrics such as Sharpe ratio, Sortino ratio, and more.
- **RI** (Risk Metrics) includes all risk metrics such as Value at Risk, Conditional Value at Risk, and more.
- **TI** (Technical Indicators) includes all technical indicators such as Moving Averages, RSI, and more.
Once you have selected all the configurations you can press the **Collect Data** button to collect data and plot
(and show tables) according to your selections. You can always change the configurations and press the button
again to update the plots.
*It's good to note that data is saved and won't be collected again when this is not required.* You can change
up the metrics or enable the growth, TTM or table toggle without needing to recollect data. However, if you
change the tickers, date range or quarterly toggle the dashboard will collect data again. This is however
relatively quick!
<span style="font-size:0.7em;">
<b>DISCLAIMER</b><br>
Please note that I am not a part of FinancialModelingPrep, the data provider used. I've merely picked them as the
primary data provider given that they have a generous free tier and fair pricing compared to other providers.
Therefore, any questions related to the data should go through
<a href="https://site.financialmodelingprep.com/contact">their contact form</a>.
When it comes to any type of ratios, performance metrics, risk metrics, technical indicators or other indicators,
feel free to reach out to me as this is my own work.
</span>
""",
)
with st.expander("Configurations", expanded=True):
# Initialize the sidebar which includes the ticker selection, start and end date selection and the
# financial metric selection
st.session_state = initalization_model.create_configurations_section(
st.session_state
)
if st.session_state["collect_data"]:
# Collect all historical data required to perform all calculations within
# the Finance Toolkit based on the input from the sidebar
st.session_state = initalization_model.initalize_financetoolkit(
st.session_state
)
st.header("Results", divider="green")
if not st.session_state["tickers"]:
st.toast("Please select at least one ticker to collect data.", icon="βοΈ")
else:
with st.spinner("Collecting data.."):
if len(st.session_state["metrics_list"]) > 0:
st.session_state["financetoolkit"] = metrics_view.plot_data(
variables=st.session_state["metrics_list"],
finance_toolkit=st.session_state["financetoolkit"],
include_table=st.session_state["include_table"],
growth=st.session_state["growth_rates"],
trailing=st.session_state["ttm_rates"],
)
st.session_state["perform_initalization"] = False
st.markdown(
"""
<style>
section[data-testid="stSidebar"][aria-expanded="true"]{
display: none;
}
</style>
""",
unsafe_allow_html=True,
)
socials_model.create_socials_sidebar()