feat(cot): add CFTC Traders-in-Financial-Futures adapter (M22 slice 7)
CI / Test & Type-Check (push) Canceled after 0s

Parse the annual FinFutYY.txt zip (leveraged-funds long/short + OI) into a
CotSeries. Registers the 'cot' source_kind, 'cot_weekly' TTL (7d), the 'cftc'
vendor family (1 req/1.5s pacing), and the adapter in the queue registry.

Uses the file-header column names so parser is robust to layout changes.
This commit is contained in:
Investor Flow Build
2026-08-10 16:35:33 -04:00
parent 8031eae1b2
commit a9fc5d243e
6 changed files with 356 additions and 2 deletions
+3 -2
View File
@@ -12,14 +12,14 @@ import {
} from '../queue/sourceRatePolicy.ts';
import { KvReadCache } from './LruCache.ts';
export type SourceKind = 'yfinance' | 'nasdaq' | 'finra-bulk' | 'finra-si' | 'sec' | 'sec-fetch' | 'sec-sc-fetch' | 'sec-tickers' | 'reddit' | 'x' | 'macro' | 'llm' | 'sec-lint-holders' | 'sec-lint-insiders' | 'fred';
export type SourceKind = 'yfinance' | 'nasdaq' | 'finra-bulk' | 'finra-si' | 'sec' | 'sec-fetch' | 'sec-sc-fetch' | 'sec-tickers' | 'reddit' | 'x' | 'macro' | 'llm' | 'sec-lint-holders' | 'sec-lint-insiders' | 'fred' | 'cot';
export type TickerKind = 'equity' | 'crypto' | 'etf' | 'index';
export type CacheKey = string; // `${SourceKind}:${kind}:${id}` e.g. 'yfinance:quote:NVDA', 'yfinance:candles:NVDA:1d'
export type TtlClass =
| 'live_quote' | 'intraday' | 'daily_permanent' | 'options_snapshot'
| 'filing_immutable' | 'quarterly_immutable' | 'thread_7d'
| 'macro_event' | 'regime_classification' | 'llm_summary' | 'symbol_meta'
| 'short_interest' | 'dividend_fundamentals' | 'fred_macro';
| 'short_interest' | 'dividend_fundamentals' | 'fred_macro' | 'cot_weekly';
export interface Provenance { fetchedAt: string; sourceKind: SourceKind; rawSourceId?: string; }
@@ -68,6 +68,7 @@ export const TTL_MS: Record<TtlClass, number> = {
short_interest: 24 * 60 * 60_000, // refreshed twice/month per source
dividend_fundamentals: 7 * 24 * 60 * 60_000, // weekly (yield/payout change slowly)
fred_macro: 24 * 60 * 60_000, // daily (rates move daily; other series slower)
cot_weekly: 7 * 24 * 60 * 60_000, // COT arrives weekly on Fridays
};
/** Parse 'source:kind:id...' into { source, kind, id } (id may contain colons). */