Skip to main content

A package for backtesting portfolio strategies and trading signals

Project description

This package serves two backtesting scenarios:

  1. Portfolio Backtest:

    1. The portfolio class is the main object for portfolio backtesting. A portfolio is defined by a pd.DataFrame of weights or shares. The formate of pd.DataFrame should be rebalance dates as index and security tickers as columns. The end date of the backtest period is encouraged to be specified. If not, the last day available in price data is used.
    2. The benchmark of the portfolio is encouraged to specify. It can be a pd.DataFrame of weights or a portfolio class. You can set benchmark weight/portfolio in benchmark variable when the testing portfolio is initialized. Or set it to the benchmark attribute of the testing portfolio.
    3. Before backtest, use 'set_price(price_data)' method to specify price data. Backtest result can be generated by 'backtest()' method.
    4. The backtest performance is in 'port_total_ret' attribute.
    5. You can also visualize the result by 'plot_performance()', or have a summary by 'performance_summary()'
    6. More information about the definitions of performance metrics: Annualized is assumed to have 250 trading days. Active return is the difference of total return from portfolio to benchmark for the whole period. Active risk is the standard deviation of daily active return multiply square root of trading days in the period. Information Ratio is active return divided by active risk.
  2. Trading Strategy Backtest: (Under development)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for backtest-pkg, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size backtest_pkg-0.1.2-py3-none-any.whl (11.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size backtest_pkg-0.1.2.tar.gz (10.5 MB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page