MCPcopy
hub / github.com/ranaroussi/quantstats / basic

Function basic

quantstats/reports.py:642–718  ·  view source on GitHub ↗
(
    returns,
    benchmark=None,
    rf=0.0,
    grayscale=False,
    figsize=(8, 5),
    display=True,
    compounded=True,
    periods_per_year=252,
    match_dates=True,
    **kwargs,
)

Source from the content-addressed store, hash-verified

640
641
642def basic(
643 returns,
644 benchmark=None,
645 rf=0.0,
646 grayscale=False,
647 figsize=(8, 5),
648 display=True,
649 compounded=True,
650 periods_per_year=252,
651 match_dates=True,
652 **kwargs,
653):
654
655 # prepare timeseries
656 if match_dates:
657 returns = returns.dropna()
658 returns = _utils._prepare_returns(returns)
659 if benchmark is not None:
660 benchmark = _utils._prepare_benchmark(benchmark, returns.index, rf)
661 if match_dates is True:
662 returns, benchmark = _match_dates(returns, benchmark)
663
664 benchmark_title = None
665 if benchmark is not None:
666 benchmark_title = kwargs.get("benchmark_title", "Benchmark")
667 strategy_title = kwargs.get("strategy_title", "Strategy")
668 active = kwargs.get("active_returns", "False")
669
670 if isinstance(returns, _pd.DataFrame):
671 if len(returns.columns) > 1 and isinstance(strategy_title, str):
672 strategy_title = list(returns.columns)
673
674 if _utils._in_notebook():
675 iDisplay(iHTML("<h4>Performance Metrics</h4>"))
676 metrics(
677 returns=returns,
678 benchmark=benchmark,
679 rf=rf,
680 display=display,
681 mode="basic",
682 compounded=compounded,
683 periods_per_year=periods_per_year,
684 prepare_returns=False,
685 benchmark_title=benchmark_title,
686 strategy_title=strategy_title,
687 )
688 iDisplay(iHTML("<h4>Strategy Visualization</h4>"))
689 else:
690 print("[Performance Metrics]\n")
691 metrics(
692 returns=returns,
693 benchmark=benchmark,
694 rf=rf,
695 display=display,
696 mode="basic",
697 compounded=compounded,
698 periods_per_year=periods_per_year,
699 prepare_returns=False,

Callers

nothing calls this directly

Calls 3

_match_datesFunction · 0.85
metricsFunction · 0.85
plotsFunction · 0.85

Tested by

no test coverage detected