-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdash_common.py
More file actions
181 lines (169 loc) · 5.76 KB
/
Copy pathdash_common.py
File metadata and controls
181 lines (169 loc) · 5.76 KB
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
from dash import html
#import dash_html_components as html
import dash_core_components as dcc
import dash_bootstrap_components as dbc
import dashcore
import DB
def get_index_data():
prices = DB.get_index_prices()
divs = []
for k in prices.keys():
div = html.Div(
[
html.Div(
[
html.h3(k),
html.h4(prices[k]['price']),
],
),
html.Div(
[
html.h4(prices[k]['change']),
],
),
]
)
divs.append(
dbc.Button(children=div,
outline=True,
className="mr-1",
id=k,
size="lg",
style = {
'height': '100px',
'width' : '200px',
},
)
)
return dbc.ButtonGroup(divs)
def get_header():
PLOTLY_LOGO = "https://images.plot.ly/logo/new-branding/plotly-logomark.png"
header = html.Div(
[
html.Br([]),
html.Div(
[
html.Img(
src=PLOTLY_LOGO,
#src=app.get_asset_url("dash-financial-logo.png"),
className="logo",
#height="40px",
style={
'height': '100px',
'float': 'left'
},
),
#html.H2(
# "Stock Analyser",
# style={'marginTop': 20, 'marginBottom': 20}
#),
html.H2('Stock Analyser',
style={'display': 'inline',
'float': 'left',
'font-size': '2.65em',
'margin-left': '7px',
'font-weight': 'bolder',
'font-family': 'Product Sans',
'color': "rgba(117, 117, 117, 0.95)",
'margin-top': '20px',
'margin-bottom': '0'
}
),
],
className="row",
),
html.Div(
[
get_index_data(),
#html.Div(
# [html.H5("Calibre Financial Index Fund Investor Shares")],
# className="seven columns main-title",
#),
#html.Div(
# [
# dcc.Link(
# "Full View",
# href="/dash-financial-report/full-view",
# className="full-view-link",
# )
# ],
# className="five columns",
#),
],
className="twelve columns",
style={"padding-left": "0"},
),
],
className="row",
)
return header
def get_menu():
menu = html.Div(
[
dcc.Link(
"Overview",
href="/dash-financial-report/overview",
className="tab first",
),
dcc.Link(
"Price Performance",
href="/dash-financial-report/price-performance",
className="tab",
),
dcc.Link(
"Portfolio & Management",
href="/dash-financial-report/portfolio-management",
className="tab",
),
dcc.Link(
"Fees & Minimums", href="/dash-financial-report/fees", className="tab"
),
dcc.Link(
"Distributions",
href="/dash-financial-report/distributions",
className="tab",
),
dcc.Link(
"News & Reviews",
href="/dash-financial-report/news-and-reviews",
className="tab",
),
],
className="row all-tabs",
)
return menu
def get_search_bar(db):
search_bar = dbc.Row(
[
dbc.Col(dbc.Input(id=db.com['sym']['input'],
type="search",
list=db.com['sym']['suggest'],
placeholder="Enter a Stock Symbol",
size='30',
value=''
)),
dbc.Col(
dbc.Button("Search",
color="primary",
className="ml-2",
id=db.com['sym']['button']
),
width="auto",
),
],
no_gutters=True,
className="ml-auto flex-nowrap mt-3 mt-md-0",
align="center",
)
return search_bar
def Header(db):
return html.Div([get_header(), html.Br([]), get_search_bar(db)])
def make_dash_table(df):
""" Return a dash definition of an HTML table for a Pandas dataframe """
table = []
for index, row in df.iterrows():
html_row = []
for i in range(len(row)):
html_row.append(html.Td([row[i]]))
table.append(html.Tr(html_row))
return table