All Projects → ranaroussi → Quantstats

ranaroussi / Quantstats

Licence: apache-2.0
Portfolio analytics for quants, written in Python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Quantstats

quanttrader
Backtest and live trading in Python
Stars: ✭ 139 (-83.11%)
Mutual labels:  algotrading, algorithmic-trading, quantitative-trading
Turingtrader
The Open-Source Backtesting Engine/ Market Simulator by Bertram Solutions.
Stars: ✭ 132 (-83.96%)
Mutual labels:  algorithmic-trading, quant, quantitative-trading
Abu
阿布量化交易系统(股票,期权,期货,比特币,机器学习) 基于python的开源量化交易,量化投资架构
Stars: ✭ 8,589 (+943.62%)
Mutual labels:  algorithmic-trading, quant, quantitative-trading
Quant Trading
Python quantitative trading strategies including VIX Calculator, Pattern Recognition, Commodity Trading Advisor, Monte Carlo, Options Straddle, Shooting Star, London Breakout, Heikin-Ashi, Pair Trading, RSI, Bollinger Bands, Parabolic SAR, Dual Thrust, Awesome, MACD
Stars: ✭ 2,407 (+192.47%)
Mutual labels:  algorithmic-trading, quant, quantitative-trading
Sgx Full Orderbook Tick Data Trading Strategy
Providing the solutions for high-frequency trading (HFT) strategies using data science approaches (Machine Learning) on Full Orderbook Tick Data.
Stars: ✭ 733 (-10.94%)
Mutual labels:  algorithmic-trading, quant, quantitative-trading
Qlib
Qlib is an AI-oriented quantitative investment platform, which aims to realize the potential, empower the research, and create the value of AI technologies in quantitative investment. With Qlib, you can easily try your ideas to create better Quant investment strategies. An increasing number of SOTA Quant research works/papers are released in Qlib.
Stars: ✭ 7,582 (+821.26%)
Mutual labels:  algorithmic-trading, quant, quantitative-trading
Zvt
modular quant framework.
Stars: ✭ 1,801 (+118.83%)
Mutual labels:  algorithmic-trading, quant, quantitative-trading
QuantResearch
Quantitative analysis, strategies and backtests
Stars: ✭ 1,013 (+23.09%)
Mutual labels:  algotrading, algorithmic-trading, quantitative-trading
Quantdom
Python-based framework for backtesting trading strategies & analyzing financial markets [GUI ]
Stars: ✭ 449 (-45.44%)
Mutual labels:  algorithmic-trading, quant, algotrading
Quantitative Notebooks
Educational notebooks on quantitative finance, algorithmic trading, financial modelling and investment strategy
Stars: ✭ 356 (-56.74%)
Mutual labels:  algorithmic-trading, quantitative-trading, algotrading
Awesome Quant
A curated list of insanely awesome libraries, packages and resources for Quants (Quantitative Finance)
Stars: ✭ 8,205 (+896.96%)
Mutual labels:  quant, quantitative-trading, algotrading
volatile
Volatile: your day-to-day trading companion.
Stars: ✭ 53 (-93.56%)
Mutual labels:  algotrading, algorithmic-trading
hyperdrive
algorithmic trading using machine learning
Stars: ✭ 28 (-96.6%)
Mutual labels:  algotrading, algorithmic-trading
Peregrine
Detects arbitrage opportunities across 131 cryptocurrency exchanges in 50 countries
Stars: ✭ 638 (-22.48%)
Mutual labels:  algorithmic-trading, algotrading
trading gym
a unified environment for supervised learning and reinforcement learning in the context of quantitative trading
Stars: ✭ 36 (-95.63%)
Mutual labels:  quant, quantitative-trading
AutoTrader
A Python-based development platform for automated trading systems - from backtesting to optimisation to livetrading.
Stars: ✭ 227 (-72.42%)
Mutual labels:  algorithmic-trading, quantitative-trading
piker
#nontina, #paperhands,, #pwnzebotz, #tradezbyguille
Stars: ✭ 63 (-92.35%)
Mutual labels:  algorithmic-trading, quantitative-trading
Tai
A composable, real time, market data and trade execution toolkit. Built with Elixir, runs on the Erlang virtual machine
Stars: ✭ 264 (-67.92%)
Mutual labels:  algorithmic-trading, quant
Example Scalping
A working example algorithm for scalping strategy trading multiple stocks concurrently using python asyncio
Stars: ✭ 267 (-67.56%)
Mutual labels:  algorithmic-trading, algotrading
FinRL Podracer
Cloud-native Financial Reinforcement Learning
Stars: ✭ 179 (-78.25%)
Mutual labels:  quant, algorithmic-trading

.. image:: https://img.shields.io/badge/python-3.5+-blue.svg?style=flat :target: https://pypi.python.org/pypi/quantstats :alt: Python version

.. image:: https://img.shields.io/pypi/v/quantstats.svg?maxAge=60 :target: https://pypi.python.org/pypi/quantstats :alt: PyPi version

.. image:: https://img.shields.io/pypi/status/quantstats.svg?maxAge=60 :target: https://pypi.python.org/pypi/quantstats :alt: PyPi status

