portfolio-backtest is a python library for backtest portfolio asset allocation on Python 3.7 and above.
Project description
portfolio-backtest
portfolio-backtest is a python library for backtest portfolio asset allocation on Python 3.7 and above.
Installation
$ pip install portfolio-backtest PyPortfolioOpt
Usage
basic run
from portfolio_backtest import Backtest
Backtest(tickers=["VTI", "AGG", "GLD"]).run()
advanced run
from portfolio_backtest import Backtest
import pprint
bt = Backtest(
tickers={
"VTI": 0.6,
"AGG": 0.25,
"GLD": 0.15,
},
target_return=0.1,
target_cvar=0.025,
data_dir="data",
start="2011-04-10",
end="2021-04-10",
)
pprint.pprint(bt.run(plot=True))
[{'Annual volatility': '10.9%',
'Conditional Value at Risk': '',
'Expected annual return': '9.6%',
'Sharpe Ratio': '0.70',
'portfolio': 'Your Portfolio',
'tickers': {'AGG': 0.25, 'GLD': 0.15, 'VTI': 0.6}},
{'Annual volatility': '6.3%',
'Conditional Value at Risk': '',
'Expected annual return': '7.0%',
'Sharpe Ratio': '0.79',
'portfolio': 'Tangency Portfolio',
'tickers': {'AGG': 0.67099, 'GLD': 0.0, 'VTI': 0.32901}},
{'Annual volatility': '4.3%',
'Conditional Value at Risk': '',
'Expected annual return': '4.3%',
'Sharpe Ratio': '0.53',
'portfolio': 'Minimum Variance Portfolio',
'tickers': {'AGG': 0.91939, 'GLD': 0.00525, 'VTI': 0.07536}},
{'Annual volatility': '4.0%',
'Conditional Value at Risk': '',
'Expected annual return': '4.1%',
'Sharpe Ratio': '0.51',
'portfolio': 'Hierarchical Risk Parity Portfolio',
'tickers': {'AGG': 0.89041, 'GLD': 0.05695, 'VTI': 0.05263}},
{'Annual volatility': '',
'Conditional Value at Risk': '0.5%',
'Expected annual return': '4.2%',
'Sharpe Ratio': '',
'portfolio': 'Minimum CVaR Portfolio',
'tickers': {'AGG': 0.93215, 'GLD': 0.0, 'VTI': 0.06785}},
{'Annual volatility': '7.7%',
'Conditional Value at Risk': '',
'Expected annual return': '10.0%',
'Sharpe Ratio': '1.04',
'portfolio': 'Semi Variance Portfolio (target return 10.0%)',
'tickers': {'AGG': 0.39504, 'GLD': 0.0, 'VTI': 0.60496}},
{'Annual volatility': '',
'Conditional Value at Risk': '2.5%',
'Expected annual return': '13.3%',
'Sharpe Ratio': '',
'portfolio': 'Return Maximize CVaR Portfolio (target CVaR 2.5%)',
'tickers': {'AGG': 0.08851, 'GLD': 0.0, 'VTI': 0.91149}}]
Supported Portfolio
- Your Portfolio
- Hierarchical Risk Parity Portfolio
- Tangency Portfolio
- Minimum Variance Portfolio
- Minimum CVaR Portfolio
- Semi Variance Portfolio
- Return Maximize CVaR Portfolio
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
Built Distribution
Close
Hashes for portfolio-backtest-0.1.16.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47f25fc233ecd309059a5288d2319a14e040faf23fc9cc75522234d97c8776d4 |
|
MD5 | d5261921a863f42cd880366ec40bbc56 |
|
BLAKE2b-256 | 3b25f861da38de15c6ffecb42003dc0801f2ead994818c58d136134331ecce31 |
Close
Hashes for portfolio_backtest-0.1.16-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9134a56fec302586134fde09f6f40627e8e80f894ea4fdd0ad9c26732021e9b |
|
MD5 | 220db808e214bf750863189c11d9eb1b |
|
BLAKE2b-256 | ef515e6b1d3f279bd61205527a36fe32b070730bacc0b9f1bf8137d139ce73a2 |