投资组合分析工具

Python 投资组合分析入门

Charlotte Werger

Data Scientist

专业的投资组合分析工具

专业投资组合管理工具的截图

Python 投资组合分析入门

回测你的策略

  • 回测:在历史数据上运行策略,查看其表现
  • 历史有效不代表未来有效:市场可能变化

与指数对比的投资组合回测结果

Python 投资组合分析入门

Quantopian 的 pyfolio 工具

$ $

Quantopian 标志

$ $ Pyfolio 标志

1 Github: https://github.com/quantopian/pyfolio
Python 投资组合分析入门

Pyfolio 的绩效与风险分析

# Install the package
!pip install pyfolio
# Import the package
import pyfolio as pf
# Read the data as a pandas series
returns=pd.Series(pd.read_csv('pf_returns.csv')
returns.index=pd.to_datetime(returns.index)
# Create a tear sheet on returns
pf.create_returns_tear_sheet(returns)
# If you have backtest and live data 
pf.create_returns_tear_sheet(returns, live_start_date='2018-03-01')
Python 投资组合分析入门

Pyfolio 报告(tear sheet)

Pyfolio 报告中的收益表

Pyfolio 报告中的滚动夏普比率

Pyfolio 报告中的回撤图

Python 投资组合分析入门

Pyfolio 的持仓与敞口

# define our sector mappings
sect_map = {'COST': 'Consumer Goods',
            'INTC': 'Technology', 
            'CERN': 'Healthcare', 
            'GPS': 'Technology',
            'MMM': 'Construction', 
            'DELL': 'Technology', 
            'AMD': 'Technology'}
pf.create_position_tear_sheet(returns, positions, 
                             sector_mappings=sect_map)
Python 投资组合分析入门

敞口报告结果

$$

Pyfolio 报告中的前 10 大持仓

$ $

Pyfolio 报告中的行业配置

Python 投资组合分析入门

开始练习!

Python 投资组合分析入门

Preparing Video For Download...