def decide(self, tdf): stochRSI = self._compute_stochRSI(tdf.close) if stochRSI < self.buy_signal: return Buy() elif stochRSI > self.sell_signal: return Sell() else: return Hold()
def decide(self, tdf): RSI = _compute_RSI(tdf.close, self.n, self.avg_method) if RSI < self.buy_signal: return Buy() elif RSI > self.sell_signal: return Sell() else: return Hold()
def decide(self, tdf): d1 = self.m1.decide(tdf) d2 = self.m2.decide(tdf) if d1.sell() and d2.sell(): return Sell() elif d1.buy() and d2.buy(): return Buy() else: return Hold()
def decide(self, tdf): today_MFI = self._compute_MFI(tdf) yesterday_MFI = self._compute_MFI(tdf.iloc[:-1]) if today_MFI > self.sell_signal: return Sell() elif today_MFI < self.buy_signal: return Buy() else: return Hold()
def decide(self, tdf): now_CCI = self._compute_CCI(tdf) old_CCIs = [ self._compute_CCI(tdf.iloc[:-i]) for i in range(1, self.trend_n) ] if now_CCI > self.buy_signal and now_CCI > max(old_CCIs): return Buy() elif now_CCI < self.sell_signal and now_CCI > min(old_CCIs): return Sell() else: return Hold()
def decide(self, tdf): C = tdf.close.iloc[-1] H = tdf.high.iloc[-self.n:].max() L = tdf.low.iloc[-self.n:].min() K = (C - L) / (H - L) * 100 if K < self.buy_signal: return Buy() elif K > self.sell_signal: return Sell() else: return Hold()
def decide(self, tdf): ts = tdf.close ma_short_today = ts.iloc[-self.short_n:].mean() ma_short_yesterday = ts.iloc[-1 - self.short_n:-1].mean() ma_long_today = ts.iloc[-self.long_n:].mean() ma_long_yesterday = ts.iloc[-1 - self.long_n:-1].mean() if ma_short_today > ma_long_today and ma_short_yesterday < ma_long_yesterday: return Buy() elif ma_short_today < ma_long_today and ma_short_yesterday > ma_long_yesterday: return Sell() else: return Hold()
def decide(self, tdf): ts = tdf.close ma_today = ts.iloc[-self.n:].mean() ma_yesterday = ts.iloc[-1 - self.n:-1].mean() today = ts.iloc[-1] yesterday = ts.iloc[-2] if today > ma_today and yesterday < ma_yesterday: return Buy() elif today < ma_today and yesterday > ma_yesterday: return Sell() else: return Hold()
def decide(self, tdf): ts = tdf.close short_EMA = self._compute_EMA(ts, self.short_n) long_EMA = self._compute_EMA(ts, self.long_n) MACD_today = short_EMA - long_EMA ts_yesterday = ts.iloc[:-1] short_EMA = self._compute_EMA(ts_yesterday, self.short_n) long_EMA = self._compute_EMA(ts_yesterday, self.long_n) MACD_yesterday = short_EMA - long_EMA if MACD_yesterday < self.signal and MACD_today > self.signal: return Buy() elif MACD_yesterday > self.signal and MACD_today < self.signal: return Sell() else: return Hold()