/** * 行情数据获取(零依赖:node 原生 fetch,Binance 公共 REST API,无需凭据)。 * * 拆分纯函数与网络层: * - parseKlines:纯函数(离线可测) * - fetchKlines:网络(集成验证) * * Binance klines 响应行(数组,字段为字符串数字): * [openTime, open, high, low, close, volume, closeTime, quoteVolume, trades, takerBase, takerQuote, ignore] */ /** K 线间隔枚举(Binance 支持集)。 */ export declare const INTERVALS: readonly ["1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "12h", "1d", "3d", "1w", "1M"]; export type Interval = (typeof INTERVALS)[number]; export interface Candle { /** 开盘时间(Unix 毫秒) */ openTime: number; open: number; high: number; low: number; close: number; volume: number; } export declare const BINANCE_KLINE_URL = "https://api.binance.com/api/v3/klines"; /** 支持的行情 provider。 */ export type MarketProvider = 'binance' | 'okx' | 'bybit' | 'sina' | 'tencent' | 'yahoo'; export declare const MARKET_PROVIDERS: readonly ["binance", "okx", "bybit", "sina", "tencent", "yahoo"]; /** 解析 Binance klines 响应行(纯函数)。非法行抛错。 */ export declare function parseKlines(rows: readonly (readonly unknown[])[]): Candle[]; /** 拉取 K 线。超时由调用方 signal 控制(建议 AbortSignal.any([exec.signal, AbortSignal.timeout(ms)]))。 */ export declare function fetchKlines(symbol: string, interval: Interval, limit: number, signal: AbortSignal, provider?: MarketProvider): Promise; /** 解析 OKX candles(倒序 → 正序,映射到统一 Candle)。 */ export declare function parseOkxKlines(rows: readonly (readonly unknown[])[]): Candle[]; /** 解析 Bybit klines(倒序 → 正序,映射到统一 Candle)。 */ export declare function parseBybitKlines(rows: readonly (readonly unknown[])[]): Candle[]; /** A 股代码校验:sh/sz/bj + 6 位数字。 */ export declare function assertAShareSymbol(symbol: string): void; /** Yahoo 代码校验:美股 ticker / 指数 ^GSPC / 港股 0700.HK 等。 */ export declare function assertYahooSymbol(symbol: string): void; /** 解析新浪 K 线(对象行:day/open/high/low/close/volume,价格为字符串)。 */ export declare function parseSinaKlines(rows: readonly Record[]): Candle[]; /** 解析腾讯 K 线(qfqday/day 行:[date, open, close, high, low, volume])。 */ export declare function parseTencentKlines(symbol: string, json: { code?: number; data?: Record; }): Candle[]; /** 解析 Yahoo chart 响应(纯函数):时间戳 + 引用的并列数组,过滤 null 行。 */ export declare function parseYahooChart(symbol: string, json: { chart?: { result?: { timestamp?: readonly number[]; indicators?: { quote?: readonly { open?: readonly (number | null)[]; high?: readonly (number | null)[]; low?: readonly (number | null)[]; close?: readonly (number | null)[]; volume?: readonly (number | null)[]; }[]; }; }[]; error?: unknown; }; }): Candle[];