You are viewing a single comment's thread from:
RE: Coding a Poloniex Trading Bot
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. :-)
Oh, need to change the call as well.
Geez, do you think in code?
I wish. :-)