A package for backtesting portfolio strategies and trading signals
Project description
This package serves two backtesting scenarios:
-
Portfolio Backtest:
- 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.
- 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.
- Before backtest, use 'set_price(price_data)' method to specify price data. Backtest result can be generated by 'backtest()' method.
- The backtest performance is in 'port_total_ret' attribute.
- You can also visualize the result by 'plot_performance()', or have a summary by 'performance_summary()'
- 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.
-
Trading Strategy Backtest: (Under development)
Project details
Release history Release notifications | RSS feed
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)
Built Distribution
Close
Hashes for backtest_pkg-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13405ea94ee1344fb60bf3e90c80d0d983c29b7310e4ef6dca157dc50e3cd2ab |
|
MD5 | 7dbd27b9151f3416599e7154e5101ba2 |
|
BLAKE2b-256 | bbe1ada48a619a21132242b61eb4cf818467bfdb9f98c9e12ba84402407fbbf3 |