INNER CODE UNIT · TypeScript

simulatePrice

alexanderwanyoike/the0 · example-bots/typescript-price-alerts/main.ts:172

function simulatePrice(
  state: BotState,
  symbol: string,
  basePrice: number
): {
  symbol: string;
  value: number;
  change_pct: number;
  high_24h: number;
  low_24h: number;
} {
  const volatility = 0.002;
  const meanReversion = 0.001;

  const randomChange = (Math.random() - 0.5) * 2 * volatility;
  const reversion =
    ((basePrice - state.lastPrice) / basePrice) * meanReversion;
  const changePercent = randomChange + reversion;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…