binance 3.0.0-beta.0 → 3.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +305 -75
- package/index.js +1 -1
- package/lib/coinm-client.d.ts +40 -22
- package/lib/coinm-client.js +4 -16
- package/lib/coinm-client.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/main-client.d.ts +94 -30
- package/lib/main-client.js +68 -36
- package/lib/main-client.js.map +1 -1
- package/lib/portfolio-client.js.map +1 -1
- package/lib/types/coin.d.ts +1 -0
- package/lib/types/futures.d.ts +15 -4
- package/lib/types/futures.js.map +1 -1
- package/lib/types/portfolio-margin.d.ts +0 -9
- package/lib/types/shared.d.ts +14 -13
- package/lib/types/spot.d.ts +174 -11
- package/lib/types/spot.js.map +1 -1
- package/lib/types/websockets/ws-api-requests.d.ts +480 -2
- package/lib/types/websockets/ws-api-responses.d.ts +565 -1
- package/lib/types/websockets/ws-api.d.ts +157 -60
- package/lib/types/websockets/ws-api.js +47 -3
- package/lib/types/websockets/ws-api.js.map +1 -1
- package/lib/types/websockets/ws-events-formatted.d.ts +18 -14
- package/lib/types/websockets/ws-events-raw.d.ts +4 -2
- package/lib/types/websockets/ws-general.d.ts +8 -18
- package/lib/usdm-client.d.ts +45 -27
- package/lib/usdm-client.js +7 -19
- package/lib/usdm-client.js.map +1 -1
- package/lib/util/BaseRestClient.js +20 -6
- package/lib/util/BaseRestClient.js.map +1 -1
- package/lib/util/BaseWSClient.d.ts +14 -3
- package/lib/util/BaseWSClient.js +87 -30
- package/lib/util/BaseWSClient.js.map +1 -1
- package/lib/util/beautifier-maps.d.ts +32 -0
- package/lib/util/beautifier-maps.js +41 -0
- package/lib/util/beautifier-maps.js.map +1 -1
- package/lib/util/beautifier.d.ts +1 -0
- package/lib/util/beautifier.js +44 -9
- package/lib/util/beautifier.js.map +1 -1
- package/lib/util/browser-support.d.ts +1 -1
- package/lib/util/browser-support.js +1 -41
- package/lib/util/browser-support.js.map +1 -1
- package/lib/util/node-support.js +7 -5
- package/lib/util/node-support.js.map +1 -1
- package/lib/util/requestUtils.d.ts +22 -4
- package/lib/util/requestUtils.js +76 -25
- package/lib/util/requestUtils.js.map +1 -1
- package/lib/util/rounding.d.ts +8 -0
- package/lib/util/rounding.js +41 -0
- package/lib/util/rounding.js.map +1 -0
- package/lib/util/typeGuards.d.ts +31 -3
- package/lib/util/typeGuards.js +105 -8
- package/lib/util/typeGuards.js.map +1 -1
- package/lib/util/webCryptoAPI.js +20 -45
- package/lib/util/webCryptoAPI.js.map +1 -1
- package/lib/util/websockets/WsStore.js +7 -2
- package/lib/util/websockets/WsStore.js.map +1 -1
- package/lib/util/websockets/enum.d.ts +11 -0
- package/lib/util/websockets/enum.js +24 -0
- package/lib/util/websockets/enum.js.map +1 -0
- package/lib/util/websockets/rest-client-cache.d.ts +3 -3
- package/lib/util/websockets/rest-client-cache.js +9 -9
- package/lib/util/websockets/rest-client-cache.js.map +1 -1
- package/lib/util/websockets/user-data-stream-manager.js +7 -8
- package/lib/util/websockets/user-data-stream-manager.js.map +1 -1
- package/lib/util/websockets/websocket-util.d.ts +27 -6
- package/lib/util/websockets/websocket-util.js +147 -52
- package/lib/util/websockets/websocket-util.js.map +1 -1
- package/lib/websocket-api-client.d.ts +401 -0
- package/lib/websocket-api-client.js +647 -0
- package/lib/websocket-api-client.js.map +1 -0
- package/lib/websocket-client-legacy.d.ts +5 -3
- package/lib/websocket-client-legacy.js +11 -10
- package/lib/websocket-client-legacy.js.map +1 -1
- package/lib/websocket-client.d.ts +26 -11
- package/lib/websocket-client.js +185 -139
- package/lib/websocket-client.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { WS_KEY_MAP, WsKey } from '../../util/websockets/websocket-util';
|
|
2
|
-
import {
|
|
3
|
-
import { numberInString } from '../shared';
|
|
2
|
+
import { FuturesExchangeInfo, NewFuturesOrderParams } from '../futures';
|
|
4
3
|
import { ExchangeInfo, NewSpotOrderParams, OrderResponse } from '../spot';
|
|
5
|
-
import { WSAPIRecvWindowTimestamp } from './ws-api-requests';
|
|
6
|
-
import {
|
|
4
|
+
import { WSAPIAccountCommissionWSAPIRequest, WSAPIAccountInformationRequest, WSAPIAllOrderListsRequest, WSAPIAllOrdersRequest, WSAPIAvgPriceRequest, WSAPIExchangeInfoRequest, WSAPIFuturesOrderBookRequest, WSAPIFuturesOrderCancelRequest, WSAPIFuturesOrderModifyRequest, WSAPIFuturesOrderStatusRequest, WSAPIFuturesTickerBookRequest, WSAPIFuturesTickerPriceRequest, WSAPIKlinesRequest, WSAPIMyAllocationsRequest, WSAPIMyPreventedMatchesRequest, WSAPIMyTradesRequest, WSAPIOpenOrdersCancelAllRequest, WSAPIOpenOrdersStatusRequest, WSAPIOrderAmendKeepPriorityRequest, WSAPIOrderBookRequest, WSAPIOrderCancelReplaceRequest, WSAPIOrderCancelRequest, WSAPIOrderListCancelRequest, WSAPIOrderListPlaceOCORequest, WSAPIOrderListPlaceOTOCORequest, WSAPIOrderListPlaceOTORequest, WSAPIOrderListPlaceRequest, WSAPIOrderListStatusRequest, WSAPIOrderStatusRequest, WSAPIOrderTestRequest, WSAPIRecvWindowTimestamp, WSAPISessionLogonRequest, WSAPISOROrderPlaceRequest, WSAPISOROrderTestRequest, WSAPITicker24hrRequest, WSAPITickerBookRequest, WSAPITickerPriceRequest, WSAPITickerRequest, WSAPITickerTradingDayRequest, WSAPITradesAggregateRequest, WSAPITradesHistoricalRequest, WSAPITradesRecentRequest } from './ws-api-requests';
|
|
5
|
+
import { WSAPIAccountCommission, WSAPIAccountInformation, WSAPIAggregateTrade, WSAPIAllocation, WSAPIAvgPrice, WSAPIBookTicker, WSAPIFullTicker, WSAPIFuturesAccountBalanceItem, WSAPIFuturesAccountStatus, WSAPIFuturesBookTicker, WSAPIFuturesOrder, WSAPIFuturesOrderBook, WSAPIFuturesPosition, WSAPIFuturesPositionV2, WSAPIFuturesPriceTicker, WSAPIKline, WSAPIMiniTicker, WSAPIOrder, WSAPIOrderBook, WSAPIOrderCancel, WSAPIOrderCancelReplaceResponse, WSAPIOrderListCancelResponse, WSAPIOrderListPlaceResponse, WSAPIOrderListStatusResponse, WSAPIOrderTestResponse, WSAPIOrderTestWithCommission, WSAPIPreventedMatch, WSAPIPriceTicker, WSAPIRateLimit, WSAPIServerTime, WSAPISessionStatus, WSAPISOROrderPlaceResponse, WSAPISOROrderTestResponse, WSAPISOROrderTestResponseWithCommission, WSAPITrade } from './ws-api-responses';
|
|
7
6
|
/**
|
|
8
7
|
* Standard WS commands (for consumers)
|
|
9
8
|
*/
|
|
@@ -11,14 +10,18 @@ export type WsOperation = 'SUBSCRIBE' | 'UNSUBSCRIBE' | 'LIST_SUBSCRIPTIONS' | '
|
|
|
11
10
|
/**
|
|
12
11
|
* WS API commands (for sending requests via WS)
|
|
13
12
|
*/
|
|
14
|
-
export declare const WS_API_Operations: readonly ["session.logon", "session.status", "session.logout", "ping", "time", "exchangeInfo", "depth", "v2/account.balance", "account.balance", "v2/account.status", "account.status", "order.place", "orderList.place", "sor.order.place"];
|
|
13
|
+
export declare const WS_API_Operations: readonly ["session.logon", "session.status", "session.logout", "ping", "time", "exchangeInfo", "depth", "trades.recent", "trades.historical", "trades.aggregate", "klines", "uiKlines", "avgPrice", "ticker.24hr", "ticker.tradingDay", "ticker", "ticker.price", "ticker.book", "account.status", "account.commission", "account.rateLimits.orders", "allOrders", "allOrderLists", "myTrades", "myPreventedMatches", "myAllocations", "v2/account.balance", "account.balance", "v2/account.status", "account.position", "v2/account.position", "order.place", "order.test", "order.status", "order.cancel", "order.cancelReplace", "order.amend.keepPriority", "order.modify", "openOrders.status", "openOrders.cancelAll", "orderList.place", "orderList.place.oco", "orderList.place.oto", "orderList.place.otoco", "orderList.status", "orderList.cancel", "openOrderLists.status", "sor.order.place", "sor.order.test", "userDataStream.start", "userDataStream.ping", "userDataStream.stop", "userDataStream.subscribe", "userDataStream.unsubscribe"];
|
|
14
|
+
export interface WSAPIUserDataListenKeyRequest {
|
|
15
|
+
apiKey: string;
|
|
16
|
+
listenKey: string;
|
|
17
|
+
}
|
|
15
18
|
export type WsAPIOperation = (typeof WS_API_Operations)[number];
|
|
16
19
|
export interface WsRequestOperationBinance<TWSTopic extends string, TWSParams extends object = any> {
|
|
17
20
|
method: WsOperation | WsAPIOperation;
|
|
18
21
|
params?: (TWSTopic | string | number)[] | TWSParams;
|
|
19
22
|
id: number;
|
|
20
23
|
}
|
|
21
|
-
export interface WSAPIResponse<TResponseData extends object = object
|
|
24
|
+
export interface WSAPIResponse<TResponseData extends object = object> {
|
|
22
25
|
/** Auto-generated */
|
|
23
26
|
id: string;
|
|
24
27
|
status: number;
|
|
@@ -32,6 +35,7 @@ export interface WSAPIResponse<TResponseData extends object = object, TOperation
|
|
|
32
35
|
}[];
|
|
33
36
|
wsKey: WsKey;
|
|
34
37
|
isWSAPIResponse: boolean;
|
|
38
|
+
request?: any;
|
|
35
39
|
}
|
|
36
40
|
export type Exact<T> = {} & {
|
|
37
41
|
[K in keyof T]: T[K];
|
|
@@ -59,7 +63,10 @@ export interface WsAPIWsKeyTopicMap {
|
|
|
59
63
|
[WS_KEY_MAP.mainWSAPITestnet]: WsAPIOperation;
|
|
60
64
|
[WS_KEY_MAP.usdmWSAPI]: WsAPIOperation;
|
|
61
65
|
[WS_KEY_MAP.usdmWSAPITestnet]: WsAPIOperation;
|
|
66
|
+
[WS_KEY_MAP.coinmWSAPI]: WsAPIOperation;
|
|
67
|
+
[WS_KEY_MAP.coinmWSAPITestnet]: WsAPIOperation;
|
|
62
68
|
}
|
|
69
|
+
export type WsAPIFuturesWsKey = typeof WS_KEY_MAP.usdmWSAPI | typeof WS_KEY_MAP.usdmWSAPITestnet;
|
|
63
70
|
/**
|
|
64
71
|
* Request parameters expected per operation.
|
|
65
72
|
*
|
|
@@ -68,7 +75,7 @@ export interface WsAPIWsKeyTopicMap {
|
|
|
68
75
|
*
|
|
69
76
|
* Make sure to add new topics to WS_API_Operations and the response param map too.
|
|
70
77
|
*/
|
|
71
|
-
export interface WsAPITopicRequestParamMap {
|
|
78
|
+
export interface WsAPITopicRequestParamMap<TWSKey = WsKey> {
|
|
72
79
|
SUBSCRIBE: never;
|
|
73
80
|
UNSUBSCRIBE: never;
|
|
74
81
|
LIST_SUBSCRIPTIONS: never;
|
|
@@ -78,11 +85,7 @@ export interface WsAPITopicRequestParamMap {
|
|
|
78
85
|
* Authentication commands & parameters:
|
|
79
86
|
* https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api/authentication-requests
|
|
80
87
|
*/
|
|
81
|
-
'session.logon':
|
|
82
|
-
apiKey: string;
|
|
83
|
-
signature: string;
|
|
84
|
-
timestamp: number;
|
|
85
|
-
};
|
|
88
|
+
'session.logon': WSAPISessionLogonRequest;
|
|
86
89
|
'session.status': void;
|
|
87
90
|
'session.logout': void;
|
|
88
91
|
/**
|
|
@@ -91,48 +94,101 @@ export interface WsAPITopicRequestParamMap {
|
|
|
91
94
|
*/
|
|
92
95
|
ping: void;
|
|
93
96
|
time: void;
|
|
94
|
-
exchangeInfo: void |
|
|
95
|
-
symbol?: string;
|
|
96
|
-
symbols?: string[];
|
|
97
|
-
permissions?: string[];
|
|
98
|
-
showPermissionSets?: boolean;
|
|
99
|
-
symbolStatus?: string;
|
|
100
|
-
};
|
|
97
|
+
exchangeInfo: void | WSAPIExchangeInfoRequest;
|
|
101
98
|
/**
|
|
102
99
|
* Market data requests & parameters:
|
|
100
|
+
* - Spot:
|
|
103
101
|
* https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api/market-data-requests
|
|
102
|
+
* - Futures:
|
|
103
|
+
* https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/websocket-api
|
|
104
104
|
*/
|
|
105
|
-
depth:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
depth: TWSKey extends WsAPIFuturesWsKey ? WSAPIFuturesOrderBookRequest : WSAPIOrderBookRequest;
|
|
106
|
+
'trades.recent': WSAPITradesRecentRequest;
|
|
107
|
+
'trades.historical': WSAPITradesHistoricalRequest;
|
|
108
|
+
'trades.aggregate': WSAPITradesAggregateRequest;
|
|
109
|
+
klines: WSAPIKlinesRequest;
|
|
110
|
+
uiKlines: WSAPIKlinesRequest;
|
|
111
|
+
avgPrice: WSAPIAvgPriceRequest;
|
|
112
|
+
'ticker.24hr': void | WSAPITicker24hrRequest;
|
|
113
|
+
'ticker.tradingDay': WSAPITickerTradingDayRequest;
|
|
114
|
+
ticker: WSAPITickerRequest;
|
|
115
|
+
'ticker.price': void | TWSKey extends WsAPIFuturesWsKey ? WSAPIFuturesTickerPriceRequest | undefined : WSAPITickerPriceRequest | undefined;
|
|
116
|
+
'ticker.book': void | TWSKey extends WsAPIFuturesWsKey ? WSAPIFuturesTickerBookRequest | undefined : WSAPITickerBookRequest | undefined;
|
|
109
117
|
/**
|
|
110
118
|
* Account requests & parameters:
|
|
111
119
|
* - Spot:
|
|
112
120
|
* https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api/account-requests
|
|
113
|
-
*
|
|
114
121
|
* - Futures:
|
|
115
122
|
* https://developers.binance.com/docs/derivatives/usds-margined-futures/account/websocket-api
|
|
116
123
|
*/
|
|
124
|
+
'account.status': void | (TWSKey extends WsAPIFuturesWsKey ? WSAPIRecvWindowTimestamp : WSAPIAccountInformationRequest);
|
|
125
|
+
'account.rateLimits.orders': void | WSAPIRecvWindowTimestamp;
|
|
126
|
+
allOrders: WSAPIAllOrdersRequest;
|
|
127
|
+
allOrderLists: void | WSAPIAllOrderListsRequest;
|
|
128
|
+
myTrades: WSAPIMyTradesRequest;
|
|
129
|
+
myPreventedMatches: WSAPIMyPreventedMatchesRequest;
|
|
130
|
+
myAllocations: WSAPIMyAllocationsRequest;
|
|
131
|
+
'account.commission': WSAPIAccountCommissionWSAPIRequest;
|
|
117
132
|
/**
|
|
118
|
-
*
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Futures:
|
|
133
|
+
* Futures account requests & parameters:
|
|
134
|
+
* https://developers.binance.com/docs/derivatives/usds-margined-futures/account/websocket-api
|
|
122
135
|
*/
|
|
123
|
-
'
|
|
136
|
+
'account.position': WSAPIRecvWindowTimestamp;
|
|
137
|
+
'v2/account.position': WSAPIRecvWindowTimestamp;
|
|
124
138
|
'account.balance': WSAPIRecvWindowTimestamp;
|
|
139
|
+
'v2/account.balance': WSAPIRecvWindowTimestamp;
|
|
125
140
|
'v2/account.status': WSAPIRecvWindowTimestamp;
|
|
126
|
-
'account.status': WSAPIRecvWindowTimestamp;
|
|
127
141
|
/**
|
|
128
142
|
* Trading requests & parameters:
|
|
143
|
+
* - Spot:
|
|
129
144
|
* https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api/trading-requests
|
|
145
|
+
* - Futures:
|
|
146
|
+
* https://developers.binance.com/docs/derivatives/usds-margined-futures/trading/websocket-api
|
|
130
147
|
*/
|
|
131
|
-
'order.place': (
|
|
148
|
+
'order.place': (TWSKey extends WsAPIFuturesWsKey ? NewFuturesOrderParams : NewSpotOrderParams) & {
|
|
132
149
|
timestamp?: number;
|
|
133
150
|
};
|
|
134
|
-
'
|
|
135
|
-
'
|
|
151
|
+
'order.test': WSAPIOrderTestRequest;
|
|
152
|
+
'order.status': TWSKey extends WsAPIFuturesWsKey ? WSAPIFuturesOrderStatusRequest : WSAPIOrderStatusRequest;
|
|
153
|
+
'order.cancel': TWSKey extends WsAPIFuturesWsKey ? WSAPIFuturesOrderCancelRequest : WSAPIOrderCancelRequest;
|
|
154
|
+
'order.modify': WSAPIFuturesOrderModifyRequest;
|
|
155
|
+
'order.cancelReplace': WSAPIOrderCancelReplaceRequest;
|
|
156
|
+
'order.amend.keepPriority': WSAPIOrderAmendKeepPriorityRequest;
|
|
157
|
+
'openOrders.status': WSAPIOpenOrdersStatusRequest;
|
|
158
|
+
'openOrders.cancelAll': WSAPIOpenOrdersCancelAllRequest;
|
|
159
|
+
/**
|
|
160
|
+
* Order list requests & parameters:
|
|
161
|
+
*/
|
|
162
|
+
'orderList.place': WSAPIOrderListPlaceRequest;
|
|
163
|
+
'orderList.place.oco': WSAPIOrderListPlaceOCORequest;
|
|
164
|
+
'orderList.place.oto': WSAPIOrderListPlaceOTORequest;
|
|
165
|
+
'orderList.place.otoco': WSAPIOrderListPlaceOTOCORequest;
|
|
166
|
+
'orderList.status': WSAPIOrderListStatusRequest;
|
|
167
|
+
'orderList.cancel': WSAPIOrderListCancelRequest;
|
|
168
|
+
'openOrderLists.status': WSAPIRecvWindowTimestamp;
|
|
169
|
+
/**
|
|
170
|
+
* SOR requests & parameters:
|
|
171
|
+
*/
|
|
172
|
+
'sor.order.place': WSAPISOROrderPlaceRequest;
|
|
173
|
+
'sor.order.test': WSAPISOROrderTestRequest;
|
|
174
|
+
/**
|
|
175
|
+
* User data stream:
|
|
176
|
+
*
|
|
177
|
+
* - Spot:
|
|
178
|
+
* https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api/user-data-stream-requests
|
|
179
|
+
*
|
|
180
|
+
* - Futures:
|
|
181
|
+
* https://developers.binance.com/docs/derivatives/usds-margined-futures/account/websocket-api
|
|
182
|
+
*
|
|
183
|
+
* Note: for the user data stream, use the subscribe*UserDataStream() methods from the WS Client.
|
|
184
|
+
*/
|
|
185
|
+
'userDataStream.start': {
|
|
186
|
+
apiKey: string;
|
|
187
|
+
};
|
|
188
|
+
'userDataStream.ping': WSAPIUserDataListenKeyRequest;
|
|
189
|
+
'userDataStream.stop': WSAPIUserDataListenKeyRequest;
|
|
190
|
+
'userDataStream.subscribe': void;
|
|
191
|
+
'userDataStream.unsubscribe': void;
|
|
136
192
|
}
|
|
137
193
|
/**
|
|
138
194
|
* Response structure expected for each operation
|
|
@@ -152,50 +208,91 @@ export interface WsAPIOperationResponseMap {
|
|
|
152
208
|
* https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api/session-authentication
|
|
153
209
|
* https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api/authentication-requests
|
|
154
210
|
*/
|
|
155
|
-
'session.login': WSAPIResponse<
|
|
156
|
-
'session.status': WSAPIResponse<
|
|
157
|
-
'session.logout': WSAPIResponse<
|
|
211
|
+
'session.login': WSAPIResponse<WSAPISessionStatus>;
|
|
212
|
+
'session.status': WSAPIResponse<WSAPISessionStatus>;
|
|
213
|
+
'session.logout': WSAPIResponse<WSAPISessionStatus>;
|
|
158
214
|
/**
|
|
159
215
|
* General responses:
|
|
160
216
|
* https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api/general-requests
|
|
161
217
|
*/
|
|
162
|
-
ping:
|
|
163
|
-
time: WSAPIResponse<
|
|
164
|
-
serverTime: number;
|
|
165
|
-
}>;
|
|
218
|
+
ping: unknown;
|
|
219
|
+
time: WSAPIResponse<WSAPIServerTime>;
|
|
166
220
|
exchangeInfo: WSAPIResponse<FuturesExchangeInfo | ExchangeInfo>;
|
|
167
221
|
/**
|
|
168
222
|
* Market data responses
|
|
223
|
+
* - Spot:
|
|
169
224
|
* https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api/market-data-requests
|
|
225
|
+
* - Futures:
|
|
226
|
+
* https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/websocket-api
|
|
170
227
|
*/
|
|
171
|
-
depth: WSAPIResponse<
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
228
|
+
depth: WSAPIResponse<WSAPIOrderBook | WSAPIFuturesOrderBook>;
|
|
229
|
+
'trades.recent': WSAPIResponse<WSAPITrade[]>;
|
|
230
|
+
'trades.historical': WSAPIResponse<WSAPITrade[]>;
|
|
231
|
+
'trades.aggregate': WSAPIResponse<WSAPIAggregateTrade[]>;
|
|
232
|
+
klines: WSAPIResponse<WSAPIKline[]>;
|
|
233
|
+
uiKlines: WSAPIResponse<WSAPIKline[]>;
|
|
234
|
+
avgPrice: WSAPIResponse<WSAPIAvgPrice>;
|
|
235
|
+
'ticker.24hr': WSAPIResponse<WSAPIFullTicker | WSAPIMiniTicker | WSAPIFullTicker[] | WSAPIMiniTicker[]>;
|
|
236
|
+
'ticker.tradingDay': WSAPIResponse<WSAPIFullTicker | WSAPIMiniTicker | WSAPIFullTicker[] | WSAPIMiniTicker[]>;
|
|
237
|
+
ticker: WSAPIResponse<WSAPIFullTicker | WSAPIMiniTicker | WSAPIFullTicker[] | WSAPIMiniTicker[]>;
|
|
238
|
+
'ticker.price': WSAPIResponse<WSAPIPriceTicker | WSAPIPriceTicker[] | WSAPIFuturesPriceTicker | WSAPIFuturesPriceTicker[]>;
|
|
239
|
+
'ticker.book': WSAPIResponse<WSAPIBookTicker | WSAPIBookTicker[] | WSAPIFuturesBookTicker | WSAPIFuturesBookTicker[]>;
|
|
176
240
|
/**
|
|
177
|
-
* Account
|
|
178
|
-
* - Spot:
|
|
241
|
+
* Account responses:
|
|
179
242
|
* https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api/account-requests
|
|
180
|
-
|
|
181
|
-
|
|
243
|
+
*/
|
|
244
|
+
'account.status': WSAPIResponse<WSAPIAccountInformation | WSAPIFuturesAccountStatus>;
|
|
245
|
+
'account.commission': WSAPIResponse<WSAPIAccountCommission>;
|
|
246
|
+
'account.rateLimits.orders': WSAPIResponse<WSAPIRateLimit[]>;
|
|
247
|
+
allOrders: WSAPIResponse<WSAPIOrder[]>;
|
|
248
|
+
allOrderLists: WSAPIResponse<WSAPIOrderListStatusResponse[]>;
|
|
249
|
+
myTrades: WSAPIResponse<WSAPITrade[]>;
|
|
250
|
+
myPreventedMatches: WSAPIResponse<WSAPIPreventedMatch[]>;
|
|
251
|
+
myAllocations: WSAPIResponse<WSAPIAllocation[]>;
|
|
252
|
+
/**
|
|
253
|
+
* Futures account responses:
|
|
182
254
|
* https://developers.binance.com/docs/derivatives/usds-margined-futures/account/websocket-api
|
|
183
255
|
*/
|
|
256
|
+
'account.position': WSAPIResponse<WSAPIFuturesPosition[]>;
|
|
257
|
+
'v2/account.position': WSAPIResponse<WSAPIFuturesPositionV2[]>;
|
|
258
|
+
'account.balance': WSAPIResponse<WSAPIFuturesAccountBalanceItem[]>;
|
|
259
|
+
'v2/account.balance': WSAPIResponse<WSAPIFuturesAccountBalanceItem[]>;
|
|
260
|
+
'v2/account.status': WSAPIResponse<WSAPIFuturesAccountStatus>;
|
|
184
261
|
/**
|
|
185
|
-
*
|
|
262
|
+
* Trading responses
|
|
263
|
+
* - Spot:
|
|
264
|
+
* https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api/trading-requests
|
|
265
|
+
* - Futures:
|
|
266
|
+
* https://developers.binance.com/docs/derivatives/usds-margined-futures/trading/websocket-api
|
|
186
267
|
*/
|
|
268
|
+
'order.place': WSAPIResponse<OrderResponse | WSAPIFuturesOrder>;
|
|
269
|
+
'order.test': WSAPIResponse<WSAPIOrderTestResponse | WSAPIOrderTestWithCommission>;
|
|
270
|
+
'order.status': WSAPIResponse<WSAPIOrder | WSAPIFuturesOrder>;
|
|
271
|
+
'order.cancel': WSAPIResponse<WSAPIOrderCancel | WSAPIFuturesOrder>;
|
|
272
|
+
'order.modify': WSAPIResponse<WSAPIFuturesOrder>;
|
|
273
|
+
'order.cancelReplace': WSAPIResponse<WSAPIOrderCancelReplaceResponse>;
|
|
274
|
+
'openOrders.status': WSAPIResponse<WSAPIOrder[] | WSAPIFuturesOrder[]>;
|
|
275
|
+
'openOrders.cancelAll': WSAPIResponse<(WSAPIOrderCancel | WSAPIOrderListCancelResponse)[]>;
|
|
187
276
|
/**
|
|
188
|
-
*
|
|
277
|
+
* Order list responses
|
|
189
278
|
*/
|
|
190
|
-
'
|
|
191
|
-
'
|
|
192
|
-
'
|
|
193
|
-
'
|
|
279
|
+
'orderList.place': WSAPIResponse<WSAPIOrderListPlaceResponse>;
|
|
280
|
+
'orderList.place.oco': WSAPIResponse<WSAPIOrderListPlaceResponse>;
|
|
281
|
+
'orderList.place.oto': WSAPIResponse<WSAPIOrderListPlaceResponse>;
|
|
282
|
+
'orderList.place.otoco': WSAPIResponse<WSAPIOrderListPlaceResponse>;
|
|
283
|
+
'orderList.status': WSAPIResponse<WSAPIOrderListStatusResponse>;
|
|
284
|
+
'orderList.cancel': WSAPIResponse<WSAPIOrderListCancelResponse>;
|
|
285
|
+
'openOrderLists.status': WSAPIResponse<WSAPIOrderListStatusResponse[]>;
|
|
194
286
|
/**
|
|
195
|
-
*
|
|
196
|
-
* https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api/trading-requests
|
|
287
|
+
* SOR responses
|
|
197
288
|
*/
|
|
198
|
-
'order.place': WSAPIResponse<
|
|
199
|
-
'
|
|
200
|
-
'
|
|
289
|
+
'sor.order.place': WSAPIResponse<WSAPISOROrderPlaceResponse>;
|
|
290
|
+
'sor.order.test': WSAPIResponse<WSAPISOROrderTestResponse | WSAPISOROrderTestResponseWithCommission>;
|
|
291
|
+
'userDataStream.start': WSAPIResponse<{
|
|
292
|
+
listenKey: string;
|
|
293
|
+
}>;
|
|
294
|
+
'userDataStream.ping': WSAPIResponse<object>;
|
|
295
|
+
'userDataStream.stop': WSAPIResponse<object>;
|
|
296
|
+
'userDataStream.subscribe': WSAPIResponse<object>;
|
|
297
|
+
'userDataStream.unsubscribe': WSAPIResponse<object>;
|
|
201
298
|
}
|
|
@@ -13,17 +13,61 @@ exports.WS_API_Operations = [
|
|
|
13
13
|
'ping',
|
|
14
14
|
'time',
|
|
15
15
|
'exchangeInfo',
|
|
16
|
-
//// Market data commands
|
|
16
|
+
//// Market data commands
|
|
17
17
|
'depth',
|
|
18
|
+
'trades.recent',
|
|
19
|
+
'trades.historical',
|
|
20
|
+
'trades.aggregate',
|
|
21
|
+
'klines',
|
|
22
|
+
'uiKlines',
|
|
23
|
+
'avgPrice',
|
|
24
|
+
'ticker.24hr',
|
|
25
|
+
'ticker.tradingDay',
|
|
26
|
+
'ticker',
|
|
27
|
+
'ticker.price',
|
|
28
|
+
'ticker.book',
|
|
18
29
|
//// Account commands
|
|
30
|
+
// Spot
|
|
31
|
+
'account.status',
|
|
32
|
+
'account.commission',
|
|
33
|
+
'account.rateLimits.orders',
|
|
34
|
+
'allOrders',
|
|
35
|
+
'allOrderLists',
|
|
36
|
+
'myTrades',
|
|
37
|
+
'myPreventedMatches',
|
|
38
|
+
'myAllocations',
|
|
19
39
|
// Futures
|
|
20
40
|
'v2/account.balance',
|
|
21
41
|
'account.balance',
|
|
22
42
|
'v2/account.status',
|
|
23
|
-
'account.
|
|
24
|
-
|
|
43
|
+
'account.position',
|
|
44
|
+
'v2/account.position',
|
|
45
|
+
//// Trading commands
|
|
25
46
|
'order.place',
|
|
47
|
+
'order.test',
|
|
48
|
+
'order.status',
|
|
49
|
+
'order.cancel',
|
|
50
|
+
'order.cancelReplace',
|
|
51
|
+
'order.amend.keepPriority',
|
|
52
|
+
'order.modify',
|
|
53
|
+
'openOrders.status',
|
|
54
|
+
'openOrders.cancelAll',
|
|
55
|
+
// Order list commands
|
|
26
56
|
'orderList.place',
|
|
57
|
+
'orderList.place.oco',
|
|
58
|
+
'orderList.place.oto',
|
|
59
|
+
'orderList.place.otoco',
|
|
60
|
+
'orderList.status',
|
|
61
|
+
'orderList.cancel',
|
|
62
|
+
'openOrderLists.status',
|
|
63
|
+
// SOR commands
|
|
27
64
|
'sor.order.place',
|
|
65
|
+
'sor.order.test',
|
|
66
|
+
// user data stream
|
|
67
|
+
'userDataStream.start',
|
|
68
|
+
'userDataStream.ping',
|
|
69
|
+
'userDataStream.stop',
|
|
70
|
+
'userDataStream.subscribe',
|
|
71
|
+
'userDataStream.unsubscribe',
|
|
28
72
|
];
|
|
29
73
|
//# sourceMappingURL=ws-api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws-api.js","sourceRoot":"","sources":["../../../src/types/websockets/ws-api.ts"],"names":[],"mappings":";;;AAAA,yEAAyE;
|
|
1
|
+
{"version":3,"file":"ws-api.js","sourceRoot":"","sources":["../../../src/types/websockets/ws-api.ts"],"names":[],"mappings":";;;AAAA,yEAAyE;AA+FzE;;GAEG;AACU,QAAA,iBAAiB,GAAG;IAC/B,eAAe;IACf,gBAAgB;IAChB,gBAAgB;IAChB,qBAAqB;IACrB,MAAM;IACN,MAAM;IACN,cAAc;IACd,yBAAyB;IACzB,OAAO;IACP,eAAe;IACf,mBAAmB;IACnB,kBAAkB;IAClB,QAAQ;IACR,UAAU;IACV,UAAU;IACV,aAAa;IACb,mBAAmB;IACnB,QAAQ;IACR,cAAc;IACd,aAAa;IACb,qBAAqB;IACrB,OAAO;IACP,gBAAgB;IAChB,oBAAoB;IACpB,2BAA2B;IAC3B,WAAW;IACX,eAAe;IACf,UAAU;IACV,oBAAoB;IACpB,eAAe;IACf,UAAU;IACV,oBAAoB;IACpB,iBAAiB;IACjB,mBAAmB;IACnB,kBAAkB;IAClB,qBAAqB;IACrB,qBAAqB;IACrB,aAAa;IACb,YAAY;IACZ,cAAc;IACd,cAAc;IACd,qBAAqB;IACrB,0BAA0B;IAC1B,cAAc;IACd,mBAAmB;IACnB,sBAAsB;IACtB,sBAAsB;IACtB,iBAAiB;IACjB,qBAAqB;IACrB,qBAAqB;IACrB,uBAAuB;IACvB,kBAAkB;IAClB,kBAAkB;IAClB,uBAAuB;IACvB,eAAe;IACf,iBAAiB;IACjB,gBAAgB;IAChB,mBAAmB;IACnB,sBAAsB;IACtB,qBAAqB;IACrB,qBAAqB;IACrB,0BAA0B;IAC1B,4BAA4B;CACpB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FuturesContractType,
|
|
2
|
-
import { KlineInterval, numberInString,
|
|
1
|
+
import { FuturesContractType, FuturesOrderType, MarginType, PositionSide, WorkingType } from '../futures';
|
|
2
|
+
import { KlineInterval, numberInString, OCOOrderStatus, OCOStatus, OrderBookRowFormatted, OrderExecutionType, OrderSide, OrderStatus, OrderTimeInForce, OrderType, SelfTradePreventionMode } from '../shared';
|
|
3
3
|
import { AccountUpdateEventType } from './ws-events-raw';
|
|
4
4
|
import { WsSharedBase } from './ws-general';
|
|
5
5
|
export interface WsMessageKlineFormatted extends WsSharedBase {
|
|
@@ -90,7 +90,7 @@ export interface WsMessage24hrMiniTickerFormatted extends WsSharedBase {
|
|
|
90
90
|
quoteAssetVolume: number;
|
|
91
91
|
}
|
|
92
92
|
export interface WsMessage24hrTickerFormatted extends WsSharedBase {
|
|
93
|
-
eventType: '24hrTicker';
|
|
93
|
+
eventType: '24hrTicker' | '!ticker@arr';
|
|
94
94
|
eventTime: number;
|
|
95
95
|
symbol: string;
|
|
96
96
|
priceChange: number;
|
|
@@ -115,27 +115,31 @@ export interface WsMessage24hrTickerFormatted extends WsSharedBase {
|
|
|
115
115
|
trades: number;
|
|
116
116
|
}
|
|
117
117
|
export interface WsMessageRollingWindowTickerFormatted extends WsSharedBase {
|
|
118
|
-
eventType: '
|
|
118
|
+
eventType: 'ticker';
|
|
119
119
|
eventTime: number;
|
|
120
120
|
symbol: string;
|
|
121
121
|
priceChange: number;
|
|
122
122
|
priceChangePercent: number;
|
|
123
123
|
weightedAveragePrice: number;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
124
|
+
open: number;
|
|
125
|
+
high: number;
|
|
126
|
+
low: number;
|
|
127
|
+
currentClose: number;
|
|
128
|
+
baseAssetVolume: number;
|
|
129
|
+
quoteAssetVolume: number;
|
|
130
|
+
openTime: number;
|
|
131
|
+
closeTime: number;
|
|
132
132
|
firstTradeId: number;
|
|
133
133
|
lastTradeId: number;
|
|
134
|
-
|
|
134
|
+
trades: number;
|
|
135
|
+
streamName: string;
|
|
136
|
+
isWSAPIResponse: false;
|
|
135
137
|
}
|
|
136
138
|
export interface WsMessageBookTickerEventFormatted extends WsSharedBase {
|
|
137
139
|
eventType: 'bookTicker';
|
|
138
140
|
updateId: number;
|
|
141
|
+
eventTime: number;
|
|
142
|
+
transactionTime: number;
|
|
139
143
|
symbol: string;
|
|
140
144
|
bidPrice: number;
|
|
141
145
|
bidQty: number;
|
|
@@ -143,7 +147,7 @@ export interface WsMessageBookTickerEventFormatted extends WsSharedBase {
|
|
|
143
147
|
askQty: number;
|
|
144
148
|
}
|
|
145
149
|
export interface WsMessagePartialBookDepthEventFormatted extends WsSharedBase {
|
|
146
|
-
eventType: 'partialBookDepth';
|
|
150
|
+
eventType: 'partialBookDepth' | 'string';
|
|
147
151
|
lastUpdateId: number;
|
|
148
152
|
bids: OrderBookRowFormatted[];
|
|
149
153
|
asks: OrderBookRowFormatted[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { KlineInterval, numberInString,
|
|
1
|
+
import { FuturesOrderType, MarginType, PositionSide, WorkingType } from '../futures';
|
|
2
|
+
import { KlineInterval, numberInString, OCOOrderStatus, OCOStatus, OrderBookRow, OrderExecutionType, OrderSide, OrderStatus, OrderTimeInForce, OrderType, SelfTradePreventionMode } from '../shared';
|
|
3
3
|
import { WsSharedBase } from './ws-general';
|
|
4
4
|
export interface WsMessageKlineRaw extends WsSharedBase {
|
|
5
5
|
e: 'kline';
|
|
@@ -109,6 +109,8 @@ export interface WsMessageRollingWindowTickerRaw extends WsSharedBase {
|
|
|
109
109
|
export interface WsMessageBookTickerEventRaw extends WsSharedBase {
|
|
110
110
|
e: 'bookTicker';
|
|
111
111
|
u: number;
|
|
112
|
+
E: number;
|
|
113
|
+
T: number;
|
|
112
114
|
s: string;
|
|
113
115
|
b: numberInString;
|
|
114
116
|
B: numberInString;
|
|
@@ -12,6 +12,7 @@ export type WsMarket = 'spot' | 'spotTestnet' | 'crossMargin' | 'isolatedMargin'
|
|
|
12
12
|
export interface WsSharedBase {
|
|
13
13
|
wsMarket: WsMarket;
|
|
14
14
|
wsKey: WsKey;
|
|
15
|
+
streamName: string;
|
|
15
16
|
}
|
|
16
17
|
export interface WsResponse {
|
|
17
18
|
type: 'message';
|
|
@@ -32,7 +33,6 @@ export type WsPrivateUSDTPerpTopic = 'position' | 'execution' | 'order' | 'stop_
|
|
|
32
33
|
export type WsPrivateSpotTopic = 'outboundAccountInfo' | 'executionReport' | 'ticketInfo';
|
|
33
34
|
export type WsPrivateTopic = WsPrivateInverseTopic | WsPrivateUSDTPerpTopic | WsPrivateSpotTopic | string;
|
|
34
35
|
export type WsTopic = WsPublicTopics | WsPrivateTopic;
|
|
35
|
-
/** This is used to differentiate product groups on a connection */
|
|
36
36
|
export interface WSClientConfigurableOptions {
|
|
37
37
|
/** Your API key */
|
|
38
38
|
api_key?: string;
|
|
@@ -40,20 +40,17 @@ export interface WSClientConfigurableOptions {
|
|
|
40
40
|
api_secret?: string;
|
|
41
41
|
beautify?: boolean;
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* Notes:
|
|
46
|
-
*
|
|
47
|
-
* - If demo trading, `testnet` should be set to false!
|
|
48
|
-
* - If testing a strategy, use demo trading instead. Testnet market data is very different from real market conditions.
|
|
43
|
+
* If true, log a warning if the beautifier is missing anything for an event
|
|
49
44
|
*/
|
|
50
|
-
|
|
45
|
+
beautifyWarnIfMissing?: boolean;
|
|
51
46
|
/**
|
|
52
|
-
* Set to `true` to connect to
|
|
47
|
+
* Set to `true` to connect to Binance's testnet environment.
|
|
53
48
|
*
|
|
54
|
-
*
|
|
49
|
+
* Notes:
|
|
50
|
+
* - Not all WebSocket categories support testnet.
|
|
51
|
+
* - If testing a strategy, this is not recommended. Testnet market data is very different from real market conditions. More guidance here: https://github.com/tiagosiebler/awesome-crypto-examples/wiki/CEX-Testnets
|
|
55
52
|
*/
|
|
56
|
-
|
|
53
|
+
testnet?: boolean;
|
|
57
54
|
/** Define a recv window when preparing a private websocket signature. This is in milliseconds, so 5000 == 5 seconds */
|
|
58
55
|
recvWindow?: number;
|
|
59
56
|
disableHeartbeat?: boolean;
|
|
@@ -70,13 +67,6 @@ export interface WSClientConfigurableOptions {
|
|
|
70
67
|
agent?: any;
|
|
71
68
|
};
|
|
72
69
|
wsUrl?: string;
|
|
73
|
-
/**
|
|
74
|
-
* Default: true.
|
|
75
|
-
*
|
|
76
|
-
* When enabled, any calls to the subscribe method will return a promise.
|
|
77
|
-
* // TODO:
|
|
78
|
-
*/
|
|
79
|
-
promiseSubscribe?: boolean;
|
|
80
70
|
/**
|
|
81
71
|
* Allows you to provide a custom "signMessage" function, e.g. to use node's much faster createHmac method
|
|
82
72
|
*
|