Coverage for src/jquantstats/_plots/_portfolio/_core.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.16.1, created at 2026-09-23 04:11 +0000

1"""The :class:`PortfolioPlots` facade combining the portfolio plot-family mixins.""" 

2 

3from __future__ import annotations 

4 

5from typing import TYPE_CHECKING 

6 

7from ._diagnostics import _DiagnosticPlotsMixin 

8from ._nav import _NavPlotsMixin 

9from ._rolling import _RollingPortfolioPlotsMixin 

10 

11if TYPE_CHECKING: 

12 from .._protocol import PortfolioLike 

13 

14 

15class PortfolioPlots( 

16 _NavPlotsMixin, 

17 _RollingPortfolioPlotsMixin, 

18 _DiagnosticPlotsMixin, 

19): 

20 """Facade for portfolio plots built with Plotly. 

21 

22 Provides convenience methods to visualize portfolio performance and 

23 diagnostics directly from a Portfolio instance (e.g., snapshot charts, 

24 lagged performance, smoothed holdings, and lead/lag IR). 

25 

26 Charts are organised into focused mixins: 

27 

28 - `_NavPlotsMixin` — accumulated-NAV curves: snapshot, lag sweep, 

29 smoothed holdings. 

30 - `_RollingPortfolioPlotsMixin` — rolling Sharpe/volatility and the 

31 per-year Sharpe breakdown. 

32 - `_DiagnosticPlotsMixin` — lead/lag IR, correlation heatmap, monthly 

33 returns calendar, trading-cost impact. 

34 """ 

35 

36 __slots__ = ("_portfolio",) 

37 

38 def __init__(self, portfolio: PortfolioLike) -> None: 

39 self._portfolio = portfolio