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.

Source Distribution

backtest_pkg-0.1.2.tar.gz (10.5 MB view hashes)

Uploaded Source

Built Distribution

backtest_pkg-0.1.2-py3-none-any.whl (11.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page