VaR_model / visualization /prices.py
MinsaitEU's picture
Upload 6 files
459d15e verified
Raw History Blame Contribute Delete
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