You are viewing a single comment's thread from:

RE: Coding a Poloniex Trading Bot

in #trading7 years ago

Nice and easy to test. Minimal change to existing code.

class PriceCrossSMABackTest(BackTest):
    def addindicators(self, **kwargs):
        self.ma = kwargs["ma"]
        self.data["ma"] = self.data["close"].rolling(self.ma).mean()

    def dostep(self):
        if self.step > self.ma:
            prevprice = self.data.ix[self.step-1, "close"]
            price = self.data.ix[self.step, "close"]
            prevma = self.data.ix[self.step-1, "ma"]
            ma = self.data.ix[self.step, "ma"]


            if price > ma and prevprice < prevma:
                self.buy(price)
            elif price < ma and prevprice > prevma:
                self.sell(price)

Really need to get a GUI going so I can visualise what the strategy is actually doing.

Later bud. :-)

Sort:  

Oh, need to change the call as well.

test = PriceCrossSMABackTest(portfolio.chartdata["ETH"], ma=50)

Coin Marketplace

STEEM 0.17
TRX 0.16
JST 0.029
BTC 74780.04
ETH 2804.04
USDT 1.00
SBD 2.49