UNPKG

okx-api

Version:

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

242 lines (241 loc) 7.67 kB
import { AlgoOrderState, AlgoOrderType, AlgoPositionSide, InstrumentType, MarginMode, numberInString, OrderSide, OrderType, PositionSide, PriceTriggerType, TradeMode } from '../shared.js'; export interface AlgoRecentHistoryRequest { ordType: AlgoOrderType; algoId?: string; instType?: InstrumentType; instId?: string; after?: string; before?: string; limit?: string; } export interface AlgoLongHistoryRequest { ordType: AlgoOrderType; state?: AlgoOrderState; algoId?: string; instType?: InstrumentType; instId?: string; after?: string; before?: string; limit?: string; } interface AlgoTriggerOrder { newTpTriggerPx?: string; newTpTriggerPxType?: 'last' | 'index' | 'mark'; newTpOrdPx?: string; newSlTriggerPx?: string; newSlTriggerPxType?: 'last' | 'index' | 'mark'; newSlOrdPx?: string; } export interface AlgoOrderRequest { instId: string; tdMode: TradeMode; ccy?: string; side: OrderSide; posSide?: AlgoPositionSide; ordType: AlgoOrderType; algoClOrdId?: string; sz: numberInString; tag?: string; reduceOnly?: boolean; tgtCcy?: string; tpTriggerPx?: numberInString; tpTriggerPxType?: PriceTriggerType; tpOrdPx?: numberInString; tpOrdKind?: string; slTriggerPx?: numberInString; slTriggerPxType?: PriceTriggerType; slOrdPx?: numberInString; cxlOnClosePos?: boolean; triggerPx?: numberInString; triggerPxType?: PriceTriggerType; orderPx?: numberInString; chaseType?: string; chaseVal?: numberInString; maxChaseType?: string; maxChaseVal?: numberInString; callbackRatio?: numberInString; callbackSpread?: numberInString; activePx?: numberInString; pxVar?: numberInString; pxSpread?: numberInString; szLimit?: numberInString; pxLimit?: numberInString; timeInterval?: string; quickMgnType?: string; closeFraction?: numberInString; advanceOrdType?: 'fok' | 'ioc' | ''; attachAlgoOrds?: { attachAlgoClOrdId?: string; tpTriggerPx?: string; tpOrdPx?: string; slTriggerPx?: string; slOrdPx?: string; tpTriggerPxType?: string; slTriggerPxType?: string; }[]; } export interface AmendOrderRequest { instId: string; cxlOnFail?: boolean; ordId?: string; clOrdId?: string; reqId?: string; newSz?: string; newPx?: string; } export type AlgoOrderDetailsRequest = { algoId: string; } | { algoClOrdId: string; }; export interface AmendAlgoOrderRequest { instId: string; algoId?: string; algoClOrdId?: string; cxlOnFail?: boolean; reqId?: string; newSz?: string; newTpTriggerPx?: string; newTpOrdPx?: string; newSlTriggerPx?: string; newSlOrdPx?: string; newTpTriggerPxType?: 'last' | 'index' | 'mark'; newSlTriggerPxType?: 'last' | 'index' | 'mark'; newTriggerPx: string; newOrdPx: string; newTriggerPxType?: 'last' | 'index' | 'mark'; attachAlgoOrds?: AlgoTriggerOrder[]; } export interface CancelAlgoOrderRequest { instId: string; algoId?: string; algoClOrdId?: string; } export interface ClosePositionRequest { instId: string; posSide?: PositionSide; mgnMode: MarginMode; ccy?: string; autoCxl?: boolean; clOrdId?: string; tag?: string; } export interface FillsHistoryRequest { instType?: InstrumentType; uly?: string; instId?: string; ordId?: string; after?: string; before?: string; begin?: string; end?: string; limit?: string; } export interface OrderIdRequest { instId: string; ordId?: string; clOrdId?: string; } export interface OrderHistoryRequest { instType: InstrumentType; uly?: string; instId?: string; ordType?: OrderType; state?: string; category?: string; after?: string; before?: string; begin?: string; end?: string; limit?: string; } export interface OrderRequest { instId: string; tdMode: TradeMode; ccy?: string; clOrdId?: string; tag?: string; side: OrderSide; posSide?: PositionSide; ordType: OrderType; /** Quantity to buy or sell */ sz: numberInString; px?: string; /** Place options orders in USD. Only applicable to options. One of px/pxUsd/pxVol must be filled for option orders */ pxUsd?: string; /** Place options orders based on implied volatility, where 1 represents 100%. Only applicable to options */ pxVol?: string; reduceOnly?: boolean; /** A spot buy on BTC-USDT with "base_ccy" would mean the QTY (sz) is in USDT */ tgtCcy?: 'base_ccy' | 'quote_ccy'; banAmend?: boolean; /** Price amendment type: "0" = do not allow amendment, "1" = allow amendment within price limit. Default is "0" */ pxAmendType?: '0' | '1'; /** Quote currency used for trading. Only applicable to SPOT. Default is quote currency of instId */ tradeQuoteCcy?: string; /** Self trade prevention mode: cancel_maker, cancel_taker, cancel_both. Default is cancel_maker */ stpMode?: 'cancel_maker' | 'cancel_taker' | 'cancel_both'; /** Take Profit & Stop Loss params */ tpTriggerPx?: string; tpOrdPx?: string; slTriggerPx?: string; slOrdPx?: string; tpTriggerPxType?: PriceTriggerType; slTriggerPxType?: PriceTriggerType; /** TP/SL information attached when placing order (supports split TPs and advanced TP/SL configurations) */ attachAlgoOrds?: { /** Client-supplied Algo ID when placing order attaching TP/SL */ attachAlgoClOrdId?: string; /** Take-profit trigger price */ tpTriggerPx?: string; /** Take profit trigger ratio, 0.3 represents 30%. Only one of tpTriggerPx and tpTriggerRatio can be passed */ tpTriggerRatio?: string; /** Take-profit order price. -1 means market price */ tpOrdPx?: string; /** TP order kind: "condition" or "limit". Default is "condition" */ tpOrdKind?: 'condition' | 'limit'; /** Stop-loss trigger price */ slTriggerPx?: string; /** Stop loss trigger ratio, 0.3 represents 30%. Only one of slTriggerPx and slTriggerRatio can be passed */ slTriggerRatio?: string; /** Stop-loss order price. -1 means market price */ slOrdPx?: string; /** Take-profit trigger price type: last, index, or mark. Default is last */ tpTriggerPxType?: 'last' | 'index' | 'mark'; /** Stop-loss trigger price type: last, index, or mark. Default is last */ slTriggerPxType?: 'last' | 'index' | 'mark'; /** Size. Only applicable to TP order of split TPs, and it is required for TP order of split TPs */ sz?: string; /** Whether to enable Cost-price SL. "0" = disable (default), "1" = Enable. Only applicable to SL order of split TPs */ amendPxOnTriggerType?: '0' | '1'; }[]; /** Quick margin type */ quickMgnType?: 'manual' | 'auto_borrow' | 'auto_repay'; } export interface GetTransactionDetailsArchiveRequest { year: string; quarter: 'Q1' | 'Q2' | 'Q3' | 'Q4'; } export interface OrderPrecheckRequest { instId: string; tdMode: string; side: string; posSide?: string; ordType: string; sz: string; px?: string; reduceOnly?: boolean; tgtCcy?: string; attachAlgoOrds?: { attachAlgoClOrdId?: string; tpTriggerPx?: string; tpOrdPx?: string; tpOrdKind?: string; slTriggerPx?: string; slOrdPx?: string; tpTriggerPxType?: string; slTriggerPxType?: string; sz?: string; }[]; } export {};