Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/node-binance-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<FuturesOrder> {
async futuresAlgoOrder(type: OrderType, side: string, symbol: string, quantity: number, price?: number, params: Dict = {}): Promise<FuturesAlgoOrder> {
params.symbol = symbol;
params.side = side;
params.type = type;
Expand Down Expand Up @@ -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<FuturesOrder> { // Either orderId or origClientOrderId must be sent
async futuresAlgoOrderStatus(symbol: string, params: Dict = {}): Promise<FuturesAlgoOrder> { // Either orderId or origClientOrderId must be sent
params.symbol = symbol;
return await this.privateFuturesRequest('v1/algoOrder', params);
}
Expand Down Expand Up @@ -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<CancelOrder> { // Either orderId or origClientOrderId must be sent
async futuresCancelAlgoOrder(symbol: string, orderId?: number | string, params: Dict = {}): Promise<CancelAlgoOrder> { // Either orderId or origClientOrderId must be sent
params.symbol = symbol;
if (orderId) params.algoid = orderId;
return await this.privateFuturesRequest('v1/algoOrder', params, 'DELETE');
Expand Down Expand Up @@ -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<FuturesOrder[]> { // Get all account orders; active, canceled, or filled.
async futuresAllAlgoOrders(symbol?: string, params: Dict = {}): Promise<FuturesAlgoOrder[]> { // Get all account orders; active, canceled, or filled.
if (symbol) params.symbol = symbol;
return await this.privateFuturesRequest('v1/allAlgoOrders', params);
}
Expand Down
79 changes: 62 additions & 17 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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'
Expand Down Expand Up @@ -359,6 +399,11 @@ export interface CancelOrder {
side: OrderSide
}

export interface CancelAlgoOrder {
algoId: number;
clientAlgoId: string;
}

export interface FuturesUserTrade {
buyer: boolean
commission: string
Expand Down
Loading