复制链接
克隆策略

获取股指期货数据

In [3]:
finicial_future_df = DataSource('bar1d_CN_FUTURE').read(instruments=['IC2301.CFX','IH2301.CFX','IF2301.CFX','IM2301.CFX'],  start_date='2022-12-01', fields=['close'])
In [4]:
finicial_future_df.head()
Out[4]:
date close instrument
0 2022-12-01 6190.399902 IC2301.CFX
1 2022-12-01 3910.399902 IF2301.CFX
2 2022-12-01 2632.600098 IH2301.CFX
3 2022-12-01 6640.200195 IM2301.CFX
4 2022-12-02 6179.399902 IC2301.CFX

获取etf数据

In [5]:
etf_df = DataSource('bar1d_CN_FUND').read(instruments=['510050.HOF','510500.HOF','510300.HOF','512100.HOF'],  start_date='2022-12-01', fields=['close','adjust_factor'])

etf_df.rename(columns  = {'close':'etf_close','instrument':'etf_instrument'},  inplace=True)

数据合并

In [6]:
merge_df = pd.merge(finicial_future_df, etf_df, on='date')
In [7]:
merge_df.head(10)
Out[7]:
date close instrument etf_instrument etf_close adjust_factor
0 2022-12-01 6190.399902 IC2301.CFX 510050.HOF 3.5800 1.360182
1 2022-12-01 6190.399902 IC2301.CFX 510300.HOF 4.6056 1.164206
2 2022-12-01 6190.399902 IC2301.CFX 510500.HOF 1.9875 0.321082
3 2022-12-01 6190.399902 IC2301.CFX 512100.HOF 0.9628 0.362227
4 2022-12-01 3910.399902 IF2301.CFX 510050.HOF 3.5800 1.360182
5 2022-12-01 3910.399902 IF2301.CFX 510300.HOF 4.6056 1.164206
6 2022-12-01 3910.399902 IF2301.CFX 510500.HOF 1.9875 0.321082
7 2022-12-01 3910.399902 IF2301.CFX 512100.HOF 0.9628 0.362227
8 2022-12-01 2632.600098 IH2301.CFX 510050.HOF 3.5800 1.360182
9 2022-12-01 2632.600098 IH2301.CFX 510300.HOF 4.6056 1.164206