bybit-api 3.10.29 → 4.0.0-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/README.md +301 -178
- package/lib/index.d.ts +0 -11
- package/lib/index.js +0 -11
- package/lib/index.js.map +1 -1
- package/lib/rest-client-v5.d.ts +1 -1
- package/lib/rest-client-v5.js +1 -1
- package/lib/spot-client-v3.d.ts +8 -81
- package/lib/spot-client-v3.js +7 -172
- package/lib/spot-client-v3.js.map +1 -1
- package/lib/types/index.d.ts +1 -2
- package/lib/types/index.js +1 -2
- package/lib/types/index.js.map +1 -1
- package/lib/types/request/index.d.ts +0 -1
- package/lib/types/request/index.js +0 -1
- package/lib/types/request/index.js.map +1 -1
- package/lib/types/request/v5-account.d.ts +1 -1
- package/lib/types/request/v5-asset.d.ts +1 -1
- package/lib/types/request/v5-market.d.ts +1 -1
- package/lib/types/request/v5-position.d.ts +1 -1
- package/lib/types/request/v5-pre-upgrade.d.ts +1 -1
- package/lib/types/request/v5-spot-leverage-token.d.ts +1 -1
- package/lib/types/request/v5-trade.d.ts +1 -1
- package/lib/types/request/v5-user.d.ts +1 -1
- package/lib/types/response/v5-account.d.ts +1 -1
- package/lib/types/response/v5-asset.d.ts +1 -1
- package/lib/types/response/v5-market.d.ts +1 -1
- package/lib/types/response/v5-position.d.ts +1 -1
- package/lib/types/response/v5-spot-leverage-token.d.ts +1 -1
- package/lib/types/response/v5-trade.d.ts +1 -1
- package/lib/types/response/v5-user.d.ts +1 -1
- package/lib/types/{request/spot.js → shared-v5.js} +1 -1
- package/lib/types/shared-v5.js.map +1 -0
- package/lib/types/shared.d.ts +1 -19
- package/lib/types/websockets/index.d.ts +3 -0
- package/lib/types/websockets/index.js +20 -0
- package/lib/types/websockets/index.js.map +1 -0
- package/lib/types/websockets/ws-api.d.ts +73 -0
- package/lib/types/websockets/ws-api.js +10 -0
- package/lib/types/websockets/ws-api.js.map +1 -0
- package/lib/types/websockets/ws-confirmations.d.ts +13 -0
- package/lib/types/{websocket.events.js → websockets/ws-confirmations.js} +1 -1
- package/lib/types/websockets/ws-confirmations.js.map +1 -0
- package/lib/types/{websocket.events.d.ts → websockets/ws-events.d.ts} +9 -2
- package/lib/types/websockets/ws-events.js +11 -0
- package/lib/types/websockets/ws-events.js.map +1 -0
- package/lib/types/{websockets.d.ts → websockets/ws-general.d.ts} +35 -10
- package/lib/types/{v5-shared.js → websockets/ws-general.js} +1 -1
- package/lib/types/websockets/ws-general.js.map +1 -0
- package/lib/util/BaseRestClient.d.ts +1 -1
- package/lib/util/BaseRestClient.js +15 -39
- package/lib/util/BaseRestClient.js.map +1 -1
- package/lib/util/BaseWSClient.d.ts +221 -0
- package/lib/util/BaseWSClient.js +733 -0
- package/lib/util/BaseWSClient.js.map +1 -0
- package/lib/util/index.d.ts +1 -2
- package/lib/util/index.js +1 -2
- package/lib/util/index.js.map +1 -1
- package/lib/util/logger.d.ts +2 -5
- package/lib/util/logger.js +3 -12
- package/lib/util/logger.js.map +1 -1
- package/lib/util/requestUtils.d.ts +7 -10
- package/lib/util/requestUtils.js +6 -33
- package/lib/util/requestUtils.js.map +1 -1
- package/lib/util/typeGuards.d.ts +7 -1
- package/lib/util/typeGuards.js +41 -5
- package/lib/util/typeGuards.js.map +1 -1
- package/lib/util/webCryptoAPI.d.ts +10 -0
- package/lib/util/webCryptoAPI.js +69 -0
- package/lib/util/webCryptoAPI.js.map +1 -0
- package/lib/util/websockets/WsStore.d.ts +71 -0
- package/lib/util/websockets/WsStore.js +269 -0
- package/lib/util/websockets/WsStore.js.map +1 -0
- package/lib/util/websockets/WsStore.types.d.ts +50 -0
- package/lib/util/websockets/WsStore.types.js +14 -0
- package/lib/util/websockets/WsStore.types.js.map +1 -0
- package/lib/util/websockets/index.d.ts +3 -0
- package/lib/util/websockets/index.js +20 -0
- package/lib/util/websockets/index.js.map +1 -0
- package/lib/util/websockets/websocket-util.d.ts +92 -0
- package/lib/util/websockets/websocket-util.js +280 -0
- package/lib/util/websockets/websocket-util.js.map +1 -0
- package/lib/websocket-client.d.ts +107 -114
- package/lib/websocket-client.js +422 -716
- package/lib/websocket-client.js.map +1 -1
- package/package.json +4 -4
- package/lib/account-asset-client-v3.d.ts +0 -87
- package/lib/account-asset-client-v3.js +0 -154
- package/lib/account-asset-client-v3.js.map +0 -1
- package/lib/account-asset-client.d.ts +0 -46
- package/lib/account-asset-client.js +0 -108
- package/lib/account-asset-client.js.map +0 -1
- package/lib/contract-client.d.ts +0 -136
- package/lib/contract-client.js +0 -251
- package/lib/contract-client.js.map +0 -1
- package/lib/copy-trading-client.d.ts +0 -60
- package/lib/copy-trading-client.js +0 -114
- package/lib/copy-trading-client.js.map +0 -1
- package/lib/inverse-client.d.ts +0 -104
- package/lib/inverse-client.js +0 -213
- package/lib/inverse-client.js.map +0 -1
- package/lib/inverse-futures-client.d.ts +0 -217
- package/lib/inverse-futures-client.js +0 -224
- package/lib/inverse-futures-client.js.map +0 -1
- package/lib/linear-client.d.ts +0 -112
- package/lib/linear-client.js +0 -225
- package/lib/linear-client.js.map +0 -1
- package/lib/spot-client.d.ts +0 -46
- package/lib/spot-client.js +0 -131
- package/lib/spot-client.js.map +0 -1
- package/lib/types/request/spot.d.ts +0 -79
- package/lib/types/request/spot.js.map +0 -1
- package/lib/types/v5-shared.js.map +0 -1
- package/lib/types/websocket.events.js.map +0 -1
- package/lib/types/websockets.js +0 -3
- package/lib/types/websockets.js.map +0 -1
- package/lib/types/ws-events/failed-topic-subscription-confirmation.d.ts +0 -4
- package/lib/types/ws-events/failed-topic-subscription-confirmation.js +0 -3
- package/lib/types/ws-events/failed-topic-subscription-confirmation.js.map +0 -1
- package/lib/types/ws-events/succeeded-topic-subscription-confirmation.d.ts +0 -4
- package/lib/types/ws-events/succeeded-topic-subscription-confirmation.js +0 -3
- package/lib/types/ws-events/succeeded-topic-subscription-confirmation.js.map +0 -1
- package/lib/types/ws-events/topic-subscription-confirmation.d.ts +0 -7
- package/lib/types/ws-events/topic-subscription-confirmation.js +0 -3
- package/lib/types/ws-events/topic-subscription-confirmation.js.map +0 -1
- package/lib/unified-margin-client.d.ts +0 -140
- package/lib/unified-margin-client.js +0 -270
- package/lib/unified-margin-client.js.map +0 -1
- package/lib/usdc-option-client.d.ts +0 -110
- package/lib/usdc-option-client.js +0 -196
- package/lib/usdc-option-client.js.map +0 -1
- package/lib/usdc-perpetual-client.d.ts +0 -97
- package/lib/usdc-perpetual-client.js +0 -191
- package/lib/usdc-perpetual-client.js.map +0 -1
- package/lib/util/WsStore.d.ts +0 -57
- package/lib/util/WsStore.js +0 -97
- package/lib/util/WsStore.js.map +0 -1
- package/lib/util/browser-support.d.ts +0 -1
- package/lib/util/browser-support.js +0 -26
- package/lib/util/browser-support.js.map +0 -1
- package/lib/util/node-support.d.ts +0 -2
- package/lib/util/node-support.js +0 -21
- package/lib/util/node-support.js.map +0 -1
- package/lib/util/websocket-util.d.ts +0 -68
- package/lib/util/websocket-util.js +0 -506
- package/lib/util/websocket-util.js.map +0 -1
- /package/lib/types/{v5-shared.d.ts → shared-v5.d.ts} +0 -0
package/lib/index.d.ts
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
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
1
|
export * from './rest-client-v5';
|
|
8
|
-
export * from './spot-client';
|
|
9
2
|
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
3
|
export * from './websocket-client';
|
|
15
4
|
export * from './util/logger';
|
|
16
5
|
export * from './util';
|
package/lib/index.js
CHANGED
|
@@ -14,19 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./account-asset-client"), exports);
|
|
18
|
-
__exportStar(require("./account-asset-client-v3"), exports);
|
|
19
|
-
__exportStar(require("./copy-trading-client"), exports);
|
|
20
|
-
__exportStar(require("./inverse-client"), exports);
|
|
21
|
-
__exportStar(require("./inverse-futures-client"), exports);
|
|
22
|
-
__exportStar(require("./linear-client"), exports);
|
|
23
17
|
__exportStar(require("./rest-client-v5"), exports);
|
|
24
|
-
__exportStar(require("./spot-client"), exports);
|
|
25
18
|
__exportStar(require("./spot-client-v3"), exports);
|
|
26
|
-
__exportStar(require("./usdc-option-client"), exports);
|
|
27
|
-
__exportStar(require("./usdc-perpetual-client"), exports);
|
|
28
|
-
__exportStar(require("./unified-margin-client"), exports);
|
|
29
|
-
__exportStar(require("./contract-client"), exports);
|
|
30
19
|
__exportStar(require("./websocket-client"), exports);
|
|
31
20
|
__exportStar(require("./util/logger"), exports);
|
|
32
21
|
__exportStar(require("./util"), exports);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,mDAAiC;AACjC,qDAAmC;AACnC,gDAA8B;AAC9B,yCAAuB;AACvB,0CAAwB;AACxB,mDAAiC"}
|
package/lib/rest-client-v5.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare class RestClientV5 extends BaseRestClient {
|
|
|
24
24
|
****** Misc Bybit APIs
|
|
25
25
|
*
|
|
26
26
|
*/
|
|
27
|
-
getClientType(): "
|
|
27
|
+
getClientType(): "v5";
|
|
28
28
|
fetchServerTime(): Promise<number>;
|
|
29
29
|
getServerTime(): Promise<APIResponseV3WithTime<{
|
|
30
30
|
timeSecond: string;
|
package/lib/rest-client-v5.js
CHANGED
package/lib/spot-client-v3.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APIResponseV3,
|
|
1
|
+
import { APIResponseV3, numberInString } from './types';
|
|
2
2
|
import BaseRestClient from './util/BaseRestClient';
|
|
3
3
|
/**
|
|
4
4
|
* REST API client for newer Spot V3 APIs.
|
|
@@ -8,98 +8,25 @@ import BaseRestClient from './util/BaseRestClient';
|
|
|
8
8
|
* Please update your code as soon as possible to use the V5 APIs instead.
|
|
9
9
|
*/
|
|
10
10
|
export declare class SpotClientV3 extends BaseRestClient {
|
|
11
|
-
getClientType(): "
|
|
11
|
+
getClientType(): "v5";
|
|
12
12
|
fetchServerTime(): Promise<number>;
|
|
13
13
|
/**
|
|
14
14
|
*
|
|
15
15
|
* Market Data Endpoints
|
|
16
16
|
*
|
|
17
17
|
*/
|
|
18
|
-
/** Get all symbols */
|
|
19
|
-
getSymbols(): Promise<APIResponseV3<any>>;
|
|
20
|
-
/** Get orderbook for symbol */
|
|
21
|
-
getOrderBook(symbol: string, limit?: number): Promise<APIResponseV3<any>>;
|
|
22
|
-
/** Get merged orderbook for symbol */
|
|
23
|
-
getMergedOrderBook(symbol: string, scale?: number, limit?: number): Promise<APIResponseV3<any>>;
|
|
24
|
-
/** Get public trading records (raw trades) */
|
|
25
|
-
getTrades(symbol: string, limit?: number): Promise<APIResponseV3<any>>;
|
|
26
|
-
/** Get candles/klines */
|
|
27
|
-
getCandles(symbol: string, interval: KlineInterval, limit?: number, startTime?: number, endTime?: number): Promise<APIResponseV3<any>>;
|
|
28
|
-
/** Get latest information for symbol (24hr ticker) */
|
|
29
|
-
get24hrTicker(symbol?: string): Promise<APIResponseV3<any>>;
|
|
30
|
-
/** Get last traded price */
|
|
31
|
-
getLastTradedPrice(symbol?: string): Promise<APIResponseV3<any>>;
|
|
32
|
-
/** Get best bid/ask price */
|
|
33
|
-
getBestBidAskPrice(symbol?: string): Promise<APIResponseV3<any>>;
|
|
34
18
|
/**
|
|
19
|
+
* Get merged orderbook for symbol
|
|
35
20
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
21
|
+
* This is the only known pre-V5 endpoint to still be online.
|
|
38
22
|
*/
|
|
39
|
-
|
|
40
|
-
/** Create order */
|
|
41
|
-
submitOrder(params: NewSpotOrderV3): Promise<APIResponseV3<any>>;
|
|
42
|
-
/** Get active order state */
|
|
43
|
-
getOrder(params: SpotOrderQueryById): Promise<APIResponseV3<any>>;
|
|
44
|
-
/** Cancel order */
|
|
45
|
-
cancelOrder(params: SpotOrderQueryById): Promise<APIResponseV3<any>>;
|
|
46
|
-
/** Batch cancel orders */
|
|
47
|
-
cancelOrderBatch(params: SpotCancelOrderBatchRequest): Promise<APIResponseV3<any>>;
|
|
48
|
-
/** Batch cancel up to 100 orders by ID */
|
|
49
|
-
cancelOrderBatchIDs(orderIds: string[]): Promise<APIResponseV3<any>>;
|
|
50
|
-
/** Get open orders */
|
|
51
|
-
getOpenOrders(symbol?: string, orderId?: string, limit?: number, orderCategory?: 0 | 1): Promise<APIResponseV3<any>>;
|
|
52
|
-
/** Get order history */
|
|
53
|
-
getPastOrders(symbol?: string, orderId?: string, limit?: number, orderCategory?: 0 | 1): Promise<APIResponseV3<any>>;
|
|
54
|
-
/**
|
|
55
|
-
* Get your trade history.
|
|
56
|
-
* If startTime is not specified, you can only query for records in the last 7 days.
|
|
57
|
-
* If you want to query for records older than 7 days, startTime is required.
|
|
58
|
-
*/
|
|
59
|
-
getMyTrades(params?: SpotMyTradesRequest): Promise<APIResponseV3<any>>;
|
|
60
|
-
/**
|
|
61
|
-
*
|
|
62
|
-
* Wallet Data Endpoints
|
|
63
|
-
*
|
|
64
|
-
*/
|
|
65
|
-
/** Get Wallet Balance */
|
|
66
|
-
getBalances(): Promise<APIResponseV3<SpotBalances>>;
|
|
23
|
+
getMergedOrderBook(symbol: string, scale?: number, limit?: number): Promise<APIResponseV3<any>>;
|
|
67
24
|
/**
|
|
68
25
|
*
|
|
69
26
|
* API Data Endpoints
|
|
70
27
|
*
|
|
71
28
|
*/
|
|
72
|
-
getServerTime(): Promise<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* Leveraged Token Endpoints
|
|
76
|
-
*
|
|
77
|
-
*/
|
|
78
|
-
/** Get all asset infos */
|
|
79
|
-
getLeveragedTokenAssetInfos(ltCode?: string): Promise<APIResponseV3<any>>;
|
|
80
|
-
/** Get leveraged token market info */
|
|
81
|
-
getLeveragedTokenMarketInfo(ltCode: string): Promise<APIResponseV3<any>>;
|
|
82
|
-
/** Purchase leveraged token */
|
|
83
|
-
purchaseLeveragedToken(ltCode: string, ltAmount: string, serialNo?: string): Promise<APIResponseV3<any>>;
|
|
84
|
-
/** Redeem leveraged token */
|
|
85
|
-
redeemLeveragedToken(ltCode: string, ltAmount: string, serialNo?: string): Promise<APIResponseV3<any>>;
|
|
86
|
-
/** Get leveraged token purchase/redemption history */
|
|
87
|
-
getLeveragedTokenPRHistory(params?: SpotLeveragedTokenPRHistoryRequest): Promise<APIResponseV3<any>>;
|
|
88
|
-
/**
|
|
89
|
-
*
|
|
90
|
-
* Cross Margin Trading Endpoints
|
|
91
|
-
*
|
|
92
|
-
*/
|
|
93
|
-
/** Borrow margin loan */
|
|
94
|
-
borrowCrossMarginLoan(coin: string, qty: string): Promise<APIResponseV3<any>>;
|
|
95
|
-
/** Repay margin loan */
|
|
96
|
-
repayCrossMarginLoan(coin: string, qty: string): Promise<APIResponseV3<any>>;
|
|
97
|
-
/** Query borrowing info */
|
|
98
|
-
getCrossMarginBorrowingInfo(params?: SpotCrossMarginBorrowingInfoRequest): Promise<APIResponseV3<any>>;
|
|
99
|
-
/** Query account info */
|
|
100
|
-
getCrossMarginAccountInfo(): Promise<APIResponseV3<any>>;
|
|
101
|
-
/** Query interest & quota */
|
|
102
|
-
getCrossMarginInterestQuota(coin: string): Promise<APIResponseV3<any>>;
|
|
103
|
-
/** Query repayment history */
|
|
104
|
-
getCrossMarginRepaymentHistory(params?: SpotCrossMarginRepaymentHistoryRequest): Promise<APIResponseV3<any>>;
|
|
29
|
+
getServerTime(): Promise<{
|
|
30
|
+
time_now: numberInString;
|
|
31
|
+
}>;
|
|
105
32
|
}
|
package/lib/spot-client-v3.js
CHANGED
|
@@ -24,8 +24,8 @@ const BaseRestClient_1 = __importDefault(require("./util/BaseRestClient"));
|
|
|
24
24
|
*/
|
|
25
25
|
class SpotClientV3 extends BaseRestClient_1.default {
|
|
26
26
|
getClientType() {
|
|
27
|
-
//
|
|
28
|
-
return util_1.REST_CLIENT_TYPE_ENUM.
|
|
27
|
+
// Doesn't really matter here, since the only remaining endpoint does not require auth.
|
|
28
|
+
return util_1.REST_CLIENT_TYPE_ENUM.v5;
|
|
29
29
|
}
|
|
30
30
|
fetchServerTime() {
|
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -38,115 +38,18 @@ class SpotClientV3 extends BaseRestClient_1.default {
|
|
|
38
38
|
* Market Data Endpoints
|
|
39
39
|
*
|
|
40
40
|
*/
|
|
41
|
-
/** Get all symbols */
|
|
42
|
-
getSymbols() {
|
|
43
|
-
return this.get('/spot/v3/public/symbols');
|
|
44
|
-
}
|
|
45
|
-
/** Get orderbook for symbol */
|
|
46
|
-
getOrderBook(symbol, limit) {
|
|
47
|
-
return this.get('/spot/v3/public/quote/depth', { symbol, limit });
|
|
48
|
-
}
|
|
49
|
-
/** Get merged orderbook for symbol */
|
|
50
|
-
getMergedOrderBook(symbol, scale, limit) {
|
|
51
|
-
return this.get('/spot/v3/public/quote/depth/merged', {
|
|
52
|
-
symbol,
|
|
53
|
-
scale,
|
|
54
|
-
limit,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
/** Get public trading records (raw trades) */
|
|
58
|
-
getTrades(symbol, limit) {
|
|
59
|
-
return this.get('/spot/v3/public/quote/trades', { symbol, limit });
|
|
60
|
-
}
|
|
61
|
-
/** Get candles/klines */
|
|
62
|
-
getCandles(symbol, interval, limit, startTime, endTime) {
|
|
63
|
-
return this.get('/spot/v3/public/quote/kline', {
|
|
64
|
-
symbol,
|
|
65
|
-
interval,
|
|
66
|
-
limit,
|
|
67
|
-
startTime,
|
|
68
|
-
endTime,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
/** Get latest information for symbol (24hr ticker) */
|
|
72
|
-
get24hrTicker(symbol) {
|
|
73
|
-
return this.get('/spot/v3/public/quote/ticker/24hr', { symbol });
|
|
74
|
-
}
|
|
75
|
-
/** Get last traded price */
|
|
76
|
-
getLastTradedPrice(symbol) {
|
|
77
|
-
return this.get('/spot/v3/public/quote/ticker/price', { symbol });
|
|
78
|
-
}
|
|
79
|
-
/** Get best bid/ask price */
|
|
80
|
-
getBestBidAskPrice(symbol) {
|
|
81
|
-
return this.get('/spot/v3/public/quote/ticker/bookTicker', { symbol });
|
|
82
|
-
}
|
|
83
41
|
/**
|
|
42
|
+
* Get merged orderbook for symbol
|
|
84
43
|
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
44
|
+
* This is the only known pre-V5 endpoint to still be online.
|
|
87
45
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
submitOrder(params) {
|
|
91
|
-
return this.postPrivate('/spot/v3/private/order', params);
|
|
92
|
-
}
|
|
93
|
-
/** Get active order state */
|
|
94
|
-
getOrder(params) {
|
|
95
|
-
return this.getPrivate('/spot/v3/private/order', params);
|
|
96
|
-
}
|
|
97
|
-
/** Cancel order */
|
|
98
|
-
cancelOrder(params) {
|
|
99
|
-
return this.postPrivate('/spot/v3/private/cancel-order', params);
|
|
100
|
-
}
|
|
101
|
-
/** Batch cancel orders */
|
|
102
|
-
cancelOrderBatch(params) {
|
|
103
|
-
const orderTypes = params.orderTypes
|
|
104
|
-
? params.orderTypes.join(',')
|
|
105
|
-
: undefined;
|
|
106
|
-
return this.postPrivate('/spot/v3/private/cancel-orders', Object.assign(Object.assign({}, params), { orderTypes }));
|
|
107
|
-
}
|
|
108
|
-
/** Batch cancel up to 100 orders by ID */
|
|
109
|
-
cancelOrderBatchIDs(orderIds) {
|
|
110
|
-
const orderIdsCsv = orderIds.join(',');
|
|
111
|
-
return this.postPrivate('/spot/v3/private/cancel-orders-by-ids', {
|
|
112
|
-
orderIds: orderIdsCsv,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
/** Get open orders */
|
|
116
|
-
getOpenOrders(symbol, orderId, limit, orderCategory) {
|
|
117
|
-
return this.getPrivate('/spot/v3/private/open-orders', {
|
|
118
|
-
symbol,
|
|
119
|
-
orderId,
|
|
120
|
-
limit,
|
|
121
|
-
orderCategory,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
/** Get order history */
|
|
125
|
-
getPastOrders(symbol, orderId, limit, orderCategory) {
|
|
126
|
-
return this.getPrivate('/spot/v3/private/history-orders', {
|
|
46
|
+
getMergedOrderBook(symbol, scale, limit) {
|
|
47
|
+
return this.get('/spot/v3/public/quote/depth/merged', {
|
|
127
48
|
symbol,
|
|
128
|
-
|
|
49
|
+
scale,
|
|
129
50
|
limit,
|
|
130
|
-
orderCategory,
|
|
131
51
|
});
|
|
132
52
|
}
|
|
133
|
-
/**
|
|
134
|
-
* Get your trade history.
|
|
135
|
-
* If startTime is not specified, you can only query for records in the last 7 days.
|
|
136
|
-
* If you want to query for records older than 7 days, startTime is required.
|
|
137
|
-
*/
|
|
138
|
-
getMyTrades(params) {
|
|
139
|
-
return this.getPrivate('/spot/v3/private/my-trades', params);
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
*
|
|
143
|
-
* Wallet Data Endpoints
|
|
144
|
-
*
|
|
145
|
-
*/
|
|
146
|
-
/** Get Wallet Balance */
|
|
147
|
-
getBalances() {
|
|
148
|
-
return this.getPrivate('/spot/v3/private/account');
|
|
149
|
-
}
|
|
150
53
|
/**
|
|
151
54
|
*
|
|
152
55
|
* API Data Endpoints
|
|
@@ -155,74 +58,6 @@ class SpotClientV3 extends BaseRestClient_1.default {
|
|
|
155
58
|
getServerTime() {
|
|
156
59
|
return this.get('/v2/public/time');
|
|
157
60
|
}
|
|
158
|
-
/**
|
|
159
|
-
*
|
|
160
|
-
* Leveraged Token Endpoints
|
|
161
|
-
*
|
|
162
|
-
*/
|
|
163
|
-
/** Get all asset infos */
|
|
164
|
-
getLeveragedTokenAssetInfos(ltCode) {
|
|
165
|
-
return this.get('/spot/v3/public/infos', { ltCode });
|
|
166
|
-
}
|
|
167
|
-
/** Get leveraged token market info */
|
|
168
|
-
getLeveragedTokenMarketInfo(ltCode) {
|
|
169
|
-
return this.getPrivate('/spot/v3/private/reference', { ltCode });
|
|
170
|
-
}
|
|
171
|
-
/** Purchase leveraged token */
|
|
172
|
-
purchaseLeveragedToken(ltCode, ltAmount, serialNo) {
|
|
173
|
-
return this.postPrivate('/spot/v3/private/purchase', {
|
|
174
|
-
ltCode,
|
|
175
|
-
ltAmount,
|
|
176
|
-
serialNo,
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
/** Redeem leveraged token */
|
|
180
|
-
redeemLeveragedToken(ltCode, ltAmount, serialNo) {
|
|
181
|
-
return this.postPrivate('/spot/v3/private/redeem', {
|
|
182
|
-
ltCode,
|
|
183
|
-
ltAmount,
|
|
184
|
-
serialNo,
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
/** Get leveraged token purchase/redemption history */
|
|
188
|
-
getLeveragedTokenPRHistory(params) {
|
|
189
|
-
return this.getPrivate('/spot/v3/private/record', params);
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
*
|
|
193
|
-
* Cross Margin Trading Endpoints
|
|
194
|
-
*
|
|
195
|
-
*/
|
|
196
|
-
/** Borrow margin loan */
|
|
197
|
-
borrowCrossMarginLoan(coin, qty) {
|
|
198
|
-
return this.postPrivate('/spot/v3/private/cross-margin-loan', {
|
|
199
|
-
coin,
|
|
200
|
-
qty,
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
/** Repay margin loan */
|
|
204
|
-
repayCrossMarginLoan(coin, qty) {
|
|
205
|
-
return this.postPrivate('/spot/v3/private/cross-margin-repay', {
|
|
206
|
-
coin,
|
|
207
|
-
qty,
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
/** Query borrowing info */
|
|
211
|
-
getCrossMarginBorrowingInfo(params) {
|
|
212
|
-
return this.getPrivate('/spot/v3/private/cross-margin-orders', params);
|
|
213
|
-
}
|
|
214
|
-
/** Query account info */
|
|
215
|
-
getCrossMarginAccountInfo() {
|
|
216
|
-
return this.getPrivate('/spot/v3/private/cross-margin-account');
|
|
217
|
-
}
|
|
218
|
-
/** Query interest & quota */
|
|
219
|
-
getCrossMarginInterestQuota(coin) {
|
|
220
|
-
return this.getPrivate('/spot/v3/private/cross-margin-loan-info', { coin });
|
|
221
|
-
}
|
|
222
|
-
/** Query repayment history */
|
|
223
|
-
getCrossMarginRepaymentHistory(params) {
|
|
224
|
-
return this.getPrivate('/spot/v3/private/cross-margin-repay-history', params);
|
|
225
|
-
}
|
|
226
61
|
}
|
|
227
62
|
exports.SpotClientV3 = SpotClientV3;
|
|
228
63
|
//# sourceMappingURL=spot-client-v3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spot-client-v3.js","sourceRoot":"","sources":["../src/spot-client-v3.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"spot-client-v3.js","sourceRoot":"","sources":["../src/spot-client-v3.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,iCAA+C;AAC/C,2EAAmD;AAEnD;;;;;;GAMG;AACH,MAAa,YAAa,SAAQ,wBAAc;IAC9C,aAAa;QACX,uFAAuF;QACvF,OAAO,4BAAqB,CAAC,EAAE,CAAC;IAClC,CAAC;IAEK,eAAe;;YACnB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;YACvC,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC9B,CAAC;KAAA;IAED;;;;OAIG;IAEH;;;;OAIG;IACH,kBAAkB,CAChB,MAAc,EACd,KAAc,EACd,KAAc;QAEd,OAAO,IAAI,CAAC,GAAG,CAAC,oCAAoC,EAAE;YACpD,MAAM;YACN,KAAK;YACL,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IAEH,aAAa;QACX,OAAO,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;CACF;AA3CD,oCA2CC"}
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED
|
@@ -17,7 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./response"), exports);
|
|
18
18
|
__exportStar(require("./request"), exports);
|
|
19
19
|
__exportStar(require("./shared"), exports);
|
|
20
|
-
__exportStar(require("./v5
|
|
20
|
+
__exportStar(require("./shared-v5"), exports);
|
|
21
21
|
__exportStar(require("./websockets"), exports);
|
|
22
|
-
__exportStar(require("./websocket.events"), exports);
|
|
23
22
|
//# sourceMappingURL=index.js.map
|
package/lib/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,4CAA0B;AAC1B,2CAAyB;AACzB,8CAA4B;AAC5B,+CAA6B
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,4CAA0B;AAC1B,2CAAyB;AACzB,8CAA4B;AAC5B,+CAA6B"}
|
|
@@ -19,7 +19,6 @@ __exportStar(require("./copy-trading"), exports);
|
|
|
19
19
|
__exportStar(require("./contract"), exports);
|
|
20
20
|
__exportStar(require("./linear"), exports);
|
|
21
21
|
__exportStar(require("./inverse"), exports);
|
|
22
|
-
__exportStar(require("./spot"), exports);
|
|
23
22
|
__exportStar(require("./usdc-perp"), exports);
|
|
24
23
|
__exportStar(require("./usdc-options"), exports);
|
|
25
24
|
__exportStar(require("./usdc-shared"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/request/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,iDAA+B;AAC/B,6CAA2B;AAC3B,2CAAyB;AACzB,4CAA0B;AAC1B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/request/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,iDAA+B;AAC/B,6CAA2B;AAC3B,2CAAyB;AACzB,4CAA0B;AAC1B,8CAA4B;AAC5B,iDAA+B;AAC/B,gDAA8B;AAC9B,mDAAiC;AACjC,+CAA6B;AAC7B,6CAA2B;AAC3B,8CAA4B;AAC5B,gDAA8B;AAC9B,mDAAiC;AACjC,6CAA2B;AAC3B,4CAA0B;AAC1B,2DAAyC;AACzC,8CAA4B;AAC5B,mDAAiC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KlineIntervalV3 } from '../shared';
|
|
2
|
-
import { CategoryV5, InstrumentStatusV5, OptionTypeV5 } from '../v5
|
|
2
|
+
import { CategoryV5, InstrumentStatusV5, OptionTypeV5 } from '../shared-v5';
|
|
3
3
|
export interface GetKlineParamsV5 {
|
|
4
4
|
category: 'spot' | 'linear' | 'inverse';
|
|
5
5
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CategoryV5, ExecTypeV5, OrderTriggerByV5, OrderTypeV5, PositionIdx, TPSLModeV5 } from '../v5
|
|
1
|
+
import { CategoryV5, ExecTypeV5, OrderTriggerByV5, OrderTypeV5, PositionIdx, TPSLModeV5 } from '../shared-v5';
|
|
2
2
|
export interface PositionInfoParamsV5 {
|
|
3
3
|
category: CategoryV5;
|
|
4
4
|
symbol?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CategoryV5, OrderFilterV5, OrderSMPTypeV5, OrderSideV5, OrderStatusV5, OrderTimeInForceV5, OrderTriggerByV5, OrderTypeV5, PositionIdx } from '../v5
|
|
1
|
+
import { CategoryV5, OrderFilterV5, OrderSMPTypeV5, OrderSideV5, OrderStatusV5, OrderTimeInForceV5, OrderTriggerByV5, OrderTypeV5, PositionIdx } from '../shared-v5';
|
|
2
2
|
export interface OrderParamsV5 {
|
|
3
3
|
category: CategoryV5;
|
|
4
4
|
symbol: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountMarginModeV5, AccountTypeV5, CategoryV5, TransactionTypeV5, UnifiedUpdateStatusV5 } from '../v5
|
|
1
|
+
import { AccountMarginModeV5, AccountTypeV5, CategoryV5, TransactionTypeV5, UnifiedUpdateStatusV5 } from '../shared-v5';
|
|
2
2
|
export interface WalletBalanceV5Coin {
|
|
3
3
|
coin: string;
|
|
4
4
|
equity: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CategoryCursorListV5, CategoryV5, ContractTypeV5, CopyTradingV5, InstrumentStatusV5, MarginTradingV5, OptionTypeV5, OrderSideV5 } from '../v5
|
|
1
|
+
import { CategoryCursorListV5, CategoryV5, ContractTypeV5, CopyTradingV5, InstrumentStatusV5, MarginTradingV5, OptionTypeV5, OrderSideV5 } from '../shared-v5';
|
|
2
2
|
/**
|
|
3
3
|
* OHLCVT candle used by v5 APIs
|
|
4
4
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CategoryV5, ExecTypeV5, OrderSideV5, OrderTypeV5, PositionIdx, PositionSideV5, PositionStatusV5, StopOrderTypeV5, TPSLModeV5, TradeModeV5 } from '../v5
|
|
1
|
+
import { CategoryV5, ExecTypeV5, OrderSideV5, OrderTypeV5, PositionIdx, PositionSideV5, PositionStatusV5, StopOrderTypeV5, TPSLModeV5, TradeModeV5 } from '../shared-v5';
|
|
2
2
|
export interface PositionV5 {
|
|
3
3
|
positionIdx: PositionIdx;
|
|
4
4
|
riskId: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CategoryV5, OrderCancelTypeV5, OrderCreateTypeV5, OrderRejectReasonV5, OrderSideV5, OrderStatusV5, OrderTimeInForceV5, OrderTriggerByV5, OrderTypeV5, PositionIdx, StopOrderTypeV5 } from '../v5
|
|
1
|
+
import { CategoryV5, OrderCancelTypeV5, OrderCreateTypeV5, OrderRejectReasonV5, OrderSideV5, OrderStatusV5, OrderTimeInForceV5, OrderTriggerByV5, OrderTypeV5, PositionIdx, StopOrderTypeV5 } from '../shared-v5';
|
|
2
2
|
export interface OrderResultV5 {
|
|
3
3
|
orderId: string;
|
|
4
4
|
orderLinkId: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-v5.js","sourceRoot":"","sources":["../../src/types/shared-v5.ts"],"names":[],"mappings":""}
|
package/lib/types/shared.d.ts
CHANGED
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
import { ContractClient } from '../contract-client';
|
|
2
|
-
import { InverseClient } from '../inverse-client';
|
|
3
|
-
import { LinearClient } from '../linear-client';
|
|
4
1
|
import { RestClientV5 } from '../rest-client-v5';
|
|
5
|
-
import { SpotClient } from '../spot-client';
|
|
6
2
|
import { SpotClientV3 } from '../spot-client-v3';
|
|
7
|
-
|
|
8
|
-
import { USDCOptionClient } from '../usdc-option-client';
|
|
9
|
-
import { USDCPerpetualClient } from '../usdc-perpetual-client';
|
|
10
|
-
export type RESTClient = InverseClient | LinearClient | SpotClient | SpotClientV3 | USDCOptionClient | USDCPerpetualClient | UnifiedMarginClient | ContractClient | RestClientV5;
|
|
3
|
+
export type RESTClient = SpotClientV3 | RestClientV5;
|
|
11
4
|
export type numberInString = string;
|
|
12
5
|
export type OrderSide = 'Buy' | 'Sell';
|
|
13
6
|
export type KlineInterval = '1m' | '3m' | '5m' | '15m' | '30m' | '1h' | '2h' | '4h' | '6h' | '12h' | '1d' | '1w' | '1M';
|
|
14
7
|
export type KlineIntervalV3 = '1' | '3' | '5' | '15' | '30' | '60' | '120' | '240' | '360' | '720' | 'D' | 'W' | 'M';
|
|
15
|
-
export interface APIResponse<T> {
|
|
16
|
-
ret_code: number;
|
|
17
|
-
ret_msg: 'OK' | string;
|
|
18
|
-
ext_code: string | null;
|
|
19
|
-
ext_info: string | null;
|
|
20
|
-
result: T;
|
|
21
|
-
}
|
|
22
8
|
export interface APIRateLimit {
|
|
23
9
|
/** Remaining requests to this endpoint before the next reset */
|
|
24
10
|
remainingRequests: number;
|
|
@@ -46,10 +32,6 @@ export interface APIResponseV3<T> {
|
|
|
46
32
|
export type APIResponseV3WithTime<T> = APIResponseV3<T> & {
|
|
47
33
|
time: number;
|
|
48
34
|
};
|
|
49
|
-
export interface APIResponseWithTime<T = {}> extends APIResponse<T> {
|
|
50
|
-
/** UTC timestamp */
|
|
51
|
-
time_now: numberInString;
|
|
52
|
-
}
|
|
53
35
|
/**
|
|
54
36
|
* Request Parameter Types
|
|
55
37
|
*/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ws-general"), exports);
|
|
18
|
+
__exportStar(require("./ws-events"), exports);
|
|
19
|
+
__exportStar(require("./ws-confirmations"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/websockets/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,8CAA4B;AAC5B,qDAAmC"}
|