Spaces:
Sleeping
Sleeping
Download visualization/simulation.py from MinsaitEU/VaR_model: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/spaces/MinsaitEU/VaR_model/resolve/main/visualization/simulation.py
- Command line
-
hf download hf://spaces/MinsaitEU/VaR_model/visualization/simulation.py
-
curl -L -o simulation.py https://huggingface.co/spaces/MinsaitEU/VaR_model/resolve/main/visualization/simulation.py
1.15 kB
| import plotly.graph_objects as go | |
| def plot_simulated_shocks( | |
| shocks, | |
| columns, | |
| ): | |
| fig = go.Figure() | |
| for i, column in enumerate(columns): | |
| fig.add_trace( | |
| go.Histogram( | |
| x=shocks[:, i], | |
| name=column, | |
| opacity=0.55, | |
| nbinsx=80, | |
| ) | |
| ) | |
| fig.update_layout( | |
| title="Simulated Market Shocks", | |
| xaxis_title="Shock", | |
| yaxis_title="Frequency", | |
| barmode="overlay", | |
| template="plotly_white", | |
| ) | |
| return fig | |
| def plot_scenario_distributions( | |
| scenario_prices, | |
| columns, | |
| ): | |
| fig = go.Figure() | |
| for i, column in enumerate(columns): | |
| fig.add_trace( | |
| go.Histogram( | |
| x=scenario_prices[:, i], | |
| name=column, | |
| opacity=0.65, | |
| ) | |
| ) | |
| fig.update_layout( | |
| title="Simulated Scenario Price Distributions", | |
| xaxis_title="Simulated Price", | |
| yaxis_title="Frequency", | |
| barmode="overlay", | |
| template="plotly_white", | |
| ) | |
| return fig |