feat: instrument picker + Pattern Lab instrument scan mode

- instruments.ts: 90 IB-options-tradable instruments in 12 categories
  (US Indices, Europe, Asia, EM, Sectors, Forex, Bonds, Metals, Energy,
   Agriculture, Crypto, Volatility) — EUR/CHF, Cotton, etc. all included

- PatternExplorer: replace text input in Instrument Lens with categorised
  grid picker (category pill filters + search + custom ticker fallback)

- PatternLab: add Instrument Scan tab alongside Event Presets
  - Pick any instrument from the shared categorised picker
  - Set period (start/end date) + horizon per pattern
  - AI scans the full period: identifies 4-6 key pattern instances each with
    their own entry date, expected move, strategy
  - 'Evaluate outcomes' fetches actual price at T+horizon per pattern
  - 'Save pattern' promotes any instance to the Pattern Library

- backend/services/pattern_lab.py: run_instrument_scan() + evaluate_instrument_outcomes()
  (per-pattern analysis_date vs shared date in event mode)
- backend/routers/pattern_lab.py: POST /instrument-scan + POST /evaluate-instrument/{id}
- useApi.ts: useInstrumentScan + useEvaluateInstrumentScan hooks

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OpenSquared
2026-06-22 18:20:22 +02:00
parent cbf989502c
commit 303ecc2a3a
6 changed files with 850 additions and 80 deletions

View File

