How to use the storage.indicators.writelist function in storage

To help you get started, we’ve selected a few storage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Galts-Gulch / avarice / indicators.py View on Github external
Helpers.WMA(storage.getlist('DMI_PosDM_list'),
                                      storage.getlist('DMI_PosDMWMA_list'), gc.ATR.Period))
        storage.writelist('DMI_NegDMWMA_list',
                          Helpers.WMA(storage.getlist('DMI_NegDM_list'),
                                      storage.getlist('DMI_NegDMWMA_list'), gc.ATR.Period))
        storage.writelist('DMI_PosDI_list',
                          storage.getlist('DMI_PosDMWMA_list')[-1]
                          / storage.getlist('ATR_ind_list')[-1])
        storage.writelist('DMI_NegDI_list',
                          storage.getlist('DMI_NegDMWMA_list')[-1]
                          / storage.getlist('ATR_ind_list')[-1])

        DIDiff = abs(storage.getlist('DMI_PosDI_list')[-1]
                     - storage.getlist('DMI_NegDI_list')[-1])
        try:
          storage.writelist('DMI_DX_list', DIDiff
                            / (storage.getlist('DMI_PosDI_list')[-1]
                               + storage.getlist('DMI_NegDI_list')[-1]))
          # ADX
          if len(storage.getlist('DMI_DX_list')) >= (gc.ATR.Period * 2):
            storage.writelist('DMI_ind_list',
                              Helpers.WMA(storage.getlist('DMI_DX_list'),
                                          storage.getlist('DMI_ind_list'), gc.ATR.Period))
        except ZeroDivisionError:
          pass

        # Hack for trading with both DI crossovers and ADX threshold.
        if storage.getlist('DMI_ind_list'):
          if storage.getlist('DMI_ind_list')[-1] > gc.DMI.Threshold:
            if storage.getlist('DMI_PosDI_list')[-1] > storage.getlist('DMI_NegDI_list')[-1]:
              # Buy
              storage.writelist('DMI_DMISignal_list', -1)
github Galts-Gulch / avarice / indicators.py View on Github external
storage.writelist('Ichimoku_Optimized_list', 1)
        OptimizedTrend = 'Bearish'
      else:
        storage.writelist('Ichimoku_Optimized_list', 0)
        OptimizedTrend = 'No trend'
      # Weak Signals
      if TS > KS:
        # BUY!
        storage.writelist('Ichimoku_Weak_list', -1)
        WeakTrend = 'Bullish'
      elif KS > TS:
        # SELL!
        storage.writelist('Ichimoku_Weak_list', 1)
        WeakTrend = 'Bearish'
      else:
        storage.writelist('Ichimoku_Weak_list', 0)
        WeakTrend = 'No trend'

      # Store price cloud history
      if CP < CloudMin:
        # Below
        storage.writelist('Ichimoku_CloudHistory_list', -1)
      elif CP > CloudMin and CP < CloudMax:
        # Inside
        storage.writelist('Ichimoku_CloudHistory_list', 0)
      elif CP > CloudMax:
        # Above
        storage.writelist('Ichimoku_CloudHistory_list', 1)

      # CloudOnly signals
      CH = storage.getlist('Ichimoku_CloudHistory_list')
      if len(CH) > 1:
github Galts-Gulch / avarice / indicators.py View on Github external
def indicator():
    # We can start DEMAs once we have max period candles
    if len(storage.getlist('MACD_Long_list')) >= max(gc.MACD.LongPeriod, gc.MACD.ShortPeriod):
      storage.writelist('DMACD_Short_list', Helpers.DEMA(storage.getlist(
          'MACD_Short_list'), storage.getlist('DMACD_Short_list'), gc.MACD.ShortPeriod))
      storage.writelist('DMACD_Long_list', Helpers.DEMA(storage.getlist(
          'MACD_Long_list'), storage.getlist('DMACD_Long_list'), gc.MACD.LongPeriod))
      storage.writelist('DMACD_ind_list', storage.getlist(
          'DMACD_Short_list')[-1] - storage.getlist('DMACD_Long_list')[-1])

      # We need MACDSignal DMACDs before generating Signal
      if len(storage.getlist('DMACD_Long_list')) >= (gc.MACD.SignalPeriod +
                                                     (abs(gc.MACD.SignalPeriod - gc.MACD.LongPeriod))):
        storage.writelist('DMACD_Signal_list', Helpers.DEMA(storage.getlist(
            'MACD_Signal_list'), storage.getlist('DMACD_Signal_list'), gc.MACD.SignalPeriod))
        storage.writelist('DMACD_Histogram_list', storage.getlist(
            'DMACD_ind_list')[-1] - storage.getlist('DMACD_Signal_list')[-1])

      if 'DMACD' in gc.Trader.VerboseIndicators:
        if not storage.getlist('DMACD_Signal_list'):
