bybit-api 2.1.10 → 2.2.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.
- package/lib/constants/enum.d.ts +30 -0
- package/lib/constants/enum.js +31 -1
- package/lib/constants/enum.js.map +1 -1
- package/lib/index.d.ts +10 -10
- package/lib/inverse-client.d.ts +69 -58
- package/lib/inverse-client.js +109 -71
- package/lib/inverse-client.js.map +1 -1
- package/lib/inverse-futures-client.d.ts +85 -50
- package/lib/inverse-futures-client.js +124 -50
- package/lib/inverse-futures-client.js.map +1 -1
- package/lib/linear-client.d.ts +75 -45
- package/lib/linear-client.js +113 -42
- package/lib/linear-client.js.map +1 -1
- package/lib/logger.js +1 -1
- package/lib/spot-client.d.ts +22 -23
- package/lib/spot-client.js +15 -16
- package/lib/spot-client.js.map +1 -1
- package/lib/types/shared.d.ts +7 -3
- package/lib/types/spot.d.ts +15 -0
- package/lib/util/BaseRestClient.d.ts +13 -9
- package/lib/util/BaseRestClient.js +65 -27
- package/lib/util/BaseRestClient.js.map +1 -1
- package/lib/util/WsStore.d.ts +2 -3
- package/lib/util/WsStore.js +3 -3
- package/lib/util/WsStore.js.map +1 -1
- package/lib/util/browser-support.js +3 -2
- package/lib/util/browser-support.js.map +1 -1
- package/lib/util/node-support.js +1 -4
- package/lib/util/node-support.js.map +1 -1
- package/lib/util/requestUtils.d.ts +8 -1
- package/lib/util/requestUtils.js +22 -10
- package/lib/util/requestUtils.js.map +1 -1
- package/lib/websocket-client.d.ts +2 -1
- package/lib/websocket-client.js +54 -36
- package/lib/websocket-client.js.map +1 -1
- package/package.json +1 -1
- package/lib/shared-endpoints.d.ts +0 -48
- package/lib/shared-endpoints.js +0 -91
- package/lib/shared-endpoints.js.map +0 -1
- package/lib/util/requestWrapper.d.ts +0 -37
- package/lib/util/requestWrapper.js +0 -154
- package/lib/util/requestWrapper.js.map +0 -1
package/lib/constants/enum.d.ts
CHANGED
|
@@ -8,3 +8,33 @@ export declare const positionTpSlModeEnum: {
|
|
|
8
8
|
/** Partial take profit/stop loss mode (multiple TP and SL orders can be placed, covering portions of the position) */
|
|
9
9
|
readonly Partial: "Partial";
|
|
10
10
|
};
|
|
11
|
+
export declare const API_ERROR_CODE: {
|
|
12
|
+
readonly BALANCE_INSUFFICIENT_SPOT: -1131;
|
|
13
|
+
readonly ORDER_NOT_FOUND_OR_TOO_LATE_SPOT: -2013;
|
|
14
|
+
/** This could mean bad request, incorrect value types or even incorrect/missing values */
|
|
15
|
+
readonly PARAMS_MISSING_OR_WRONG: 10001;
|
|
16
|
+
readonly ORDER_NOT_FOUND_OR_TOO_LATE: 20001;
|
|
17
|
+
readonly POSITION_STATUS_NOT_NORMAL: 30013;
|
|
18
|
+
readonly CANNOT_SET_TRADING_STOP_FOR_ZERO_POS: 30024;
|
|
19
|
+
/** Seen when placing an order */
|
|
20
|
+
readonly INSUFFICIENT_BALANCE_FOR_ORDER_COST: 30031;
|
|
21
|
+
readonly POSITION_IDX_NOT_MATCH_POSITION_MODE: 30041;
|
|
22
|
+
/** Seen if a conditional order is too large */
|
|
23
|
+
readonly INSUFFICIENT_BALANCE: 30042;
|
|
24
|
+
/** E.g. trying to change position margin while on cross */
|
|
25
|
+
readonly POSITION_IS_CROSS_MARGIN: 30056;
|
|
26
|
+
readonly POSITION_MODE_NOT_MODIFIED: 30083;
|
|
27
|
+
readonly ISOLATED_NOT_MODIFIED: 30084;
|
|
28
|
+
readonly RISK_LIMIT_NOT_EXISTS: 30090;
|
|
29
|
+
readonly LEVERAGE_NOT_MODIFIED: 34036;
|
|
30
|
+
readonly SAME_SLTP_MODE: 37002;
|
|
31
|
+
readonly ORDER_NOT_FOUND_OR_TOO_LATE_LINEAR: 130010;
|
|
32
|
+
readonly ORDER_COST_NOT_AVAILABLE: 130021;
|
|
33
|
+
readonly CANNOT_SET_LINEAR_TRADING_STOP_FOR_ZERO_POS: 130024;
|
|
34
|
+
readonly ISOLATED_NOT_MODIFIED_LINEAR: 130056;
|
|
35
|
+
readonly POSITION_SIZE_IS_ZERO: 130057;
|
|
36
|
+
readonly AUTO_ADD_MARGIN_NOT_MODIFIED: 130060;
|
|
37
|
+
readonly INSUFFICIENT_BALANCE_FOR_ORDER_COST_LINEAR: 130080;
|
|
38
|
+
readonly SAME_SLTP_MODE_LINEAR: 130150;
|
|
39
|
+
readonly RISK_ID_NOT_MODIFIED: 134026;
|
|
40
|
+
};
|
package/lib/constants/enum.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.positionTpSlModeEnum = exports.linearPositionModeEnum = void 0;
|
|
3
|
+
exports.API_ERROR_CODE = exports.positionTpSlModeEnum = exports.linearPositionModeEnum = void 0;
|
|
4
4
|
exports.linearPositionModeEnum = {
|
|
5
5
|
OneWayMode: 'MergedSingle',
|
|
6
6
|
HedgeMode: 'BothSide',
|
|
@@ -11,4 +11,34 @@ exports.positionTpSlModeEnum = {
|
|
|
11
11
|
/** Partial take profit/stop loss mode (multiple TP and SL orders can be placed, covering portions of the position) */
|
|
12
12
|
Partial: 'Partial',
|
|
13
13
|
};
|
|
14
|
+
exports.API_ERROR_CODE = {
|
|
15
|
+
BALANCE_INSUFFICIENT_SPOT: -1131,
|
|
16
|
+
ORDER_NOT_FOUND_OR_TOO_LATE_SPOT: -2013,
|
|
17
|
+
/** This could mean bad request, incorrect value types or even incorrect/missing values */
|
|
18
|
+
PARAMS_MISSING_OR_WRONG: 10001,
|
|
19
|
+
ORDER_NOT_FOUND_OR_TOO_LATE: 20001,
|
|
20
|
+
POSITION_STATUS_NOT_NORMAL: 30013,
|
|
21
|
+
CANNOT_SET_TRADING_STOP_FOR_ZERO_POS: 30024,
|
|
22
|
+
/** Seen when placing an order */
|
|
23
|
+
INSUFFICIENT_BALANCE_FOR_ORDER_COST: 30031,
|
|
24
|
+
POSITION_IDX_NOT_MATCH_POSITION_MODE: 30041,
|
|
25
|
+
/** Seen if a conditional order is too large */
|
|
26
|
+
INSUFFICIENT_BALANCE: 30042,
|
|
27
|
+
/** E.g. trying to change position margin while on cross */
|
|
28
|
+
POSITION_IS_CROSS_MARGIN: 30056,
|
|
29
|
+
POSITION_MODE_NOT_MODIFIED: 30083,
|
|
30
|
+
ISOLATED_NOT_MODIFIED: 30084,
|
|
31
|
+
RISK_LIMIT_NOT_EXISTS: 30090,
|
|
32
|
+
LEVERAGE_NOT_MODIFIED: 34036,
|
|
33
|
+
SAME_SLTP_MODE: 37002,
|
|
34
|
+
ORDER_NOT_FOUND_OR_TOO_LATE_LINEAR: 130010,
|
|
35
|
+
ORDER_COST_NOT_AVAILABLE: 130021,
|
|
36
|
+
CANNOT_SET_LINEAR_TRADING_STOP_FOR_ZERO_POS: 130024,
|
|
37
|
+
ISOLATED_NOT_MODIFIED_LINEAR: 130056,
|
|
38
|
+
POSITION_SIZE_IS_ZERO: 130057,
|
|
39
|
+
AUTO_ADD_MARGIN_NOT_MODIFIED: 130060,
|
|
40
|
+
INSUFFICIENT_BALANCE_FOR_ORDER_COST_LINEAR: 130080,
|
|
41
|
+
SAME_SLTP_MODE_LINEAR: 130150,
|
|
42
|
+
RISK_ID_NOT_MODIFIED: 134026,
|
|
43
|
+
};
|
|
14
44
|
//# sourceMappingURL=enum.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../src/constants/enum.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG;IACpC,UAAU,EAAE,cAAc;IAC1B,SAAS,EAAE,UAAU;CACb,CAAC;AAEE,QAAA,oBAAoB,GAAG;IAClC,4HAA4H;IAC5H,IAAI,EAAE,MAAM;IACZ,sHAAsH;IACtH,OAAO,EAAE,SAAS;CACV,CAAC"}
|
|
1
|
+
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../src/constants/enum.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG;IACpC,UAAU,EAAE,cAAc;IAC1B,SAAS,EAAE,UAAU;CACb,CAAC;AAEE,QAAA,oBAAoB,GAAG;IAClC,4HAA4H;IAC5H,IAAI,EAAE,MAAM;IACZ,sHAAsH;IACtH,OAAO,EAAE,SAAS;CACV,CAAC;AAEE,QAAA,cAAc,GAAG;IAC5B,yBAAyB,EAAE,CAAC,IAAI;IAChC,gCAAgC,EAAE,CAAC,IAAI;IACvC,0FAA0F;IAC1F,uBAAuB,EAAE,KAAK;IAC9B,2BAA2B,EAAE,KAAK;IAClC,0BAA0B,EAAE,KAAK;IACjC,oCAAoC,EAAE,KAAK;IAC3C,iCAAiC;IACjC,mCAAmC,EAAE,KAAK;IAC1C,oCAAoC,EAAE,KAAK;IAC3C,+CAA+C;IAC/C,oBAAoB,EAAE,KAAK;IAC3B,2DAA2D;IAC3D,wBAAwB,EAAE,KAAK;IAC/B,0BAA0B,EAAE,KAAK;IACjC,qBAAqB,EAAE,KAAK;IAC5B,qBAAqB,EAAE,KAAK;IAC5B,qBAAqB,EAAE,KAAK;IAC5B,cAAc,EAAE,KAAK;IACrB,kCAAkC,EAAE,MAAM;IAC1C,wBAAwB,EAAE,MAAM;IAChC,2CAA2C,EAAE,MAAM;IACnD,4BAA4B,EAAE,MAAM;IACpC,qBAAqB,EAAE,MAAM;IAC7B,4BAA4B,EAAE,MAAM;IACpC,0CAA0C,EAAE,MAAM;IAClD,qBAAqB,EAAE,MAAM;IAC7B,oBAAoB,EAAE,MAAM;CACpB,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
1
|
+
export * from './inverse-client';
|
|
2
|
+
export * from './inverse-futures-client';
|
|
3
|
+
export * from './linear-client';
|
|
4
|
+
export * from './spot-client';
|
|
5
|
+
export * from './websocket-client';
|
|
6
|
+
export * from './logger';
|
|
7
|
+
export * from './types/shared';
|
|
8
|
+
export * from './types/spot';
|
|
9
|
+
export * from './util/WsStore';
|
|
10
|
+
export * from './constants/enum';
|
package/lib/inverse-client.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
export declare class InverseClient extends SharedEndpoints {
|
|
7
|
-
protected requestWrapper: RequestWrapper;
|
|
2
|
+
import { RestClientOptions } from './util/requestUtils';
|
|
3
|
+
import { APIResponseWithTime, AssetExchangeRecordsReq, CoinParam, SymbolInfo, SymbolIntervalFromLimitParam, SymbolLimitParam, SymbolParam, SymbolPeriodLimitParam, WalletFundRecordsReq, WithdrawRecordsReq } from './types/shared';
|
|
4
|
+
import BaseRestClient from './util/BaseRestClient';
|
|
5
|
+
export declare class InverseClient extends BaseRestClient {
|
|
8
6
|
/**
|
|
9
7
|
* @public Creates an instance of the inverse REST API client.
|
|
10
8
|
*
|
|
@@ -15,24 +13,53 @@ export declare class InverseClient extends SharedEndpoints {
|
|
|
15
13
|
* @param {AxiosRequestConfig} [requestOptions={}] HTTP networking options for axios
|
|
16
14
|
*/
|
|
17
15
|
constructor(key?: string | undefined, secret?: string | undefined, useLivenet?: boolean, restClientOptions?: RestClientOptions, requestOptions?: AxiosRequestConfig);
|
|
16
|
+
fetchServerTime(): Promise<number>;
|
|
18
17
|
/**
|
|
19
18
|
*
|
|
20
19
|
* Market Data Endpoints
|
|
21
20
|
*
|
|
22
21
|
*/
|
|
23
|
-
|
|
22
|
+
getOrderBook(params: SymbolParam): Promise<APIResponseWithTime<any[]>>;
|
|
23
|
+
getKline(params: SymbolIntervalFromLimitParam): Promise<APIResponseWithTime<any[]>>;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Get latest information for symbol
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
getTickers(params?: Partial<SymbolParam>): Promise<APIResponseWithTime<any[]>>;
|
|
28
|
+
getTrades(params: SymbolLimitParam): Promise<APIResponseWithTime<any[]>>;
|
|
29
|
+
getSymbols(): Promise<APIResponseWithTime<SymbolInfo[]>>;
|
|
30
|
+
getMarkPriceKline(params: SymbolIntervalFromLimitParam): Promise<APIResponseWithTime<any[]>>;
|
|
31
|
+
getIndexPriceKline(params: SymbolIntervalFromLimitParam): Promise<APIResponseWithTime<any[]>>;
|
|
32
|
+
getPremiumIndexKline(params: SymbolIntervalFromLimitParam): Promise<APIResponseWithTime<any[]>>;
|
|
28
33
|
/**
|
|
29
|
-
*
|
|
34
|
+
*
|
|
35
|
+
* Market Data : Advanced
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
getOpenInterest(params: SymbolPeriodLimitParam): Promise<APIResponseWithTime<any[]>>;
|
|
39
|
+
getLatestBigDeal(params: SymbolLimitParam): Promise<APIResponseWithTime<any[]>>;
|
|
40
|
+
getLongShortRatio(params: SymbolPeriodLimitParam): Promise<APIResponseWithTime<any[]>>;
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* Account Data Endpoints
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
getApiKeyInfo(): Promise<APIResponseWithTime<any>>;
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* Wallet Data Endpoints
|
|
50
|
+
*
|
|
30
51
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
52
|
+
getWalletBalance(params?: Partial<CoinParam>): Promise<APIResponseWithTime<any>>;
|
|
53
|
+
getWalletFundRecords(params?: WalletFundRecordsReq): Promise<APIResponseWithTime<any>>;
|
|
54
|
+
getWithdrawRecords(params?: WithdrawRecordsReq): Promise<APIResponseWithTime<any>>;
|
|
55
|
+
getAssetExchangeRecords(params?: AssetExchangeRecordsReq): Promise<APIResponseWithTime<any>>;
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* API Data Endpoints
|
|
59
|
+
*
|
|
60
|
+
*/
|
|
61
|
+
getServerTime(): Promise<APIResponseWithTime<{}>>;
|
|
62
|
+
getApiAnnouncements(): Promise<APIResponseWithTime<any[]>>;
|
|
36
63
|
/**
|
|
37
64
|
*
|
|
38
65
|
* Account Data Endpoints
|
|
@@ -55,20 +82,20 @@ export declare class InverseClient extends SharedEndpoints {
|
|
|
55
82
|
sl_trigger_by?: 'LastPrice' | 'MarkPrice' | 'IndexPrice';
|
|
56
83
|
close_on_trigger?: boolean;
|
|
57
84
|
order_link_id?: string;
|
|
58
|
-
}):
|
|
85
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
59
86
|
getActiveOrderList(params: {
|
|
60
87
|
symbol: string;
|
|
61
88
|
order_status?: string;
|
|
62
89
|
direction?: string;
|
|
63
90
|
limit?: number;
|
|
64
91
|
cursor?: string;
|
|
65
|
-
}):
|
|
92
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
66
93
|
cancelActiveOrder(params: {
|
|
67
94
|
symbol: string;
|
|
68
95
|
order_id?: string;
|
|
69
96
|
order_link_id?: string;
|
|
70
|
-
}):
|
|
71
|
-
cancelAllActiveOrders(params: SymbolParam):
|
|
97
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
98
|
+
cancelAllActiveOrders(params: SymbolParam): Promise<APIResponseWithTime<any>>;
|
|
72
99
|
replaceActiveOrder(params: {
|
|
73
100
|
order_id?: string;
|
|
74
101
|
order_link_id?: string;
|
|
@@ -79,12 +106,12 @@ export declare class InverseClient extends SharedEndpoints {
|
|
|
79
106
|
stop_loss?: number;
|
|
80
107
|
tp_trigger_by?: string;
|
|
81
108
|
sl_trigger_by?: string;
|
|
82
|
-
}):
|
|
109
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
83
110
|
queryActiveOrder(params: {
|
|
84
111
|
order_id?: string;
|
|
85
112
|
order_link_id?: string;
|
|
86
113
|
symbol: string;
|
|
87
|
-
}):
|
|
114
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
88
115
|
/**
|
|
89
116
|
* Conditional orders
|
|
90
117
|
*/
|
|
@@ -100,20 +127,21 @@ export declare class InverseClient extends SharedEndpoints {
|
|
|
100
127
|
trigger_by?: string;
|
|
101
128
|
close_on_trigger?: boolean;
|
|
102
129
|
order_link_id?: string;
|
|
103
|
-
}):
|
|
130
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
131
|
+
/** get conditional order list. This may see delays, use queryConditionalOrder() for real-time queries */
|
|
104
132
|
getConditionalOrder(params: {
|
|
105
133
|
symbol: string;
|
|
106
134
|
stop_order_status?: string;
|
|
107
135
|
direction?: string;
|
|
108
136
|
limit?: number;
|
|
109
137
|
cursor?: string;
|
|
110
|
-
}):
|
|
138
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
111
139
|
cancelConditionalOrder(params: {
|
|
112
140
|
symbol: string;
|
|
113
141
|
stop_order_id?: string;
|
|
114
142
|
order_link_id?: string;
|
|
115
|
-
}):
|
|
116
|
-
cancelAllConditionalOrders(params: SymbolParam):
|
|
143
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
144
|
+
cancelAllConditionalOrders(params: SymbolParam): Promise<APIResponseWithTime<any>>;
|
|
117
145
|
replaceConditionalOrder(params: {
|
|
118
146
|
stop_order_id?: string;
|
|
119
147
|
order_link_id?: string;
|
|
@@ -121,28 +149,20 @@ export declare class InverseClient extends SharedEndpoints {
|
|
|
121
149
|
p_r_qty?: number;
|
|
122
150
|
p_r_price?: string;
|
|
123
151
|
p_r_trigger_price?: string;
|
|
124
|
-
}):
|
|
152
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
125
153
|
queryConditionalOrder(params: {
|
|
126
154
|
symbol: string;
|
|
127
155
|
stop_order_id?: string;
|
|
128
156
|
order_link_id?: string;
|
|
129
|
-
}):
|
|
157
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
130
158
|
/**
|
|
131
159
|
* Position
|
|
132
160
|
*/
|
|
133
|
-
|
|
134
|
-
* @deprecated use getPosition() instead
|
|
135
|
-
*/
|
|
136
|
-
getUserLeverage(): GenericAPIResponse;
|
|
137
|
-
getPosition(params?: Partial<SymbolParam>): GenericAPIResponse;
|
|
138
|
-
/**
|
|
139
|
-
* @deprecated use getPosition() instead
|
|
140
|
-
*/
|
|
141
|
-
getPositions(): GenericAPIResponse;
|
|
161
|
+
getPosition(params?: Partial<SymbolParam>): Promise<APIResponseWithTime<any>>;
|
|
142
162
|
changePositionMargin(params: {
|
|
143
163
|
symbol: string;
|
|
144
164
|
margin: string;
|
|
145
|
-
}):
|
|
165
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
146
166
|
setTradingStop(params: {
|
|
147
167
|
symbol: string;
|
|
148
168
|
take_profit?: number;
|
|
@@ -151,16 +171,12 @@ export declare class InverseClient extends SharedEndpoints {
|
|
|
151
171
|
tp_trigger_by?: string;
|
|
152
172
|
sl_trigger_by?: string;
|
|
153
173
|
new_trailing_active?: number;
|
|
154
|
-
}):
|
|
174
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
155
175
|
setUserLeverage(params: {
|
|
156
176
|
symbol: string;
|
|
157
177
|
leverage: number;
|
|
158
178
|
leverage_only?: boolean;
|
|
159
|
-
}):
|
|
160
|
-
/**
|
|
161
|
-
* @deprecated use setUserLeverage() instead
|
|
162
|
-
*/
|
|
163
|
-
changeUserLeverage(params: any): GenericAPIResponse;
|
|
179
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
164
180
|
getTradeRecords(params: {
|
|
165
181
|
order_id?: string;
|
|
166
182
|
symbol: string;
|
|
@@ -168,7 +184,7 @@ export declare class InverseClient extends SharedEndpoints {
|
|
|
168
184
|
page?: number;
|
|
169
185
|
limit?: number;
|
|
170
186
|
order?: string;
|
|
171
|
-
}):
|
|
187
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
172
188
|
getClosedPnl(params: {
|
|
173
189
|
symbol: string;
|
|
174
190
|
start_time?: number;
|
|
@@ -176,38 +192,33 @@ export declare class InverseClient extends SharedEndpoints {
|
|
|
176
192
|
exec_type?: string;
|
|
177
193
|
page?: number;
|
|
178
194
|
limit?: number;
|
|
179
|
-
}):
|
|
180
|
-
setPositionMode(params: {
|
|
181
|
-
symbol: string;
|
|
182
|
-
mode: 0 | 3;
|
|
183
|
-
}): GenericAPIResponse;
|
|
195
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
184
196
|
setSlTpPositionMode(params: {
|
|
185
197
|
symbol: string;
|
|
186
198
|
tp_sl_mode: 'Full' | 'Partial';
|
|
187
|
-
}):
|
|
199
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
188
200
|
setMarginType(params: {
|
|
189
201
|
symbol: string;
|
|
190
202
|
is_isolated: boolean;
|
|
191
203
|
buy_leverage: number;
|
|
192
204
|
sell_leverage: number;
|
|
193
|
-
}):
|
|
205
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
194
206
|
/**
|
|
195
207
|
* Risk Limit
|
|
196
208
|
*/
|
|
197
|
-
getRiskLimitList():
|
|
209
|
+
getRiskLimitList(): Promise<APIResponseWithTime<any>>;
|
|
198
210
|
setRiskLimit(params: {
|
|
199
211
|
symbol: string;
|
|
200
212
|
risk_id: string;
|
|
201
|
-
}):
|
|
213
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
202
214
|
/**
|
|
203
215
|
* Funding
|
|
204
216
|
*/
|
|
205
|
-
getLastFundingRate(params: SymbolParam):
|
|
206
|
-
getMyLastFundingFee(params: SymbolParam):
|
|
207
|
-
getPredictedFunding(params: SymbolParam):
|
|
217
|
+
getLastFundingRate(params: SymbolParam): Promise<APIResponseWithTime<any>>;
|
|
218
|
+
getMyLastFundingFee(params: SymbolParam): Promise<APIResponseWithTime<any>>;
|
|
219
|
+
getPredictedFunding(params: SymbolParam): Promise<APIResponseWithTime<any>>;
|
|
208
220
|
/**
|
|
209
221
|
* LCP Info
|
|
210
222
|
*/
|
|
211
|
-
getLcpInfo(params: SymbolParam):
|
|
212
|
-
getAPIKeyInfo(): GenericAPIResponse;
|
|
223
|
+
getLcpInfo(params: SymbolParam): Promise<APIResponseWithTime<any>>;
|
|
213
224
|
}
|
package/lib/inverse-client.js
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
5
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
15
|
exports.InverseClient = void 0;
|
|
7
16
|
const requestUtils_1 = require("./util/requestUtils");
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
class InverseClient extends shared_endpoints_1.default {
|
|
17
|
+
const BaseRestClient_1 = __importDefault(require("./util/BaseRestClient"));
|
|
18
|
+
class InverseClient extends BaseRestClient_1.default {
|
|
11
19
|
/**
|
|
12
20
|
* @public Creates an instance of the inverse REST API client.
|
|
13
21
|
*
|
|
@@ -18,41 +26,96 @@ class InverseClient extends shared_endpoints_1.default {
|
|
|
18
26
|
* @param {AxiosRequestConfig} [requestOptions={}] HTTP networking options for axios
|
|
19
27
|
*/
|
|
20
28
|
constructor(key, secret, useLivenet = false, restClientOptions = {}, requestOptions = {}) {
|
|
21
|
-
super();
|
|
22
|
-
this.requestWrapper = new requestWrapper_1.default(key, secret, requestUtils_1.getRestBaseUrl(useLivenet, restClientOptions), restClientOptions, requestOptions);
|
|
29
|
+
super(key, secret, requestUtils_1.getRestBaseUrl(useLivenet, restClientOptions), restClientOptions, requestOptions, requestUtils_1.REST_CLIENT_TYPE_ENUM.inverse);
|
|
23
30
|
return this;
|
|
24
31
|
}
|
|
32
|
+
fetchServerTime() {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const res = yield this.getServerTime();
|
|
35
|
+
return Number(res.time_now);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
25
38
|
/**
|
|
26
39
|
*
|
|
27
40
|
* Market Data Endpoints
|
|
28
41
|
*
|
|
29
42
|
*/
|
|
30
|
-
|
|
31
|
-
return this.
|
|
43
|
+
getOrderBook(params) {
|
|
44
|
+
return this.get('v2/public/orderBook/L2', params);
|
|
32
45
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*/
|
|
36
|
-
getLatestInformation(params) {
|
|
37
|
-
return this.getTickers(params);
|
|
46
|
+
getKline(params) {
|
|
47
|
+
return this.get('v2/public/kline/list', params);
|
|
38
48
|
}
|
|
39
49
|
/**
|
|
40
|
-
*
|
|
50
|
+
* Get latest information for symbol
|
|
41
51
|
*/
|
|
42
|
-
|
|
43
|
-
return this.
|
|
52
|
+
getTickers(params) {
|
|
53
|
+
return this.get('v2/public/tickers', params);
|
|
44
54
|
}
|
|
45
55
|
getTrades(params) {
|
|
46
|
-
return this.
|
|
56
|
+
return this.get('v2/public/trading-records', params);
|
|
57
|
+
}
|
|
58
|
+
getSymbols() {
|
|
59
|
+
return this.get('v2/public/symbols');
|
|
47
60
|
}
|
|
48
61
|
getMarkPriceKline(params) {
|
|
49
|
-
return this.
|
|
62
|
+
return this.get('v2/public/mark-price-kline', params);
|
|
50
63
|
}
|
|
51
64
|
getIndexPriceKline(params) {
|
|
52
|
-
return this.
|
|
65
|
+
return this.get('v2/public/index-price-kline', params);
|
|
53
66
|
}
|
|
54
67
|
getPremiumIndexKline(params) {
|
|
55
|
-
return this.
|
|
68
|
+
return this.get('v2/public/premium-index-kline', params);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
*
|
|
72
|
+
* Market Data : Advanced
|
|
73
|
+
*
|
|
74
|
+
*/
|
|
75
|
+
getOpenInterest(params) {
|
|
76
|
+
return this.get('v2/public/open-interest', params);
|
|
77
|
+
}
|
|
78
|
+
getLatestBigDeal(params) {
|
|
79
|
+
return this.get('v2/public/big-deal', params);
|
|
80
|
+
}
|
|
81
|
+
getLongShortRatio(params) {
|
|
82
|
+
return this.get('v2/public/account-ratio', params);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
*
|
|
86
|
+
* Account Data Endpoints
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
getApiKeyInfo() {
|
|
90
|
+
return this.getPrivate('v2/private/account/api-key');
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
*
|
|
94
|
+
* Wallet Data Endpoints
|
|
95
|
+
*
|
|
96
|
+
*/
|
|
97
|
+
getWalletBalance(params) {
|
|
98
|
+
return this.getPrivate('v2/private/wallet/balance', params);
|
|
99
|
+
}
|
|
100
|
+
getWalletFundRecords(params) {
|
|
101
|
+
return this.getPrivate('v2/private/wallet/fund/records', params);
|
|
102
|
+
}
|
|
103
|
+
getWithdrawRecords(params) {
|
|
104
|
+
return this.getPrivate('v2/private/wallet/withdraw/list', params);
|
|
105
|
+
}
|
|
106
|
+
getAssetExchangeRecords(params) {
|
|
107
|
+
return this.getPrivate('v2/private/exchange-order/list', params);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
*
|
|
111
|
+
* API Data Endpoints
|
|
112
|
+
*
|
|
113
|
+
*/
|
|
114
|
+
getServerTime() {
|
|
115
|
+
return this.get('v2/public/time');
|
|
116
|
+
}
|
|
117
|
+
getApiAnnouncements() {
|
|
118
|
+
return this.get('v2/public/announcement');
|
|
56
119
|
}
|
|
57
120
|
/**
|
|
58
121
|
*
|
|
@@ -63,124 +126,99 @@ class InverseClient extends shared_endpoints_1.default {
|
|
|
63
126
|
* Active orders
|
|
64
127
|
*/
|
|
65
128
|
placeActiveOrder(orderRequest) {
|
|
66
|
-
return this.
|
|
129
|
+
return this.postPrivate('v2/private/order/create', orderRequest);
|
|
67
130
|
}
|
|
68
131
|
getActiveOrderList(params) {
|
|
69
|
-
return this.
|
|
132
|
+
return this.getPrivate('v2/private/order/list', params);
|
|
70
133
|
}
|
|
71
134
|
cancelActiveOrder(params) {
|
|
72
|
-
return this.
|
|
135
|
+
return this.postPrivate('v2/private/order/cancel', params);
|
|
73
136
|
}
|
|
74
137
|
cancelAllActiveOrders(params) {
|
|
75
|
-
return this.
|
|
138
|
+
return this.postPrivate('v2/private/order/cancelAll', params);
|
|
76
139
|
}
|
|
77
140
|
replaceActiveOrder(params) {
|
|
78
|
-
return this.
|
|
141
|
+
return this.postPrivate('v2/private/order/replace', params);
|
|
79
142
|
}
|
|
80
143
|
queryActiveOrder(params) {
|
|
81
|
-
return this.
|
|
144
|
+
return this.getPrivate('v2/private/order', params);
|
|
82
145
|
}
|
|
83
146
|
/**
|
|
84
147
|
* Conditional orders
|
|
85
148
|
*/
|
|
86
149
|
placeConditionalOrder(params) {
|
|
87
|
-
return this.
|
|
150
|
+
return this.postPrivate('v2/private/stop-order/create', params);
|
|
88
151
|
}
|
|
152
|
+
/** get conditional order list. This may see delays, use queryConditionalOrder() for real-time queries */
|
|
89
153
|
getConditionalOrder(params) {
|
|
90
|
-
return this.
|
|
154
|
+
return this.getPrivate('v2/private/stop-order/list', params);
|
|
91
155
|
}
|
|
92
156
|
cancelConditionalOrder(params) {
|
|
93
|
-
return this.
|
|
157
|
+
return this.postPrivate('v2/private/stop-order/cancel', params);
|
|
94
158
|
}
|
|
95
159
|
cancelAllConditionalOrders(params) {
|
|
96
|
-
return this.
|
|
160
|
+
return this.postPrivate('v2/private/stop-order/cancelAll', params);
|
|
97
161
|
}
|
|
98
162
|
replaceConditionalOrder(params) {
|
|
99
|
-
return this.
|
|
163
|
+
return this.postPrivate('v2/private/stop-order/replace', params);
|
|
100
164
|
}
|
|
101
165
|
queryConditionalOrder(params) {
|
|
102
|
-
return this.
|
|
166
|
+
return this.getPrivate('v2/private/stop-order', params);
|
|
103
167
|
}
|
|
104
168
|
/**
|
|
105
169
|
* Position
|
|
106
170
|
*/
|
|
107
|
-
/**
|
|
108
|
-
* @deprecated use getPosition() instead
|
|
109
|
-
*/
|
|
110
|
-
getUserLeverage() {
|
|
111
|
-
return this.requestWrapper.get('user/leverage');
|
|
112
|
-
}
|
|
113
171
|
getPosition(params) {
|
|
114
|
-
return this.
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* @deprecated use getPosition() instead
|
|
118
|
-
*/
|
|
119
|
-
getPositions() {
|
|
120
|
-
return this.requestWrapper.get('position/list');
|
|
172
|
+
return this.getPrivate('v2/private/position/list', params);
|
|
121
173
|
}
|
|
122
174
|
changePositionMargin(params) {
|
|
123
|
-
return this.
|
|
175
|
+
return this.postPrivate('position/change-position-margin', params);
|
|
124
176
|
}
|
|
125
177
|
setTradingStop(params) {
|
|
126
|
-
return this.
|
|
178
|
+
return this.postPrivate('v2/private/position/trading-stop', params);
|
|
127
179
|
}
|
|
128
180
|
setUserLeverage(params) {
|
|
129
|
-
return this.
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* @deprecated use setUserLeverage() instead
|
|
133
|
-
*/
|
|
134
|
-
changeUserLeverage(params) {
|
|
135
|
-
return this.setUserLeverage(params);
|
|
181
|
+
return this.postPrivate('v2/private/position/leverage/save', params);
|
|
136
182
|
}
|
|
137
183
|
getTradeRecords(params) {
|
|
138
|
-
return this.
|
|
184
|
+
return this.getPrivate('v2/private/execution/list', params);
|
|
139
185
|
}
|
|
140
186
|
getClosedPnl(params) {
|
|
141
|
-
return this.
|
|
142
|
-
}
|
|
143
|
-
setPositionMode(params) {
|
|
144
|
-
return this.requestWrapper.post('v2/private/position/switch-mode', params);
|
|
187
|
+
return this.getPrivate('v2/private/trade/closed-pnl/list', params);
|
|
145
188
|
}
|
|
146
189
|
setSlTpPositionMode(params) {
|
|
147
|
-
return this.
|
|
190
|
+
return this.postPrivate('v2/private/tpsl/switch-mode', params);
|
|
148
191
|
}
|
|
149
192
|
setMarginType(params) {
|
|
150
|
-
return this.
|
|
193
|
+
return this.postPrivate('v2/private/position/switch-isolated', params);
|
|
151
194
|
}
|
|
152
195
|
/**
|
|
153
196
|
* Risk Limit
|
|
154
197
|
*/
|
|
155
198
|
getRiskLimitList() {
|
|
156
|
-
return this.
|
|
199
|
+
return this.getPrivate('open-api/wallet/risk-limit/list');
|
|
157
200
|
}
|
|
158
201
|
setRiskLimit(params) {
|
|
159
|
-
return this.
|
|
202
|
+
return this.postPrivate('open-api/wallet/risk-limit', params);
|
|
160
203
|
}
|
|
161
204
|
/**
|
|
162
205
|
* Funding
|
|
163
206
|
*/
|
|
164
207
|
getLastFundingRate(params) {
|
|
165
|
-
return this.
|
|
208
|
+
return this.get('v2/public/funding/prev-funding-rate', params);
|
|
166
209
|
}
|
|
167
210
|
getMyLastFundingFee(params) {
|
|
168
|
-
return this.
|
|
211
|
+
return this.getPrivate('v2/private/funding/prev-funding', params);
|
|
169
212
|
}
|
|
170
213
|
getPredictedFunding(params) {
|
|
171
|
-
return this.
|
|
214
|
+
return this.getPrivate('v2/private/funding/predicted-funding', params);
|
|
172
215
|
}
|
|
173
216
|
/**
|
|
174
217
|
* LCP Info
|
|
175
218
|
*/
|
|
176
219
|
getLcpInfo(params) {
|
|
177
|
-
return this.
|
|
178
|
-
}
|
|
179
|
-
//API Key Info
|
|
180
|
-
getAPIKeyInfo() {
|
|
181
|
-
return this.requestWrapper.get('v2/private/account/api-key');
|
|
220
|
+
return this.getPrivate('v2/private/account/lcp', params);
|
|
182
221
|
}
|
|
183
222
|
}
|
|
184
223
|
exports.InverseClient = InverseClient;
|
|
185
|
-
;
|
|
186
224
|
//# sourceMappingURL=inverse-client.js.map
|