在回测中读、写pickle文件
使用pickle.dumps()输出文件至研究、pickle.load()读取研究中的pkl文件
```
import cPickle as pickle
from six import StringIO
import pandas as pd
# 生成文件
a = ['a','b','c']
b = ['o','p','q']
result = {}
score_df = pd.DataFrame(np.zeros(len(a)*len(b)).reshape(len(a),len(b)),\
index = a,columns = b)
result['2017-04-17'] = score_df
score_df = score_df + 1
result['2017-04-18'] = score_df
score_df = score_df + 1
result['2017-04-19'] = score_df
print result
# 输出文件
content = pickle.dumps(result)
write_file(path = 'research.pkl', content = content, append=False)
# 导入文件
pkl_file_read = read_file('research.pkl')
result = pickle.load(StringIO(pkl_file_read))
#打印结果
print result
```
![屏幕快照 2019-01-25 12.00.32.png][1]
[1]: https://image.joinquant.com/1aa4dada3eb5127fcc0531a4e589b66b
2019-01-25