Package: quantstats-lumi
Fork of Original QuantStats by Ran AroussiThis is a forked version of the original QuantStats library by Ran Aroussi. The original library can be found athttps://github.com/ranaroussi/quantstatsThis forked version was created because it seems that the original library is no longer being maintained. The original library has a number of issues and pull requests that have been open for a long time and have not been addressed. This forked version aims to address some of these issues and pull requests.This forked version is created and maintained by the Lumiwealth team. We are a team of data scientists and software engineers who are passionate about quantitative finance and algorithmic trading. We use QuantStats in our daily work with the Lumibot library and we want to make sure that QuantStats is a reliable and well-maintained library.If you’re interested in learning how to make your own trading algorithms, check out our Lumibot library athttps://github.com/Lumiwealth/lumibotand check out our courses athttps://lumiwealth.comQuantStats: Portfolio analytics for quantsQuantStatsPython library that performs portfolio profiling, allowing quants and portfolio managers to understand their performance better by providing them with in-depth analytics and risk metrics.Changelog »QuantStats is comprised of 3 main modules:quantstats.stats- for calculating various performance metrics, like Sharpe ratio, Win rate, Volatility, etc.quantstats.plots- for visualizing performance, drawdowns, rolling statistics, monthly returns, etc.quantstats.reports- for generating metrics reports, batch plotting, and creating tear sheets that can be saved as an HTML file.Here’s an example of a simple tear sheet analyzing a strategy:Quick StartInstall QuantStats Lumi using pip:$pipinstallquantstats-lumi%matplotlibinlineimportquantstats_lumiasqs# extend pandas functionality with metrics, etc.qs.extend_pandas()# fetch the daily returns for a stockstock=qs.utils.download_returns('META')# show sharpe ratioqs.stats.sharpe(stock)# or using extend_pandas() :)stock.sharpe()Output:0.8135304438803402Visualize stock performanceqs.plots.snapshot(stock,title='Facebook Performance',show=True)# can also be called via:# stock.plot_snapshot(title='Facebook Performance', show=True)Output:Creating a reportYou can create 7 different report tearsheets:qs.reports.metrics(mode='basic|full",...)- shows basic/full metricsqs.reports.plots(mode='basic|full",...)- shows basic/full plotsqs.reports.basic(...)- shows basic metrics and plotsqs.reports.full(...)- shows full metrics and plotsqs.reports.html(...)- generates a complete report as htmlLet’ create an html tearsheet(benchmarkcanbeapandasSeriesorticker)qs.reports.html(stock,"SPY")Output will generate something like this:(view original html file)To view a complete list of available methods, run[fforfindir(qs.stats)iff[0]!='_']['avg_loss',
 'avg_return',
 'avg_win',
 'best',
 'cagr',
 'calmar',
 'common_sense_ratio',
 'comp',
 'compare',
 'compsum',
 'conditional_value_at_risk',
 'consecutive_losses',
 'consecutive_wins',
 'cpc_index',
 'cvar',
 'drawdown_details',
 'expected_return',
 'expected_shortfall',
 'exposure',
 'gain_to_pain_ratio',
 'geometric_mean',
 'ghpr',
 'greeks',
 'implied_volatility',
 'information_ratio',
 'kelly_criterion',
 'kurtosis',
 'max_drawdown',
 'monthly_returns',
 'outlier_loss_ratio',
 'outlier_win_ratio',
 'outliers',
 'payoff_ratio',
 'profit_factor',
 'profit_ratio',
 'r2',
 'r_squared',
 'rar',
 'recovery_factor',
 'remove_outliers',
 'risk_of_ruin',
 'risk_return_ratio',
 'rolling_greeks',
 'ror',
 'sharpe',
 'skew',
 'sortino',
 'adjusted_sortino',
 'tail_ratio',
 'to_drawdown_series',
 'ulcer_index',
 'ulcer_performance_index',
 'upi',
 'utils',
 'value_at_risk',
 'var',
 'volatility',
 'win_loss_ratio',
 'win_rate',
 'worst'][fforfindir(qs.plots)iff[0]!='_']['daily_returns',
 'distribution',
 'drawdown',
 'drawdowns_periods',
 'earnings',
 'histogram',
 'log_returns',
 'monthly_heatmap',
 'returns',
 'rolling_beta',
 'rolling_sharpe',
 'rolling_sortino',
 'rolling_volatility',
 'snapshot',
 'yearly_returns']*** Full documenttion coming soon ***In the meantime, you can get insights as to optional parameters for each method, by using Python’shelpmethod:help(qs.stats.conditional_value_at_risk)Help on function conditional_value_at_risk in module quantstats.stats:

conditional_value_at_risk(returns, sigma=1, confidence=0.99)
    calculats the conditional daily value-at-risk (aka expected shortfall)
    quantifies the amount of tail risk an investmentInstallationInstall usingpip:$pipinstallquantstats--upgrade--no-cache-dirInstall usingconda:$condainstall-cranaroussiquantstatsRequirementsPython>= 3.5+pandas(tested to work with >=0.24.0)numpy>= 1.15.0scipy>= 1.2.0matplotlib>= 3.0.0seaborn>= 0.9.0tabulate>= 0.8.0yfinance>= 0.1.38plotly>= 3.4.1 (optional, for usingplots.to_plotly())Questions?This is a new library… If you find a bug, pleaseopen an issuein this repository.If you’d like to contribute, a great place to look is theissues marked with help-wanted.Known IssuesFor some reason, I couldn’t find a way to tell seaborn not to return the
monthly returns heatmap when instructed to save - so even if you save the plot (by passingsavefig={...}) it will still show the plot.Legal StuffQuantStatsis distributed under theApache Software License. See theLICENSE.txtfile in the release for details.P.S.Please drop me a note with any feedback you have.Ran Aroussi