Charts
stochPathSim.viz
Interactive Plotly charts. Every function returns a plotly.graph_objects.Figure.
portfolio_risk_chart
portfolio_risk_chart(risk, labels=None)
Interactive stacked comparison of signed component VaR and ES.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
risk
|
PortfolioRisk
|
Output of stochPathSim.risk.normal_portfolio_risk. |
required |
labels
|
sequence of str
|
Labels for each asset; defaults to asset_0, asset_1, etc. |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
Grouped bars per asset, retaining signed contributions. |
correlation_heatmap
correlation_heatmap(result, on='increments', names=None, title=None)
Correlation between the states of a result.
on="increments" correlates step increments pooled over paths and time (the
instantaneous correlation); on="terminal" correlates the terminal values.
density_evolution
density_evolution(result, name=None, kind='heatmap', n_bins=60, n_times=60, title=None)
How the cross-sectional distribution evolves over time.
kind is "heatmap" (time x value), "surface" (3-D density surface) or
"animation" (a histogram per time step, played with a slider).
fan
fan(result, name=None, quantiles=(0.01, 0.05, 0.25, 0.75, 0.95, 0.99), title=None)
Fan chart: nested symmetric quantile bands around the median.
path_explorer
path_explorer(result, max_paths=50, title=None)
Explore every state of a result: a dropdown picks the state, a slider the number of paths.
terminal_distribution
terminal_distribution(result, name=None, t=None, bins=80, pdf=None, title=None)
Histogram of values at time t (default: the horizon), with an optional analytic density.
pdf is a callable evaluated on a grid of values and overlaid as a line.
curve_fit_check
curve_fit_check(result, curve, title=None)
Monte Carlo discount factors (with a 95% band) against the initial curve P(0, t).
result must contain a discount state, as every short-rate model does.
short_rate_fan
short_rate_fan(result, quantiles=(0.01, 0.05, 0.25, 0.75, 0.95, 0.99), title=None)
Fan chart of the simulated short rate.
backtest_dashboard
backtest_dashboard(pit, realised=None, bands=None, level=0.99, times=None, title=None)
Three-panel risk-factor backtest.
- histogram of PIT values against the uniform density;
- QQ plot of sorted PIT values against uniform quantiles;
- exceedance timeline: realised values against the simulated
bands((lower, upper)arrays), or PIT values against1 - level/levelthresholds when no bands are given.
exposure_dashboard
exposure_dashboard(profile, title=None)
EE, ENE, PFE and Effective EE of an :class:~stochPathSim.risk.ExposureProfile, with EPE marked.
var_plot
var_plot(pnl, level=0.99, bins=80, title=None)
P&L histogram with historical VaR and Expected Shortfall marked (losses are positive).
set_theme
set_theme(style='light')
Use the light or dark stochPathSim theme for every figure the package creates.
Returns the name of the Plotly template now in use.
template
template()
Name of the Plotly template currently used by stochPathSim figures.
attribution
Plotly risk-contribution charts for normal portfolio VaR and ES.
portfolio_risk_chart
portfolio_risk_chart(risk, labels=None)
Interactive stacked comparison of signed component VaR and ES.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
risk
|
PortfolioRisk
|
Output of stochPathSim.risk.normal_portfolio_risk. |
required |
labels
|
sequence of str
|
Labels for each asset; defaults to asset_0, asset_1, etc. |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
Grouped bars per asset, retaining signed contributions. |
paths
Interactive charts of simulated paths and their distributions.
paths
paths(result, name=None, n_paths=30, quantiles=(0.01, 0.99), show_mean=True, title=None)
Sample paths with the mean and a quantile band.
Traces: the quantile band (2 traces, if quantiles), one trace per sample path, and the mean.
fan
fan(result, name=None, quantiles=(0.01, 0.05, 0.25, 0.75, 0.95, 0.99), title=None)
Fan chart: nested symmetric quantile bands around the median.
path_explorer
path_explorer(result, max_paths=50, title=None)
Explore every state of a result: a dropdown picks the state, a slider the number of paths.
terminal_distribution
terminal_distribution(result, name=None, t=None, bins=80, pdf=None, title=None)
Histogram of values at time t (default: the horizon), with an optional analytic density.
pdf is a callable evaluated on a grid of values and overlaid as a line.
density_evolution
density_evolution(result, name=None, kind='heatmap', n_bins=60, n_times=60, title=None)
How the cross-sectional distribution evolves over time.
kind is "heatmap" (time x value), "surface" (3-D density surface) or
"animation" (a histogram per time step, played with a slider).
correlation_heatmap
correlation_heatmap(result, on='increments', names=None, title=None)
Correlation between the states of a result.
on="increments" correlates step increments pooled over paths and time (the
instantaneous correlation); on="terminal" correlates the terminal values.
rates
Interactive charts for interest-rate models.
curve_fit_check
curve_fit_check(result, curve, title=None)
Monte Carlo discount factors (with a 95% band) against the initial curve P(0, t).
result must contain a discount state, as every short-rate model does.
short_rate_fan
short_rate_fan(result, quantiles=(0.01, 0.05, 0.25, 0.75, 0.95, 0.99), title=None)
Fan chart of the simulated short rate.
risk
Interactive risk dashboards: exposure, backtests and VaR.
exposure_dashboard
exposure_dashboard(profile, title=None)
EE, ENE, PFE and Effective EE of an :class:~stochPathSim.risk.ExposureProfile, with EPE marked.
backtest_dashboard
backtest_dashboard(pit, realised=None, bands=None, level=0.99, times=None, title=None)
Three-panel risk-factor backtest.
- histogram of PIT values against the uniform density;
- QQ plot of sorted PIT values against uniform quantiles;
- exceedance timeline: realised values against the simulated
bands((lower, upper)arrays), or PIT values against1 - level/levelthresholds when no bands are given.
var_plot
var_plot(pnl, level=0.99, bins=80, title=None)
P&L histogram with historical VaR and Expected Shortfall marked (losses are positive).
theme
The stochPathSim Plotly theme.
set_theme
set_theme(style='light')
Use the light or dark stochPathSim theme for every figure the package creates.
Returns the name of the Plotly template now in use.
template
template()
Name of the Plotly template currently used by stochPathSim figures.
rgba
rgba(hex_color, alpha)
#RRGGBB to an rgba(...) string.
new_figure
new_figure(title=None, xaxis=None, yaxis=None)
An empty figure with the stochPathSim theme applied.