帮助找到最佳投资组合配置的工具

portfoliofinder的Python项目详细描述


Porfolio查找器

PyPI version fury.ioPyPI pyversionsBuild StatusDocumentation Status

一个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

efficient_frontier

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java使用字符而不是字符串的意义   部分匹配长度字符串相似性的java正则表达式   java获取构造函数错误(错误:“(”或“[”)   java@Value注释无法正常工作SpringBoot   java hasKey在响应中没有看到字段   java JavaFX,没有JFXButtons和所有   在Log4j2中,是否可以根据键从记录器中筛选出某些键值对?   如何使用Java中Kafka的消息,从特定偏移量开始   java在单击后存储动态按钮的值   java Android编码:ViewRootImpl$CalledFromErrorThreadException。[Noob]   通过FileChooser保存pdf格式会提示在java中出现第二个对话框   用于空文件的java Spring集成文件标记   java我们应该如何编写get方法,以便私有字段不会超出其预期范围?   java Eclipse产品问题,Juno RequireHandle:org。日食e4。果心服务