UNPKG

tardis-dev

Version:

Convenient access to tick-level historical and real-time cryptocurrency market data via Node.js

296 lines 12.3 kB
import { CircularBuffer } from '../handy'; import { BookChange, BookTicker, DerivativeTicker, Exchange, Liquidation, OptionSummary, Trade } from '../types'; import { Mapper } from './mapper'; export declare class HuobiTradesMapper implements Mapper<'huobi' | 'huobi-dm' | 'huobi-dm-swap' | 'huobi-dm-linear-swap' | 'huobi-dm-options', Trade> { private readonly _exchange; constructor(_exchange: Exchange); canHandle(message: HuobiDataMessage): boolean; getFilters(symbols?: string[]): { readonly channel: "trade"; readonly symbols: string[] | undefined; }[]; map(message: HuobiTradeDataMessage, localTimestamp: Date): IterableIterator<Trade>; } export declare class HuobiBookChangeMapper implements Mapper<'huobi' | 'huobi-dm' | 'huobi-dm-swap' | 'huobi-dm-linear-swap' | 'huobi-dm-options', BookChange> { protected readonly _exchange: Exchange; constructor(_exchange: Exchange); canHandle(message: HuobiDataMessage): boolean; getFilters(symbols?: string[]): { readonly channel: "depth"; readonly symbols: string[] | undefined; }[]; map(message: HuobiDepthDataMessage, localTimestamp: Date): Generator<{ readonly type: "book_change"; readonly symbol: string; readonly exchange: "bitmex" | "deribit" | "binance-futures" | "binance-delivery" | "binance-options" | "binance-european-options" | "binance" | "ftx" | "okex-futures" | "okex-options" | "okex-swap" | "okex" | "okex-spreads" | "huobi-dm" | "huobi-dm-swap" | "huobi-dm-linear-swap" | "huobi" | "bitfinex-derivatives" | "bitfinex" | "coinbase" | "coinbase-international" | "cryptofacilities" | "kraken" | "bitstamp" | "gemini" | "poloniex" | "bybit" | "bybit-spot" | "bybit-options" | "phemex" | "delta" | "ftx-us" | "binance-us" | "gate-io-futures" | "gate-io" | "okcoin" | "bitflyer" | "hitbtc" | "coinflex" | "binance-jersey" | "binance-dex" | "upbit" | "ascendex" | "dydx" | "dydx-v4" | "serum" | "mango" | "huobi-dm-options" | "star-atlas" | "crypto-com" | "crypto-com-derivatives" | "kucoin" | "kucoin-futures" | "bitnomial" | "woo-x" | "blockchain-com" | "bitget" | "bitget-futures" | "hyperliquid"; readonly isSnapshot: boolean; readonly bids: { price: number; amount: number; }[]; readonly asks: { price: number; amount: number; }[]; readonly timestamp: Date; readonly localTimestamp: Date; }, void, unknown>; private _mapBookLevel; } export declare class HuobiMBPBookChangeMapper implements Mapper<'huobi', BookChange> { protected readonly _exchange: Exchange; protected readonly symbolToMBPInfoMapping: { [key: string]: MBPInfo; }; constructor(_exchange: Exchange); canHandle(message: any): any; getFilters(symbols?: string[]): { readonly channel: "mbp"; readonly symbols: string[] | undefined; }[]; map(message: HuobiMBPDataMessage | HuobiMBPSnapshot, localTimestamp: Date): Generator<{ readonly type: "book_change"; readonly symbol: string; readonly exchange: "bitmex" | "deribit" | "binance-futures" | "binance-delivery" | "binance-options" | "binance-european-options" | "binance" | "ftx" | "okex-futures" | "okex-options" | "okex-swap" | "okex" | "okex-spreads" | "huobi-dm" | "huobi-dm-swap" | "huobi-dm-linear-swap" | "huobi" | "bitfinex-derivatives" | "bitfinex" | "coinbase" | "coinbase-international" | "cryptofacilities" | "kraken" | "bitstamp" | "gemini" | "poloniex" | "bybit" | "bybit-spot" | "bybit-options" | "phemex" | "delta" | "ftx-us" | "binance-us" | "gate-io-futures" | "gate-io" | "okcoin" | "bitflyer" | "hitbtc" | "coinflex" | "binance-jersey" | "binance-dex" | "upbit" | "ascendex" | "dydx" | "dydx-v4" | "serum" | "mango" | "huobi-dm-options" | "star-atlas" | "crypto-com" | "crypto-com-derivatives" | "kucoin" | "kucoin-futures" | "bitnomial" | "woo-x" | "blockchain-com" | "bitget" | "bitget-futures" | "hyperliquid"; readonly isSnapshot: false; readonly bids: { price: number; amount: number; }[]; readonly asks: { price: number; amount: number; }[]; readonly timestamp: Date; readonly localTimestamp: Date; } | { readonly type: "book_change"; readonly symbol: string; readonly exchange: "bitmex" | "deribit" | "binance-futures" | "binance-delivery" | "binance-options" | "binance-european-options" | "binance" | "ftx" | "okex-futures" | "okex-options" | "okex-swap" | "okex" | "okex-spreads" | "huobi-dm" | "huobi-dm-swap" | "huobi-dm-linear-swap" | "huobi" | "bitfinex-derivatives" | "bitfinex" | "coinbase" | "coinbase-international" | "cryptofacilities" | "kraken" | "bitstamp" | "gemini" | "poloniex" | "bybit" | "bybit-spot" | "bybit-options" | "phemex" | "delta" | "ftx-us" | "binance-us" | "gate-io-futures" | "gate-io" | "okcoin" | "bitflyer" | "hitbtc" | "coinflex" | "binance-jersey" | "binance-dex" | "upbit" | "ascendex" | "dydx" | "dydx-v4" | "serum" | "mango" | "huobi-dm-options" | "star-atlas" | "crypto-com" | "crypto-com-derivatives" | "kucoin" | "kucoin-futures" | "bitnomial" | "woo-x" | "blockchain-com" | "bitget" | "bitget-futures" | "hyperliquid"; readonly isSnapshot: true; readonly bids: { price: number; amount: number; }[]; readonly asks: { price: number; amount: number; }[]; readonly timestamp: Date; readonly localTimestamp: Date; }, void, unknown>; private _mapMBPUpdate; private _mapBookLevel; } export declare class HuobiDerivativeTickerMapper implements Mapper<'huobi-dm' | 'huobi-dm-swap' | 'huobi-dm-linear-swap', DerivativeTicker> { private readonly _exchange; private readonly pendingTickerInfoHelper; constructor(_exchange: Exchange); canHandle(message: any): any; getFilters(symbols?: string[]): import("../types").Filter<"trade" | "depth" | "detail" | "bbo" | "basis" | "liquidation_orders" | "contract_info" | "open_interest" | "elite_account_ratio" | "elite_position_ratio" | "funding_rate">[]; map(message: HuobiBasisDataMessage | HuobiFundingRateNotification | HuobiOpenInterestDataMessage, localTimestamp: Date): IterableIterator<DerivativeTicker>; } export declare class HuobiLiquidationsMapper implements Mapper<'huobi-dm' | 'huobi-dm-swap' | 'huobi-dm-linear-swap', Liquidation> { private readonly _exchange; private readonly _contractCodeToSymbolMap; private readonly _contractTypesSuffixes; constructor(_exchange: Exchange); canHandle(message: HuobiLiquidationOrder | HuobiContractInfo): boolean; getFilters(symbols?: string[]): ({ readonly channel: "liquidation_orders"; readonly symbols: string[] | undefined; } | { readonly channel: "contract_info"; readonly symbols: string[] | undefined; })[]; private _updateContractCodeToSymbolMap; map(message: HuobiLiquidationOrder, localTimestamp: Date): IterableIterator<Liquidation>; } export declare class HuobiOptionsSummaryMapper implements Mapper<'huobi-dm-options', OptionSummary> { private readonly _indexPrices; private readonly _openInterest; canHandle(message: HuobiOpenInterestDataMessage | HuobiOptionsIndexMessage | HuobiOptionsMarketIndexMessage): boolean; getFilters(symbols?: string[]): ({ readonly channel: "open_interest"; readonly symbols: string[] | undefined; } | { readonly channel: "option_index"; readonly symbols: string[] | undefined; } | { readonly channel: "option_market_index"; readonly symbols: string[] | undefined; })[]; map(message: HuobiOpenInterestDataMessage | HuobiOptionsIndexMessage | HuobiOptionsMarketIndexMessage, localTimestamp: Date): IterableIterator<OptionSummary> | undefined; } export declare class HuobiBookTickerMapper implements Mapper<'huobi' | 'huobi-dm' | 'huobi-dm-swap' | 'huobi-dm-linear-swap', BookTicker> { private readonly _exchange; constructor(_exchange: Exchange); canHandle(message: HuobiDataMessage): boolean; getFilters(symbols?: string[]): { readonly channel: "bbo"; readonly symbols: string[] | undefined; }[]; map(message: HuobiBBOMessage, localTimestamp: Date): IterableIterator<BookTicker>; } type HuobiDataMessage = { ch: string; }; type HuobiTradeDataMessage = HuobiDataMessage & { tick: { data: { id: number; tradeId?: number; price: number; amount: number; direction: 'buy' | 'sell'; ts: number; }[]; }; }; type HuobiBookLevel = [number, number]; type HuobiDepthDataMessage = HuobiDataMessage & ({ update?: boolean; ts: number; tick: { bids: HuobiBookLevel[] | null; asks: HuobiBookLevel[] | null; }; } | { ts: number; tick: { bids?: HuobiBookLevel[] | null; asks?: HuobiBookLevel[] | null; event: 'snapshot' | 'update'; }; }); type HuobiBasisDataMessage = HuobiDataMessage & { ts: number; tick: { index_price: string; contract_price: string; }; }; type HuobiFundingRateNotification = { op: 'notify'; topic: string; ts: number; data: { settlement_time: string; funding_rate: string; estimated_rate: string; contract_code: string; }[]; }; type HuobiOpenInterestDataMessage = HuobiDataMessage & { ts: number; data: { volume: number; }[]; }; type HuobiMBPDataMessage = HuobiDataMessage & { ts: number; tick: { bids?: HuobiBookLevel[] | null; asks?: HuobiBookLevel[] | null; seqNum: number; prevSeqNum: number; }; }; type HuobiMBPSnapshot = { ts: number; rep: string; data?: { bids: HuobiBookLevel[]; asks: HuobiBookLevel[]; seqNum: number; }; }; type MBPInfo = { bufferedUpdates: CircularBuffer<HuobiMBPDataMessage>; snapshotProcessed?: boolean; }; type HuobiLiquidationOrder = { op: 'notify'; topic: string; ts: number; data: { symbol: string; contract_code: string; direction: 'buy' | 'sell'; offset: string; volume: number; price: number; created_at: number; }[]; }; type HuobiContractInfo = { op: 'notify'; topic: string; ts: number; data: { symbol: string; contract_code: string; contract_type: 'this_week' | 'next_week' | 'quarter' | 'next_quarter'; }[]; }; type HuobiOptionsIndexMessage = { ch: 'market.BTC-USDT.option_index'; generated: true; data: { symbol: 'BTC-USDT'; index_price: 43501.21; index_ts: 1621295997270; }; ts: 1621296002825; }; type HuobiOptionsMarketIndexMessage = { ch: 'market.BTC-USDT-210521-P-42000.option_market_index'; generated: true; data: { contract_code: 'BTC-USDT-210521-P-42000'; symbol: 'BTC'; iv_last_price: 1.62902357; iv_ask_one: 1.64869787; iv_bid_one: 1.13185884; iv_mark_price: 1.39190675; delta: -0.3704996546766173; gamma: 0.00006528; theta: -327.85540508; vega: 15.70293917; ask_one: 2000; bid_one: 1189.49; last_price: 1968.83; mark_price: 1594.739777491571343067; trade_partition: 'USDT'; contract_type: 'this_week'; option_right_type: 'P'; }; ts: 1621296002820; }; type HuobiBBOMessage = { ch: 'market.BTC-USDT.bbo'; ts: 1630454400495; tick: { mrid: 64797873746; id: 1630454400; bid: [47176.5, 1] | undefined; ask: [47176.6, 9249] | undefined; ts: 1630454400495; version: 64797873746; ch: 'market.BTC-USDT.bbo'; }; } | { ch: 'market.btcusdt.bbo'; ts: 1575158404058; tick: { seqId: 103273695595; ask: 7543.59; askSize: 2.323241; bid: 7541.16; bidSize: 0.002329; quoteTime: number; symbol: 'btcusdt'; }; }; export {}; //# sourceMappingURL=huobi.d.ts.map