github Galts-Gulch / avarice / indicators.py View on Github external
def indicator():
    # We can start SMA calculations once we have max period candles
    if len(ldb.price_list) >= max(gc.SMA.LongPeriod, gc.SMA.ShortPeriod):
      storage.writelist(
          'SMA_Short_list', Helpers.SMA(ldb.price_list, gc.SMA.ShortPeriod))
      storage.writelist(
          'SMA_Long_list', Helpers.SMA(ldb.price_list, gc.SMA.LongPeriod))
      storage.writelist('SMA_Diff_list', Helpers.ListDiff(
          storage.getlist('SMA_Short_list'), storage.getlist('SMA_Long_list')))

    if 'SMA' in gc.Trader.VerboseIndicators:
      if not storage.getlist('SMA_Long_list'):
        print('SMA: Not yet enough data to determine trend')
      else:
        gu.PrintIndicatorTrend('SMA', storage.getlist('SMA_Short_list'), storage.getlist(
            'SMA_Long_list'), storage.getlist('SMA_Diff_list'), gc.SMA.DiffDown, gc.SMA.DiffUp)
github Galts-Gulch / avarice / indicators.py View on Github external
def indicator():
    # We need a minimum of 2 candles to start RS calculations
    if len(ldb.price_list) >= 2:
      if ldb.price_list[-1] > ldb.price_list[-2]:
        gain = ldb.price_list[-1] - ldb.price_list[-2]
        storage.writelist('RSI_RS_gain_list', gain)
        storage.writelist('RSI_RS_loss_list', 0)
      elif ldb.price_list[-1] < ldb.price_list[-2]:
        loss = ldb.price_list[-2] - ldb.price_list[-1]
        storage.writelist('RSI_RS_loss_list', loss)
        storage.writelist('RSI_RS_gain_list', 0)

      # Do RS calculations if we have all requested periods
      if len(storage.getlist('RSI_RS_gain_list')) >= gc.RSI.Period:
        if len(storage.getlist('RSI_avg_gain_list')) > 1:
          storage.writelist('RSI_avg_gain_list', ((storage.getlist('RSI_avg_gain_list')[-1] *
                                                   (gc.RSI.Period - 1))
                                                  + storage.getlist('RSI_RS_gain_list')[-1])
                            / gc.RSI.Period)
          storage.writelist('RSI_avg_loss_list', ((storage.getlist('RSI_avg_loss_list')[-1] *
                                                   (gc.RSI.Period - 1))
                                                  + storage.getlist('RSI_RS_loss_list')[-1])
                            / gc.RSI.Period)
        # Fist run, can't yet apply smoothing
        else:
          storage.writelist('RSI_avg_gain_list', math.fsum(
              storage.getlist('RSI_RS_gain_list')[(gc.RSI.Period * -1):]) / gc.RSI.Period)
          storage.writelist('RSI_avg_loss_list', math.fsum(
              storage.getlist('RSI_RS_loss_list')[(gc.RSI.Period * -1):]) / gc.RSI.Period)

        # Calculate and append current RS to RS_list
        storage.writelist('RSI_RS_list', storage.getlist(
github Galts-Gulch / avarice / indicators.py View on Github external
OptimizedTrend = 'Bullish'
      elif CP < CloudMax and KS > TS:
        # SELL!
        storage.writelist('Ichimoku_Optimized_list', 1)
        OptimizedTrend = 'Bearish'
      else:
        storage.writelist('Ichimoku_Optimized_list', 0)
        OptimizedTrend = 'No trend'
      # Weak Signals
      if TS > KS:
        # BUY!
        storage.writelist('Ichimoku_Weak_list', -1)
        WeakTrend = 'Bullish'
      elif KS > TS:
        # SELL!
        storage.writelist('Ichimoku_Weak_list', 1)
        WeakTrend = 'Bearish'
      else:
        storage.writelist('Ichimoku_Weak_list', 0)
        WeakTrend = 'No trend'

      # Store price cloud history
      if CP < CloudMin:
        # Below
        storage.writelist('Ichimoku_CloudHistory_list', -1)
      elif CP > CloudMin and CP < CloudMax:
        # Inside
        storage.writelist('Ichimoku_CloudHistory_list', 0)
      elif CP > CloudMax:
        # Above
        storage.writelist('Ichimoku_CloudHistory_list', 1)
github Galts-Gulch / avarice / indicators.py View on Github external
def indicator():
    # We can start calculations once we have two periods
    if len(ldb.price_list) >= (gc.ChandExit.Period * 2):
      storage.writelist(
          'ChandExit_TR_list', Helpers.TrueRange(ldb.price_list, gc.ChandExit.Period))
      if len(storage.getlist('ChandExit_TR_list')) >= gc.ChandExit.Period:
        try:
          storage.writelist('ChandExit_ATR_list', Helpers.WMA(storage.getlist(
              'ChandExit_TR_list'), storage.getlist('ChandExit_ATR_list'), gc.ChandExit.Period))
          storage.writelist('ChandExit_Long_list', max(
              ldb.price_list[-gc.ChandExit.Period:]) - storage.getlist('ChandExit_ATR_list')[-1] * gc.ChandExit.Multiplier)
          storage.writelist('ChandExit_Short_list', min(
              ldb.price_list[-gc.ChandExit.Period:]) + storage.getlist('ChandExit_ATR_list')[-1] * gc.ChandExit.Multiplier)
        # For an empty sequence at low volatility or high frequency
        except ValueError:
          pass

        # Use a hack for determining signals despite it's intended confirmation
        # usage
        cp = ldb.price_list[-1]
        if cp < storage.getlist('ChandExit_Long_list')[-1]:
          storage.writelist('ChandExit_signal_list', 1)
        elif cp > storage.getlist('ChandExit_Short_list')[-1]:
          storage.writelist('ChandExit_signal_list', -1)

    if 'ChandExit' in gc.Trader.VerboseIndicators:
github Galts-Gulch / avarice / indicators.py View on Github external
def indicator():
    # We can start BollBandwidth calculations once we have BollBands
    if storage.getlist('BollBands_Lower_list'):
      storage.writelist('BollBandwidth_ind_list', (storage.getlist(
          'BollBands_Upper_list')[-1] - storage.getlist('BollBands_Lower_list')[-1]) / storage.getlist('BollBands_Middle_list')[-1])

    if 'BollBandwidth' in gc.Trader.VerboseIndicators:
      if storage.getlist('BollBandwidth_ind_list'):
        print('BollBandwidth:', storage.getlist('BollBandwidth_ind_list')[-1])
      else:
        print('BollBandwidth: Not yet enough data to calculate')
github Galts-Gulch / avarice / indicators.py View on Github external
storage.writelist('Ichimoku_Strong_list', 1)
        StrongTrend = 'Bearish'
      else:
        storage.writelist('Ichimoku_Strong_list', 0)
        StrongTrend = 'No trend'
      # Optimized Signals
      if CP > CloudMin and TS > KS:
        # BUY!
        storage.writelist('Ichimoku_Optimized_list', -1)
        OptimizedTrend = 'Bullish'
      elif CP < CloudMax and KS > TS:
        # SELL!
        storage.writelist('Ichimoku_Optimized_list', 1)
        OptimizedTrend = 'Bearish'
      else:
        storage.writelist('Ichimoku_Optimized_list', 0)
        OptimizedTrend = 'No trend'
      # Weak Signals
      if TS > KS:
        # BUY!
        storage.writelist('Ichimoku_Weak_list', -1)
        WeakTrend = 'Bullish'
      elif KS > TS:
        # SELL!
        storage.writelist('Ichimoku_Weak_list', 1)
        WeakTrend = 'Bearish'
      else:
        storage.writelist('Ichimoku_Weak_list', 0)
        WeakTrend = 'No trend'

      # Store price cloud history
      if CP < CloudMin:
github Galts-Gulch / avarice / indicators.py View on Github external
(gc.RSI.Period - 1))
                                                  + storage.getlist('RSI_RS_loss_list')[-1])
                            / gc.RSI.Period)
        # Fist run, can't yet apply smoothing
        else:
          storage.writelist('RSI_avg_gain_list', math.fsum(
              storage.getlist('RSI_RS_gain_list')[(gc.RSI.Period * -1):]) / gc.RSI.Period)
          storage.writelist('RSI_avg_loss_list', math.fsum(
              storage.getlist('RSI_RS_loss_list')[(gc.RSI.Period * -1):]) / gc.RSI.Period)

        # Calculate and append current RS to RS_list
        storage.writelist('RSI_RS_list', storage.getlist(
            'RSI_avg_gain_list')[-1] / storage.getlist('RSI_avg_loss_list')[-1])

        # Calculate and append current RSI to ind_list
        storage.writelist(
            'RSI_ind_list', 100 - (100 / (1 + storage.getlist('RSI_RS_list')[-1])))

    if 'RSI' in gc.Trader.VerboseIndicators:
      if not storage.getlist('RSI_ind_list'):
        print('RSI: Not yet enough data to calculate')
      else:
        print('RSI:', storage.getlist('RSI_ind_list')[-1])