@@ -0,0 +1,146 @@
/**
* Comprehensive list of IB-options-tradable instruments, organised by category.
* Used in PatternExplorer (Instrument Lens) and PatternLab (Instrument Scan).
*/
export interface Instrument {
ticker: string
name: string
category: string
flag?: string
}
export const INSTRUMENT_CATEGORIES = [
'US Indices',
'Europe',
'Asia-Pacific',
'Emerging Markets',
'Sectors',
'Forex',
'Bonds',
'Metals',
'Energy',
'Agriculture',
'Crypto',
'Volatility',
]
export const INSTRUMENTS: Instrument[] = [
// ── US Indices ──────────────────────────────────────────────────────────────
{ ticker: 'SPY', name: 'S&P 500', category: 'US Indices' },
{ ticker: 'QQQ', name: 'Nasdaq 100', category: 'US Indices' },
{ ticker: 'IWM', name: 'Russell 2000', category: 'US Indices' },
{ ticker: 'DIA', name: 'Dow Jones', category: 'US Indices' },
{ ticker: 'MDY', name: 'S&P MidCap 400', category: 'US Indices' },
{ ticker: 'SPY', name: 'S&P 500', category: 'US Indices' },
// ── Europe ──────────────────────────────────────────────────────────────────
{ ticker: 'EWG', name: 'Germany (DAX)', category: 'Europe', flag: '🇩🇪' },
{ ticker: 'EWU', name: 'UK (FTSE 100)', category: 'Europe', flag: '🇬🇧' },
{ ticker: 'EWI', name: 'Italy (MIB)', category: 'Europe', flag: '🇮🇹' },
{ ticker: 'EWP', name: 'Spain (IBEX)', category: 'Europe', flag: '🇪🇸' },
{ ticker: 'EWL', name: 'Switzerland', category: 'Europe', flag: '🇨🇭' },
{ ticker: 'EWQ', name: 'France (CAC)', category: 'Europe', flag: '🇫🇷' },
{ ticker: 'EWN', name: 'Netherlands', category: 'Europe', flag: '🇳🇱' },
{ ticker: 'EWD', name: 'Sweden', category: 'Europe', flag: '🇸🇪' },
// ── Asia-Pacific ─────────────────────────────────────────────────────────────
{ ticker: 'EWJ', name: 'Japan (Nikkei)', category: 'Asia-Pacific', flag: '🇯🇵' },
{ ticker: 'FXI', name: 'China (CSI 300)', category: 'Asia-Pacific', flag: '🇨🇳' },
{ ticker: 'KWEB', name: 'China Internet', category: 'Asia-Pacific', flag: '🇨🇳' },
{ ticker: 'EWY', name: 'South Korea', category: 'Asia-Pacific', flag: '🇰🇷' },
{ ticker: 'EWT', name: 'Taiwan', category: 'Asia-Pacific', flag: '🇹🇼' },
{ ticker: 'EWA', name: 'Australia', category: 'Asia-Pacific', flag: '🇦🇺' },
{ ticker: 'EWS', name: 'Singapore', category: 'Asia-Pacific', flag: '🇸🇬' },
{ ticker: 'INDA', name: 'India', category: 'Asia-Pacific', flag: '🇮🇳' },
// ── Emerging Markets ─────────────────────────────────────────────────────────
{ ticker: 'EEM', name: 'Emerging Markets', category: 'Emerging Markets' },
{ ticker: 'EWZ', name: 'Brazil', category: 'Emerging Markets', flag: '🇧🇷' },
{ ticker: 'TUR', name: 'Turkey', category: 'Emerging Markets', flag: '🇹🇷' },
{ ticker: 'EWW', name: 'Mexico', category: 'Emerging Markets', flag: '🇲🇽' },
{ ticker: 'EWH', name: 'Hong Kong', category: 'Emerging Markets', flag: '🇭🇰' },
{ ticker: 'EZA', name: 'South Africa', category: 'Emerging Markets', flag: '🇿🇦' },
{ ticker: 'THD', name: 'Thailand', category: 'Emerging Markets', flag: '🇹🇭' },
// ── Sectors ───────────────────────────────────────────────────────────────────
{ ticker: 'XLF', name: 'Financials', category: 'Sectors' },
{ ticker: 'XLE', name: 'Energy', category: 'Sectors' },
{ ticker: 'XLK', name: 'Technology', category: 'Sectors' },
{ ticker: 'XLV', name: 'Healthcare', category: 'Sectors' },
{ ticker: 'XLI', name: 'Industrials', category: 'Sectors' },
{ ticker: 'XLB', name: 'Materials', category: 'Sectors' },
{ ticker: 'XLU', name: 'Utilities', category: 'Sectors' },
{ ticker: 'XLP', name: 'Consumer Staples', category: 'Sectors' },
{ ticker: 'XLY', name: 'Consumer Discret.', category: 'Sectors' },
{ ticker: 'XLC', name: 'Communication', category: 'Sectors' },
{ ticker: 'SMH', name: 'Semiconductors', category: 'Sectors' },
{ ticker: 'IBB', name: 'Biotech', category: 'Sectors' },
{ ticker: 'ARKK', name: 'ARK Innovation', category: 'Sectors' },
// ── Forex ─────────────────────────────────────────────────────────────────────
{ ticker: 'EURUSD=X', name: 'EUR/USD', category: 'Forex' },
{ ticker: 'GBPUSD=X', name: 'GBP/USD', category: 'Forex' },
{ ticker: 'USDJPY=X', name: 'USD/JPY', category: 'Forex' },
{ ticker: 'USDCHF=X', name: 'USD/CHF', category: 'Forex' },
{ ticker: 'EURCHF=X', name: 'EUR/CHF', category: 'Forex' },
{ ticker: 'AUDUSD=X', name: 'AUD/USD', category: 'Forex' },
{ ticker: 'USDCAD=X', name: 'USD/CAD', category: 'Forex' },
{ ticker: 'USDCNH=X', name: 'USD/CNH', category: 'Forex' },
{ ticker: 'NZDUSD=X', name: 'NZD/USD', category: 'Forex' },
{ ticker: 'USDMXN=X', name: 'USD/MXN', category: 'Forex' },
{ ticker: 'EURGBP=X', name: 'EUR/GBP', category: 'Forex' },
{ ticker: 'EURJPY=X', name: 'EUR/JPY', category: 'Forex' },
{ ticker: 'GBPJPY=X', name: 'GBP/JPY', category: 'Forex' },
{ ticker: 'USDSEK=X', name: 'USD/SEK', category: 'Forex' },
{ ticker: 'USDNOK=X', name: 'USD/NOK', category: 'Forex' },
{ ticker: 'USDTRY=X', name: 'USD/TRY', category: 'Forex' },
{ ticker: 'USDZAR=X', name: 'USD/ZAR', category: 'Forex' },
// ── Bonds ─────────────────────────────────────────────────────────────────────
{ ticker: 'TLT', name: '20Y+ US Treasury', category: 'Bonds' },
{ ticker: 'IEF', name: '7-10Y Treasury', category: 'Bonds' },
{ ticker: 'SHY', name: '1-3Y Treasury', category: 'Bonds' },
{ ticker: 'HYG', name: 'High Yield Corp', category: 'Bonds' },
{ ticker: 'LQD', name: 'Investment Grade', category: 'Bonds' },
{ ticker: 'TIP', name: 'TIPS (Inflation)', category: 'Bonds' },
{ ticker: 'BIL', name: 'T-Bills 1-3M', category: 'Bonds' },
{ ticker: 'EMB', name: 'EM Sovereign', category: 'Bonds' },
{ ticker: 'MBB', name: 'Mortgage-Backed', category: 'Bonds' },
// ── Metals ────────────────────────────────────────────────────────────────────
{ ticker: 'GLD', name: 'Gold', category: 'Metals' },
{ ticker: 'SLV', name: 'Silver', category: 'Metals' },
{ ticker: 'PPLT', name: 'Platinum', category: 'Metals' },
{ ticker: 'PALL', name: 'Palladium', category: 'Metals' },
{ ticker: 'COPX', name: 'Copper Miners', category: 'Metals' },
{ ticker: 'DBB', name: 'Base Metals', category: 'Metals' },
// ── Energy ────────────────────────────────────────────────────────────────────
{ ticker: 'USO', name: 'WTI Crude Oil', category: 'Energy' },
{ ticker: 'BNO', name: 'Brent Crude Oil', category: 'Energy' },
{ ticker: 'UNG', name: 'Natural Gas (US)', category: 'Energy' },
{ ticker: 'UGA', name: 'Gasoline RBOB', category: 'Energy' },
{ ticker: 'AMLP', name: 'Pipelines MLP', category: 'Energy' },
// ── Agriculture ───────────────────────────────────────────────────────────────
{ ticker: 'WEAT', name: 'Wheat', category: 'Agriculture' },
{ ticker: 'CORN', name: 'Corn', category: 'Agriculture' },
{ ticker: 'SOYB', name: 'Soybeans', category: 'Agriculture' },
{ ticker: 'BAL', name: 'Cotton', category: 'Agriculture' },
{ ticker: 'CANE', name: 'Sugar', category: 'Agriculture' },
{ ticker: 'NIB', name: 'Cocoa', category: 'Agriculture' },
{ ticker: 'JO', name: 'Coffee', category: 'Agriculture' },
{ ticker: 'DBA', name: 'Agri Diversified', category: 'Agriculture' },
// ── Crypto ────────────────────────────────────────────────────────────────────
{ ticker: 'BTC-USD', name: 'Bitcoin', category: 'Crypto' },
{ ticker: 'ETH-USD', name: 'Ethereum', category: 'Crypto' },
{ ticker: 'SOL-USD', name: 'Solana', category: 'Crypto' },
// ── Volatility ────────────────────────────────────────────────────────────────
{ ticker: '^VIX', name: 'CBOE VIX', category: 'Volatility' },
{ ticker: 'VXX', name: 'VIX Short-Term', category: 'Volatility' },
{ ticker: 'UVXY', name: 'Ultra VIX 1.5x', category: 'Volatility' },
{ ticker: 'SVXY', name: 'Short VIX -0.5x', category: 'Volatility' },
]