bybit-api 3.7.1-beta.0 → 3.7.2
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 +34 -6
- package/lib/constants/enum.d.ts +4 -1
- package/lib/constants/enum.js +4 -1
- package/lib/constants/enum.js.map +1 -1
- package/lib/rest-client-v5.d.ts +3 -3
- package/lib/rest-client-v5.js.map +1 -1
- package/lib/types/request/v5-trade.d.ts +2 -2
- package/lib/types/response/v5-market.d.ts +4 -1
- package/package.json +1 -13
- package/src/account-asset-client-v3.ts +0 -310
- package/src/account-asset-client.ts +0 -149
- package/src/constants/enum.ts +0 -105
- package/src/contract-client.ts +0 -360
- package/src/copy-trading-client.ts +0 -159
- package/src/index.ts +0 -18
- package/src/inverse-client.ts +0 -337
- package/src/inverse-futures-client.ts +0 -403
- package/src/linear-client.ts +0 -387
- package/src/rest-client-v5.ts +0 -1638
- package/src/spot-client-v3.ts +0 -303
- package/src/spot-client.ts +0 -180
- package/src/types/index.ts +0 -5
- package/src/types/request/account-asset.ts +0 -258
- package/src/types/request/contract.ts +0 -139
- package/src/types/request/copy-trading.ts +0 -53
- package/src/types/request/index.ts +0 -18
- package/src/types/request/inverse.ts +0 -135
- package/src/types/request/linear.ts +0 -201
- package/src/types/request/spot.ts +0 -89
- package/src/types/request/unified-margin.ts +0 -247
- package/src/types/request/usdc-options.ts +0 -134
- package/src/types/request/usdc-perp.ts +0 -100
- package/src/types/request/usdc-shared.ts +0 -39
- package/src/types/request/v5-account.ts +0 -40
- package/src/types/request/v5-asset.ts +0 -133
- package/src/types/request/v5-market.ts +0 -127
- package/src/types/request/v5-position.ts +0 -107
- package/src/types/request/v5-pre-upgrade.ts +0 -37
- package/src/types/request/v5-spot-leverage-token.ts +0 -23
- package/src/types/request/v5-trade.ts +0 -133
- package/src/types/request/v5-user.ts +0 -21
- package/src/types/response/account-asset.ts +0 -236
- package/src/types/response/contract.ts +0 -74
- package/src/types/response/index.ts +0 -13
- package/src/types/response/shared.ts +0 -19
- package/src/types/response/spot.ts +0 -17
- package/src/types/response/unified-margin.ts +0 -71
- package/src/types/response/usdt-perp.ts +0 -58
- package/src/types/response/v5-account.ts +0 -122
- package/src/types/response/v5-asset.ts +0 -170
- package/src/types/response/v5-market.ts +0 -271
- package/src/types/response/v5-position.ts +0 -118
- package/src/types/response/v5-spot-leverage-token.ts +0 -70
- package/src/types/response/v5-trade.ts +0 -103
- package/src/types/response/v5-user.ts +0 -58
- package/src/types/shared.ts +0 -175
- package/src/types/v5-shared.ts +0 -213
- package/src/types/websockets.ts +0 -115
- package/src/types/ws-events/failed-topic-subscription-confirmation.ts +0 -6
- package/src/types/ws-events/succeeded-topic-subscription-confirmation.ts +0 -6
- package/src/types/ws-events/topic-subscription-confirmation.ts +0 -7
- package/src/unified-margin-client.ts +0 -400
- package/src/usdc-option-client.ts +0 -333
- package/src/usdc-perpetual-client.ts +0 -312
- package/src/util/BaseRestClient.ts +0 -502
- package/src/util/WsStore.ts +0 -160
- package/src/util/browser-support.ts +0 -29
- package/src/util/index.ts +0 -5
- package/src/util/logger.ts +0 -26
- package/src/util/node-support.ts +0 -9
- package/src/util/requestUtils.ts +0 -171
- package/src/util/websocket-util.ts +0 -550
- package/src/websocket-client.ts +0 -1262
package/src/linear-client.ts
DELETED
|
@@ -1,387 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { REST_CLIENT_TYPE_ENUM } from './util/requestUtils';
|
|
3
|
-
import {
|
|
4
|
-
APIResponse,
|
|
5
|
-
APIResponseWithTime,
|
|
6
|
-
AssetExchangeRecordsReq,
|
|
7
|
-
CoinParam,
|
|
8
|
-
LinearCancelConditionalOrderRequest,
|
|
9
|
-
LinearCancelOrderRequest,
|
|
10
|
-
LinearConditionalOrderRequest,
|
|
11
|
-
LinearGetClosedPnlRequest,
|
|
12
|
-
LinearGetConditionalOrderRequest,
|
|
13
|
-
LinearGetHistoryTradeRecordsRequest,
|
|
14
|
-
LinearGetOrderRequest,
|
|
15
|
-
LinearGetOrdersRequest,
|
|
16
|
-
LinearGetTradeRecordsRequest,
|
|
17
|
-
LinearOrder,
|
|
18
|
-
LinearQueryConditionalOrderRequest,
|
|
19
|
-
LinearReplaceConditionalOrderRequest,
|
|
20
|
-
LinearReplaceOrderRequest,
|
|
21
|
-
LinearSetAddReduceMarginRequest,
|
|
22
|
-
LinearSetAutoAddMarginRequest,
|
|
23
|
-
LinearSetMarginSwitchRequest,
|
|
24
|
-
LinearSetPositionModeRequest,
|
|
25
|
-
LinearSetPositionTpSlModeRequest,
|
|
26
|
-
LinearSetRiskLimitRequest,
|
|
27
|
-
LinearSetTradingStopRequest,
|
|
28
|
-
LinearSetUserLeverageRequest,
|
|
29
|
-
NewLinearOrder,
|
|
30
|
-
PerpPosition,
|
|
31
|
-
PerpPositionRoot,
|
|
32
|
-
SymbolInfo,
|
|
33
|
-
SymbolIntervalFromLimitParam,
|
|
34
|
-
SymbolLimitParam,
|
|
35
|
-
SymbolParam,
|
|
36
|
-
SymbolPeriodLimitParam,
|
|
37
|
-
WalletBalances,
|
|
38
|
-
WalletFundRecordsReq,
|
|
39
|
-
WithdrawRecordsReq,
|
|
40
|
-
} from './types';
|
|
41
|
-
import BaseRestClient from './util/BaseRestClient';
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* REST API client for linear/USD perpetual futures APIs (v2)
|
|
45
|
-
*/
|
|
46
|
-
export class LinearClient extends BaseRestClient {
|
|
47
|
-
getClientType() {
|
|
48
|
-
return REST_CLIENT_TYPE_ENUM.linear;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async fetchServerTime(): Promise<number> {
|
|
52
|
-
const timeRes = await this.getServerTime();
|
|
53
|
-
return Number(timeRes.time_now);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
*
|
|
58
|
-
* Market Data Endpoints
|
|
59
|
-
*
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
getOrderBook(params: SymbolParam): Promise<APIResponseWithTime<any[]>> {
|
|
63
|
-
return this.get('v2/public/orderBook/L2', params);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
getKline(
|
|
67
|
-
params: SymbolIntervalFromLimitParam
|
|
68
|
-
): Promise<APIResponseWithTime<any[]>> {
|
|
69
|
-
return this.get('public/linear/kline', params);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Get latest information for symbol
|
|
74
|
-
*/
|
|
75
|
-
getTickers(
|
|
76
|
-
params?: Partial<SymbolParam>
|
|
77
|
-
): Promise<APIResponseWithTime<any[]>> {
|
|
78
|
-
return this.get('v2/public/tickers', params);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
getTrades(params: SymbolLimitParam): Promise<APIResponseWithTime<any[]>> {
|
|
82
|
-
return this.get('public/linear/recent-trading-records', params);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
getSymbols(): Promise<APIResponse<SymbolInfo[]>> {
|
|
86
|
-
return this.get('v2/public/symbols');
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
getLastFundingRate(params: SymbolParam): Promise<APIResponseWithTime<any[]>> {
|
|
90
|
-
return this.get('public/linear/funding/prev-funding-rate', params);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
getMarkPriceKline(
|
|
94
|
-
params: SymbolIntervalFromLimitParam
|
|
95
|
-
): Promise<APIResponseWithTime<any[]>> {
|
|
96
|
-
return this.get('public/linear/mark-price-kline', params);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
getIndexPriceKline(
|
|
100
|
-
params: SymbolIntervalFromLimitParam
|
|
101
|
-
): Promise<APIResponseWithTime<any[]>> {
|
|
102
|
-
return this.get('public/linear/index-price-kline', params);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
getPremiumIndexKline(
|
|
106
|
-
params: SymbolIntervalFromLimitParam
|
|
107
|
-
): Promise<APIResponseWithTime<any[]>> {
|
|
108
|
-
return this.get('public/linear/premium-index-kline', params);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
*
|
|
113
|
-
* Market Data : Advanced
|
|
114
|
-
*
|
|
115
|
-
*/
|
|
116
|
-
|
|
117
|
-
getOpenInterest(
|
|
118
|
-
params: SymbolPeriodLimitParam
|
|
119
|
-
): Promise<APIResponseWithTime<any[]>> {
|
|
120
|
-
return this.get('v2/public/open-interest', params);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
getLatestBigDeal(
|
|
124
|
-
params: SymbolLimitParam
|
|
125
|
-
): Promise<APIResponseWithTime<any[]>> {
|
|
126
|
-
return this.get('v2/public/big-deal', params);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
getLongShortRatio(
|
|
130
|
-
params: SymbolPeriodLimitParam
|
|
131
|
-
): Promise<APIResponseWithTime<any[]>> {
|
|
132
|
-
return this.get('v2/public/account-ratio', params);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
*
|
|
137
|
-
* Account Data Endpoints
|
|
138
|
-
*
|
|
139
|
-
*/
|
|
140
|
-
|
|
141
|
-
getApiKeyInfo(): Promise<APIResponseWithTime<any>> {
|
|
142
|
-
return this.getPrivate('v2/private/account/api-key');
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
*
|
|
147
|
-
* Wallet Data Endpoints
|
|
148
|
-
*
|
|
149
|
-
*/
|
|
150
|
-
|
|
151
|
-
getWalletBalance(
|
|
152
|
-
params?: Partial<CoinParam>
|
|
153
|
-
): Promise<APIResponseWithTime<WalletBalances>> {
|
|
154
|
-
return this.getPrivate('v2/private/wallet/balance', params);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
getWalletFundRecords(
|
|
158
|
-
params?: WalletFundRecordsReq
|
|
159
|
-
): Promise<APIResponseWithTime<any>> {
|
|
160
|
-
return this.getPrivate('v2/private/wallet/fund/records', params);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
getWithdrawRecords(
|
|
164
|
-
params?: WithdrawRecordsReq
|
|
165
|
-
): Promise<APIResponseWithTime<any>> {
|
|
166
|
-
return this.getPrivate('v2/private/wallet/withdraw/list', params);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
getAssetExchangeRecords(
|
|
170
|
-
params?: AssetExchangeRecordsReq
|
|
171
|
-
): Promise<APIResponseWithTime<any>> {
|
|
172
|
-
return this.getPrivate('v2/private/exchange-order/list', params);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
*
|
|
177
|
-
* API Data Endpoints
|
|
178
|
-
*
|
|
179
|
-
*/
|
|
180
|
-
|
|
181
|
-
getServerTime(): Promise<APIResponseWithTime<{}>> {
|
|
182
|
-
return this.get('v2/public/time');
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
getApiAnnouncements(): Promise<APIResponseWithTime<any>> {
|
|
186
|
-
return this.get('v2/public/announcement');
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
*
|
|
191
|
-
* Account Data Endpoints
|
|
192
|
-
*
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
|
-
placeActiveOrder(
|
|
196
|
-
params: NewLinearOrder
|
|
197
|
-
): Promise<APIResponseWithTime<LinearOrder | null>> {
|
|
198
|
-
return this.postPrivate('private/linear/order/create', params);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
getActiveOrderList(
|
|
202
|
-
params: LinearGetOrdersRequest
|
|
203
|
-
): Promise<APIResponseWithTime<any>> {
|
|
204
|
-
return this.getPrivate('private/linear/order/list', params);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
cancelActiveOrder(
|
|
208
|
-
params: LinearCancelOrderRequest
|
|
209
|
-
): Promise<APIResponseWithTime<any>> {
|
|
210
|
-
return this.postPrivate('private/linear/order/cancel', params);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
cancelAllActiveOrders(
|
|
214
|
-
params: SymbolParam
|
|
215
|
-
): Promise<APIResponseWithTime<any>> {
|
|
216
|
-
return this.postPrivate('private/linear/order/cancel-all', params);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
replaceActiveOrder(
|
|
220
|
-
params: LinearReplaceOrderRequest
|
|
221
|
-
): Promise<APIResponseWithTime<any>> {
|
|
222
|
-
return this.postPrivate('private/linear/order/replace', params);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
queryActiveOrder(
|
|
226
|
-
params: LinearGetOrderRequest
|
|
227
|
-
): Promise<APIResponseWithTime<any>> {
|
|
228
|
-
return this.getPrivate('private/linear/order/search', params);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Conditional orders
|
|
233
|
-
*/
|
|
234
|
-
|
|
235
|
-
placeConditionalOrder(
|
|
236
|
-
params: LinearConditionalOrderRequest
|
|
237
|
-
): Promise<APIResponseWithTime<any>> {
|
|
238
|
-
return this.postPrivate('private/linear/stop-order/create', params);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
getConditionalOrder(
|
|
242
|
-
params: LinearGetConditionalOrderRequest
|
|
243
|
-
): Promise<APIResponseWithTime<any>> {
|
|
244
|
-
return this.getPrivate('private/linear/stop-order/list', params);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
cancelConditionalOrder(
|
|
248
|
-
params: LinearCancelConditionalOrderRequest
|
|
249
|
-
): Promise<APIResponseWithTime<any>> {
|
|
250
|
-
return this.postPrivate('private/linear/stop-order/cancel', params);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
cancelAllConditionalOrders(
|
|
254
|
-
params: SymbolParam
|
|
255
|
-
): Promise<APIResponseWithTime<any>> {
|
|
256
|
-
return this.postPrivate('private/linear/stop-order/cancel-all', params);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
replaceConditionalOrder(
|
|
260
|
-
params: LinearReplaceConditionalOrderRequest
|
|
261
|
-
): Promise<APIResponseWithTime<any>> {
|
|
262
|
-
return this.postPrivate('private/linear/stop-order/replace', params);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
queryConditionalOrder(
|
|
266
|
-
params: LinearQueryConditionalOrderRequest
|
|
267
|
-
): Promise<APIResponseWithTime<any>> {
|
|
268
|
-
return this.getPrivate('private/linear/stop-order/search', params);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Position
|
|
273
|
-
*/
|
|
274
|
-
|
|
275
|
-
getPosition(): Promise<APIResponseWithTime<PerpPositionRoot[]>>;
|
|
276
|
-
|
|
277
|
-
getPosition(
|
|
278
|
-
params: Partial<SymbolParam>
|
|
279
|
-
): Promise<APIResponseWithTime<PerpPosition[]>>;
|
|
280
|
-
|
|
281
|
-
getPosition(
|
|
282
|
-
params?: Partial<SymbolParam>
|
|
283
|
-
): Promise<APIResponseWithTime<PerpPosition[] | PerpPositionRoot[]>> {
|
|
284
|
-
return this.getPrivate('private/linear/position/list', params);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
setAutoAddMargin(
|
|
288
|
-
params?: LinearSetAutoAddMarginRequest
|
|
289
|
-
): Promise<APIResponseWithTime<any>> {
|
|
290
|
-
return this.postPrivate(
|
|
291
|
-
'private/linear/position/set-auto-add-margin',
|
|
292
|
-
params
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
setMarginSwitch(
|
|
297
|
-
params?: LinearSetMarginSwitchRequest
|
|
298
|
-
): Promise<APIResponseWithTime<any>> {
|
|
299
|
-
return this.postPrivate('private/linear/position/switch-isolated', params);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Switch between one-way vs hedge mode. Use `linearPositionModeEnum` for the mode parameter.
|
|
304
|
-
*/
|
|
305
|
-
setPositionMode(
|
|
306
|
-
params: LinearSetPositionModeRequest
|
|
307
|
-
): Promise<APIResponseWithTime<any>> {
|
|
308
|
-
return this.postPrivate('private/linear/position/switch-mode', params);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Switch TP/SL mode between full or partial. When set to Partial, TP/SL orders may have a quantity less than the position size.
|
|
313
|
-
* This is set with the setTradingStop() method. Use `positionTpSlModeEnum` for the tp_sl_mode parameter.
|
|
314
|
-
*/
|
|
315
|
-
setPositionTpSlMode(
|
|
316
|
-
params: LinearSetPositionTpSlModeRequest
|
|
317
|
-
): Promise<APIResponseWithTime<any>> {
|
|
318
|
-
return this.postPrivate('private/linear/tpsl/switch-mode', params);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
setAddReduceMargin(
|
|
322
|
-
params?: LinearSetAddReduceMarginRequest
|
|
323
|
-
): Promise<APIResponseWithTime<any>> {
|
|
324
|
-
return this.postPrivate('private/linear/position/add-margin', params);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
setUserLeverage(
|
|
328
|
-
params: LinearSetUserLeverageRequest
|
|
329
|
-
): Promise<APIResponseWithTime<any>> {
|
|
330
|
-
return this.postPrivate('private/linear/position/set-leverage', params);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
setTradingStop(
|
|
334
|
-
params: LinearSetTradingStopRequest
|
|
335
|
-
): Promise<APIResponseWithTime<any>> {
|
|
336
|
-
return this.postPrivate('private/linear/position/trading-stop', params);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
getTradeRecords(
|
|
340
|
-
params: LinearGetTradeRecordsRequest
|
|
341
|
-
): Promise<APIResponseWithTime<any>> {
|
|
342
|
-
return this.getPrivate('private/linear/trade/execution/list', params);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
getHistoryTradeRecords(
|
|
346
|
-
params: LinearGetHistoryTradeRecordsRequest
|
|
347
|
-
): Promise<APIResponseWithTime<any>> {
|
|
348
|
-
return this.getPrivate(
|
|
349
|
-
'/private/linear/trade/execution/history-list',
|
|
350
|
-
params
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
getClosedPnl(
|
|
355
|
-
params: LinearGetClosedPnlRequest
|
|
356
|
-
): Promise<APIResponseWithTime<any>> {
|
|
357
|
-
return this.getPrivate('private/linear/trade/closed-pnl/list', params);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* Risk Limit
|
|
362
|
-
*/
|
|
363
|
-
|
|
364
|
-
getRiskLimitList(params: SymbolParam): Promise<APIResponseWithTime<any>> {
|
|
365
|
-
return this.getPrivate('public/linear/risk-limit', params);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
setRiskLimit(
|
|
369
|
-
params: LinearSetRiskLimitRequest
|
|
370
|
-
): Promise<APIResponseWithTime<any>> {
|
|
371
|
-
return this.postPrivate('private/linear/position/set-risk', params);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Funding
|
|
376
|
-
*/
|
|
377
|
-
|
|
378
|
-
getPredictedFundingFee(
|
|
379
|
-
params: SymbolParam
|
|
380
|
-
): Promise<APIResponseWithTime<any>> {
|
|
381
|
-
return this.getPrivate('private/linear/funding/predicted-funding', params);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
getLastFundingFee(params: SymbolParam): Promise<APIResponseWithTime<any>> {
|
|
385
|
-
return this.getPrivate('private/linear/funding/prev-funding', params);
|
|
386
|
-
}
|
|
387
|
-
}
|