A package for backtesting portfolio strategies and trading signals
This package serves two backtesting scenarios:
- 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)
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|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|
Hashes for backtest_pkg-0.1.2-py3-none-any.whl