def showStrategies(self): rate = 1 logs.info('STRATEGY,BUY TIMES, SELL TIMES, DOWNS, FINAL EQUITY') logtr.info('OP,STRATEGY,TIME,VOLUME,PRICE,POSITION,NOTES,EQUITY,BALANCE') for s in self.strategies: if s[0] == 0: break logs.info(s[0].strategyName + ',' + str(len(s[0].stats['buy']['date'])) + ',' + str(len(s[0].stats['sell']['date'])) + ',' + str(s[0].stats['downDays']) + ',' + str(s[1])) for tl in s[0].stats['log']: logtr.info(tl) s[0].generateGraph(rate) rate += 1
def showStrategies(self): rate = 1 logs.info('STRATEGY,BUY TIMES, SELL TIMES, DOWN DAYS, FINAL EQUITY') logtr.info('OP,STRATEGY,TIME,COUNTER,PRICE,VOLUMN,POSITION,NOTES') for s in self.strategies: if s[0] == 0: break logs.info(s[0].strategyName + ',' + str(len(s[0].stats['buy']['date'])) + ',' + str(len(s[0].stats['sell']['date'])) + ',' + str(s[0].stats['downDays']) + ',' + str(s[1])) for tl in s[0].stats['log']: logtr.info(tl) s[0].generateGraph(rate) rate += 1
def doTrade(tname, front, ops): pools = pool.VoterPool(1, prices) pools.estimate(tname, ops, front) pools.showVoters() t = Trader(tname) lastArea = -1 countdowns = [3] * 4 vols = [0] * 4 for i in range(front, l): price = prices[i] volume = 0 area = areas[i] notes = 'AREA:' + str(area) + ';VOL:' + str(vols[area]) + '->' + str( ops[i]) volume = ops[i] - vols[area] vols[area] = ops[i] countdowns[area] = 3 if volume == 0: notes = '' for j in range(4): if j == area: continue if countdowns[j] > 0: countdowns[j] -= 1 if countdowns[j] == 0 and vols[j] != 0: volume -= vols[j] notes += ';CLOSE AREA:' + str(j) + ';VOL:' + str( vols[j]) + '->0' vols[j] = 0 if volume != 0: t.processOrder(price['dt'], price['rmb'], volume * 1000, notes=notes) else: t.summary(price['dt'], price['rmb']) logs.info(t.strategyName + ',' + str(len(t.stats['buy']['date'])) + ',' + str(len(t.stats['sell']['date'])) + ',' + str(t.stats['downDays']) + ',' + str(t.equity)) logtr.info('OP,STRATEGY,TIME,VOLUME,PRICE,POSITION,NOTES,EQUITY,BALANCE') for tl in t.stats['log']: logtr.info(tl) t.generateGraph(0)
def doTrade(tname, front, ops): pools = pool.VoterPool(1, prices) pools.estimate(tname, ops, front) pools.showVoters() t = Trader(tname) lastArea = -1 countdowns = [COUNT_DOWN] * 4 vols = [0] * 4 for i in range(front, l): price = prices[i] volume = 0 area = areas[i] if pool.checkTime(price['dt']): if vols[area] == 0: notes = 'AREA:' + str(area) + ';VOL:' + str(vols[area]) + '->' + str(ops[i]) + ';' volume = ops[i] - vols[area] vols[area] = ops[i] countdowns[area] = COUNT_DOWN if volume == 0: notes = '' for j in range(4): #if j == area: continue if countdowns[j] > 0: countdowns[j] -= 1 if countdowns[j] == 0 and vols[j] != 0: volume -= vols[j] notes += 'CLOSE AREA:' + str(j) + ';VOL:' + str(vols[j]) + '->0;' vols[j] = 0 else: # not trading time for j in range(4): if countdowns[j] > 0: countdowns[j] -= 1 if volume != 0: t.processOrder(price['dt'], price['rmb'], volume, notes=notes) else: t.summary(price['dt'], price['rmb']) logs.info(t.strategyName + ',' + str(len(t.stats['buy']['date'])) + ',' + str(len(t.stats['sell']['date'])) + ',' + str(t.stats['downDays']) + ',' + str(t.equity)) logtr.info('OP,STRATEGY,TIME,VOLUME,PRICE,POSITION,NOTES,EQUITY,BALANCE') for tl in t.stats['log']: logtr.info(tl) t.generateGraph(0)