|
7 | 7 | import pandas as pd
|
8 | 8 | import plotly.graph_objects as go
|
9 | 9 | import plotly.express as px
|
| 10 | +import plotly |
10 | 11 |
|
11 | 12 | from src.apps.treasury.util.constants import BCT_ERC20_CONTRACT
|
12 | 13 | from src.apps.treasury.data.protocol_metrics import \
|
|
22 | 23 | # last_metric_df = sg.query_df([last_metric.marketCap, last_metric.treasuryMarketValue, ...])
|
23 | 24 |
|
24 | 25 | # Market Cap indicator
|
25 |
| -mc_fig = go.Figure( |
| 26 | +metric_fig = go.Figure( |
26 | 27 | go.Indicator(
|
27 | 28 | mode="number",
|
28 | 29 | value=sg.query([last_metric.marketCap]),
|
29 | 30 | number={"prefix": "$", "valueformat": ".2s"},
|
30 | 31 | title={"text": "Market Cap"},
|
31 |
| - domain={'y': [0, 1], 'x': [0.25, 0.75]} |
32 |
| - ) |
| 32 | + domain={'y': [0, 0.5], 'x': [0.25, 0.75]} |
| 33 | + ), |
33 | 34 | )
|
34 | 35 |
|
35 |
| -# Net Asset Value / Total Treasury Value ($) indicator |
36 |
| -nav_fig = go.Figure( |
| 36 | +metric_fig.add_trace( |
| 37 | + # Net Asset Value / Total Treasury Value ($) indicator |
37 | 38 | go.Indicator(
|
38 | 39 | mode="number",
|
39 | 40 | value=sg.query([last_metric.treasuryMarketValue]),
|
40 | 41 | number={"prefix": "$", "valueformat": ".2s"},
|
41 | 42 | title={"text": "Net Asset Value"},
|
42 |
| - domain={'y': [0, 1], 'x': [0.25, 0.75]} |
| 43 | + domain={'y': [0.5, 1], 'x': [0.25, 0.75]} |
43 | 44 | )
|
44 | 45 | )
|
45 | 46 |
|
|
116 | 117 | {"bucket": "Treasury Holdings", "value": treasury_value, "target": 0.48}
|
117 | 118 | ]
|
118 | 119 | green_ratio_df = pd.DataFrame.from_records(green_ratio_data)
|
| 120 | +order = [ |
| 121 | + 'Op Ex', 'Carbon Forwards', |
| 122 | + 'Carbon Backing', 'Treasury Holdings' |
| 123 | +] |
| 124 | + |
119 | 125 |
|
120 |
| -# TODO: style colors based on KIP |
121 | 126 | # TODO: style holdings as $xx.yy[m/k] (i.e. human-formatted like indicators)
|
122 | 127 | # TODO: visualize targets in some way
|
123 | 128 | # TODO: load targets from Google Sheet for ease of maintenance
|
|
129 | 134 | 'Carbon Forwards': '#6fff93',
|
130 | 135 | 'Carbon Backing': '#00cc33',
|
131 | 136 | 'Treasury Holdings': '#ddf641'
|
132 |
| - } |
| 137 | + }, |
| 138 | + category_orders={'bucket': order}, |
| 139 | + title="Green Ratio: Current", |
| 140 | +) |
| 141 | +green_ratio_fig.update_layout( |
| 142 | + title_x=0.5, |
| 143 | + legend=dict( |
| 144 | + yanchor='bottom', |
| 145 | + y=-.5, |
| 146 | + xanchor='auto', |
| 147 | + x=.5 |
| 148 | + ) |
133 | 149 | )
|
134 | 150 |
|
135 |
| -# target_indicators = |
| 151 | +green_ratio_target_fig = px.pie( |
| 152 | + green_ratio_df, values="target", |
| 153 | + names="bucket", hole=.3, color="bucket", |
| 154 | + color_discrete_map={ |
| 155 | + 'Op Ex': '#f2ae00', |
| 156 | + 'Carbon Forwards': '#6fff93', |
| 157 | + 'Carbon Backing': '#00cc33', |
| 158 | + 'Treasury Holdings': '#ddf641' |
| 159 | + }, |
| 160 | + category_orders={'bucket': order}, |
| 161 | + title="Green Ratio: Target", |
| 162 | +) |
| 163 | +green_ratio_target_fig.update_layout( |
| 164 | + title_x=0.5, |
| 165 | + legend=dict( |
| 166 | + yanchor='bottom', |
| 167 | + y=-.5, |
| 168 | + xanchor='auto', |
| 169 | + x=.5 |
| 170 | + ) |
| 171 | +) |
136 | 172 |
|
137 | 173 | layout = dbc.Container([
|
138 | 174 | html.Div([
|
139 | 175 | dbc.Row([
|
140 | 176 | dbc.Col([
|
141 |
| - dcc.Graph(figure=mc_fig) |
142 |
| - ], xs=12, sm=12, md=12, lg=3, xl=3), |
143 |
| - dbc.Col([ |
144 |
| - dcc.Graph(figure=nav_fig) |
145 |
| - ], xs=12, sm=12, md=12, lg=3, xl=3), |
| 177 | + dcc.Graph(figure=metric_fig) |
| 178 | + ], xs=12, sm=12, md=12, lg=4, xl=4), |
146 | 179 | dbc.Col([
|
147 | 180 | dcc.Graph(figure=green_ratio_fig)
|
148 |
| - ], xs=12, sm=12, md=12, lg=6, xl=6), |
| 181 | + ], xs=12, sm=6, md=6, lg=4, xl=4), |
| 182 | + dbc.Col([ |
| 183 | + dcc.Graph(figure=green_ratio_target_fig) |
| 184 | + ], xs=12, sm=6, md=6, lg=4, xl=4) |
149 | 185 | ]),
|
150 | 186 | ], className='center'),
|
151 | 187 | ], id='page_content_hud', fluid=True)
|
0 commit comments