Skip to content

Commit 769492a

Browse files
committed
type return type
1 parent 981f5cd commit 769492a

3 files changed

Lines changed: 45 additions & 5 deletions

File tree

examples/oco-order.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ async function main() {
2929
}
3030

3131
const oco1 = await binance.ocoOrder(side, symbol, quantity, params);
32-
console.log('oco1', oco1);
32+
console.log('oco1', oco1.orderListId);
33+
console.log(oco1.orderReports[0].orderId)
34+
console.log(oco1.orderReports[1].orderId)
3335

3436
}
3537

src/node-binance-api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import nodeFetch from 'node-fetch';
1616
import zip from 'lodash.zipobject';
1717
import stringHash from 'string-hash';
1818
// eslint-disable-next-line
19-
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 } from './types.js';
19+
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';
2020
// 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';
2121

2222
export interface Dictionary<T> {
@@ -874,7 +874,7 @@ export default class Binance {
874874
}
875875

876876
/**
877-
* Create a OCO spot order
877+
* Create an OCO spot order
878878
* @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-list---oco-trade
879879
* @param {OrderSide} side - BUY or SELL
880880
* @param {string} symbol - The symbol to buy or sell
@@ -893,7 +893,7 @@ export default class Binance {
893893
* @param {string} params.belowTimeInForce - The time in force of the below order
894894
* @return {undefined}
895895
*/
896-
async ocoOrder(side: OrderSide, symbol: string, quantity: number, params: Dict = {}): Promise<any> {
896+
async ocoOrder(side: OrderSide, symbol: string, quantity: number, params: Dict = {}): Promise<OCOOrder> {
897897
const request = {
898898
symbol: symbol,
899899
side: side,

src/types.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,4 +602,42 @@ export interface SymbolConfig {
602602
isAutoAddMargin: boolean
603603
leverage: number
604604
maxNotionalValue: string
605-
}
605+
}
606+
607+
/**
608+
* The response structure for an OCO order, based on Binance API documentation.
609+
* See: https://binance-docs.github.io/apidocs/spot/en/#new-oco-trade
610+
*/
611+
export interface OCOOrder {
612+
orderListId: number;
613+
contingencyType: string;
614+
listStatusType: string;
615+
listOrderStatus: string;
616+
listClientOrderId: string;
617+
transactionTime: number;
618+
symbol: string;
619+
orders: Array<{
620+
symbol: string;
621+
orderId: number;
622+
clientOrderId: string;
623+
}>;
624+
orderReports: Array<{
625+
symbol: string;
626+
orderId: number;
627+
orderListId: number;
628+
clientOrderId: string;
629+
transactTime: number;
630+
price: string;
631+
origQty: string;
632+
executedQty: string;
633+
cummulativeQuoteQty: string;
634+
status: string;
635+
timeInForce: string;
636+
type: string;
637+
side: string;
638+
stopPrice?: string;
639+
icebergQty?: string;
640+
workingTime?: number;
641+
selfTradePreventionMode?: string;
642+
}>;
643+
}

0 commit comments

Comments
 (0)