diff --git a/src/node-binance-api.ts b/src/node-binance-api.ts index 17cffe04..e2beed89 100644 --- a/src/node-binance-api.ts +++ b/src/node-binance-api.ts @@ -16,7 +16,7 @@ import nodeFetch from 'node-fetch'; import zip from 'lodash.zipobject'; import stringHash from 'string-hash'; // eslint-disable-next-line -import { Interval, PositionRisk, Order, FuturesOrder, PositionSide, WorkingType, OrderType, OrderStatus, TimeInForce, Callback, IConstructorArgs, OrderSide, FundingRate, CancelOrder, AggregatedTrade, Trade, MyTrade, WithdrawHistoryResponse, DepositHistoryResponse, DepositAddress, WithdrawResponse, Candle, FuturesCancelAllOpenOrder, OrderBook, Ticker, FuturesUserTrade, Account, FuturesAccountInfo, FuturesBalance, QueryOrder, HttpMethod, BookTicker, DailyStats, PremiumIndex, OpenInterest, IWebsocketsMethods, SymbolConfig, OCOOrder } from './types.js'; +import { Interval, PositionRisk, Order, FuturesOrder, PositionSide, WorkingType, OrderType, OrderStatus, TimeInForce, Callback, IConstructorArgs, OrderSide, FundingRate, CancelOrder, AggregatedTrade, Trade, MyTrade, WithdrawHistoryResponse, DepositHistoryResponse, DepositAddress, WithdrawResponse, Candle, FuturesCancelAllOpenOrder, OrderBook, Ticker, FuturesUserTrade, Account, FuturesAccountInfo, FuturesBalance, QueryOrder, HttpMethod, BookTicker, DailyStats, PremiumIndex, OpenInterest, IWebsocketsMethods, SymbolConfig, OCOOrder, FuturesAlgoOrder, CancelAlgoOrder } from './types.js'; // export { Interval, PositionRisk, Order, FuturesOrder, PositionSide, WorkingType, OrderType, OrderStatus, TimeInForce, Callback, IConstructorArgs, OrderSide, FundingRate, CancelOrder, AggregatedTrade, Trade, MyTrade, WithdrawHistoryResponse, DepositHistoryResponse, DepositAddress, WithdrawResponse, Candle, FuturesCancelAllOpenOrder, OrderBook, Ticker, FuturesUserTrade, FuturesAccountInfo, FuturesBalance, QueryOrder } from './types'; export interface Dictionary { @@ -1158,6 +1158,7 @@ export default class Binance { // Futures internal functions /** * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/New-Order + * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/New-Algo-Order * @param type * @param side * @param symbol symbol if the market @@ -1223,7 +1224,7 @@ export default class Binance { * @param params extra parameters to be sent in the request * @returns */ - async futuresAlgoOrder(type: OrderType, side: string, symbol: string, quantity: number, price?: number, params: Dict = {}): Promise { + async futuresAlgoOrder(type: OrderType, side: string, symbol: string, quantity: number, price?: number, params: Dict = {}): Promise { params.symbol = symbol; params.side = side; params.type = type; @@ -4584,7 +4585,7 @@ export default class Binance { * @param params extra parameters to be sent in the request * @returns */ - async futuresAlgoOrderStatus(symbol: string, params: Dict = {}): Promise { // Either orderId or origClientOrderId must be sent + async futuresAlgoOrderStatus(symbol: string, params: Dict = {}): Promise { // Either orderId or origClientOrderId must be sent params.symbol = symbol; return await this.privateFuturesRequest('v1/algoOrder', params); } @@ -4616,7 +4617,7 @@ export default class Binance { * @param params extra parameters to be sent in the request * @returns */ - async futuresCancelAlgoOrder(symbol: string, orderId?: number | string, params: Dict = {}): Promise { // Either orderId or origClientOrderId must be sent + async futuresCancelAlgoOrder(symbol: string, orderId?: number | string, params: Dict = {}): Promise { // Either orderId or origClientOrderId must be sent params.symbol = symbol; if (orderId) params.algoid = orderId; return await this.privateFuturesRequest('v1/algoOrder', params, 'DELETE'); @@ -4706,7 +4707,7 @@ export default class Binance { * @param params extra parameters to be sent in the request * @returns */ - async futuresAllAlgoOrders(symbol?: string, params: Dict = {}): Promise { // Get all account orders; active, canceled, or filled. + async futuresAllAlgoOrders(symbol?: string, params: Dict = {}): Promise { // Get all account orders; active, canceled, or filled. if (symbol) params.symbol = symbol; return await this.privateFuturesRequest('v1/allAlgoOrders', params); } diff --git a/src/types.ts b/src/types.ts index b3c12367..99d6ffcd 100644 --- a/src/types.ts +++ b/src/types.ts @@ -96,28 +96,28 @@ export interface Order { } export interface FuturesOrder { - clientOrderId?: string - cumQty?: string - cumQuote?: string - executedQty?: string - orderId?: number - avgPrice?: string - origQty?: string + clientOrderId: string + cumQty: string + cumQuote: string + executedQty: string + orderId: number + avgPrice: string + origQty: string price: string reduceOnly: boolean side: OrderSide positionSide: PositionSide - status?: OrderStatus - stopPrice?: string - closePosition?: boolean + status: OrderStatus + stopPrice: string + closePosition: boolean symbol: string - timeInForce?: TimeInForce - type?: OrderType - origType?: OrderType - activatePrice?: string - priceRate?: string - updateTime?: number - workingType?: WorkingType + timeInForce: TimeInForce + type: OrderType + origType: OrderType + activatePrice: string + priceRate: string + updateTime: number + workingType: WorkingType // algo orders fields algoId?: number; triggerPrice?: string; @@ -132,6 +132,46 @@ export interface FuturesOrder { slPrice?: string; tpOrderType?: string; slOrderType?: string; + algoType?: string; + orderType?: OrderType; + quantity?: string; + icebergQuantity?: string; + selfTradePreventionMode?: string; + priceMatch?: string; + priceProtect?: boolean; + callbackRate?: string; //TRAILING_STOP_MARKET order + createTime?: number; + triggerTime?: number; + goodTillDate?: number; +} + +export interface FuturesAlgoOrder { + algoId: number; + clientOrderId: string; + clientAlgoId: string; + algoType: string; + orderType: OrderType; + symbol: string; + side: OrderSide; + positionSide: PositionSide; + timeInForce: TimeInForce; + quantity: string; + algoStatus: string; + triggerPrice: string; + price: string; + icebergQuantity: string | null; + selfTradePreventionMode: string; + workingType: WorkingType; + priceMatch: string; + closePosition: boolean; + priceProtect: boolean; + reduceOnly: boolean; + activatePrice: string; //TRAILING_STOP_MARKET order + callbackRate: string; //TRAILING_STOP_MARKET order + createTime: number; + updateTime: number; + triggerTime: number; + goodTillDate: number; } export type PositionSide = 'BOTH' | 'SHORT' | 'LONG' @@ -359,6 +399,11 @@ export interface CancelOrder { side: OrderSide } +export interface CancelAlgoOrder { + algoId: number; + clientAlgoId: string; +} + export interface FuturesUserTrade { buyer: boolean commission: string