code
# -*- coding: utf-8 -*-
"""
strat_donchian.py
"""
import itertools; type(itertools)
import os, pathlib, datetime; type(os); type(pathlib);type(datetime)
import pandas as pd; type(pd)
import numpy as np; type(np)
import matplotlib.pyplot as plt; type(plt)
from copy import deepcopy;type(deepcopy)
from collections import OrderedDict ; type(OrderedDict)
import toolkit.myDataIO as mdio ; type(mdio)
import util.ttr as ttr
import strat_sz100iw_report as wr; type(wr)
import imp; type(imp)
#imp.reload(mdio)
#imp.reload(ttr)
from config import gc
#%%
def main():
'''
>>> main()
首先查看一下参数设置:
code = 399330
start_year = None
hh_n = 4
ll_n = 4
maxloss_pct = 0.12
with_plot = True
标的资产的代码和名称是: 深证100 (399330)
++++++++++++++++++++++++++++++++++++++++
初级的买入信号的数量: 279
初级的卖出信号的数量: 173
去除连续的买入信号的数量: 45
去除连续的卖出信号的数量: 45
整理首尾后的买入信号的数量: 45
整理首尾后的卖出信号的数量: 46
End equity : 17369.60
hh_n : 4
ll_n : 4
start_date : 2006-01-25 00:00:00
end_date : 2020-05-15 00:00:00
end_index : 4802.32
index_growth : 4.995
end_equity : 17369.603
end_nav : 18.065
cagr : 0.224
mdd : 0.306
sharpe : 1.108
annu_volatility : 0.202
策略收益率的标准差 : 0.028
'''
print('首先查看一下参数设置:')
for k,v in gc.params.items():
print('{:20s} = {}'.format(k,v) )
print()
qsq=ttr.QsQuant(**gc.params)
qsq.load_data()
qsq.generate_signal()
df, perf_dict = qsq.simulate_LineMode()