/** * Alltick Agent - Type Definitions * * Real-time financial market data API types */ /** * Alltick API configuration */ export interface AlltickConfig { /** API token for authentication */ token: string; /** Base URL for REST API (default: https://quote.alltick.io) */ baseUrl?: string; /** WebSocket URL (default: wss://quote.alltick.io) */ wsUrl?: string; /** Request timeout in ms (default: 30000) */ timeout?: number; } /** * Kline (candlestick) type enum * @see https://www.alltick.co/ 非小号 */ export declare enum KlineType { /** 1分钟 K线 */ MINUTE_1 = 1, /** 5分钟 K线 */ MINUTE_5 = 5, /** 15分钟 K线 */ MINUTE_15 = 15, /** 30分钟 K线 */ MINUTE_30 = 30, /** 1小时 K线 */ HOUR_1 = 60, /** 4小时 K线 */ HOUR_4 = 240, /** 日K线 */ DAY = 1000, /** 周K线 */ WEEK = 2000, /** 月K线 */ MONTH = 3000 } /** * Adjust type for historical data */ export declare enum AdjustType { /** 不复权 */ NONE = 0, /** 前复权 */ FORWARD = 1, /** 后复权 */ BACKWARD = 2 } /** * Common product codes */ export declare const ProductCodes: { readonly CRYPTO: { readonly BTCUSDT: "BTCUSDT"; readonly ETHUSDT: "ETHUSDT"; readonly BNBUSDT: "BNBUSDT"; readonly SOLUSDT: "SOLUSDT"; readonly XRPUSDT: "XRPUSDT"; }; readonly HK: { readonly TENCENT: "00700.HK"; readonly ALIBABA_HK: "09988.HK"; readonly MEITUAN: "03690.HK"; }; readonly US: { readonly APPLE: "AAPL.US"; readonly TESLA: "TSLA.US"; readonly NVIDIA: "NVDA.US"; readonly GOOGLE: "GOOGL.US"; readonly MICROSOFT: "MSFT.US"; }; readonly CN: { readonly KWEICHOU: "600519.SH"; readonly CATL: "300750.SZ"; }; readonly FOREX: { readonly EURUSD: "EURUSD"; readonly GBPUSD: "GBPUSD"; readonly USDJPY: "USDJPY"; readonly AUDUSD: "AUDUSD"; }; readonly COMMODITIES: { readonly GOLD: "XAUUSD"; readonly SILVER: "XAGUSD"; readonly CRUDE_OIL: "USOIL"; }; }; /** * Symbol type for filtering */ export type SymbolType = 'crypto' | 'stock' | 'forex' | 'commodity'; /** * Parse symbol to get type and code */ export declare function parseSymbol(symbol: string): { type: SymbolType; code: string; }; /** * Kline data point */ export interface Kline { /** 开仓时间 (Unix timestamp in milliseconds) */ timestamp: number; /** 开盘价 */ open: number; /** 最高价 */ high: number; /** 最低价 */ low: number; /** 收盘价 */ close: number; /** 成交量 */ volume: number; } /** * Trade quote (tick data) */ export interface TradeQuote { /** 交易代码 */ code: string; /** 最新价 */ price: number; /** 成交量 */ volume: number; /** 成交时间 */ timestamp: number; /** 买一价 */ bidPrice?: number; /** 卖一价 */ askPrice?: number; } /** * Order book level */ export interface OrderBookLevel { /** 价格 */ price: number; /** 数量 */ volume: number; } /** * Order book data */ export interface OrderBook { /** 交易代码 */ code: string; /** 买盘 (按价格降序) */ bids: OrderBookLevel[]; /** 卖盘 (按价格升序) */ asks: OrderBookLevel[]; /** 数据时间 */ timestamp: number; } /** * Kline query parameters */ export interface KlineQuery { /** 交易代码 */ code: string; /** K线类型 */ klineType: KlineType; /** 结束时间戳 (0 = 最新) */ klineTimestampEnd?: number; /** 查询K线数量 (默认: 100) */ queryKlineNum?: number; /** 复权类型 */ adjustType?: AdjustType; } /** * Batch kline query parameters */ export interface BatchKlineQuery { /** 交易代码列表 */ codes: string[]; /** K线类型 */ klineType: KlineType; /** 结束时间戳 */ klineTimestampEnd?: number; /** 查询数量 */ queryKlineNum?: number; } /** * API response wrapper */ export interface ApiResponse { /** 响应代码 (0 = 成功) */ code: string; /** 消息 */ msg: string; /** 数据 */ data?: T; } /** * Kline API response data */ export interface KlineResponseData { /** K线数据列表 */ klines: string[]; /** 分页信息 */ pagination?: { hasMore: boolean; nextCursor?: string; }; } /** * Trade quote API response data */ export interface TradeResponseData { /** 交易代码 */ code: string; /** 最新价 */ price: string; /** 成交量 */ volume: string; /** 时间戳 */ timestamp: number; } /** * Order book API response data */ export interface OrderBookResponseData { /** 交易代码 */ code: string; /** 买盘 */ bids: [string, string][]; /** 卖盘 */ asks: [string, string][]; /** 时间戳 */ timestamp: number; } /** * WebSocket message types */ export declare enum WsMessageType { /** 登录请求 */ LOGIN = 1, /** 登录响应 */ LOGIN_RESPONSE = 2, /** 订阅请求 */ SUBSCRIBE = 5, /** 订阅响应 */ SUBSCRIBE_RESPONSE = 6, /** 取消订阅 */ UNSUBSCRIBE = 7, /** 数据推送 */ PUSH = 11, /** 心跳 */ HEARTBEAT = 2 } /** * WebSocket subscription type */ export declare enum WsSubscribeType { /** 实时成交 */ TRADE = 1, /** 订单簿 */ ORDER_BOOK = 2 } /** * WebSocket trade push data */ export interface WsTradePushData { code: string; price: string; volume: string; timestamp: number; } /** * WebSocket order book push data */ export interface WsOrderBookPushData { code: string; bids: [string, string][]; asks: [string, string][]; timestamp: number; } /** * WebSocket push message */ export interface WsPushMessage { /** 消息类型 */ msgType: WsMessageType; /** 业务数据 */ data?: WsTradePushData | WsOrderBookPushData; /** 错误码 (0 = 成功) */ code?: number; /** 错误消息 */ msg?: string; } /** * WebSocket login parameters */ export interface WsLoginParams { /** API token */ token: string; } /** * WebSocket subscription parameters */ export interface WsSubscribeParams { /** 订阅类型 */ subType: WsSubscribeType; /** 交易代码列表 */ codes: string[]; } /** * Default configuration */ export declare const DEFAULT_CONFIG: Partial; export type TradeQuery = TradeQuote; export type OrderBookQuery = OrderBook; export type KlineResponse = ApiResponse; export type TradeResponse = ApiResponse; export type OrderBookResponse = ApiResponse; export type WsConfig = AlltickConfig & { reconnectInterval?: number; maxReconnectAttempts?: number; heartbeatInterval?: number; }; export type WsTradeData = WsTradePushData; export type WsOrderBookData = WsOrderBookPushData; export type WsPushData = WsTradePushData | WsOrderBookPushData; /** * Demo token (limited usage) * @see https://www.alltick.co/ */ export declare const DEMO_TOKEN = "a0248da3d1c9bf4e63a7e1c9368ee67e-c-app"; //# sourceMappingURL=index.d.ts.map