-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.py
293 lines (257 loc) · 12.7 KB
/
app.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
import dash
import dash_bootstrap_components as dbc
from dash import dcc
from dash import html
from dash.dependencies import Input, Output, State
from dash_bootstrap_templates import load_figure_template
from utils.styles import CONTENT_INTRO, CONTENT_STYLE
dbc_css = "https://cdn.jsdelivr.net/gh/AnnMarieW/[email protected]/dbc.min.css"
app = dash.Dash(__name__,
external_stylesheets=[dbc.themes.SPACELAB, dbc_css],
meta_tags=[{'name': 'viewport',
'content': 'width=device-width,initial-scale=1.0'}],
use_pages=True,
)
server = app.server
load_figure_template("lux")
title = html.H1(children="Yield Curves Visualization",
className='text-center mt-4',
style={'fontSize': 30})
# Modal
with open("learn_more.md", "r") as f:
howto_md = f.read()
modal_overlay = dbc.Modal(
[
dbc.ModalBody(html.Div([dcc.Markdown(howto_md)], id="howto-md")),
dbc.ModalFooter(dbc.Button("Close", id="howto-close", className="howto-bn")),
],
id="modal",
size="lg",
)
button_howto = dbc.Button(
"Learn More",
id="howto-open",
outline=True,
color="info",
# Turn off lowercase transformation for class .button in stylesheet
style={"textTransform": "none"},
)
button_github = dbc.Button(
"GitHub Repository",
outline=True,
color="primary",
href="https://github.com/quantgirluk/Yield-Curves-Visual",
id="gh-link",
style={"text-transform": "none"},
)
# Header
header = dbc.Navbar(
dbc.Container(
[
dbc.Row(
[
dbc.Col(
# html.Img(
# id="logo",
# src=app.get_asset_url("dash-logo-new.png"),
# height="30px",
# ),
# md="auto",
),
dbc.Col(
[
html.Div(
[
html.H4("Yield Curves Visualisation"),
html.P(dcc.Markdown("By [Dialid Santiago](https://quantgirl.blog)"))
],
id="app-title",
)
],
md="auto",
align="center",
),
],
align="center",
),
dbc.Row(
[
dbc.Col(
[
dbc.NavbarToggler(id="navbar-toggler"),
dbc.Collapse(
dbc.Nav(
[
dbc.NavItem(button_howto),
dbc.NavItem(button_github),
],
navbar=True,
),
id="navbar-collapse",
navbar=True,
),
modal_overlay,
],
# md=2,
),
],
align="center",
),
],
fluid=True,
),
dark=False,
# color="dark",
# sticky="top",
)
# Description
description = dbc.Col(
[
dbc.Card(
id="description-card",
children=[
dbc.CardHeader("Explanation"),
dbc.CardBody(
[
dbc.Row(
[
dbc.Col(
[
html.Img(
src="assets/segmentation_img_example_marks.jpg",
width="200px",
)
],
md="auto",
),
dbc.Col(
html.P(
"This is an example of interactive machine learning for image classification. "
"To train the classifier, draw some marks on the picture using different "
"colors for "
'different parts, like in the example image. Then enable "Show segmentation" '
'to see the '
"classes a Random Forest Classifier gave to regions of the image, based on the "
"marks you "
"used as a guide. You may add more marks to clarify parts of the image where "
"the "
"classifier was not successful and the classification will update."
),
md=True,
),
]
),
]
),
],
)
],
md=12,
)
app.layout = html.Div(children=[header,
dbc.Container(
dbc.Row([html.Div(id='yield-curve-101',
children=[
dcc.Markdown('''
---
**Yield Curve 101**
The yield curve shows how much it costs the federal
government to borrow money
for a given amount of time, revealing the relationship between long- and short-term
interest rates.
It is, inherently, a forecast for what the economy holds in the
future — how much inflation there will be, for example, and how healthy growth will
be over the years ahead — all embodied in the price of money today, tomorrow and
many years from now.
— *The New York Times (2015)*.
---
''')
],
className='text-justify mt-4', style={'fontSize': 15})
]),
fluid=True,
style=CONTENT_INTRO,
class_name="dbc"
),
dbc.Row([html.Div(id='button',
children=[dbc.Button(page['name'],
href=page['path'],
outline=True,
color='dark',
className="me-1")
for page in dash.page_registry.values()
],
className='text-center mt-4 mb-4', style={'fontSize': 10})
]),
dbc.Spinner(
dash.page_container,
fullscreen=True,
show_initially=True,
delay_hide=600,
type='grow',
spinner_style={"width": "3rem", "height": "3rem"}),
html.Br(),
dbc.Container(
dbc.Row([html.Div(id='text-container1',
children=[dcc.Markdown('''
If you like this project, please give it a star
in [GitHub](https://github.com/quantgirluk/Yield-Curves-Visual) ⭐️
''')
],
className='text-center mt-4', style={'fontSize': 15})
]),
fluid=True,
style=CONTENT_INTRO,
class_name="dbc"
),
dbc.Container(
dbc.Row([html.Div(id='about-me',
children=[
dcc.Markdown('''
---
### About Me
Hello, my name is [Dialid](https://quantgirl.blog/about-me/). I am a
Mathematician and a Finance Quantitative Analyst based in London. I create
open source projects and write about financial mathematics, programming,
statistics, data visualisation, and related topics.
I have over 8 years of experience working as a Quant. Currently, I am
working in the Cross-Asset front office quant team at Bank of America.
My previous experience includes the development and implementation of
mathematical models for Counterparty Credit Risk, Market Risk, and Wholesale
Credit Risk, as well as Validation in Retail Credit Risk.
I hold a PhD in Mathematics/Statistics from the University of Warwick where
I spent 4 amazing years focusing on non-linear stochastic processes.
Before coming to the UK, I obtained an MSc in Probability and Statistics,
and a BSc in Applied Mathematics in Mexico.
I regularly write about diverse topics [here](https://quantgirl.blog).
Connect with me via:
- 🦜 [Twitter](https://twitter.com/Quant_Girl)
- 👩🏽💼 [Linkedin](https://www.linkedin.com/in/dialidsantiago/)
- 📸 [Instagram](https://www.instagram.com/quant_girl/)
- 👾 [Personal Website](https://quantgirl.blog)
Thanks for visiting ✨
''')
],
className='text-justify mt-4 mb-4', style={'fontSize': 15})
]),
fluid=True,
style=CONTENT_INTRO,
class_name="dbc"
),
])
# Callback for modal popup
@app.callback(
Output("modal", "is_open"),
[Input("howto-open", "n_clicks"), Input("howto-close", "n_clicks")],
[State("modal", "is_open")],
)
def toggle_modal(n1, n2, is_open):
if n1 or n2:
return not is_open
return is_open
if __name__ == '__main__':
server = app.server
app.run_server(debug=False,
host='0.0.0.0',
port=10000
)