帮助找到最佳投资组合配置的工具
portfoliofinder的Python项目详细描述
Porfolio查找器
一个Python库,主要基于pandas, 通过回溯测试确定最优的投资组合配置。在
API Documentation可用于阅读文档。在
示例用法
这些示例都使用了data.csv,它为 1970-2019年的少数基金。在
找到最佳投资组合分配,以最小化实现目标价值所需的时间范围
fromportfoliofinderimportAllocationsAllocations(0.05,['USA_TSM','WLDx_TSM','USA_INT','EM'])\ .filter('USA_TSM>=0.6 & WLDx_TSM<=0.2 & USA_INT>=0.3')\ .with_returns("data.csv")\ .with_regular_contributions(100000,10000)\ .get_backtested_timeframes(target_value=1000000)\ .get_statistics(['min','max','mean','std'])\ .filter_by_min_of('max')\ .filter_by_max_of('min')\ .get_allocation_which_min_statistic('std')
Output
^{pr2}$找到最佳投资组合配置,在固定时间内以最小的风险实现价值最大化
fromportfoliofinderimportAllocationsAllocations(0.05,['USA_TSM','WLDx_TSM','USA_INT','EM'])\ .filter('USA_TSM>=0.6 & WLDx_TSM<=0.2 & USA_INT>=0.3')\ .with_returns("data.csv")\ .with_regular_contributions(100000,10000)\ .get_backtested_values(timeframe=10)\ .get_statistics(['mean','std'])\ .filter_by_gte_percentile_of(90,'mean')\ .get_allocation_which_min_statistic('std')
Output
Statistic mean 446560.590088 std 117448.007302 Name: Allocation(USA_TSM=0.6, WLDx_TSM=0.0, USA_INT=0.3, EM=0.1), dtype: float64
从多个投资组合分配中绘制统计图,以可视化其有效边界
fromportfoliofinderimportAllocationsAllocations(0.05,['USA_TSM','WLDx_TSM','USA_INT','EM'])\ .filter('USA_TSM>=0.2 & USA_INT>=0.2')\ .with_returns("data.csv")\ .with_regular_contributions(100000,10000)\ .get_backtested_values(timeframe=10)\ .get_statistics()\ .graph('std','mean')
Output
- 项目
标签: