Spaces:
Sleeping
Sleeping
Download visualization/prices.py from MinsaitEU/VaR_model: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/spaces/MinsaitEU/VaR_model/resolve/main/visualization/prices.py
- Command line
-
hf download hf://spaces/MinsaitEU/VaR_model/visualization/prices.py
-
curl -L -o prices.py https://huggingface.co/spaces/MinsaitEU/VaR_model/resolve/main/visualization/prices.py
1.26 kB
| import plotly.graph_objects as go | |
| def plot_prices(prices): | |
| fig = go.Figure() | |
| for column in prices.columns: | |
| fig.add_trace( | |
| go.Scatter( | |
| x=prices.index, | |
| y=prices[column], | |
| mode="lines", | |
| name=column, | |
| ) | |
| ) | |
| fig.update_layout( | |
| title="Historical Prices", | |
| xaxis_title="Date", | |
| yaxis_title="Price", | |
| template="plotly_white", | |
| hovermode="x unified", | |
| ) | |
| return fig | |
| def plot_normalized_prices(prices): | |
| normalized = ( | |
| prices | |
| / prices.iloc[0] | |
| * 100 | |
| ) | |
| fig = go.Figure() | |
| for column in normalized.columns: | |
| fig.add_trace( | |
| go.Scatter( | |
| x=normalized.index, | |
| y=normalized[column], | |
| mode="lines", | |
| name=column, | |
| ) | |
| ) | |
| fig.add_hline( | |
| y=100, | |
| line_dash="dash", | |
| ) | |
| fig.update_layout( | |
| title="Normalized Prices", | |
| xaxis_title="Date", | |
| yaxis_title="Normalized Price (Start = 100)", | |
| template="plotly_white", | |
| hovermode="x unified", | |
| ) | |
| return fig |