def doTrade(pool, stdPeriod, stdGuage1, stdGuage2, aft, af, as1t, as1, as2t, as2, bft, bf, bs1t, bs1, bs2t, bs2, cft, cf, cs1t, cs1, cs2t, cs2): global std, prices sname = str(stdPeriod) + '_' + str(stdGuage1) + '_' + str(stdGuage2) sname += '_' + aft + '_' + str(af) + '_' + as1t + '_' + str(as1) + '_' + as2t + '_' + str(as2) sname += '_' + bft + '_' + str(bf) + '_' + bs1t + '_' + str(bs1) + '_' + bs2t + '_' + str(bs2) sname += '_' + cft + '_' + str(cf) + '_' + cs1t + '_' + str(cs1) + '_' + cs2t + '_' + str(cs2) afma, as1ma, as2ma = getMas(aft, af), getMas(as1t, as1), getMas(as2t, as2) bfma, bs1ma, bs2ma = getMas(bft, bf), getMas(bs1t, bs1), getMas(bs2t, bs2) cfma, cs1ma, cs2ma = getMas(cft, cf), getMas(cs1t, cs1), getMas(cs2t, cs2) front = max(as1, as2, bs1, bs2, cs1, cs2) t = Trader(sname) t.args = [aft, af, as1t, as1, as2t, as2, bft, bf, bs1t, bs1, bs2t, bs2, cft, cf, cs1t, cs1, cs2t, cs2] for i in range(front, len(prices)): price = prices[i] if std[stdPeriod][i] > stdGuage2: t.switchActiveCounter(2, price['dt'], price['rmb']) elif std[stdPeriod][i] > stdGuage1: t.switchActiveCounter(1, price['dt'], price['rmb']) else: t.switchActiveCounter(3, price['dt'], price['rmb']) for cntNo in range(3): if cntNo == 0: fma, s1, s1ma, s2, s2ma = afma, as1, as1ma, as2, as2ma if cntNo == 1: fma, s1, s1ma, s2, s2ma = bfma, bs1, bs1ma, bs2, bs2ma if cntNo == 2: fma, s1, s1ma, s2, s2ma = cfma, cs1, cs1ma, cs2, cs2ma if s1 == 0 and s2 == 0: continue volume = 0 notes = '' if s1 > 0 and fma[i - 1] <= s1ma[i - 1] and fma[i] > s1ma[i]: notes += 'f>s1;' + str(fma[i - 1]) + ';' + str(s1ma[i - 1]) + ';' + str(fma[i]) + ';' + str(s1ma[i]) + ';' volume += 1 if s1 > 0 and fma[i - 1] >= s1ma[i - 1] and fma[i] < s1ma[i]: notes += 'f<s1;' + str(fma[i - 1]) + ';' + str(s1ma[i - 1]) + ';' + str(fma[i]) + ';' + str(s1ma[i]) + ';' volume -= 1 if s2 > 0 and fma[i - 1] <= s2ma[i - 1] and fma[i] > s2ma[i]: notes += 'f>s2;' + str(fma[i - 1]) + ';' + str(s2ma[i - 1]) + ';' + str(fma[i]) + ';' + str(s2ma[i]) + ';' volume += 1 if s2 > 0 and fma[i - 1] >= s2ma[i - 1] and fma[i] < s2ma[i]: notes += 'f<s2;' + str(fma[i - 1]) + ';' + str(s2ma[i - 1]) + ';' + str(fma[i]) + ';' + str(s2ma[i]) + ';' volume -= 1 t.processOrder(price['dt'], price['rmb'], volume, cntNo=cntNo, notes=notes) pool.estimate(t) return t
def doTrade(pool, vfmt, vf, vsmt, vs, afmt, af, as1mt, as1, bfmt, bf, bs1mt, bs1): global prices sname = vfmt + '_' + str(vf) + '_' + vsmt + '_' + str(vs) sname += '_' + afmt + '_' + str(af) + '_' + as1mt + '_' + str(as1) sname += '_' + bfmt + '_' + str(bf) + '_' + bs1mt + '_' + str(bs1) if const.currentSecId: sname = const.currentSecId + '_' + sname vfma, vsma = getVmas(vfmt, vf), getVmas(vsmt, vs) afma, as1ma = getMas(afmt, af), getMas(as1mt, as1) bfma, bs1ma = getMas(bfmt, bf), getMas(bs1mt, bs1) front = max(vs, as1, bs1) active = 0 a1pos = b1pos = 0 a1wait = b1wait = 0 a1price = b1price = 0 t = Trader(sname) t.args = [afmt, af, as1mt, as1, bfmt, bf, bs1mt, bs1] for i in range(front, len(prices)): price = prices[i] active = 'A' if vfma[i] > vsma[i]: active = 'B' volume = 0 notes = '' oa1pos, ob1pos = a1pos, b1pos oa1wait, ob1wait = a1wait, b1wait #A if as1 > 0 and prices[i]['close'] > prices[ i - 1]['close'] and afma[i] > afma[i - 1] and afma[ i - 1] <= as1ma[i - 1] and afma[i] > as1ma[i]: a1wait = 1 if as1 > 0 and afma[i - 1] >= as1ma[i - 1] and afma[i] < as1ma[i]: a1wait = -1 if bs1 > 0 and prices[i]['close'] > prices[ i - 1]['close'] and bfma[i] > bfma[i - 1] and bfma[ i - 1] <= bs1ma[i - 1] and bfma[i] > bs1ma[i]: b1wait = 1 if bs1 > 0 and bfma[i - 1] >= bs1ma[i - 1] and bfma[i] < bs1ma[i]: b1wait = -1 if const.DIRECTION == 1 and a1wait == -1: a1wait = 0 if const.DIRECTION == 1 and b1wait == -1: b1wait = 0 if a1wait == 0: a1pos = 0 elif active == 'A' and a1wait != oa1wait: a1pos = genVolume(price['trade'], a1wait) if b1wait == 0: b1pos = 0 elif active == 'B' and b1wait != ob1wait: b1pos = genVolume(price['trade'], b1wait) if oa1pos != a1pos: volume += a1pos - oa1pos notes += 'A1:' + str(oa1pos) + '->' + str(a1pos) + ';' + str( a1price) + '->' + str(price['trade']) + ';' + 'afma:' + str( afma[i - 1]) + '->' + str(afma[i]) + ';as1ma:' + str( as1ma[i - 1]) + '->' + str(as1ma[i]) + ';' a1price = price['trade'] if ob1pos != b1pos: volume += b1pos - ob1pos notes += 'B1:' + str(ob1pos) + '->' + str(b1pos) + ';' + str( b1price) + '->' + str(price['trade']) + ';' + 'afma:' + str( bfma[i - 1]) + '->' + str(bfma[i]) + ';bs1ma:' + str( bs1ma[i - 1]) + '->' + str(bs1ma[i]) + ';' b1price = price['trade'] if volume != 0: t.processOrder(price['dt'], price['trade'], volume, notes=notes) else: t.summary(price['dt'], price['trade']) pool.estimate(t) return t
def doTrade(pool, vfmt, vf, vsmt, vs, afmt, af, as1mt, as1, bfmt, bf, bs1mt, bs1): global prices sname = vfmt + '_' + str(vf) + '_' + vsmt + '_' + str(vs) sname += '_' + afmt + '_' + str(af) + '_' + as1mt + '_' + str(as1) sname += '_' + bfmt + '_' + str(bf) + '_' + bs1mt + '_' + str(bs1) if const.currentSecId: sname = const.currentSecId + '_' + sname vfma, vsma = getVmas(vfmt, vf), getVmas(vsmt, vs) afma, as1ma = getMas(afmt, af), getMas(as1mt, as1) bfma, bs1ma = getMas(bfmt, bf), getMas(bs1mt, bs1) front = max(vs, as1, bs1) active = 0 a1pos = b1pos = 0 a1wait = b1wait = 0 a1price = b1price = 0 t = Trader(sname) t.args = [afmt, af, as1mt, as1, bfmt, bf, bs1mt, bs1] for i in range(front, len(prices)): price = prices[i] active = 'A' if vfma[i] > vsma[i]: active = 'B' volume = 0 notes = '' oa1pos, ob1pos = a1pos, b1pos oa1wait, ob1wait = a1wait, b1wait #A if as1 > 0 and prices[i]['close'] > prices[i - 1]['close'] and afma[i] > afma[i - 1] and afma[i - 1] <= as1ma[i - 1] and afma[i] > as1ma[i]: a1wait = 1 if as1 > 0 and afma[i - 1] >= as1ma[i - 1] and afma[i] < as1ma[i]: a1wait = -1 if bs1 > 0 and prices[i]['close'] > prices[i - 1]['close'] and bfma[i] > bfma[i - 1] and bfma[i - 1] <= bs1ma[i - 1] and bfma[i] > bs1ma[i]: b1wait = 1 if bs1 > 0 and bfma[i - 1] >= bs1ma[i - 1] and bfma[i] < bs1ma[i]: b1wait = -1 if const.DIRECTION == 1 and a1wait == -1: a1wait = 0 if const.DIRECTION == 1 and b1wait == -1: b1wait = 0 if a1wait == 0: a1pos = 0 elif active == 'A' and a1wait != oa1wait: a1pos = genVolume(price['trade'], a1wait) if b1wait == 0: b1pos = 0 elif active == 'B' and b1wait != ob1wait: b1pos = genVolume(price['trade'], b1wait) if oa1pos != a1pos: volume += a1pos - oa1pos notes += 'A1:'+ str(oa1pos) + '->' + str(a1pos) + ';' + str(a1price) + '->' + str(price['trade']) + ';' + 'afma:'+ str(afma[i - 1]) + '->' + str(afma[i]) + ';as1ma:' + str(as1ma[i - 1]) + '->' + str(as1ma[i]) + ';' a1price = price['trade'] if ob1pos != b1pos: volume += b1pos - ob1pos notes += 'B1:'+ str(ob1pos) + '->' + str(b1pos) + ';' + str(b1price) + '->' + str(price['trade']) + ';' + 'afma:'+ str(bfma[i - 1]) + '->' + str(bfma[i]) + ';bs1ma:' + str(bs1ma[i - 1]) + '->' + str(bs1ma[i]) + ';' b1price = price['trade'] if volume != 0: t.processOrder(price['dt'], price['trade'], volume, notes=notes) else: t.summary(price['dt'], price['trade']) pool.estimate(t) return t
def doTrade(pool, stdPeriod, stdGuage1, stdGuage2, aft, af, as1t, as1, as2t, as2, bft, bf, bs1t, bs1, bs2t, bs2, cft, cf, cs1t, cs1, cs2t, cs2): global std, prices sname = str(stdPeriod) + '_' + str(stdGuage1) + '_' + str(stdGuage2) sname += '_' + aft + '_' + str(af) + '_' + as1t + '_' + str( as1) + '_' + as2t + '_' + str(as2) sname += '_' + bft + '_' + str(bf) + '_' + bs1t + '_' + str( bs1) + '_' + bs2t + '_' + str(bs2) sname += '_' + cft + '_' + str(cf) + '_' + cs1t + '_' + str( cs1) + '_' + cs2t + '_' + str(cs2) afma, as1ma, as2ma = getMas(aft, af), getMas(as1t, as1), getMas(as2t, as2) bfma, bs1ma, bs2ma = getMas(bft, bf), getMas(bs1t, bs1), getMas(bs2t, bs2) cfma, cs1ma, cs2ma = getMas(cft, cf), getMas(cs1t, cs1), getMas(cs2t, cs2) front = max(as1, as2, bs1, bs2, cs1, cs2) t = Trader(sname) t.args = [ aft, af, as1t, as1, as2t, as2, bft, bf, bs1t, bs1, bs2t, bs2, cft, cf, cs1t, cs1, cs2t, cs2 ] for i in range(front, len(prices)): price = prices[i] if std[stdPeriod][i] > stdGuage2: t.switchActiveCounter(2, price['dt'], price['rmb']) elif std[stdPeriod][i] > stdGuage1: t.switchActiveCounter(1, price['dt'], price['rmb']) else: t.switchActiveCounter(3, price['dt'], price['rmb']) for cntNo in range(3): if cntNo == 0: fma, s1, s1ma, s2, s2ma = afma, as1, as1ma, as2, as2ma if cntNo == 1: fma, s1, s1ma, s2, s2ma = bfma, bs1, bs1ma, bs2, bs2ma if cntNo == 2: fma, s1, s1ma, s2, s2ma = cfma, cs1, cs1ma, cs2, cs2ma if s1 == 0 and s2 == 0: continue volume = 0 notes = '' if s1 > 0 and fma[i - 1] <= s1ma[i - 1] and fma[i] > s1ma[i]: notes += 'f>s1;' + str(fma[i - 1]) + ';' + str( s1ma[i - 1]) + ';' + str(fma[i]) + ';' + str(s1ma[i]) + ';' volume += 1 if s1 > 0 and fma[i - 1] >= s1ma[i - 1] and fma[i] < s1ma[i]: notes += 'f<s1;' + str(fma[i - 1]) + ';' + str( s1ma[i - 1]) + ';' + str(fma[i]) + ';' + str(s1ma[i]) + ';' volume -= 1 if s2 > 0 and fma[i - 1] <= s2ma[i - 1] and fma[i] > s2ma[i]: notes += 'f>s2;' + str(fma[i - 1]) + ';' + str( s2ma[i - 1]) + ';' + str(fma[i]) + ';' + str(s2ma[i]) + ';' volume += 1 if s2 > 0 and fma[i - 1] >= s2ma[i - 1] and fma[i] < s2ma[i]: notes += 'f<s2;' + str(fma[i - 1]) + ';' + str( s2ma[i - 1]) + ';' + str(fma[i]) + ';' + str(s2ma[i]) + ';' volume -= 1 t.processOrder(price['dt'], price['rmb'], volume, cntNo=cntNo, notes=notes) pool.estimate(t) return t
def doTrade(pool, stdPeriod, stdGuage, afmt, af, as1mt, as1, as2mt, as2, bfmt, bf, bs1mt, bs1, bs2mt, bs2): global std, prices sname = str(stdPeriod) + "_" + str(stdGuage) sname += "_" + afmt + "_" + str(af) + "_" + as1mt + "_" + str(as1) if as2 > 0: sname += "_" + as2mt + "_" + str(as2) sname += "_" + bfmt + "_" + str(bf) + "_" + bs1mt + "_" + str(bs1) if bs2 > 0: sname += "_" + bs2mt + "_" + str(bs2) afma, as1ma, as2ma = getMas(afmt, af), getMas(as1mt, as1), getMas(as2mt, as2) bfma, bs1ma, bs2ma = getMas(bfmt, bf), getMas(bs1mt, bs1), getMas(bs2mt, bs2) front = max(as1, as2, bs1, bs2) t = Trader(sname) t.args = [stdPeriod, stdGuage, afmt, af, as1mt, as1, as2mt, as2, bfmt, bf, bs1mt, bs1, bs2mt, bs2] for i in range(front, len(prices)): price = prices[i] if std[stdPeriod][i] > stdGuage: t.switchActiveCounter(1, price["dt"], price["rmb"]) else: t.switchActiveCounter(0, price["dt"], price["rmb"]) # if std[stdPeriod][i] > 1.3: # t.switchActiveCounter(1, price['dt'], price['rmb']) # elif std[stdPeriod][i] > stdGuage: # t.switchActiveCounter(0, price['dt'], price['rmb']) # else: # t.switchActiveCounter(2, price['dt'], price['rmb']) volume = 0 notes = "" if as1 > 0 and afma[i - 1] <= as1ma[i - 1] and afma[i] > as1ma[i]: notes += ( "af>as1;" + str(afma[i - 1]) + ";" + str(as1ma[i - 1]) + ";" + str(afma[i]) + ";" + str(as1ma[i]) + ";" ) volume += 1 if as1 > 0 and afma[i - 1] >= as1ma[i - 1] and afma[i] < as1ma[i]: notes += ( "af<as1;" + str(afma[i - 1]) + ";" + str(as1ma[i - 1]) + ";" + str(afma[i]) + ";" + str(as1ma[i]) + ";" ) volume += -1 if as2 > 0 and afma[i - 1] <= as2ma[i - 1] and afma[i] > as2ma[i]: notes += ( "af>as2;" + str(afma[i - 1]) + ";" + str(as2ma[i - 1]) + ";" + str(afma[i]) + ";" + str(as2ma[i]) + ";" ) volume += 1 if as2 > 0 and afma[i - 1] >= as2ma[i - 1] and afma[i] < as2ma[i]: notes += ( "af<as2;" + str(afma[i - 1]) + ";" + str(as2ma[i - 1]) + ";" + str(afma[i]) + ";" + str(as2ma[i]) + ";" ) volume += -1 t.processOrder(price["dt"], price["rmb"], volume * 1000, cntNo=0, notes=notes) volume = 0 notes = "" if bs1 > 0 and bfma[i - 1] <= bs1ma[i - 1] and bfma[i] > bs1ma[i]: notes += ( "bf>bs1;" + str(bfma[i - 1]) + ";" + str(bs1ma[i - 1]) + ";" + str(bfma[i]) + ";" + str(bs1ma[i]) + ";" ) volume += 1 if bs1 > 0 and bfma[i - 1] >= bs1ma[i - 1] and bfma[i] < bs1ma[i]: notes += ( "bf<bs1," + str(bfma[i - 1]) + ";" + str(bs1ma[i - 1]) + ";" + str(bfma[i]) + ";" + str(bs1ma[i]) + ";" ) volume += -1 if bs2 > 0 and bfma[i - 1] <= bs2ma[i - 1] and bfma[i] > bs2ma[i]: notes += ( "bf>bs2;" + str(bfma[i - 1]) + ";" + str(bs2ma[i - 1]) + ";" + str(bfma[i]) + ";" + str(bs2ma[i]) + ";" ) volume += 1 if bs2 > 0 and bfma[i - 1] >= bs2ma[i - 1] and bfma[i] < bs2ma[i]: notes += "bf<bs2;" + str(bfma[i - 1]) + ";" + str(bs2ma[i - 1]) + ";" + str(bfma[i]) + ";" + str(bs2ma[i]) volume += -1 t.processOrder(price["dt"], price["rmb"], volume * 1000, cntNo=1, notes=notes) pool.estimate(t) print t.stats["equity"] return t
def doTrade(pool, stdPeriod, stdGuage, afmt, af, as1mt, as1, as2mt, as2, bfmt, bf, bs1mt, bs1, bs2mt, bs2): global std, prices sname = str(stdPeriod) + '_' + str(stdGuage) sname += '_' + afmt + '_' + str(af) + '_' + as1mt + '_' + str(as1) if as2 > 0: sname += '_' + as2mt + '_' + str(as2) sname += '_' + bfmt + '_' + str(bf) + '_' + bs1mt + '_' + str(bs1) if bs2 > 0: sname += '_' + bs2mt + '_' + str(bs2) afma, as1ma, as2ma = getMas(afmt, af), getMas(as1mt, as1), getMas(as2mt, as2) bfma, bs1ma, bs2ma = getMas(bfmt, bf), getMas(bs1mt, bs1), getMas(bs2mt, bs2) front = max(as1, as2, bs1, bs2) t = Trader(sname) t.args = [ stdPeriod, stdGuage, afmt, af, as1mt, as1, as2mt, as2, bfmt, bf, bs1mt, bs1, bs2mt, bs2 ] for i in range(front, len(prices)): price = prices[i] if std[stdPeriod][i] > stdGuage: t.switchActiveCounter(1, price['dt'], price['rmb']) else: t.switchActiveCounter(0, price['dt'], price['rmb']) #if std[stdPeriod][i] > 1.3: # t.switchActiveCounter(1, price['dt'], price['rmb']) #elif std[stdPeriod][i] > stdGuage: # t.switchActiveCounter(0, price['dt'], price['rmb']) #else: # t.switchActiveCounter(2, price['dt'], price['rmb']) if as1 > 0 and afma[i - 1] <= as1ma[i - 1] and afma[i] > as1ma[i]: notes = 'af>as1;' + str(afma[i - 1]) + ';' + str( as1ma[i - 1]) + ';' + str(afma[i]) + ';' + str(as1ma[i]) t.buy(price['dt'], price['rmb'], cntNo=0, notes=notes) if as1 > 0 and afma[i - 1] >= as1ma[i - 1] and afma[i] < as1ma[i]: notes = 'af<as1;' + str(afma[i - 1]) + ';' + str( as1ma[i - 1]) + ';' + str(afma[i]) + ';' + str(as1ma[i]) t.sell(price['dt'], price['rmb'], cntNo=0, notes=notes) if as2 > 0 and afma[i - 1] <= as2ma[i - 1] and afma[i] > as2ma[i]: notes = 'af>as2;' + str(afma[i - 1]) + ';' + str( as2ma[i - 1]) + ';' + str(afma[i]) + ';' + str(as2ma[i]) t.buy(price['dt'], price['rmb'], cntNo=0, notes=notes) if as2 > 0 and afma[i - 1] >= as2ma[i - 1] and afma[i] < as2ma[i]: notes = 'af<as2;' + str(afma[i - 1]) + ';' + str( as2ma[i - 1]) + ';' + str(afma[i]) + ';' + str(as2ma[i]) t.sell(price['dt'], price['rmb'], cntNo=0, notes=notes) if bs1 > 0 and bfma[i - 1] <= bs1ma[i - 1] and bfma[i] > bs1ma[i]: notes = 'bf>bs1;' + str(bfma[i - 1]) + ';' + str( bs1ma[i - 1]) + ';' + str(bfma[i]) + ';' + str(bs1ma[i]) t.buy(price['dt'], price['rmb'], cntNo=1, notes=notes) if bs1 > 0 and bfma[i - 1] >= bs1ma[i - 1] and bfma[i] < bs1ma[i]: notes = 'bf<bs1,' + str(bfma[i - 1]) + ';' + str( bs1ma[i - 1]) + ';' + str(bfma[i]) + ';' + str(bs1ma[i]) t.sell(price['dt'], price['rmb'], cntNo=1, notes=notes) if bs2 > 0 and bfma[i - 1] <= bs2ma[i - 1] and bfma[i] > bs2ma[i]: notes = 'bf>bs2;' + str(bfma[i - 1]) + ';' + str( bs2ma[i - 1]) + ';' + str(bfma[i]) + ';' + str(bs2ma[i]) t.buy(price['dt'], price['rmb'], cntNo=1, notes=notes) if bs2 > 0 and bfma[i - 1] >= bs2ma[i - 1] and bfma[i] < bs2ma[i]: notes = 'bf<bs2;' + str(bfma[i - 1]) + ';' + str( bs2ma[i - 1]) + ';' + str(bfma[i]) + ';' + str(bs2ma[i]) t.sell(price['dt'], price['rmb'], cntNo=1, notes=notes) t.show(price['dt'], price['rmb']) pool.estimate(t) return t
def doTrade(pool, stdPeriod, stdGuage, afmt, af, as1mt, as1, as2mt, as2, bfmt, bf, bs1mt, bs1, bs2mt, bs2): global std, prices sname = str(stdPeriod) + '_' + str(stdGuage) sname += '_' + afmt + '_' + str(af) + '_' + as1mt + '_' + str(as1) if as2 > 0: sname += '_' + as2mt + '_' + str(as2) sname += '_' + bfmt + '_' + str(bf) + '_' + bs1mt + '_' +str(bs1) if bs2 > 0: sname += '_' + bs2mt + '_' + str(bs2) afma, as1ma, as2ma = getMas(afmt, af), getMas(as1mt, as1), getMas(as2mt, as2) bfma, bs1ma, bs2ma = getMas(bfmt, bf), getMas(bs1mt, bs1), getMas(bs2mt, bs2) front = max(as1, as2, bs1, bs2) t = Trader(sname) t.args = [stdPeriod, stdGuage, afmt, af, as1mt, as1, as2mt, as2, bfmt, bf, bs1mt, bs1, bs2mt, bs2] for i in range(front, len(prices)): price = prices[i] if std[stdPeriod][i] > stdGuage: t.switchActiveCounter(1, price['dt'], price['rmb']) else: t.switchActiveCounter(0, price['dt'], price['rmb']) #if std[stdPeriod][i] > 1.3: # t.switchActiveCounter(1, price['dt'], price['rmb']) #elif std[stdPeriod][i] > stdGuage: # t.switchActiveCounter(0, price['dt'], price['rmb']) #else: # t.switchActiveCounter(2, price['dt'], price['rmb']) if as1 > 0 and afma[i - 1] <= as1ma[i - 1] and afma[i] > as1ma[i]: notes = 'af>as1;' + str(afma[i - 1]) + ';' + str(as1ma[i - 1]) + ';' + str(afma[i]) + ';' + str(as1ma[i]) t.buy(price['dt'], price['rmb'], cntNo=0, notes=notes) if as1 > 0 and afma[i - 1] >= as1ma[i - 1] and afma[i] < as1ma[i]: notes = 'af<as1;' + str(afma[i - 1]) + ';' + str(as1ma[i - 1]) + ';' + str(afma[i]) + ';' + str(as1ma[i]) t.sell(price['dt'], price['rmb'], cntNo=0, notes=notes) if as2 > 0 and afma[i - 1] <= as2ma[i - 1] and afma[i] > as2ma[i]: notes = 'af>as2;' + str(afma[i - 1]) + ';' + str(as2ma[i - 1]) + ';' + str(afma[i]) + ';' + str(as2ma[i]) t.buy(price['dt'], price['rmb'], cntNo=0, notes=notes) if as2 > 0 and afma[i - 1] >= as2ma[i - 1] and afma[i] < as2ma[i]: notes = 'af<as2;' + str(afma[i - 1]) + ';' + str(as2ma[i - 1]) + ';' + str(afma[i]) + ';' + str(as2ma[i]) t.sell(price['dt'], price['rmb'], cntNo=0, notes=notes) if bs1 > 0 and bfma[i - 1] <= bs1ma[i - 1] and bfma[i] > bs1ma[i]: notes = 'bf>bs1;' + str(bfma[i - 1]) + ';' + str(bs1ma[i - 1]) + ';' + str(bfma[i]) + ';' + str(bs1ma[i]) t.buy(price['dt'], price['rmb'], cntNo=1, notes=notes) if bs1 > 0 and bfma[i - 1] >= bs1ma[i - 1] and bfma[i] < bs1ma[i]: notes = 'bf<bs1,' + str(bfma[i - 1]) + ';' + str(bs1ma[i - 1]) + ';' + str(bfma[i]) + ';' + str(bs1ma[i]) t.sell(price['dt'], price['rmb'], cntNo=1, notes=notes) if bs2 > 0 and bfma[i - 1] <= bs2ma[i - 1] and bfma[i] > bs2ma[i]: notes = 'bf>bs2;' + str(bfma[i - 1]) + ';' + str(bs2ma[i - 1]) + ';' + str(bfma[i]) + ';' + str(bs2ma[i]) t.buy(price['dt'], price['rmb'], cntNo=1, notes=notes) if bs2 > 0 and bfma[i - 1] >= bs2ma[i - 1] and bfma[i] < bs2ma[i]: notes = 'bf<bs2;' + str(bfma[i - 1]) + ';' + str(bs2ma[i - 1]) + ';' + str(bfma[i]) + ';' + str(bs2ma[i]) t.sell(price['dt'], price['rmb'], cntNo=1, notes=notes) t.show(price['dt'], price['rmb']) pool.estimate(t) return t