def bt_init(rdat, codLst, inxLst, tim0Str, tim9Str='', priceSgn='avg', prjNam='TQ01'): ''' [输入参数] rdat,数据目录,一般日线数据是 rdatCN='/zDat/cn/day/' codLst,股票池代码列表 inxLst,指数池代码列表 vlst,bt回溯初始化变量参数列表 [btTim0Str='',btTim9Str=''] ''' # #---set.bt.var # set time #qx.btTim0Str,qx.btTim9Str=vlst[0],vlst[1] qx = ztq.tq_init(rdat, codLst, inxLst, priceSgn, prjNam) #tq_init(rs0,codLst,inxLst=['000001'],priceSgn='avg',priceDFlag=True,prjNam='TQ001'): # # ztq.tq_pools_call(qx, bt_init_data) qx = bt_init_tim(qx, tim0Str, tim9Str) # #b2=ztq.tq_trdObjInit(qx,0) #qx.trdLib=qx.trdLib.append(b2.T,ignore_index=True) qx.trdLib = pd.DataFrame(columns=zsys.qx_trdName, index=['ID']) #所有交易记录清单列表 qx.trdLib.dropna(inplace=True) # qx.usrPools = {} #用户持有的股票资产数据 字典格式 # qx.usrMoney0, qx.usrMoney, qx.usrTotal = zsys.qx_bt_money0, zsys.qx_bt_money0, zsys.qx_bt_money0 qx.usrLevel = 5 qx.usrMoney0nil = qx.usrMoney0 * qx.usrLevel # #qx.trd_mode,qx.trd_nilFlag=1,False ztq.tq_usrPoolsInit(qx, addFg=False) # xtim, qx.trdCnt = qx.btTim0Str, 0 qx.trdLib = pd.DataFrame(columns=zsys.qx_trdName, index=['ID']) #所有交易记录清单列表 qx.trdLib.dropna(inplace=True) ''' r1=pd.Series(zsys.qx_trdNil,index=zsys.qx_trdName); r1['cash'],r1['time']=qx.usrMoney0,qx.btTim0Str r1['ID']=ztq.tq_usrIDSet(qx) qx.trdLib=qx.trdLib.append(r1.T,ignore_index=True) ''' #ztq.tq_usr2trdLib010(qx,xtim,'cash',0,0,0,qx.usrMoney0) # return qx
import ztools_draw as zdr import ztools_data as zdat #---------- #1 预处理 pd.set_option('display.width', 450) pyplt = py.offline.plot #--------------- #2 set data,init codLst = [] inxLst = ['000001'] rs0 = zsys.rdatCN0 #'/zDat/cn/' print('\n#1,set data,init,', rs0) qx = ztq.tq_init(rs0, codLst, inxLst) # #3 xcod = qx.wrkInxCod print('\n#3,qx.wrkInx') print('\nqx.wrkInxCod,', qx.wrkInxCod) print('\nqx.wrkInxFinfo,', qx.wrkInxInfo) print('\nqx.wrkInxDat.tail') print(qx.wrkInxDat.tail()) # #4--plot print('\n#4,plot-->tmp/tmp_.html') hdr, fss = 'k线图-指数:' + xcod, 'tmp/tmp_.html' df2 = qx.wrkInxDat.tail(100)