bybit-api 3.7.1-beta.0 → 3.7.1

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.
Files changed (69) hide show
  1. package/README.md +34 -6
  2. package/lib/rest-client-v5.d.ts +3 -3
  3. package/lib/rest-client-v5.js.map +1 -1
  4. package/lib/types/request/v5-trade.d.ts +2 -2
  5. package/package.json +1 -13
  6. package/src/account-asset-client-v3.ts +0 -310
  7. package/src/account-asset-client.ts +0 -149
  8. package/src/constants/enum.ts +0 -105
  9. package/src/contract-client.ts +0 -360
  10. package/src/copy-trading-client.ts +0 -159
  11. package/src/index.ts +0 -18
  12. package/src/inverse-client.ts +0 -337
  13. package/src/inverse-futures-client.ts +0 -403
  14. package/src/linear-client.ts +0 -387
  15. package/src/rest-client-v5.ts +0 -1638
  16. package/src/spot-client-v3.ts +0 -303
  17. package/src/spot-client.ts +0 -180
  18. package/src/types/index.ts +0 -5
  19. package/src/types/request/account-asset.ts +0 -258
  20. package/src/types/request/contract.ts +0 -139
  21. package/src/types/request/copy-trading.ts +0 -53
  22. package/src/types/request/index.ts +0 -18
  23. package/src/types/request/inverse.ts +0 -135
  24. package/src/types/request/linear.ts +0 -201
  25. package/src/types/request/spot.ts +0 -89
  26. package/src/types/request/unified-margin.ts +0 -247
  27. package/src/types/request/usdc-options.ts +0 -134
  28. package/src/types/request/usdc-perp.ts +0 -100
  29. package/src/types/request/usdc-shared.ts +0 -39
  30. package/src/types/request/v5-account.ts +0 -40
  31. package/src/types/request/v5-asset.ts +0 -133
  32. package/src/types/request/v5-market.ts +0 -127
  33. package/src/types/request/v5-position.ts +0 -107
  34. package/src/types/request/v5-pre-upgrade.ts +0 -37
  35. package/src/types/request/v5-spot-leverage-token.ts +0 -23
  36. package/src/types/request/v5-trade.ts +0 -133
  37. package/src/types/request/v5-user.ts +0 -21
  38. package/src/types/response/account-asset.ts +0 -236
  39. package/src/types/response/contract.ts +0 -74
  40. package/src/types/response/index.ts +0 -13
  41. package/src/types/response/shared.ts +0 -19
  42. package/src/types/response/spot.ts +0 -17
  43. package/src/types/response/unified-margin.ts +0 -71
  44. package/src/types/response/usdt-perp.ts +0 -58
  45. package/src/types/response/v5-account.ts +0 -122
  46. package/src/types/response/v5-asset.ts +0 -170
  47. package/src/types/response/v5-market.ts +0 -271
  48. package/src/types/response/v5-position.ts +0 -118
  49. package/src/types/response/v5-spot-leverage-token.ts +0 -70
  50. package/src/types/response/v5-trade.ts +0 -103
  51. package/src/types/response/v5-user.ts +0 -58
  52. package/src/types/shared.ts +0 -175
  53. package/src/types/v5-shared.ts +0 -213
  54. package/src/types/websockets.ts +0 -115
  55. package/src/types/ws-events/failed-topic-subscription-confirmation.ts +0 -6
  56. package/src/types/ws-events/succeeded-topic-subscription-confirmation.ts +0 -6
  57. package/src/types/ws-events/topic-subscription-confirmation.ts +0 -7
  58. package/src/unified-margin-client.ts +0 -400
  59. package/src/usdc-option-client.ts +0 -333
  60. package/src/usdc-perpetual-client.ts +0 -312
  61. package/src/util/BaseRestClient.ts +0 -502
  62. package/src/util/WsStore.ts +0 -160
  63. package/src/util/browser-support.ts +0 -29
  64. package/src/util/index.ts +0 -5
  65. package/src/util/logger.ts +0 -26
  66. package/src/util/node-support.ts +0 -9
  67. package/src/util/requestUtils.ts +0 -171
  68. package/src/util/websocket-util.ts +0 -550
  69. package/src/websocket-client.ts +0 -1262
