bybit-api 2.1.10 → 2.2.0-beta.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 +63 -26
- 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.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/linear-client.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import SharedEndpoints from './shared-endpoints';
|
|
5
|
-
import { SymbolIntervalFromLimitParam, SymbolLimitParam, SymbolParam } from './types/shared';
|
|
2
|
+
import { RestClientOptions } from './util/requestUtils';
|
|
3
|
+
import { APIResponse, APIResponseWithTime, AssetExchangeRecordsReq, CoinParam, SymbolInfo, SymbolIntervalFromLimitParam, SymbolLimitParam, SymbolParam, SymbolPeriodLimitParam, WalletFundRecordsReq, WithdrawRecordsReq } from './types/shared';
|
|
6
4
|
import { linearPositionModeEnum, positionTpSlModeEnum } from './constants/enum';
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import BaseRestClient from './util/BaseRestClient';
|
|
6
|
+
export declare class LinearClient extends BaseRestClient {
|
|
9
7
|
/**
|
|
10
|
-
* @public Creates an instance of the linear REST API client.
|
|
8
|
+
* @public Creates an instance of the linear (USD Perps) REST API client.
|
|
11
9
|
*
|
|
12
10
|
* @param {string} key - your API key
|
|
13
11
|
* @param {string} secret - your API secret
|
|
@@ -16,17 +14,54 @@ export declare class LinearClient extends SharedEndpoints {
|
|
|
16
14
|
* @param {AxiosRequestConfig} [requestOptions={}] HTTP networking options for axios
|
|
17
15
|
*/
|
|
18
16
|
constructor(key?: string | undefined, secret?: string | undefined, useLivenet?: boolean, restClientOptions?: RestClientOptions, requestOptions?: AxiosRequestConfig);
|
|
17
|
+
fetchServerTime(): Promise<number>;
|
|
19
18
|
/**
|
|
20
19
|
*
|
|
21
20
|
* Market Data Endpoints
|
|
22
21
|
*
|
|
23
22
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
getOrderBook(params: SymbolParam): Promise<APIResponseWithTime<any[]>>;
|
|
24
|
+
getKline(params: SymbolIntervalFromLimitParam): Promise<APIResponseWithTime<any[]>>;
|
|
25
|
+
/**
|
|
26
|
+
* Get latest information for symbol
|
|
27
|
+
*/
|
|
28
|
+
getTickers(params?: Partial<SymbolParam>): Promise<APIResponseWithTime<any[]>>;
|
|
29
|
+
getTrades(params: SymbolLimitParam): Promise<APIResponseWithTime<any[]>>;
|
|
30
|
+
getSymbols(): Promise<APIResponse<SymbolInfo[]>>;
|
|
31
|
+
getLastFundingRate(params: SymbolParam): Promise<APIResponseWithTime<any[]>>;
|
|
32
|
+
getMarkPriceKline(params: SymbolIntervalFromLimitParam): Promise<APIResponseWithTime<any[]>>;
|
|
33
|
+
getIndexPriceKline(params: SymbolIntervalFromLimitParam): Promise<APIResponseWithTime<any[]>>;
|
|
34
|
+
getPremiumIndexKline(params: SymbolIntervalFromLimitParam): Promise<APIResponseWithTime<any[]>>;
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* Market Data : Advanced
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
getOpenInterest(params: SymbolPeriodLimitParam): Promise<APIResponseWithTime<any[]>>;
|
|
41
|
+
getLatestBigDeal(params: SymbolLimitParam): Promise<APIResponseWithTime<any[]>>;
|
|
42
|
+
getLongShortRatio(params: SymbolPeriodLimitParam): Promise<APIResponseWithTime<any[]>>;
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* Account Data Endpoints
|
|
46
|
+
*
|
|
47
|
+
*/
|
|
48
|
+
getApiKeyInfo(): Promise<APIResponseWithTime<any>>;
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* Wallet Data Endpoints
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
getWalletBalance(params?: Partial<CoinParam>): Promise<APIResponseWithTime<any>>;
|
|
55
|
+
getWalletFundRecords(params?: WalletFundRecordsReq): Promise<APIResponseWithTime<any>>;
|
|
56
|
+
getWithdrawRecords(params?: WithdrawRecordsReq): Promise<APIResponseWithTime<any>>;
|
|
57
|
+
getAssetExchangeRecords(params?: AssetExchangeRecordsReq): Promise<APIResponseWithTime<any>>;
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* API Data Endpoints
|
|
61
|
+
*
|
|
62
|
+
*/
|
|
63
|
+
getServerTime(): Promise<APIResponseWithTime<{}>>;
|
|
64
|
+
getApiAnnouncements(): Promise<APIResponseWithTime<any>>;
|
|
30
65
|
/**
|
|
31
66
|
*
|
|
32
67
|
* Account Data Endpoints
|
|
@@ -47,7 +82,7 @@ export declare class LinearClient extends SharedEndpoints {
|
|
|
47
82
|
close_on_trigger: boolean;
|
|
48
83
|
order_link_id?: string;
|
|
49
84
|
position_idx?: number;
|
|
50
|
-
}):
|
|
85
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
51
86
|
getActiveOrderList(params: {
|
|
52
87
|
order_id?: string;
|
|
53
88
|
order_link_id?: string;
|
|
@@ -56,13 +91,13 @@ export declare class LinearClient extends SharedEndpoints {
|
|
|
56
91
|
page?: number;
|
|
57
92
|
limit?: number;
|
|
58
93
|
order_status?: string;
|
|
59
|
-
}):
|
|
94
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
60
95
|
cancelActiveOrder(params: {
|
|
61
96
|
symbol: string;
|
|
62
97
|
order_id?: string;
|
|
63
98
|
order_link_id?: string;
|
|
64
|
-
}):
|
|
65
|
-
cancelAllActiveOrders(params: SymbolParam):
|
|
99
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
100
|
+
cancelAllActiveOrders(params: SymbolParam): Promise<APIResponseWithTime<any>>;
|
|
66
101
|
replaceActiveOrder(params: {
|
|
67
102
|
order_id?: string;
|
|
68
103
|
order_link_id?: string;
|
|
@@ -73,12 +108,12 @@ export declare class LinearClient extends SharedEndpoints {
|
|
|
73
108
|
stop_loss?: number;
|
|
74
109
|
tp_trigger_by?: string;
|
|
75
110
|
sl_trigger_by?: string;
|
|
76
|
-
}):
|
|
111
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
77
112
|
queryActiveOrder(params: {
|
|
78
113
|
order_id?: string;
|
|
79
114
|
order_link_id?: string;
|
|
80
115
|
symbol: string;
|
|
81
|
-
}):
|
|
116
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
82
117
|
/**
|
|
83
118
|
* Conditional orders
|
|
84
119
|
*/
|
|
@@ -99,7 +134,7 @@ export declare class LinearClient extends SharedEndpoints {
|
|
|
99
134
|
stop_loss?: number;
|
|
100
135
|
tp_trigger_by?: string;
|
|
101
136
|
sl_trigger_by?: string;
|
|
102
|
-
}):
|
|
137
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
103
138
|
getConditionalOrder(params: {
|
|
104
139
|
stop_order_id?: string;
|
|
105
140
|
order_link_id?: string;
|
|
@@ -108,13 +143,13 @@ export declare class LinearClient extends SharedEndpoints {
|
|
|
108
143
|
order?: string;
|
|
109
144
|
page?: number;
|
|
110
145
|
limit?: number;
|
|
111
|
-
}):
|
|
146
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
112
147
|
cancelConditionalOrder(params: {
|
|
113
148
|
symbol: string;
|
|
114
149
|
stop_order_id?: string;
|
|
115
150
|
order_link_id?: string;
|
|
116
|
-
}):
|
|
117
|
-
cancelAllConditionalOrders(params: SymbolParam):
|
|
151
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
152
|
+
cancelAllConditionalOrders(params: SymbolParam): Promise<APIResponseWithTime<any>>;
|
|
118
153
|
replaceConditionalOrder(params: {
|
|
119
154
|
stop_order_id?: string;
|
|
120
155
|
order_link_id?: string;
|
|
@@ -126,39 +161,34 @@ export declare class LinearClient extends SharedEndpoints {
|
|
|
126
161
|
stop_loss?: number;
|
|
127
162
|
tp_trigger_by?: string;
|
|
128
163
|
sl_trigger_by?: string;
|
|
129
|
-
}):
|
|
164
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
130
165
|
queryConditionalOrder(params: {
|
|
131
166
|
symbol: string;
|
|
132
167
|
stop_order_id?: string;
|
|
133
168
|
order_link_id?: string;
|
|
134
|
-
}):
|
|
169
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
135
170
|
/**
|
|
136
171
|
* Position
|
|
137
172
|
*/
|
|
138
|
-
getPosition(params?: Partial<SymbolParam>):
|
|
173
|
+
getPosition(params?: Partial<SymbolParam>): Promise<APIResponseWithTime<any>>;
|
|
139
174
|
setAutoAddMargin(params?: {
|
|
140
175
|
symbol: string;
|
|
141
176
|
side: string;
|
|
142
177
|
auto_add_margin: boolean;
|
|
143
|
-
}):
|
|
178
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
144
179
|
setMarginSwitch(params?: {
|
|
145
180
|
symbol: string;
|
|
146
181
|
is_isolated: boolean;
|
|
147
182
|
buy_leverage: number;
|
|
148
183
|
sell_leverage: number;
|
|
149
|
-
}):
|
|
184
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
150
185
|
/**
|
|
151
186
|
* Switch between one-way vs hedge mode. Use `linearPositionModeEnum` for the mode parameter.
|
|
152
187
|
*/
|
|
153
188
|
setPositionMode(params: {
|
|
154
189
|
symbol: string;
|
|
155
190
|
mode: typeof linearPositionModeEnum[keyof typeof linearPositionModeEnum];
|
|
156
|
-
}):
|
|
157
|
-
/** @deprecated use setPositionTpSlMode() instead */
|
|
158
|
-
setSwitchMode(params?: {
|
|
159
|
-
symbol: string;
|
|
160
|
-
tp_sl_mode: typeof positionTpSlModeEnum[keyof typeof positionTpSlModeEnum];
|
|
161
|
-
}): GenericAPIResponse;
|
|
191
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
162
192
|
/**
|
|
163
193
|
* Switch TP/SL mode between full or partial. When set to Partial, TP/SL orders may have a quantity less than the position size.
|
|
164
194
|
* This is set with the setTradingStop() method. Use `positionTpSlModeEnum` for the tp_sl_mode parameter.
|
|
@@ -166,17 +196,17 @@ export declare class LinearClient extends SharedEndpoints {
|
|
|
166
196
|
setPositionTpSlMode(params: {
|
|
167
197
|
symbol: string;
|
|
168
198
|
tp_sl_mode: typeof positionTpSlModeEnum[keyof typeof positionTpSlModeEnum];
|
|
169
|
-
}):
|
|
199
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
170
200
|
setAddReduceMargin(params?: {
|
|
171
201
|
symbol: string;
|
|
172
202
|
side: string;
|
|
173
203
|
margin: number;
|
|
174
|
-
}):
|
|
204
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
175
205
|
setUserLeverage(params: {
|
|
176
206
|
symbol: string;
|
|
177
207
|
buy_leverage: number;
|
|
178
208
|
sell_leverage: number;
|
|
179
|
-
}):
|
|
209
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
180
210
|
setTradingStop(params: {
|
|
181
211
|
symbol: string;
|
|
182
212
|
side: string;
|
|
@@ -187,7 +217,7 @@ export declare class LinearClient extends SharedEndpoints {
|
|
|
187
217
|
sl_trigger_by?: string;
|
|
188
218
|
sl_size?: number;
|
|
189
219
|
tp_size?: number;
|
|
190
|
-
}):
|
|
220
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
191
221
|
getTradeRecords(params: {
|
|
192
222
|
symbol: string;
|
|
193
223
|
start_time?: number;
|
|
@@ -195,7 +225,7 @@ export declare class LinearClient extends SharedEndpoints {
|
|
|
195
225
|
exec_type?: string;
|
|
196
226
|
page?: number;
|
|
197
227
|
limit?: number;
|
|
198
|
-
}):
|
|
228
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
199
229
|
getClosedPnl(params: {
|
|
200
230
|
symbol: string;
|
|
201
231
|
start_time?: number;
|
|
@@ -203,19 +233,19 @@ export declare class LinearClient extends SharedEndpoints {
|
|
|
203
233
|
exec_type?: string;
|
|
204
234
|
page?: number;
|
|
205
235
|
limit?: number;
|
|
206
|
-
}):
|
|
236
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
207
237
|
/**
|
|
208
238
|
* Risk Limit
|
|
209
239
|
*/
|
|
210
|
-
getRiskLimitList(params: SymbolParam):
|
|
240
|
+
getRiskLimitList(params: SymbolParam): Promise<APIResponseWithTime<any>>;
|
|
211
241
|
setRiskLimit(params: {
|
|
212
242
|
symbol: string;
|
|
213
243
|
side: string;
|
|
214
|
-
risk_id:
|
|
215
|
-
}):
|
|
244
|
+
risk_id: number;
|
|
245
|
+
}): Promise<APIResponseWithTime<any>>;
|
|
216
246
|
/**
|
|
217
247
|
* Funding
|
|
218
248
|
*/
|
|
219
|
-
getPredictedFundingFee(params: SymbolParam):
|
|
220
|
-
getLastFundingFee(params: SymbolParam):
|
|
249
|
+
getPredictedFundingFee(params: SymbolParam): Promise<APIResponseWithTime<any>>;
|
|
250
|
+
getLastFundingFee(params: SymbolParam): Promise<APIResponseWithTime<any>>;
|
|
221
251
|
}
|
package/lib/linear-client.js
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
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.LinearClient = void 0;
|
|
7
16
|
const requestUtils_1 = require("./util/requestUtils");
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
class LinearClient extends shared_endpoints_1.default {
|
|
17
|
+
const BaseRestClient_1 = __importDefault(require("./util/BaseRestClient"));
|
|
18
|
+
class LinearClient extends BaseRestClient_1.default {
|
|
11
19
|
/**
|
|
12
|
-
* @public Creates an instance of the linear REST API client.
|
|
20
|
+
* @public Creates an instance of the linear (USD Perps) REST API client.
|
|
13
21
|
*
|
|
14
22
|
* @param {string} key - your API key
|
|
15
23
|
* @param {string} secret - your API secret
|
|
@@ -18,32 +26,99 @@ class LinearClient 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.linear);
|
|
23
30
|
return this;
|
|
24
31
|
}
|
|
32
|
+
fetchServerTime() {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const timeRes = yield this.getServerTime();
|
|
35
|
+
return Number(timeRes.time_now);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
25
38
|
/**
|
|
26
39
|
*
|
|
27
40
|
* Market Data Endpoints
|
|
28
41
|
*
|
|
29
42
|
*/
|
|
43
|
+
getOrderBook(params) {
|
|
44
|
+
return this.get('v2/public/orderBook/L2', params);
|
|
45
|
+
}
|
|
30
46
|
getKline(params) {
|
|
31
|
-
return this.
|
|
47
|
+
return this.get('public/linear/kline', params);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get latest information for symbol
|
|
51
|
+
*/
|
|
52
|
+
getTickers(params) {
|
|
53
|
+
return this.get('v2/public/tickers', params);
|
|
32
54
|
}
|
|
33
55
|
getTrades(params) {
|
|
34
|
-
return this.
|
|
56
|
+
return this.get('public/linear/recent-trading-records', params);
|
|
57
|
+
}
|
|
58
|
+
getSymbols() {
|
|
59
|
+
return this.get('v2/public/symbols');
|
|
35
60
|
}
|
|
36
61
|
getLastFundingRate(params) {
|
|
37
|
-
return this.
|
|
62
|
+
return this.get('public/linear/funding/prev-funding-rate', params);
|
|
38
63
|
}
|
|
39
64
|
getMarkPriceKline(params) {
|
|
40
|
-
return this.
|
|
65
|
+
return this.get('public/linear/mark-price-kline', params);
|
|
41
66
|
}
|
|
42
67
|
getIndexPriceKline(params) {
|
|
43
|
-
return this.
|
|
68
|
+
return this.get('public/linear/index-price-kline', params);
|
|
44
69
|
}
|
|
45
70
|
getPremiumIndexKline(params) {
|
|
46
|
-
return this.
|
|
71
|
+
return this.get('public/linear/premium-index-kline', params);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* Market Data : Advanced
|
|
76
|
+
*
|
|
77
|
+
*/
|
|
78
|
+
getOpenInterest(params) {
|
|
79
|
+
return this.get('v2/public/open-interest', params);
|
|
80
|
+
}
|
|
81
|
+
getLatestBigDeal(params) {
|
|
82
|
+
return this.get('v2/public/big-deal', params);
|
|
83
|
+
}
|
|
84
|
+
getLongShortRatio(params) {
|
|
85
|
+
return this.get('v2/public/account-ratio', params);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
*
|
|
89
|
+
* Account Data Endpoints
|
|
90
|
+
*
|
|
91
|
+
*/
|
|
92
|
+
getApiKeyInfo() {
|
|
93
|
+
return this.getPrivate('v2/private/account/api-key');
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
*
|
|
97
|
+
* Wallet Data Endpoints
|
|
98
|
+
*
|
|
99
|
+
*/
|
|
100
|
+
getWalletBalance(params) {
|
|
101
|
+
return this.getPrivate('v2/private/wallet/balance', params);
|
|
102
|
+
}
|
|
103
|
+
getWalletFundRecords(params) {
|
|
104
|
+
return this.getPrivate('v2/private/wallet/fund/records', params);
|
|
105
|
+
}
|
|
106
|
+
getWithdrawRecords(params) {
|
|
107
|
+
return this.getPrivate('v2/private/wallet/withdraw/list', params);
|
|
108
|
+
}
|
|
109
|
+
getAssetExchangeRecords(params) {
|
|
110
|
+
return this.getPrivate('v2/private/exchange-order/list', params);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
*
|
|
114
|
+
* API Data Endpoints
|
|
115
|
+
*
|
|
116
|
+
*/
|
|
117
|
+
getServerTime() {
|
|
118
|
+
return this.get('v2/public/time');
|
|
119
|
+
}
|
|
120
|
+
getApiAnnouncements() {
|
|
121
|
+
return this.get('v2/public/announcement');
|
|
47
122
|
}
|
|
48
123
|
/**
|
|
49
124
|
*
|
|
@@ -51,105 +126,101 @@ class LinearClient extends shared_endpoints_1.default {
|
|
|
51
126
|
*
|
|
52
127
|
*/
|
|
53
128
|
placeActiveOrder(params) {
|
|
54
|
-
return this.
|
|
129
|
+
return this.postPrivate('private/linear/order/create', params);
|
|
55
130
|
}
|
|
56
131
|
getActiveOrderList(params) {
|
|
57
|
-
return this.
|
|
132
|
+
return this.getPrivate('private/linear/order/list', params);
|
|
58
133
|
}
|
|
59
134
|
cancelActiveOrder(params) {
|
|
60
|
-
return this.
|
|
135
|
+
return this.postPrivate('private/linear/order/cancel', params);
|
|
61
136
|
}
|
|
62
137
|
cancelAllActiveOrders(params) {
|
|
63
|
-
return this.
|
|
138
|
+
return this.postPrivate('private/linear/order/cancel-all', params);
|
|
64
139
|
}
|
|
65
140
|
replaceActiveOrder(params) {
|
|
66
|
-
return this.
|
|
141
|
+
return this.postPrivate('private/linear/order/replace', params);
|
|
67
142
|
}
|
|
68
143
|
queryActiveOrder(params) {
|
|
69
|
-
return this.
|
|
144
|
+
return this.getPrivate('private/linear/order/search', params);
|
|
70
145
|
}
|
|
71
146
|
/**
|
|
72
147
|
* Conditional orders
|
|
73
148
|
*/
|
|
74
149
|
placeConditionalOrder(params) {
|
|
75
|
-
return this.
|
|
150
|
+
return this.postPrivate('private/linear/stop-order/create', params);
|
|
76
151
|
}
|
|
77
152
|
getConditionalOrder(params) {
|
|
78
|
-
return this.
|
|
153
|
+
return this.getPrivate('private/linear/stop-order/list', params);
|
|
79
154
|
}
|
|
80
155
|
cancelConditionalOrder(params) {
|
|
81
|
-
return this.
|
|
156
|
+
return this.postPrivate('private/linear/stop-order/cancel', params);
|
|
82
157
|
}
|
|
83
158
|
cancelAllConditionalOrders(params) {
|
|
84
|
-
return this.
|
|
159
|
+
return this.postPrivate('private/linear/stop-order/cancel-all', params);
|
|
85
160
|
}
|
|
86
161
|
replaceConditionalOrder(params) {
|
|
87
|
-
return this.
|
|
162
|
+
return this.postPrivate('private/linear/stop-order/replace', params);
|
|
88
163
|
}
|
|
89
164
|
queryConditionalOrder(params) {
|
|
90
|
-
return this.
|
|
165
|
+
return this.getPrivate('private/linear/stop-order/search', params);
|
|
91
166
|
}
|
|
92
167
|
/**
|
|
93
168
|
* Position
|
|
94
169
|
*/
|
|
95
170
|
getPosition(params) {
|
|
96
|
-
return this.
|
|
171
|
+
return this.getPrivate('private/linear/position/list', params);
|
|
97
172
|
}
|
|
98
173
|
setAutoAddMargin(params) {
|
|
99
|
-
return this.
|
|
174
|
+
return this.postPrivate('private/linear/position/set-auto-add-margin', params);
|
|
100
175
|
}
|
|
101
176
|
setMarginSwitch(params) {
|
|
102
|
-
return this.
|
|
177
|
+
return this.postPrivate('private/linear/position/switch-isolated', params);
|
|
103
178
|
}
|
|
104
179
|
/**
|
|
105
180
|
* Switch between one-way vs hedge mode. Use `linearPositionModeEnum` for the mode parameter.
|
|
106
181
|
*/
|
|
107
182
|
setPositionMode(params) {
|
|
108
|
-
return this.
|
|
109
|
-
}
|
|
110
|
-
/** @deprecated use setPositionTpSlMode() instead */
|
|
111
|
-
setSwitchMode(params) {
|
|
112
|
-
return this.requestWrapper.post('private/linear/tpsl/switch-mode', params);
|
|
183
|
+
return this.postPrivate('private/linear/position/switch-mode', params);
|
|
113
184
|
}
|
|
114
185
|
/**
|
|
115
186
|
* Switch TP/SL mode between full or partial. When set to Partial, TP/SL orders may have a quantity less than the position size.
|
|
116
187
|
* This is set with the setTradingStop() method. Use `positionTpSlModeEnum` for the tp_sl_mode parameter.
|
|
117
188
|
*/
|
|
118
189
|
setPositionTpSlMode(params) {
|
|
119
|
-
return this.
|
|
190
|
+
return this.postPrivate('private/linear/tpsl/switch-mode', params);
|
|
120
191
|
}
|
|
121
192
|
setAddReduceMargin(params) {
|
|
122
|
-
return this.
|
|
193
|
+
return this.postPrivate('private/linear/position/add-margin', params);
|
|
123
194
|
}
|
|
124
195
|
setUserLeverage(params) {
|
|
125
|
-
return this.
|
|
196
|
+
return this.postPrivate('private/linear/position/set-leverage', params);
|
|
126
197
|
}
|
|
127
198
|
setTradingStop(params) {
|
|
128
|
-
return this.
|
|
199
|
+
return this.postPrivate('private/linear/position/trading-stop', params);
|
|
129
200
|
}
|
|
130
201
|
getTradeRecords(params) {
|
|
131
|
-
return this.
|
|
202
|
+
return this.getPrivate('private/linear/trade/execution/list', params);
|
|
132
203
|
}
|
|
133
204
|
getClosedPnl(params) {
|
|
134
|
-
return this.
|
|
205
|
+
return this.getPrivate('private/linear/trade/closed-pnl/list', params);
|
|
135
206
|
}
|
|
136
207
|
/**
|
|
137
208
|
* Risk Limit
|
|
138
209
|
*/
|
|
139
210
|
getRiskLimitList(params) {
|
|
140
|
-
return this.
|
|
211
|
+
return this.getPrivate('public/linear/risk-limit', params);
|
|
141
212
|
}
|
|
142
213
|
setRiskLimit(params) {
|
|
143
|
-
return this.
|
|
214
|
+
return this.postPrivate('private/linear/position/set-risk', params);
|
|
144
215
|
}
|
|
145
216
|
/**
|
|
146
217
|
* Funding
|
|
147
218
|
*/
|
|
148
219
|
getPredictedFundingFee(params) {
|
|
149
|
-
return this.
|
|
220
|
+
return this.getPrivate('private/linear/funding/predicted-funding', params);
|
|
150
221
|
}
|
|
151
222
|
getLastFundingFee(params) {
|
|
152
|
-
return this.
|
|
223
|
+
return this.getPrivate('private/linear/funding/prev-funding', params);
|
|
153
224
|
}
|
|
154
225
|
}
|
|
155
226
|
exports.LinearClient = LinearClient;
|
package/lib/linear-client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linear-client.js","sourceRoot":"","sources":["../src/linear-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"linear-client.js","sourceRoot":"","sources":["../src/linear-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,sDAI6B;AAe7B,2EAAmD;AAEnD,MAAa,YAAa,SAAQ,wBAAc;IAC9C;;;;;;;;OAQG;IACH,YACE,GAAwB,EACxB,MAA2B,EAC3B,aAAsB,KAAK,EAC3B,oBAAuC,EAAE,EACzC,iBAAqC,EAAE;QAEvC,KAAK,CACH,GAAG,EACH,MAAM,EACN,6BAAc,CAAC,UAAU,EAAE,iBAAiB,CAAC,EAC7C,iBAAiB,EACjB,cAAc,EACd,oCAAqB,CAAC,MAAM,CAC7B,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAEK,eAAe;;YACnB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;YAC3C,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAClC,CAAC;KAAA;IAED;;;;OAIG;IAEH,YAAY,CAAC,MAAmB;QAC9B,OAAO,IAAI,CAAC,GAAG,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;IAED,QAAQ,CACN,MAAoC;QAEpC,OAAO,IAAI,CAAC,GAAG,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,UAAU,CACR,MAA6B;QAE7B,OAAO,IAAI,CAAC,GAAG,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED,SAAS,CAAC,MAAwB;QAChC,OAAO,IAAI,CAAC,GAAG,CAAC,sCAAsC,EAAE,MAAM,CAAC,CAAC;IAClE,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACvC,CAAC;IAED,kBAAkB,CAAC,MAAmB;QACpC,OAAO,IAAI,CAA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CAAC,CAAC;IACxE,CAAC;IAED,YAAY,CAAC,MAOZ;QACC,OAAO,IAAI,CAAC,UAAU,CAAC,sCAAsC,EAAE,MAAM,CAAC,CAAC;IACzE,CAAC;IAED;;OAEG;IAEH,gBAAgB,CAAC,MAAmB;QAClC,OAAO,IAAI,CAAC,UAAU,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC;IAC7D,CAAC;IAED,YAAY,CAAC,MAIZ;QACC,OAAO,IAAI,CAAC,WAAW,CAAC,kCAAkC,EAAE,MAAM,CAAC,CAAC;IACtE,CAAC;IAED;;OAEG;IAEH,sBAAsB,CACpB,MAAmB;QAEnB,OAAO,IAAI,CAAC,UAAU,CAAC,0CAA0C,EAAE,MAAM,CAAC,CAAC;IAC7E,CAAC;IAED,iBAAiB,CAAC,MAAmB;QACnC,OAAO,IAAI,CAAC,UAAU,CAAC,qCAAqC,EAAE,MAAM,CAAC,CAAC;IACxE,CAAC;CACF;AA7bD,oCA6bC"}
|
package/lib/logger.js
CHANGED
package/lib/spot-client.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { KlineInterval } from './types/shared';
|
|
3
|
-
import { NewSpotOrder, OrderSide, OrderTypeSpot, SpotOrderQueryById } from './types/spot';
|
|
2
|
+
import { APIResponse, KlineInterval } from './types/shared';
|
|
3
|
+
import { NewSpotOrder, OrderSide, OrderTypeSpot, SpotOrderQueryById, SpotSymbolInfo } from './types/spot';
|
|
4
4
|
import BaseRestClient from './util/BaseRestClient';
|
|
5
|
-
import {
|
|
6
|
-
import RequestWrapper from './util/requestWrapper';
|
|
5
|
+
import { RestClientOptions } from './util/requestUtils';
|
|
7
6
|
export declare class SpotClient extends BaseRestClient {
|
|
8
|
-
protected requestWrapper: RequestWrapper;
|
|
9
7
|
/**
|
|
10
8
|
* @public Creates an instance of the Spot REST API client.
|
|
11
9
|
*
|
|
@@ -16,36 +14,37 @@ export declare class SpotClient extends BaseRestClient {
|
|
|
16
14
|
* @param {AxiosRequestConfig} [requestOptions={}] HTTP networking options for axios
|
|
17
15
|
*/
|
|
18
16
|
constructor(key?: string | undefined, secret?: string | undefined, useLivenet?: boolean, restClientOptions?: RestClientOptions, requestOptions?: AxiosRequestConfig);
|
|
19
|
-
|
|
17
|
+
fetchServerTime(): Promise<number>;
|
|
18
|
+
getServerTime(): Promise<number>;
|
|
20
19
|
/**
|
|
21
20
|
*
|
|
22
21
|
* Market Data Endpoints
|
|
23
22
|
*
|
|
24
|
-
|
|
25
|
-
getSymbols():
|
|
26
|
-
getOrderBook(symbol: string, limit?: number):
|
|
27
|
-
getMergedOrderBook(symbol: string, scale?: number, limit?: number):
|
|
28
|
-
getTrades(symbol: string, limit?: number):
|
|
29
|
-
getCandles(symbol: string, interval: KlineInterval, limit?: number, startTime?: number, endTime?: number):
|
|
30
|
-
get24hrTicker(symbol?: string):
|
|
31
|
-
getLastTradedPrice(symbol?: string):
|
|
32
|
-
getBestBidAskPrice(symbol?: string):
|
|
23
|
+
**/
|
|
24
|
+
getSymbols(): Promise<APIResponse<SpotSymbolInfo[]>>;
|
|
25
|
+
getOrderBook(symbol: string, limit?: number): Promise<APIResponse<any>>;
|
|
26
|
+
getMergedOrderBook(symbol: string, scale?: number, limit?: number): Promise<APIResponse<any>>;
|
|
27
|
+
getTrades(symbol: string, limit?: number): Promise<APIResponse<any[]>>;
|
|
28
|
+
getCandles(symbol: string, interval: KlineInterval, limit?: number, startTime?: number, endTime?: number): Promise<APIResponse<any[]>>;
|
|
29
|
+
get24hrTicker(symbol?: string): Promise<APIResponse<any>>;
|
|
30
|
+
getLastTradedPrice(symbol?: string): Promise<APIResponse<any>>;
|
|
31
|
+
getBestBidAskPrice(symbol?: string): Promise<APIResponse<any>>;
|
|
33
32
|
/**
|
|
34
33
|
* Account Data Endpoints
|
|
35
34
|
*/
|
|
36
|
-
submitOrder(params: NewSpotOrder):
|
|
37
|
-
getOrder(params: SpotOrderQueryById):
|
|
38
|
-
cancelOrder(params: SpotOrderQueryById):
|
|
35
|
+
submitOrder(params: NewSpotOrder): Promise<APIResponse<any>>;
|
|
36
|
+
getOrder(params: SpotOrderQueryById): Promise<APIResponse<any>>;
|
|
37
|
+
cancelOrder(params: SpotOrderQueryById): Promise<APIResponse<any>>;
|
|
39
38
|
cancelOrderBatch(params: {
|
|
40
39
|
symbol: string;
|
|
41
40
|
side?: OrderSide;
|
|
42
41
|
orderTypes: OrderTypeSpot[];
|
|
43
|
-
}):
|
|
44
|
-
getOpenOrders(symbol?: string, orderId?: string, limit?: number):
|
|
45
|
-
getPastOrders(symbol?: string, orderId?: string, limit?: number):
|
|
46
|
-
getMyTrades(symbol?: string, limit?: number, fromId?: number, toId?: number):
|
|
42
|
+
}): Promise<APIResponse<any>>;
|
|
43
|
+
getOpenOrders(symbol?: string, orderId?: string, limit?: number): Promise<APIResponse<any>>;
|
|
44
|
+
getPastOrders(symbol?: string, orderId?: string, limit?: number): Promise<APIResponse<any>>;
|
|
45
|
+
getMyTrades(symbol?: string, limit?: number, fromId?: number, toId?: number): Promise<APIResponse<any>>;
|
|
47
46
|
/**
|
|
48
47
|
* Wallet Data Endpoints
|
|
49
48
|
*/
|
|
50
|
-
getBalances():
|
|
49
|
+
getBalances(): Promise<APIResponse<any>>;
|
|
51
50
|
}
|