bybit-api 3.7.0 → 3.7.1-beta.0
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/lib/util/websocket-util.d.ts +2 -1
- package/lib/util/websocket-util.js +2 -2
- package/lib/util/websocket-util.js.map +1 -1
- package/lib/websocket-client.js +1 -1
- package/lib/websocket-client.js.map +1 -1
- package/package.json +13 -1
- package/src/account-asset-client-v3.ts +310 -0
- package/src/account-asset-client.ts +149 -0
- package/src/constants/enum.ts +105 -0
- package/src/contract-client.ts +360 -0
- package/src/copy-trading-client.ts +159 -0
- package/src/index.ts +18 -0
- package/src/inverse-client.ts +337 -0
- package/src/inverse-futures-client.ts +403 -0
- package/src/linear-client.ts +387 -0
- package/src/rest-client-v5.ts +1638 -0
- package/src/spot-client-v3.ts +303 -0
- package/src/spot-client.ts +180 -0
- package/src/types/index.ts +5 -0
- package/src/types/request/account-asset.ts +258 -0
- package/src/types/request/contract.ts +139 -0
- package/src/types/request/copy-trading.ts +53 -0
- package/src/types/request/index.ts +18 -0
- package/src/types/request/inverse.ts +135 -0
- package/src/types/request/linear.ts +201 -0
- package/src/types/request/spot.ts +89 -0
- package/src/types/request/unified-margin.ts +247 -0
- package/src/types/request/usdc-options.ts +134 -0
- package/src/types/request/usdc-perp.ts +100 -0
- package/src/types/request/usdc-shared.ts +39 -0
- package/src/types/request/v5-account.ts +40 -0
- package/src/types/request/v5-asset.ts +133 -0
- package/src/types/request/v5-market.ts +127 -0
- package/src/types/request/v5-position.ts +107 -0
- package/src/types/request/v5-pre-upgrade.ts +37 -0
- package/src/types/request/v5-spot-leverage-token.ts +23 -0
- package/src/types/request/v5-trade.ts +133 -0
- package/src/types/request/v5-user.ts +21 -0
- package/src/types/response/account-asset.ts +236 -0
- package/src/types/response/contract.ts +74 -0
- package/src/types/response/index.ts +13 -0
- package/src/types/response/shared.ts +19 -0
- package/src/types/response/spot.ts +17 -0
- package/src/types/response/unified-margin.ts +71 -0
- package/src/types/response/usdt-perp.ts +58 -0
- package/src/types/response/v5-account.ts +122 -0
- package/src/types/response/v5-asset.ts +170 -0
- package/src/types/response/v5-market.ts +271 -0
- package/src/types/response/v5-position.ts +118 -0
- package/src/types/response/v5-spot-leverage-token.ts +70 -0
- package/src/types/response/v5-trade.ts +103 -0
- package/src/types/response/v5-user.ts +58 -0
- package/src/types/shared.ts +175 -0
- package/src/types/v5-shared.ts +213 -0
- package/src/types/websockets.ts +115 -0
- package/src/types/ws-events/failed-topic-subscription-confirmation.ts +6 -0
- package/src/types/ws-events/succeeded-topic-subscription-confirmation.ts +6 -0
- package/src/types/ws-events/topic-subscription-confirmation.ts +7 -0
- package/src/unified-margin-client.ts +400 -0
- package/src/usdc-option-client.ts +333 -0
- package/src/usdc-perpetual-client.ts +312 -0
- package/src/util/BaseRestClient.ts +502 -0
- package/src/util/WsStore.ts +160 -0
- package/src/util/browser-support.ts +29 -0
- package/src/util/index.ts +5 -0
- package/src/util/logger.ts +26 -0
- package/src/util/node-support.ts +9 -0
- package/src/util/requestUtils.ts +171 -0
- package/src/util/websocket-util.ts +550 -0
- package/src/websocket-client.ts +1262 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import {
|
|
3
|
+
APIResponseV3,
|
|
4
|
+
APIResponseWithTime,
|
|
5
|
+
CopyTradingCancelOrderRequest,
|
|
6
|
+
CopyTradingCloseOrderRequest,
|
|
7
|
+
CopyTradingOrderListRequest,
|
|
8
|
+
CopyTradingOrderRequest,
|
|
9
|
+
CopyTradingTradingStopRequest,
|
|
10
|
+
CopyTradingTransferRequest,
|
|
11
|
+
} from './types';
|
|
12
|
+
import { REST_CLIENT_TYPE_ENUM } from './util';
|
|
13
|
+
import BaseRestClient from './util/BaseRestClient';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* REST API client for USDC Perpetual APIs
|
|
17
|
+
*/
|
|
18
|
+
export class CopyTradingClient extends BaseRestClient {
|
|
19
|
+
getClientType() {
|
|
20
|
+
// Follows the same authentication mechanism as USDC APIs
|
|
21
|
+
return REST_CLIENT_TYPE_ENUM.v3;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async fetchServerTime(): Promise<number> {
|
|
25
|
+
const res = await this.getServerTime();
|
|
26
|
+
return Number(res.time_now);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* Market Data Endpoints
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
getSymbols(): Promise<APIResponseV3<any>> {
|
|
36
|
+
return this.get('/contract/v3/public/copytrading/symbol/list');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* Account Data Endpoints
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/** -> Order API */
|
|
46
|
+
|
|
47
|
+
/** Create order */
|
|
48
|
+
submitOrder(params: CopyTradingOrderRequest): Promise<APIResponseV3<any>> {
|
|
49
|
+
return this.postPrivate(
|
|
50
|
+
'/contract/v3/private/copytrading/order/create',
|
|
51
|
+
params
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Set Trading Stop */
|
|
56
|
+
setTradingStop(
|
|
57
|
+
params: CopyTradingTradingStopRequest
|
|
58
|
+
): Promise<APIResponseV3<any>> {
|
|
59
|
+
return this.postPrivate(
|
|
60
|
+
'/contract/v3/private/copytrading/order/trading-stop',
|
|
61
|
+
params
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Query Order List */
|
|
66
|
+
getActiveOrders(
|
|
67
|
+
params?: CopyTradingOrderListRequest
|
|
68
|
+
): Promise<APIResponseV3<any>> {
|
|
69
|
+
return this.getPrivate(
|
|
70
|
+
'/contract/v3/private/copytrading/order/list',
|
|
71
|
+
params
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Cancel order */
|
|
76
|
+
cancelOrder(
|
|
77
|
+
params: CopyTradingCancelOrderRequest
|
|
78
|
+
): Promise<APIResponseV3<any>> {
|
|
79
|
+
return this.postPrivate(
|
|
80
|
+
'/contract/v3/private/copytrading/order/cancel',
|
|
81
|
+
params
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Close Order. This endpoint's rate_limit will decrease by 10 per request; ie, one request to this endpoint consumes 10 from the limit allowed per minute. */
|
|
86
|
+
closeOrder(
|
|
87
|
+
params: CopyTradingCloseOrderRequest
|
|
88
|
+
): Promise<APIResponseV3<any>> {
|
|
89
|
+
return this.postPrivate(
|
|
90
|
+
'/contract/v3/private/copytrading/order/close',
|
|
91
|
+
params
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** -> Positions API */
|
|
96
|
+
|
|
97
|
+
/** Position List */
|
|
98
|
+
getPositions(symbol?: string): Promise<APIResponseV3<any>> {
|
|
99
|
+
return this.getPrivate('/contract/v3/private/copytrading/position/list', {
|
|
100
|
+
symbol,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Close Position */
|
|
105
|
+
closePosition(
|
|
106
|
+
symbol: string,
|
|
107
|
+
positionIdx: string
|
|
108
|
+
): Promise<APIResponseV3<any>> {
|
|
109
|
+
return this.postPrivate('/contract/v3/private/copytrading/position/close', {
|
|
110
|
+
symbol,
|
|
111
|
+
positionIdx,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Only integers can be set to set the leverage */
|
|
116
|
+
setLeverage(
|
|
117
|
+
symbol: string,
|
|
118
|
+
buyLeverage: string,
|
|
119
|
+
sellLeverage: string
|
|
120
|
+
): Promise<APIResponseV3<any>> {
|
|
121
|
+
return this.postPrivate(
|
|
122
|
+
'/contract/v3/private/copytrading/position/set-leverage',
|
|
123
|
+
{ symbol, buyLeverage, sellLeverage }
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
*
|
|
129
|
+
* Wallet Data Endpoints
|
|
130
|
+
*
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
/** Get Wallet Balance */
|
|
134
|
+
getBalances(): Promise<APIResponseV3<any>> {
|
|
135
|
+
return this.getPrivate('/contract/v3/private/copytrading/wallet/balance');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** Transfer */
|
|
139
|
+
transfer(params: CopyTradingTransferRequest): Promise<APIResponseV3<any>> {
|
|
140
|
+
return this.postPrivate(
|
|
141
|
+
'/contract/v3/private/copytrading/wallet/transfer',
|
|
142
|
+
params
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
*
|
|
148
|
+
* API Data Endpoints
|
|
149
|
+
*
|
|
150
|
+
*/
|
|
151
|
+
|
|
152
|
+
getServerTime(): Promise<APIResponseWithTime> {
|
|
153
|
+
return this.get('/v2/public/time');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
getAnnouncements(): Promise<APIResponseWithTime<any[]>> {
|
|
157
|
+
return this.get('/v2/public/announcement');
|
|
158
|
+
}
|
|
159
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from './account-asset-client';
|
|
2
|
+
export * from './account-asset-client-v3';
|
|
3
|
+
export * from './copy-trading-client';
|
|
4
|
+
export * from './inverse-client';
|
|
5
|
+
export * from './inverse-futures-client';
|
|
6
|
+
export * from './linear-client';
|
|
7
|
+
export * from './rest-client-v5';
|
|
8
|
+
export * from './spot-client';
|
|
9
|
+
export * from './spot-client-v3';
|
|
10
|
+
export * from './usdc-option-client';
|
|
11
|
+
export * from './usdc-perpetual-client';
|
|
12
|
+
export * from './unified-margin-client';
|
|
13
|
+
export * from './contract-client';
|
|
14
|
+
export * from './websocket-client';
|
|
15
|
+
export * from './util/logger';
|
|
16
|
+
export * from './util';
|
|
17
|
+
export * from './types';
|
|
18
|
+
export * from './constants/enum';
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { REST_CLIENT_TYPE_ENUM } from './util';
|
|
3
|
+
import {
|
|
4
|
+
APIResponseWithTime,
|
|
5
|
+
AssetExchangeRecordsReq,
|
|
6
|
+
CoinParam,
|
|
7
|
+
InverseActiveConditionalOrderRequest,
|
|
8
|
+
InverseActiveOrdersRequest,
|
|
9
|
+
InverseCancelConditionalOrderRequest,
|
|
10
|
+
InverseCancelOrderRequest,
|
|
11
|
+
InverseChangePositionMarginRequest,
|
|
12
|
+
InverseConditionalOrderRequest,
|
|
13
|
+
InverseGetClosedPnlRequest,
|
|
14
|
+
InverseGetOrderRequest,
|
|
15
|
+
InverseGetTradeRecordsRequest,
|
|
16
|
+
InverseOrderRequest,
|
|
17
|
+
InverseReplaceConditionalOrderRequest,
|
|
18
|
+
InverseReplaceOrderRequest,
|
|
19
|
+
InverseSetLeverageRequest,
|
|
20
|
+
InverseSetMarginTypeRequest,
|
|
21
|
+
InverseSetSlTpPositionModeRequest,
|
|
22
|
+
InverseSetTradingStopRequest,
|
|
23
|
+
SymbolInfo,
|
|
24
|
+
SymbolIntervalFromLimitParam,
|
|
25
|
+
SymbolLimitParam,
|
|
26
|
+
SymbolParam,
|
|
27
|
+
SymbolPeriodLimitParam,
|
|
28
|
+
WalletFundRecordsReq,
|
|
29
|
+
WithdrawRecordsReq,
|
|
30
|
+
} from './types';
|
|
31
|
+
import BaseRestClient from './util/BaseRestClient';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* REST API client for Inverse Perpetual Futures APIs (v2)
|
|
35
|
+
*/
|
|
36
|
+
export class InverseClient extends BaseRestClient {
|
|
37
|
+
getClientType() {
|
|
38
|
+
return REST_CLIENT_TYPE_ENUM.inverse;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async fetchServerTime(): Promise<number> {
|
|
42
|
+
const res = await this.getServerTime();
|
|
43
|
+
return Number(res.time_now);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* Market Data Endpoints
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
getOrderBook(params: SymbolParam): Promise<APIResponseWithTime<any[]>> {
|
|
53
|
+
return this.get('v2/public/orderBook/L2', params);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
getKline(
|
|
57
|
+
params: SymbolIntervalFromLimitParam
|
|
58
|
+
): Promise<APIResponseWithTime<any[]>> {
|
|
59
|
+
return this.get('v2/public/kline/list', params);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Get latest information for symbol
|
|
64
|
+
*/
|
|
65
|
+
getTickers(
|
|
66
|
+
params?: Partial<SymbolParam>
|
|
67
|
+
): Promise<APIResponseWithTime<any[]>> {
|
|
68
|
+
return this.get('v2/public/tickers', params);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
getTrades(params: SymbolLimitParam): Promise<APIResponseWithTime<any[]>> {
|
|
72
|
+
return this.get('v2/public/trading-records', params);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
getSymbols(): Promise<APIResponseWithTime<SymbolInfo[]>> {
|
|
76
|
+
return this.get('v2/public/symbols');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
getMarkPriceKline(
|
|
80
|
+
params: SymbolIntervalFromLimitParam
|
|
81
|
+
): Promise<APIResponseWithTime<any[]>> {
|
|
82
|
+
return this.get('v2/public/mark-price-kline', params);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
getIndexPriceKline(
|
|
86
|
+
params: SymbolIntervalFromLimitParam
|
|
87
|
+
): Promise<APIResponseWithTime<any[]>> {
|
|
88
|
+
return this.get('v2/public/index-price-kline', params);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
getPremiumIndexKline(
|
|
92
|
+
params: SymbolIntervalFromLimitParam
|
|
93
|
+
): Promise<APIResponseWithTime<any[]>> {
|
|
94
|
+
return this.get('v2/public/premium-index-kline', params);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
*
|
|
99
|
+
* Market Data : Advanced
|
|
100
|
+
*
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
getOpenInterest(
|
|
104
|
+
params: SymbolPeriodLimitParam
|
|
105
|
+
): Promise<APIResponseWithTime<any[]>> {
|
|
106
|
+
return this.get('v2/public/open-interest', params);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
getLatestBigDeal(
|
|
110
|
+
params: SymbolLimitParam
|
|
111
|
+
): Promise<APIResponseWithTime<any[]>> {
|
|
112
|
+
return this.get('v2/public/big-deal', params);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
getLongShortRatio(
|
|
116
|
+
params: SymbolPeriodLimitParam
|
|
117
|
+
): Promise<APIResponseWithTime<any[]>> {
|
|
118
|
+
return this.get('v2/public/account-ratio', params);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
*
|
|
123
|
+
* Account Data Endpoints
|
|
124
|
+
*
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
getApiKeyInfo(): Promise<APIResponseWithTime<any>> {
|
|
128
|
+
return this.getPrivate('v2/private/account/api-key');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
*
|
|
133
|
+
* Wallet Data Endpoints
|
|
134
|
+
*
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
getWalletBalance(
|
|
138
|
+
params?: Partial<CoinParam>
|
|
139
|
+
): Promise<APIResponseWithTime<any>> {
|
|
140
|
+
return this.getPrivate('v2/private/wallet/balance', params);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
getWalletFundRecords(
|
|
144
|
+
params?: WalletFundRecordsReq
|
|
145
|
+
): Promise<APIResponseWithTime<any>> {
|
|
146
|
+
return this.getPrivate('v2/private/wallet/fund/records', params);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
getWithdrawRecords(
|
|
150
|
+
params?: WithdrawRecordsReq
|
|
151
|
+
): Promise<APIResponseWithTime<any>> {
|
|
152
|
+
return this.getPrivate('v2/private/wallet/withdraw/list', params);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
getAssetExchangeRecords(
|
|
156
|
+
params?: AssetExchangeRecordsReq
|
|
157
|
+
): Promise<APIResponseWithTime<any>> {
|
|
158
|
+
return this.getPrivate('v2/private/exchange-order/list', params);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
*
|
|
163
|
+
* API Data Endpoints
|
|
164
|
+
*
|
|
165
|
+
*/
|
|
166
|
+
|
|
167
|
+
getServerTime(): Promise<APIResponseWithTime<{}>> {
|
|
168
|
+
return this.get('v2/public/time');
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
getApiAnnouncements(): Promise<APIResponseWithTime<any[]>> {
|
|
172
|
+
return this.get('v2/public/announcement');
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
*
|
|
177
|
+
* Account Data Endpoints
|
|
178
|
+
*
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Active orders
|
|
183
|
+
*/
|
|
184
|
+
|
|
185
|
+
placeActiveOrder(
|
|
186
|
+
orderRequest: InverseOrderRequest
|
|
187
|
+
): Promise<APIResponseWithTime<any>> {
|
|
188
|
+
return this.postPrivate('v2/private/order/create', orderRequest);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
getActiveOrderList(
|
|
192
|
+
params: InverseActiveOrdersRequest
|
|
193
|
+
): Promise<APIResponseWithTime<any>> {
|
|
194
|
+
return this.getPrivate('v2/private/order/list', params);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
cancelActiveOrder(
|
|
198
|
+
params: InverseCancelOrderRequest
|
|
199
|
+
): Promise<APIResponseWithTime<any>> {
|
|
200
|
+
return this.postPrivate('v2/private/order/cancel', params);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
cancelAllActiveOrders(
|
|
204
|
+
params: SymbolParam
|
|
205
|
+
): Promise<APIResponseWithTime<any>> {
|
|
206
|
+
return this.postPrivate('v2/private/order/cancelAll', params);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
replaceActiveOrder(
|
|
210
|
+
params: InverseReplaceOrderRequest
|
|
211
|
+
): Promise<APIResponseWithTime<any>> {
|
|
212
|
+
return this.postPrivate('v2/private/order/replace', params);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
queryActiveOrder(
|
|
216
|
+
params: InverseGetOrderRequest
|
|
217
|
+
): Promise<APIResponseWithTime<any>> {
|
|
218
|
+
return this.getPrivate('v2/private/order', params);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Conditional orders
|
|
223
|
+
*/
|
|
224
|
+
|
|
225
|
+
placeConditionalOrder(
|
|
226
|
+
params: InverseConditionalOrderRequest
|
|
227
|
+
): Promise<APIResponseWithTime<any>> {
|
|
228
|
+
return this.postPrivate('v2/private/stop-order/create', params);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** get conditional order list. This may see delays, use queryConditionalOrder() for real-time queries */
|
|
232
|
+
getConditionalOrder(
|
|
233
|
+
params: InverseActiveConditionalOrderRequest
|
|
234
|
+
): Promise<APIResponseWithTime<any>> {
|
|
235
|
+
return this.getPrivate('v2/private/stop-order/list', params);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
cancelConditionalOrder(
|
|
239
|
+
params: InverseCancelConditionalOrderRequest
|
|
240
|
+
): Promise<APIResponseWithTime<any>> {
|
|
241
|
+
return this.postPrivate('v2/private/stop-order/cancel', params);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
cancelAllConditionalOrders(
|
|
245
|
+
params: SymbolParam
|
|
246
|
+
): Promise<APIResponseWithTime<any>> {
|
|
247
|
+
return this.postPrivate('v2/private/stop-order/cancelAll', params);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
replaceConditionalOrder(
|
|
251
|
+
params: InverseReplaceConditionalOrderRequest
|
|
252
|
+
): Promise<APIResponseWithTime<any>> {
|
|
253
|
+
return this.postPrivate('v2/private/stop-order/replace', params);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
queryConditionalOrder(
|
|
257
|
+
params: InverseGetOrderRequest
|
|
258
|
+
): Promise<APIResponseWithTime<any>> {
|
|
259
|
+
return this.getPrivate('v2/private/stop-order', params);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Position
|
|
264
|
+
*/
|
|
265
|
+
|
|
266
|
+
getPosition(
|
|
267
|
+
params?: Partial<SymbolParam>
|
|
268
|
+
): Promise<APIResponseWithTime<any>> {
|
|
269
|
+
return this.getPrivate('v2/private/position/list', params);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
changePositionMargin(
|
|
273
|
+
params: InverseChangePositionMarginRequest
|
|
274
|
+
): Promise<APIResponseWithTime<any>> {
|
|
275
|
+
return this.postPrivate('position/change-position-margin', params);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
setTradingStop(
|
|
279
|
+
params: InverseSetTradingStopRequest
|
|
280
|
+
): Promise<APIResponseWithTime<any>> {
|
|
281
|
+
return this.postPrivate('v2/private/position/trading-stop', params);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
setUserLeverage(
|
|
285
|
+
params: InverseSetLeverageRequest
|
|
286
|
+
): Promise<APIResponseWithTime<any>> {
|
|
287
|
+
return this.postPrivate('v2/private/position/leverage/save', params);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
getTradeRecords(
|
|
291
|
+
params: InverseGetTradeRecordsRequest
|
|
292
|
+
): Promise<APIResponseWithTime<any>> {
|
|
293
|
+
return this.getPrivate('v2/private/execution/list', params);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
getClosedPnl(
|
|
297
|
+
params: InverseGetClosedPnlRequest
|
|
298
|
+
): Promise<APIResponseWithTime<any>> {
|
|
299
|
+
return this.getPrivate('v2/private/trade/closed-pnl/list', params);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
setSlTpPositionMode(
|
|
303
|
+
params: InverseSetSlTpPositionModeRequest
|
|
304
|
+
): Promise<APIResponseWithTime<any>> {
|
|
305
|
+
return this.postPrivate('v2/private/tpsl/switch-mode', params);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
setMarginType(
|
|
309
|
+
params: InverseSetMarginTypeRequest
|
|
310
|
+
): Promise<APIResponseWithTime<any>> {
|
|
311
|
+
return this.postPrivate('v2/private/position/switch-isolated', params);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Funding
|
|
316
|
+
*/
|
|
317
|
+
|
|
318
|
+
getLastFundingRate(params: SymbolParam): Promise<APIResponseWithTime<any>> {
|
|
319
|
+
return this.get('v2/public/funding/prev-funding-rate', params);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
getMyLastFundingFee(params: SymbolParam): Promise<APIResponseWithTime<any>> {
|
|
323
|
+
return this.getPrivate('v2/private/funding/prev-funding', params);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
getPredictedFunding(params: SymbolParam): Promise<APIResponseWithTime<any>> {
|
|
327
|
+
return this.getPrivate('v2/private/funding/predicted-funding', params);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* LCP Info
|
|
332
|
+
*/
|
|
333
|
+
|
|
334
|
+
getLcpInfo(params: SymbolParam): Promise<APIResponseWithTime<any>> {
|
|
335
|
+
return this.getPrivate('v2/private/account/lcp', params);
|
|
336
|
+
}
|
|
337
|
+
}
|