@@ -1,333 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import {
3
- APIResponseV3,
4
- APIResponseWithTime,
5
- USDCOptionsActiveOrdersRealtimeRequest,
6
- USDCOptionsActiveOrdersRequest,
7
- USDCOptionsCancelAllOrdersRequest,
8
- USDCOptionsCancelOrderRequest,
9
- USDCOptionsContractInfoRequest,
10
- USDCOptionsDeliveryHistoryRequest,
11
- USDCOptionsDeliveryPriceRequest,
12
- USDCOptionsHistoricOrdersRequest,
13
- USDCOptionsHistoricalVolatilityRequest,
14
- USDCOptionsModifyMMPRequest,
15
- USDCOptionsModifyOrderRequest,
16
- USDCOptionsOrderExecutionRequest,
17
- USDCOptionsOrderRequest,
18
- USDCOptionsPositionsInfoExpiryRequest,
19
- USDCOptionsRecentTradesRequest,
20
- USDCPositionsRequest,
21
- USDCTransactionLogRequest,
22
- } from './types';
23
- import { REST_CLIENT_TYPE_ENUM } from './util';
24
- import BaseRestClient from './util/BaseRestClient';
25
-
26
- /**
27
- * REST API client for USDC Option APIs
28
- */
29
- export class USDCOptionClient extends BaseRestClient {
30
- getClientType() {
31
- return REST_CLIENT_TYPE_ENUM.v3;
32
- }
33
-
34
- async fetchServerTime(): Promise<number> {
35
- const res = await this.getServerTime();
36
- return Number(res.time_now);
37
- }
38
-
39
- /**
40
- *
41
- * Market Data Endpoints
42
- *
43
- */
44
-
45
- /** Query order book info. Each side has a depth of 25 orders. */
46
- getOrderBook(symbol: string): Promise<APIResponseV3<any>> {
47
- return this.get('/option/usdc/openapi/public/v1/order-book', { symbol });
48
- }
49
-
50
- /** Fetch trading rules (such as min/max qty). Query for all if blank. */
51
- getContractInfo(
52
- params?: USDCOptionsContractInfoRequest
53
- ): Promise<APIResponseV3<any>> {
54
- return this.get('/option/usdc/openapi/public/v1/symbols', params);
55
- }
56
-
57
- /** Get a symbol price/statistics ticker */
58
- getSymbolTicker(symbol: string): Promise<APIResponseV3<any>> {
59
- return this.get('/option/usdc/openapi/public/v1/tick', { symbol });
60
- }
61
-
62
- /** Get delivery information */
63
- getDeliveryPrice(
64
- params?: USDCOptionsDeliveryPriceRequest
65
- ): Promise<APIResponseV3<any>> {
66
- return this.get('/option/usdc/openapi/public/v1/delivery-price', params);
67
- }
68
-
69
- /** Returned records are Taker Buy in default. */
70
- getLast500Trades(
71
- params: USDCOptionsRecentTradesRequest
72
- ): Promise<APIResponseV3<any>> {
73
- return this.get(
74
- '/option/usdc/openapi/public/v1/query-trade-latest',
75
- params
76
- );
77
- }
78
-
79
- /**
80
- * The data is in hourly.
81
- * If time field is not passed, it returns the recent 1 hour data by default.
82
- * It could be any timeframe by inputting startTime & endTime, but it must satisfy [endTime - startTime] <= 30 days.
83
- * It returns all data in 2 years when startTime & endTime are not passed.
84
- * Both startTime & endTime entered together or both are left blank
85
- */
86
- getHistoricalVolatility(
87
- params?: USDCOptionsHistoricalVolatilityRequest
88
- ): Promise<APIResponseV3<any>> {
89
- return this.get(
90
- '/option/usdc/openapi/public/v1/query-historical-volatility',
91
- params
92
- );
93
- }
94
-
95
- /**
96
- *
97
- * Account Data Endpoints
98
- *
99
- */
100
-
101
- /** -> Order API */
102
-
103
- /**
104
- * Place an order using the USDC Derivatives Account.
105
- * The request status can be queried in real-time.
106
- * The response parameters must be queried through a query or a WebSocket response.
107
- */
108
- submitOrder(params: USDCOptionsOrderRequest): Promise<APIResponseV3<any>> {
109
- return this.postPrivate(
110
- '/option/usdc/openapi/private/v1/place-order',
111
- params
112
- );
113
- }
114
-
115
- /**
116
- * Each request supports a max. of four orders. The reduceOnly parameter should be separate and unique for each order in the request.
117
- */
118
- batchSubmitOrders(
119
- orderRequest: USDCOptionsOrderRequest[]
120
- ): Promise<APIResponseV3<any>> {
121
- return this.postPrivate(
122
- '/option/usdc/openapi/private/v1/batch-place-orders',
123
- { orderRequest }
124
- );
125
- }
126
-
127
- /** For Options, at least one of the three parameters — price, quantity or implied volatility — must be input. */
128
- modifyOrder(
129
- params: USDCOptionsModifyOrderRequest
130
- ): Promise<APIResponseV3<any>> {
131
- return this.postPrivate(
132
- '/option/usdc/openapi/private/v1/replace-order',
133
- params
134
- );
135
- }
136
-
137
- /** Each request supports a max. of four orders. The reduceOnly parameter should be separate and unique for each order in the request. */
138
- batchModifyOrders(
139
- replaceOrderRequest: USDCOptionsModifyOrderRequest[]
140
- ): Promise<APIResponseV3<any>> {
141
- return this.postPrivate(
142
- '/option/usdc/openapi/private/v1/batch-replace-orders',
143
- { replaceOrderRequest }
144
- );
145
- }
146
-
147
- /** Cancel order */
148
- cancelOrder(
149
- params: USDCOptionsCancelOrderRequest
150
- ): Promise<APIResponseV3<any>> {
151
- return this.postPrivate(
152
- '/option/usdc/openapi/private/v1/cancel-order',
153
- params
154
- );
155
- }
156
-
157
- /** Batch cancel orders */
158
- batchCancelOrders(
159
- cancelRequest: USDCOptionsCancelOrderRequest[]
160
- ): Promise<APIResponseV3<any>> {
161
- return this.postPrivate(
162
- '/option/usdc/openapi/private/v1/batch-cancel-orders',
163
- { cancelRequest }
164
- );
165
- }
166
-
167
- /** This is used to cancel all active orders. The real-time response indicates whether the request is successful, depending on retCode. */
168
- cancelActiveOrders(
169
- params?: USDCOptionsCancelAllOrdersRequest
170
- ): Promise<APIResponseV3<any>> {
171
- return this.postPrivate(
172
- '/option/usdc/openapi/private/v1/cancel-all',
173
- params
174
- );
175
- }
176
-
177
- /** Query Unfilled/Partially Filled Orders(real-time), up to last 7 days of partially filled/unfilled orders */
178
- getActiveRealtimeOrders(
179
- params?: USDCOptionsActiveOrdersRealtimeRequest
180
- ): Promise<APIResponseV3<any>> {
181
- return this.getPrivate(
182
- '/option/usdc/openapi/private/v1/trade/query-active-orders',
183
- params
184
- );
185
- }
186
-
187
- /** Query Unfilled/Partially Filled Orders */
188
- getActiveOrders(
189
- params: USDCOptionsActiveOrdersRequest
190
- ): Promise<APIResponseV3<any>> {
191
- return this.postPrivate(
192
- '/option/usdc/openapi/private/v1/query-active-orders',
193
- params
194
- );
195
- }
196
-
197
- /** Query order history. The endpoint only supports up to 30 days of queried records */
198
- getHistoricOrders(
199
- params: USDCOptionsHistoricOrdersRequest
200
- ): Promise<APIResponseV3<any>> {
201
- return this.postPrivate(
202
- '/option/usdc/openapi/private/v1/query-order-history',
203
- params
204
- );
205
- }
206
-
207
- /**
208
- * Query trade history.
209
- * The endpoint only supports up to 30 days of queried records.
210
- * An error will be returned if startTime is more than 30 days.
211
- */
212
- getOrderExecutionHistory(
213
- params: USDCOptionsOrderExecutionRequest
214
- ): Promise<APIResponseV3<any>> {
215
- return this.postPrivate(
216
- '/option/usdc/openapi/private/v1/execution-list',
217
- params
218
- );
219
- }
220
-
221
- /** -> Account API */
222
-
223
- /** The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
224
- getTransactionLog(
225
- params: USDCTransactionLogRequest
226
- ): Promise<APIResponseV3<any>> {
227
- return this.postPrivate(
228
- '/option/usdc/openapi/private/v1/query-transaction-log',
229
- params
230
- );
231
- }
232
-
233
- /** Wallet info for USDC account. */
234
- getBalances(): Promise<APIResponseV3<any>> {
235
- return this.postPrivate(
236
- '/option/usdc/openapi/private/v1/query-wallet-balance'
237
- );
238
- }
239
-
240
- /** Asset Info */
241
- getAssetInfo(baseCoin?: string): Promise<APIResponseV3<any>> {
242
- return this.postPrivate(
243
- '/option/usdc/openapi/private/v1/query-asset-info',
244
- { baseCoin }
245
- );
246
- }
247
-
248
- /**
249
- * If USDC derivatives account balance is greater than X, you can open PORTFOLIO_MARGIN,
250
- * and if it is less than Y, it will automatically close PORTFOLIO_MARGIN and change back to REGULAR_MARGIN.
251
- * X and Y will be adjusted according to operational requirements.
252
- * Rest API returns the result of checking prerequisites. You could get the real status of margin mode change by subscribing margin mode.
253
- */
254
- setMarginMode(
255
- newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN'
256
- ): Promise<APIResponseV3<any>> {
257
- return this.postPrivate(
258
- '/option/usdc/private/asset/account/setMarginMode',
259
- { setMarginMode: newMarginMode }
260
- );
261
- }
262
-
263
- /** Query margin mode for USDC account. */
264
- getMarginMode(): Promise<APIResponseV3<any>> {
265
- return this.postPrivate(
266
- '/option/usdc/openapi/private/v1/query-margin-info'
267
- );
268
- }
269
-
270
- /** -> Positions API */
271
-
272
- /** Query my positions */
273
- getPositions(params: USDCPositionsRequest): Promise<APIResponseV3<any>> {
274
- return this.postPrivate(
275
- '/option/usdc/openapi/private/v1/query-position',
276
- params
277
- );
278
- }
279
-
280
- /** Query Delivery History */
281
- getDeliveryHistory(
282
- params: USDCOptionsDeliveryHistoryRequest
283
- ): Promise<APIResponseV3<any>> {
284
- return this.postPrivate(
285
- '/option/usdc/openapi/private/v1/query-delivery-list',
286
- params
287
- );
288
- }
289
-
290
- /** Query Positions Info Upon Expiry */
291
- getPositionsInfoUponExpiry(
292
- params?: USDCOptionsPositionsInfoExpiryRequest
293
- ): Promise<APIResponseV3<any>> {
294
- return this.postPrivate(
295
- '/option/usdc/openapi/private/v1/query-position-exp-date',
296
- params
297
- );
298
- }
299
-
300
- /** -> Market Maker Protection */
301
-
302
- /** modifyMMP */
303
- modifyMMP(params: USDCOptionsModifyMMPRequest): Promise<APIResponseV3<any>> {
304
- return this.postPrivate(
305
- '/option/usdc/openapi/private/v1/mmp-modify',
306
- params
307
- );
308
- }
309
-
310
- /** resetMMP */
311
- resetMMP(currency: string): Promise<APIResponseV3<any>> {
312
- return this.postPrivate('/option/usdc/openapi/private/v1/mmp-reset', {
313
- currency,
314
- });
315
- }
316
-
317
- /** queryMMPState */
318
- queryMMPState(baseCoin: string): Promise<APIResponseV3<any>> {
319
- return this.postPrivate('/option/usdc/openapi/private/v1/get-mmp-state', {
320
- baseCoin,
321
- });
322
- }
323
-
324
- /**
325
- *
326
- * API Data Endpoints
327
- *
328
- */
329
-
330
- getServerTime(): Promise<APIResponseWithTime> {
331
- return this.get('/v2/public/time');
332
- }
333
- }
@@ -1,312 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import {
3
- APIResponseV3,
4
- APIResponseWithTime,
5
- SymbolLimitParam,
6
- SymbolPeriodLimitParam,
7
- USDCKlineRequest,
8
- USDCLast500TradesRequest,
9
- USDCOpenInterestRequest,
10
- USDCOrderFilter,
11
- USDCPerpActiveOrdersRequest,
12
- USDCPerpCancelOrderRequest,
13
- USDCPerpHistoricOrdersRequest,
14
- USDCPerpModifyOrderRequest,
15
- USDCPerpOrderRequest,
16
- USDCPositionsRequest,
17
- USDCSymbolDirectionLimit,
18
- USDCSymbolDirectionLimitCursor,
19
- USDCTransactionLogRequest,
20
- } from './types';
21
- import { REST_CLIENT_TYPE_ENUM } from './util';
22
- import BaseRestClient from './util/BaseRestClient';
23
-
24
- /**
25
- * REST API client for USDC Perpetual APIs
26
- */
27
- export class USDCPerpetualClient extends BaseRestClient {
28
- getClientType() {
29
- // Follows the same authentication mechanism as other v3 APIs (e.g. USDC)
30
- return REST_CLIENT_TYPE_ENUM.v3;
31
- }
32
-
33
- async fetchServerTime(): Promise<number> {
34
- const res = await this.getServerTime();
35
- return Number(res.time_now);
36
- }
37
-
38
- /**
39
- *
40
- * Market Data Endpoints
41
- *
42
- */
43
-
44
- getOrderBook(symbol: string): Promise<APIResponseV3<any>> {
45
- return this.get('/perpetual/usdc/openapi/public/v1/order-book', { symbol });
46
- }
47
-
48
- /** Fetch trading rules (such as min/max qty). Query for all if blank. */
49
- getContractInfo(
50
- params?: USDCSymbolDirectionLimit
51
- ): Promise<APIResponseV3<any>> {
52
- return this.get('/perpetual/usdc/openapi/public/v1/symbols', params);
53
- }
54
-
55
- /** Get a symbol price/statistics ticker */
56
- getSymbolTicker(symbol: string): Promise<APIResponseV3<any>> {
57
- return this.get('/perpetual/usdc/openapi/public/v1/tick', { symbol });
58
- }
59
-
60
- getCandles(params: USDCKlineRequest): Promise<APIResponseV3<any>> {
61
- return this.get('/perpetual/usdc/openapi/public/v1/kline/list', params);
62
- }
63
-
64
- getMarkPrice(params: USDCKlineRequest): Promise<APIResponseV3<any>> {
65
- return this.get(
66
- '/perpetual/usdc/openapi/public/v1/mark-price-kline',
67
- params
68
- );
69
- }
70
-
71
- getIndexPrice(params: USDCKlineRequest): Promise<APIResponseV3<any>> {
72
- return this.get(
73
- '/perpetual/usdc/openapi/public/v1/index-price-kline',
74
- params
75
- );
76
- }
77
-
78
- getIndexPremium(params: USDCKlineRequest): Promise<APIResponseV3<any>> {
79
- return this.get(
80
- '/perpetual/usdc/openapi/public/v1/premium-index-kline',
81
- params
82
- );
83
- }
84
-
85
- getOpenInterest(
86
- params: USDCOpenInterestRequest
87
- ): Promise<APIResponseV3<any>> {
88
- return this.get('/perpetual/usdc/openapi/public/v1/open-interest', params);
89
- }
90
-
91
- getLargeOrders(
92
- params: SymbolLimitParam<string>
93
- ): Promise<APIResponseV3<any>> {
94
- return this.get('/perpetual/usdc/openapi/public/v1/big-deal', params);
95
- }
96
-
97
- getLongShortRatio(
98
- params: SymbolPeriodLimitParam<string>
99
- ): Promise<APIResponseV3<any>> {
100
- return this.get('/perpetual/usdc/openapi/public/v1/account-ratio', params);
101
- }
102
-
103
- getLast500Trades(
104
- params: USDCLast500TradesRequest
105
- ): Promise<APIResponseV3<any>> {
106
- return this.get(
107
- '/option/usdc/openapi/public/v1/query-trade-latest',
108
- params
109
- );
110
- }
111
-
112
- /**
113
- *
114
- * Account Data Endpoints
115
- *
116
- */
117
-
118
- /** -> Order API */
119
-
120
- /**
121
- * Place an order using the USDC Derivatives Account.
122
- * The request status can be queried in real-time.
123
- * The response parameters must be queried through a query or a WebSocket response.
124
- */
125
- submitOrder(params: USDCPerpOrderRequest): Promise<APIResponseV3<any>> {
126
- return this.postPrivate(
127
- '/perpetual/usdc/openapi/private/v1/place-order',
128
- params
129
- );
130
- }
131
-
132
- /** Active order parameters (such as quantity, price) and stop order parameters cannot be modified in one request at the same time. Please request modification separately. */
133
- modifyOrder(params: USDCPerpModifyOrderRequest): Promise<APIResponseV3<any>> {
134
- return this.postPrivate(
135
- '/perpetual/usdc/openapi/private/v1/replace-order',
136
- params
137
- );
138
- }
139
-
140
- /** Cancel order */
141
- cancelOrder(params: USDCPerpCancelOrderRequest): Promise<APIResponseV3<any>> {
142
- return this.postPrivate(
143
- '/perpetual/usdc/openapi/private/v1/cancel-order',
144
- params
145
- );
146
- }
147
-
148
- /** Cancel all active orders. The real-time response indicates whether the request is successful, depending on retCode. */
149
- cancelActiveOrders(
150
- symbol: string,
151
- orderFilter: USDCOrderFilter
152
- ): Promise<APIResponseV3<any>> {
153
- return this.postPrivate('/perpetual/usdc/openapi/private/v1/cancel-all', {
154
- symbol,
155
- orderFilter,
156
- });
157
- }
158
-
159
- /** Query Unfilled/Partially Filled Orders */
160
- getActiveOrders(
161
- params: USDCPerpActiveOrdersRequest
162
- ): Promise<APIResponseV3<any>> {
163
- return this.postPrivate(
164
- '/option/usdc/openapi/private/v1/query-active-orders',
165
- params
166
- );
167
- }
168
-
169
- /** Query order history. The endpoint only supports up to 30 days of queried records */
170
- getHistoricOrders(
171
- params: USDCPerpHistoricOrdersRequest
172
- ): Promise<APIResponseV3<any>> {
173
- return this.postPrivate(
174
- '/option/usdc/openapi/private/v1/query-order-history',
175
- params
176
- );
177
- }
178
-
179
- /** Query trade history. The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
180
- getOrderExecutionHistory(
181
- params: USDCPerpActiveOrdersRequest
182
- ): Promise<APIResponseV3<any>> {
183
- return this.postPrivate(
184
- '/option/usdc/openapi/private/v1/execution-list',
185
- params
186
- );
187
- }
188
-
189
- /** -> Account API */
190
-
191
- /** The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
192
- getTransactionLog(
193
- params: USDCTransactionLogRequest
194
- ): Promise<APIResponseV3<any>> {
195
- return this.postPrivate(
196
- '/option/usdc/openapi/private/v1/query-transaction-log',
197
- params
198
- );
199
- }
200
-
201
- /** Wallet info for USDC account. */
202
- getBalances(): Promise<APIResponseV3<any>> {
203
- return this.postPrivate(
204
- '/option/usdc/openapi/private/v1/query-wallet-balance'
205
- );
206
- }
207
-
208
- /** Asset Info */
209
- getAssetInfo(baseCoin?: string): Promise<APIResponseV3<any>> {
210
- return this.postPrivate(
211
- '/option/usdc/openapi/private/v1/query-asset-info',
212
- { baseCoin }
213
- );
214
- }
215
-
216
- /**
217
- * If USDC derivatives account balance is greater than X, you can open PORTFOLIO_MARGIN,
218
- * and if it is less than Y, it will automatically close PORTFOLIO_MARGIN and change back to REGULAR_MARGIN.
219
- * X and Y will be adjusted according to operational requirements.
220
- * Rest API returns the result of checking prerequisites. You could get the real status of margin mode change by subscribing margin mode.
221
- */
222
- setMarginMode(
223
- newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN'
224
- ): Promise<APIResponseV3<any>> {
225
- return this.postPrivate(
226
- '/option/usdc/private/asset/account/setMarginMode',
227
- { setMarginMode: newMarginMode }
228
- );
229
- }
230
-
231
- /** Query margin mode for USDC account. */
232
- getMarginMode(): Promise<APIResponseV3<any>> {
233
- return this.postPrivate(
234
- '/option/usdc/openapi/private/v1/query-margin-info'
235
- );
236
- }
237
-
238
- /** -> Positions API */
239
-
240
- /** Query my positions */
241
- getPositions(params: USDCPositionsRequest): Promise<APIResponseV3<any>> {
242
- return this.postPrivate(
243
- '/option/usdc/openapi/private/v1/query-position',
244
- params
245
- );
246
- }
247
-
248
- /** Only for REGULAR_MARGIN */
249
- setLeverage(symbol: string, leverage: string): Promise<APIResponseV3<any>> {
250
- return this.postPrivate(
251
- '/perpetual/usdc/openapi/private/v1/position/leverage/save',
252
- { symbol, leverage }
253
- );
254
- }
255
-
256
- /** Query Settlement History */
257
- getSettlementHistory(
258
- params?: USDCSymbolDirectionLimitCursor
259
- ): Promise<APIResponseV3<any>> {
260
- return this.postPrivate(
261
- '/option/usdc/openapi/private/v1/session-settlement',
262
- params
263
- );
264
- }
265
-
266
- /** -> Risk Limit API */
267
-
268
- /** Query risk limit */
269
- getRiskLimit(symbol: string): Promise<APIResponseV3<any>> {
270
- return this.getPrivate(
271
- '/perpetual/usdc/openapi/public/v1/risk-limit/list',
272
- {
273
- symbol,
274
- }
275
- );
276
- }
277
-
278
- /** Set risk limit */
279
- setRiskLimit(symbol: string, riskId: number): Promise<APIResponseV3<any>> {
280
- return this.postPrivate(
281
- '/perpetual/usdc/openapi/private/v1/position/set-risk-limit',
282
- { symbol, riskId }
283
- );
284
- }
285
-
286
- /** -> Funding API */
287
-
288
- /** Funding settlement occurs every 8 hours at 00:00 UTC, 08:00 UTC and 16:00 UTC. The current interval's fund fee settlement is based on the previous interval's fund rate. For example, at 16:00, the settlement is based on the fund rate generated at 8:00. The fund rate generated at 16:00 will be used at 0:00 the next day. */
289
- getLastFundingRate(symbol: string): Promise<APIResponseV3<any>> {
290
- return this.get('/perpetual/usdc/openapi/public/v1/prev-funding-rate', {
291
- symbol,
292
- });
293
- }
294
-
295
- /** Get predicted funding rate and my predicted funding fee */
296
- getPredictedFundingRate(symbol: string): Promise<APIResponseV3<any>> {
297
- return this.postPrivate(
298
- '/perpetual/usdc/openapi/private/v1/predicted-funding',
299
- { symbol }
300
- );
301
- }
302
-
303
- /**
304
- *
305
- * API Data Endpoints
306
- *
307
- */
308
-
309
- getServerTime(): Promise<APIResponseWithTime> {
310
- return this.get('/v2/public/time');
311
- }
312
- }