def __update_SMA_EMA(self, all_candles, period, previous_EMA):
     if len(all_candles) > period:
         last_candles = Candle.select_last_candles(all_candles, self.pair,
                                                   period)
         SMA = self.SMA.SMA(Candle.select_closing_prices(last_candles))
         EMA = self.EMA.EMA(Candle.select_closing_prices(last_candles),
                            previous_EMA)
         return SMA, EMA
Example #2
0
 def feed(self, all_candles, last_14_candles):
     if len(all_candles) < 14:
         return
     last_14_closing_prices = Candle.select_closing_prices(last_14_candles)
     if len(all_candles) == 14:
         gains = 0
         losses = 0
         for x in range(1, 14):
             delta = last_14_closing_prices[x] - last_14_closing_prices[x -
                                                                        1]
             if delta < 0:
                 losses += abs(delta)
             else:
                 gains += delta
         self.RSI_previous_average_gain = gains / 14
         self.RSI_previous_average_loss = losses / 14
     else:
         delta = last_14_closing_prices[-1] - last_14_closing_prices[-2]
         current_gain = 0
         current_loss = 0
         if delta < 0:
             current_loss = abs(delta)
         else:
             current_gain = delta
         self.RSI_previous_average_gain = (
             self.RSI_previous_average_gain * 13 + current_gain) / 14
         self.RSI_previous_average_loss = (
             self.RSI_previous_average_loss * 13 + current_loss) / 14
         RS = self.RSI_previous_average_gain / self.RSI_previous_average_loss
         self.RSI.append(100 - 100 / (1 + RS))
         self.__update_RSI_indicator()
 def __update_standard_deviation(self, all_candles):
     if len(all_candles) < 20:
         return
     last_20_candles = Candle.select_last_candles(all_candles, self.pair,
                                                  20)
     last_20_closing_prices = Candle.select_closing_prices(last_20_candles)
     from numpy import std
     self.standard_deviation.append(std(last_20_closing_prices))
 def __update_SMA_EMA_first_time(self, all_candles, period):
     if len(all_candles) < period:
         raise AverageComputationTooEarly
     if len(all_candles) == period:
         last_candles = Candle.select_last_candles(all_candles, self.pair,
                                                   period)
         SMA = self.SMA.SMA(Candle.select_closing_prices(last_candles))
         return SMA, SMA
Example #5
0
 def __debug_plot_charts(self, all_candles):
     all_USDT_ETH_candles = Candle.select_last_candles(
         all_candles, "USDT_ETH", -1)
     closing_prices = Candle.select_closing_prices(all_USDT_ETH_candles)
     dates = Candle.select_dates(all_USDT_ETH_candles)
     self.__drawer.draw(closing_prices, dates,
                        self.__USDT_ETH_indicators.EMA.EMA_12,
                        self.__USDT_ETH_indicators.EMA.EMA_26,
                        self.__USDT_ETH_indicators.MACD.MACD,
                        self.__USDT_ETH_indicators.MACD.MACD_signal,
                        self.__USDT_ETH_indicators.stochastic.stochastic_D,
                        self.__USDT_ETH_indicators.RSI.RSI,
                        self.__USDT_ETH_indicators.ADX.ADX)