.. image:: https://img.shields.io/travis/ranaroussi/quantstats/master.svg?maxAge=1 :target: https://travis-ci.com/ranaroussi/quantstats :alt: Travis-CI build status

.. image:: https://img.shields.io/pypi/dm/quantstats.svg?maxAge=2592000&label=installs&color=%2327B1FF :target: https://pypi.python.org/pypi/quantstats :alt: PyPi downloads

.. image:: https://www.codefactor.io/repository/github/ranaroussi/quantstats/badge :target: https://www.codefactor.io/repository/github/ranaroussi/quantstats :alt: CodeFactor

.. image:: https://img.shields.io/github/stars/ranaroussi/quantstats.svg?style=social&label=Star&maxAge=60 :target: https://github.com/ranaroussi/quantstats :alt: Star this repo

.. image:: https://img.shields.io/twitter/follow/aroussi.svg?style=social&label=Follow&maxAge=60 :target: https://twitter.com/aroussi :alt: Follow me on twitter

\

QuantStats: Portfolio analytics for quants

QuantStats Python 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 » <./CHANGELOG.rst>__

QuantStats is comprised of 3 main modules:


1. ``quantstats.stats`` - for calculating various performance metrics, like Sharpe ratio, Win rate, Volatility, etc.
2. ``quantstats.plots`` - for visualizing performance, drawdowns, rolling statistics, monthly returns, etc.
3. ``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 Start
===========

.. code:: python

    %matplotlib inline
    import quantstats as qs

    # extend pandas functionality with metrics, etc.
    qs.extend_pandas()

    # fetch the daily returns for a stock
    stock = qs.utils.download_returns('FB')

    # show sharpe ratio
    qs.stats.sharpe(stock)

    # or using extend_pandas() :)
    stock.sharpe()

Output:

.. code:: text

    0.8135304438803402


Visualize stock performance
~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: python

    qs.plots.snapshot(stock, title='Facebook Performance')

    # can also be called via:
    # stock.plot_snapshot(title='Facebook Performance')

Output:

.. image:: https://raw.githubusercontent.com/ranaroussi/quantstats/dev/docs/snapshot.jpg
    :alt: Snapshot plot


Creating a report
~~~~~~~~~~~~~~~~~

You can create 7 different report tearsheets:

1. ``qs.reports.metrics(mode='basic|full", ...)`` - shows basic/full metrics
2. ``qs.reports.plots(mode='basic|full", ...)`` - shows basic/full plots
3. ``qs.reports.basic(...)`` - shows basic metrics and plots
4. ``qs.reports.full(...)`` - shows full metrics and plots
5. ``qs.reports.html(...)`` - generates a complete report as html

Let' create an html tearsheet

.. code:: python

    (benchmark can be a pandas Series or ticker)
    qs.reports.html(stock, "SPY")

Output will generate something like this:

.. image:: https://raw.githubusercontent.com/ranaroussi/quantstats/dev/docs/report.jpg
    :alt: HTML tearsheet

(`view original html file <https://rawcdn.githack.com/ranaroussi/quantstats/bd0e70bd284798a58c569363bc7e1c3c8c6e3fd9/docs/tearsheet.html>`_)


To view a complete list of available methods, run

.. code:: python

[f for f in dir(qs.stats) if f[0] != '_']

.. code:: text

['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',
 'tail_ratio',
 'to_drawdown_series',
 'ulcer_index',
 'ulcer_performance_index',
 'upi',
 'utils',
 'value_at_risk',
 'var',
 'volatility',
 'win_loss_ratio',
 'win_rate',
 'worst']

.. code:: python

[f for f in dir(qs.plots) if f[0] != '_']

.. code:: text

['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's help method:

.. code:: python

help(qs.stats.conditional_value_at_risk)

.. code:: text

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 investment

Installation

Install using pip:

.. code:: bash

$ pip install quantstats --upgrade --no-cache-dir

Install using conda:

.. code:: bash

$ conda install -c ranaroussi quantstats

Requirements

  • Python <https://www.python.org>_ >= 3.5+
  • pandas <https://github.com/pydata/pandas>_ (tested to work with >=0.24.0)
  • numpy <http://www.numpy.org>_ >= 1.15.0
  • scipy <https://www.scipy.org>_ >= 1.2.0
  • matplotlib <https://matplotlib.org>_ >= 3.0.0
  • seaborn <https://seaborn.pydata.org>_ >= 0.9.0
  • tabulate <https://bitbucket.org/astanin/python-tabulate>_ >= 0.8.0
  • yfinance <https://github.com/ranaroussi/yfinance>_ >= 0.1.38
  • plotly <https://plot.ly/>_ >= 3.4.1 (optional, for using plots.to_plotly())

Questions?

This is a new library... If you find a bug, please open an issue <https://github.com/ranaroussi/quantstats/issues>_ in this repository.

If you'd like to contribute, a great place to look is the issues marked with help-wanted <https://github.com/ranaroussi/quantstats/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22>_.

Known Issues

For 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 passing savefig={...}) it will still show the plot.

Legal Stuff

QuantStats is distributed under the Apache Software License. See the LICENSE.txt <./LICENSE.txt>_ file in the release for details.

P.S.

Please drop me a note with any feedback you have.

Ran Aroussi

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].