markowizard.visualization¶
visualization ¶
Plotly-based visualization functions for portfolio analysis.
Returns standalone Plotly Figure objects (not tied to Dash).
efficiency_frontier_plot ¶
efficiency_frontier_plot(
portfolios: DataFrame, highlight_portfolio: int = 0
) -> Figure
Plot the efficient frontier as a scatter plot of expected return vs risk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
portfolios
|
DataFrame
|
DataFrame with 'Expected Return', 'Risk', and 'Sharpe' columns (as produced by MarkowitzOptimizer). |
required |
highlight_portfolio
|
int
|
Index of the portfolio to highlight (default 0). |
0
|
Returns:
| Type | Description |
|---|---|
Figure
|
|
allocation_pie ¶
allocation_pie(portfolio: Series) -> Figure
Pie chart showing asset allocation for a single portfolio.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
portfolio
|
Series
|
A single portfolio row from the efficient frontier DataFrame. Non-zero asset weights are displayed; meta columns like 'Expected Return', 'Risk', 'Sharpe' are excluded. |
required |
Returns:
| Type | Description |
|---|---|
Figure
|
|
capital_allocation_line_plot ¶
capital_allocation_line_plot(
cal_points: list[dict], highlight_point: int = 0
) -> Figure
Plot the Capital Allocation Line (CAL) showing risk-return trade-offs for different mixes of risky portfolio and risk-free asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cal_points
|
list of dict
|
Output from CapitalAllocator.capital_allocation_line(). |
required |
highlight_point
|
int
|
Index of the point to highlight (default 0). |
0
|
Returns:
| Type | Description |
|---|---|
Figure
|
|
correlation_timeline ¶
correlation_timeline(
prices: DataFrame,
ticker_a: str,
ticker_b: str | None = None,
) -> Figure
Plot the price history of one or two assets, normalizing when comparing two different assets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prices
|
DataFrame
|
DataFrame of historical prices with DatetimeIndex and tickers as columns. |
required |
ticker_a
|
str
|
Primary ticker. |
required |
ticker_b
|
str or None
|
Secondary ticker. If None or equal to ticker_a, plots a single line. |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
|
correlation_heatmap ¶
correlation_heatmap(corr_matrix: DataFrame) -> Figure
Plot a correlation matrix heatmap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
corr_matrix
|
DataFrame
|
Square correlation matrix with ticker names as index and columns. |
required |
Returns:
| Type | Description |
|---|---|
Figure
|
|