macrosynergy.pnl.multi_pnl#
The MultiPnL class allows for the visualization and analysis of PnLs across multiple return categories. It also provides functionality to calculate a weighted aggregate PnL based on user-defined weights for each PnL.
- class MultiPnL[source]#
Bases:
object
Manages multiple NaivePnL instances, enabling combined PnL analysis and visualization.
- add_pnl(pnl, pnl_xcats)[source]#
Add PnL(s) from a NaivePnL object. PnL categories will be ingested into the MultiPnL object as ‘pnl_xcat/return’.
- combine_pnls(pnl_xcats, composite_pnl_xcat, weights=None)[source]#
Combine PnLs with optional weighting.
- Parameters:
pnl_xcats (List[str]) – List of PnLs to combine. Must be in the format ‘xcat/return’ and added using add_pnl().
composite_pnl_xcat (str) – xcat for the combined PnL.
weights (Optional[Dict[str, float]]) – Weights for each PnL, by default None. Must be in the format {‘xcat’: weight} or {‘xcat/return’: weight}.
- plot_pnls(pnl_xcats=None, title=None, title_fontsize=14, xcat_labels=None)[source]#
Creates a plot of PnLs from added NaivePnL objects and/or combined PnLs created with combine_pnls().
- evaluate_pnls(pnl_xcats=None)[source]#
Returns a DataFrame containing the following evaluation metrics for specified PnLs:
Return %
St. Dev. %
Sharpe Ratio
Sortino Ratio
Max 21-Day Draw %
Max 6-Month Draw %
Peak to Trough Draw %
Top 5% Monthly PnL Share
Traded Months
Correlation with benchmarks (if available)
Note
The evaluation metrics are calculated in a manner similar to NaivePnL’s evaluate_pnls().
Benchmark correlation is not currently supported for combined PnLs.