INNER CODE UNIT · JavaScript

idx

dearvn/tradovate-trading-bot · agents/market-data/index.js:189

        const idx = stored.findIndex(b => b.timestamp === bar.timestamp);
        if (idx >= 0) {
          stored[idx] = bar;
        } else {
          stored.push(bar);
          if (stored.length > MAX_STORED_BARS) stored = stored.slice(-MAX_STORED_BARS);
        }
      }
      await cache.redis.set(BARS_CACHE_KEY(symbol), JSON.stringify(stored), 'EX', BARS_TTL_SECONDS);
    }
  } catch (err) {
    logger.error({ err, symbol }, 'Failed to store chart bars in Redis');
  }
};

const createBridge = (pub, logger) => {
  const isLive = config.get('mode') === 'production';
  const tradingUrl = isLive ? LIVE_WS_URL : DEMO_WS_URL;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…