def runVoter(in_prices): global prices, areas, l prices = in_prices directs, slopes, stds, areas = pool.calc_variants(prices) l = len(prices) ps = [p['close'] for p in prices] mafront, maOps = getMaOps(ps) doTrade('MA', mafront, maOps) return macdfront, macdOps = getMacdOps(prices) doTrade('MACD', macdfront, macdOps) return front = max(mafront, macdfront) ops = [0] * l for i in range(l): if maOps[i] + macdOps[i] >= 2: ops[i] = 1 elif maOps[i] + macdOps[i] <= -2: ops[i] = -1 doTrade('MA', front, ops) return
def runVoter(in_prices): global prices, areas, l prices = in_prices directs, slopes, stds, areas = pool.calc_variants(prices) l = len(prices) ps = [p['close'] for p in prices] mafront, maOps = getMaOps(ps) doTrade('MA', mafront, maOps) return
def drawStat(prices): l = len(prices) directs, slopes, stds, areas = pool.calc_variants(prices) dts = [p['dt'] for p in prices] ps = [p['close'] for p in prices] fig = plt.figure() ax1 = fig.add_subplot(211) ax1.plot_date(dts, areas, 'r-') ax1.set_ylim(-1, 4) #ax1.plot_date(dts, stds, 'r-') ax2 = fig.add_subplot(212) ax2.plot_date(dts, ps, 'b-') plt.show()