UNPKG

okx-api

Version:

Complete Node.js SDK for OKX's REST APIs and WebSockets, with TypeScript & end-to-end tests

368 lines (367 loc) 8.74 kB
import { InstrumentType, numberInString } from '../shared.js'; export interface Ticker { instType: InstrumentType; instId: string; last: numberInString; lastSz: numberInString; askPx: numberInString; askSz: numberInString; bidPx: numberInString; bidSz: numberInString; open24h: numberInString; high24h: numberInString; low24h: numberInString; volCcy24h: numberInString; vol24h: numberInString; sodUtc0: numberInString; sodUtc8: numberInString; ts: numberInString; } export interface IndexTicker { instId: string; idxPx: string; high24h: string; sodUtc0: string; open24h: string; low24h: string; sodUtc8: string; ts: string; } type OBPrice = string; type OBAssetQty = string; type OBOrderCount = string; type OrderBookLevel = [OBPrice, OBAssetQty, '0', OBOrderCount]; export interface OrderBook { asks: OrderBookLevel[]; bids: OrderBookLevel[]; ts: string; } type timestamp = string; type openPrice = string; type highPrice = string; type lowPrice = string; type closePrice = string; type vol = string; type volCcy = string; type volCcyQuote = string; type confirm = string; export type Candle = [ timestamp, openPrice, highPrice, lowPrice, closePrice, vol, volCcy, volCcyQuote, confirm ]; export type CandleNoVolume = [ timestamp, openPrice, highPrice, lowPrice, closePrice ]; export interface Trade { instId: string; side: string; sz: string; px: string; tradeId: string; ts: string; source?: string; } export interface InstrumentUpcomingParamChange { param: 'tickSz' | 'minSz' | 'maxMktSz' | string; newValue: string; effTime: string; } export interface Instrument { instType: InstrumentType; /** Series id for EVENTS, e.g. BTC-ABOVE-DAILY. */ seriesId?: string; instId: string; uly: string; instFamily: string; category: string; baseCcy: string; quoteCcy: string; settleCcy: string; ctVal: string; ctMult: string; ctValCcy: string; optType: string; stk: string; listTime: string; contTdSwTime?: string; preMktSwTime?: string; expTime: string; lever: string; tickSz: string; lotSz: string; minSz: string; ctType: string; /** * FUTURES contract label (deprecated prefer `expTime` for delivery time; removal planned). * Includes `this_five_years` / `next_five_years` (X-Perps / 5Y-style contracts). */ alias: string; /** * Instrument status: live, suspend, rebase (SWAP only), post_only (SWAP only), preopen, test, expired, settling (EVENTS), */ state: string; openType?: string; maxLmtSz: string; maxLmtAmt?: string; maxMktSz: string; maxMktAmt?: string; maxTwapSz: string; maxIcebergSz: string; maxTriggerSz: string; maxStopSz: string; /** * e.g. `normal`, `pre_market`, `rebase_contract`, `xperp` (perpetual-style expiry futures, some FUTURES only). */ ruleType: string; auctionEndTime: string; futureSettlement?: boolean; tradeQuoteCcyList?: string[]; instIdCode?: number; /** * Asset category of the instrument's base asset (first segment of `instId`). E.g. BTC-USDT-SWAP category of BTC. * 1: Crypto, 3: Stocks, 4: Commodities, 5: Forex, 6: Bonds, "": not available */ instCategory?: string; posLmtAmt?: string; posLmtPct?: string; longPosRemainingQuota?: string; shortPosRemainingQuota?: string; maxPlatOILmt?: string; groupId?: string; upcChg?: InstrumentUpcomingParamChange[]; } export interface EconomicCalendarData { calendarId: string; date: string; region: string; category: string; event: string; refDate: string; actual: string; previous: string; forecast: string; dateSpan: string; importance: string; uTime: string; prevInitial: string; ccy: string; unit: string; } export interface UnitConvertData { type: '1' | '2'; instId: string; px: string; sz: string; unit: 'coin' | 'usds'; } /** * @see GET /api/v5/public/funding-rate * `instType` is `SWAP` (perp) or `FUTURES` (X-Perp) when applicable. */ export interface PublicFundingRate { instType: string; instId: string; method: string; formulaType: string; fundingRate: string; nextFundingRate: string; fundingTime: string; nextFundingTime: string; minFundingRate: string; maxFundingRate: string; interestRate: string; impactValue: string; settState: string; settFundingRate: string; premium: string; ts: string; } export interface FundingRateHistory { /** Perpetual (`SWAP`) or X-Perp (`FUTURES`). */ instType: string; instId: string; fundingRate: string; realizedRate: string; fundingTime: string; method: string; formulaType?: string; } export interface SystemTime { ts: string; } /** * @see GET /api/v5/public/estimated-price */ export interface EstimatedDeliveryExercisePrice { instType: string; instId: string; settlePx: string; ts: string; } export interface OptionsTradeInfo { instId: string; tradeId: string; px: string; sz: string; side: 'buy' | 'sell'; ts: string; } export interface OptionTrade { vol24h: string; optType: 'C' | 'P'; tradeInfo: OptionsTradeInfo[]; } export interface OptionTrades { instId: string; instFamily: string; tradeId: string; px: string; sz: string; side: 'buy' | 'sell'; optType: 'C' | 'P'; fillVol: string; fwdPx: string; idxPx: string; markPx: string; ts: string; } export interface Announcement { annType: string; pTime: string; businessPTime: string; title: string; url: string; } /** Public borrow history record (GET /api/v5/finance/savings/lending-rate-history) */ export interface PublicBorrowHistoryRecord { ccy: string; amt: string; rate: string; lendingRate: string; ts: string; } export interface BasicInterestRate { ccy: string; rate: string; quota: string; } export interface VIPInterestInfo { level: string; loanQuotaCoef: string; irDiscount: string; } export interface RegularUserInterestInfo { level: string; loanQuotaCoef: string; irDiscount: string; } export interface ConfigCcyItem { ccy: string; rate: string; } export interface LoanQuotaConfig { ccy: string; stgyType: string; quota: string; level: string; } export interface InterestRateAndLoanQuota { basic: BasicInterestRate[]; vip: VIPInterestInfo[]; regular: RegularUserInterestInfo[]; configCcyList: ConfigCcyItem[]; config: LoanQuotaConfig[]; } /** * @see GET /api/v5/public/market-data-history */ export interface MarketDataHistoryFileGroup { dateTs: string; filename: string; sizeMB: string; url: string; } export interface MarketDataHistoryGroupDetail { instId: string; instFamily: string; instType: string; dateRangeStart: string; dateRangeEnd: string; groupSizeMB: string; groupDetails: MarketDataHistoryFileGroup[]; } export interface MarketDataHistoryResult { dateAggrType: string; details: MarketDataHistoryGroupDetail[]; totalSizeMB: string; ts: string; } /** @see GET /api/v5/finance/staking-defi/eth/product-info */ export interface EthStakingProductInfo { fastRedemptionDailyLimit: string; rate: string; redemptDays: string; minAmt: string; } /** @see GET /api/v5/finance/staking-defi/sol/product-info */ export interface SolStakingProductInfo { fastRedemptionAvail: string; fastRedemptionDailyLimit: string; rate: string; redemptDays: string; minAmt: string; } /** * @see GET /api/v5/public/event-contract/series */ export interface EventContractSettlement { method: string; closeEarly: boolean; srcName: string; underlying: string; } export interface EventContractSeries { seriesId: string; freq: string; title: string; category: string; settlement: EventContractSettlement; } /** * @see GET /api/v5/public/event-contract/events */ export interface EventContractEvent { seriesId: string; eventId: string; expTime: string; state: string; fixTime?: string; } /** * @see GET /api/v5/public/event-contract/markets */ export interface EventContractMarket { seriesId: string; eventId: string; instId: string; listTime: string; expTime: string; state: string; fixTime: string; outcome: string; floorStrike: string; settleValue: string; disputed: boolean; } export {};