Bot & Automation

Market AI

/root/hermes-projects/Market AI

src/constants/markets.ts text
import type { MarketSymbol } from "../domain/types";

export const MARKET_SYMBOLS: MarketSymbol[] = [
  {
    code: "EURUSD",
    label: "EUR/USD",
    category: "forex",
    aliases: ["EUR/USD", "EU"],
    pipSize: 0.0001,
    pipValuePerLot: 10,
    minLot: 0.01,
    maxLot: 50,
    defaultSpreadPips: 1.2
  },
  {
    code: "GBPUSD",
    label: "GBP/USD",
    category: "forex",
    aliases: ["GBP/USD", "GU"],
    pipSize: 0.0001,
    pipValuePerLot: 10,
    minLot: 0.01,
    maxLot: 50,
    defaultSpreadPips: 1.6
  },
  {
    code: "USDJPY",
    label: "USD/JPY",
    category: "forex",
    aliases: ["USD/JPY", "UJ"],
    pipSize: 0.01,
    pipValuePerLot: 9,
    minLot: 0.01,
    maxLot: 50,
    defaultSpreadPips: 1.4
  },
  {
    code: "GBPJPY",
    label: "GBP/JPY",
    category: "forex",
    aliases: ["GBP/JPY", "GJ"],
    pipSize: 0.01,
    pipValuePerLot: 9,
    minLot: 0.01,
    maxLot: 30,
    defaultSpreadPips: 2.3
  },
  {
    code: "AUDUSD",
    label: "AUD/USD",
    category: "forex",
    aliases: ["AUD/USD", "AU"],
    pipSize: 0.0001,
    pipValuePerLot: 10,
    minLot: 0.01,
    maxLot: 50,
    defaultSpreadPips: 1.4
  },
  {
    code: "XAUUSD",
    label: "Gold / XAUUSD",
    category: "gold",
    aliases: ["XAU/USD", "XAUSD", "GOLD", "EMAS"],
    pipSize: 0.1,
    pipValuePerLot: 10,
    minLot: 0.01,
    maxLot: 20,
    defaultSpreadPips: 3.5
  },
  {
    code: "BTCUSD",
    label: "Bitcoin / BTCUSD",
    category: "crypto",
    aliases: ["BTC/USD", "BITCOIN", "BTC"],
    pipSize: 1.0,
    pipValuePerLot: 1,
    minLot: 0.01,
    maxLot: 10,
    defaultSpreadPips: 10.0
  }
];

export function findMarketSymbol(input: string): MarketSymbol | null {
  const normalized = input.toUpperCase().replace(/[^A-Z0-9]/g, "");

  return (
    MARKET_SYMBOLS.find((symbol) => {
      const candidates = [symbol.code, symbol.label, ...symbol.aliases].map((value) =>
        value.toUpperCase().replace(/[^A-Z0-9]/g, "")
      );

      return candidates.includes(normalized);
    }) ?? null
  );
}

export function detectMarketSymbolFromText(text: string): MarketSymbol | null {
  const normalized = text.toUpperCase().replace(/[^A-Z0-9 ]/g, " ");

  return (
    MARKET_SYMBOLS.find((symbol) => {
      const candidates = [symbol.code, symbol.label, ...symbol.aliases].map((value) =>
        value.toUpperCase().replace(/[^A-Z0-9]/g, "")
      );

      return candidates.some((candidate) => normalized.replace(/\s/g, "").includes(candidate));
    }) ?? null
  );
}