bybit-api 3.1.3 → 3.3.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 +5 -3
- package/lib/constants/enum.d.ts +8 -0
- package/lib/constants/enum.js +8 -0
- package/lib/constants/enum.js.map +1 -1
- package/lib/contract-client.d.ts +118 -0
- package/lib/contract-client.js +233 -0
- package/lib/contract-client.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/types/request/contract.d.ts +115 -0
- package/lib/types/request/contract.js +3 -0
- package/lib/types/request/contract.js.map +1 -0
- package/lib/types/request/index.d.ts +1 -0
- package/lib/types/request/index.js +1 -0
- package/lib/types/request/index.js.map +1 -1
- package/lib/types/response/index.d.ts +1 -0
- package/lib/types/response/index.js +1 -0
- package/lib/types/response/index.js.map +1 -1
- package/lib/types/response/unified-margin.d.ts +65 -0
- package/lib/types/response/unified-margin.js +3 -0
- package/lib/types/response/unified-margin.js.map +1 -0
- package/lib/types/shared.d.ts +2 -1
- package/lib/types/websockets.d.ts +1 -1
- package/lib/unified-margin-client.d.ts +3 -3
- package/lib/unified-margin-client.js.map +1 -1
- package/lib/usdc-perpetual-client.js +1 -0
- package/lib/usdc-perpetual-client.js.map +1 -1
- package/lib/util/BaseRestClient.js +6 -3
- package/lib/util/BaseRestClient.js.map +1 -1
- package/lib/util/requestUtils.d.ts +8 -1
- package/lib/util/requestUtils.js +5 -2
- package/lib/util/requestUtils.js.map +1 -1
- package/lib/util/websocket-util.d.ts +4 -0
- package/lib/util/websocket-util.js +46 -1
- package/lib/util/websocket-util.js.map +1 -1
- package/lib/websocket-client.d.ts +6 -1
- package/lib/websocket-client.js +77 -19
- package/lib/websocket-client.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
Node.js connector for the Bybit APIs and WebSockets:
|
|
12
12
|
- Complete integration with all bybit APIs.
|
|
13
13
|
- TypeScript support (with type declarations for most API requests & responses).
|
|
14
|
-
- Over 300
|
|
14
|
+
- Over 300 end-to-end tests making real API calls & WebSocket connections, validating any changes before they reach npm.
|
|
15
15
|
- Robust WebSocket integration with configurable connection heartbeats & automatic reconnect then resubscribe workflows.
|
|
16
16
|
- Browser support (via webpack bundle - see "Browser Usage" below).
|
|
17
17
|
|
|
@@ -25,10 +25,10 @@ Node.js connector for the Bybit APIs and WebSockets:
|
|
|
25
25
|
## Related projects
|
|
26
26
|
Check out my related projects:
|
|
27
27
|
- Try my connectors:
|
|
28
|
-
- [ftx-api](https://www.npmjs.com/package/ftx-api)
|
|
29
|
-
- [bybit-api](https://www.npmjs.com/package/bybit-api)
|
|
30
28
|
- [binance](https://www.npmjs.com/package/binance)
|
|
29
|
+
- [bybit-api](https://www.npmjs.com/package/bybit-api)
|
|
31
30
|
- [okx-api](https://www.npmjs.com/package/okx-api)
|
|
31
|
+
- [ftx-api](https://www.npmjs.com/package/ftx-api)
|
|
32
32
|
- Try my misc utilities:
|
|
33
33
|
- [orderbooks](https://www.npmjs.com/package/orderbooks)
|
|
34
34
|
- Check out my examples:
|
|
@@ -180,6 +180,8 @@ The WebsocketClient can be configured to a specific API group using the market p
|
|
|
180
180
|
| Copy Trading | `market: 'linear'` | The [copy trading](https://bybit-exchange.github.io/docs/copy_trading/#t-websocket) category. Use the linear market to listen to all copy trading topics. |
|
|
181
181
|
| USDC Perps | `market: 'usdcPerp` | The [USDC perps](https://bybit-exchange.github.io/docs/usdc/perpetual/#t-websocket) category. |
|
|
182
182
|
| USDC Options | `market: 'usdcOption'`| The [USDC options](https://bybit-exchange.github.io/docs/usdc/option/#t-websocket) category. |
|
|
183
|
+
| Contract v3 USDT | `market: 'contractUSDT'`| The [Contract V3](https://bybit-exchange.github.io/docs/derivativesV3/contract/#t-websocket) category (USDT perps) |
|
|
184
|
+
| Contract v3 Inverse | `market: 'contractInverse'`| The [Contract V3](https://bybit-exchange.github.io/docs/derivativesV3/contract/#t-websocket) category (inverse perps) |
|
|
183
185
|
|
|
184
186
|
```javascript
|
|
185
187
|
const { WebsocketClient } = require('bybit-api');
|
package/lib/constants/enum.d.ts
CHANGED
|
@@ -43,6 +43,8 @@ export declare const API_ERROR_CODE: {
|
|
|
43
43
|
readonly RISK_LIMIT_NOT_EXISTS: 30090;
|
|
44
44
|
readonly LEVERAGE_NOT_MODIFIED: 34036;
|
|
45
45
|
readonly SAME_SLTP_MODE: 37002;
|
|
46
|
+
readonly COPY_TRADE_NOT_OPEN_ORDER: 39426;
|
|
47
|
+
readonly QTY_EXCEEDS_MAX_LIMIT: 130006;
|
|
46
48
|
readonly ORDER_NOT_FOUND_OR_TOO_LATE_LINEAR: 130010;
|
|
47
49
|
readonly ORDER_COST_NOT_AVAILABLE: 130021;
|
|
48
50
|
readonly CANNOT_SET_LINEAR_TRADING_STOP_FOR_ZERO_POS: 130024;
|
|
@@ -52,6 +54,12 @@ export declare const API_ERROR_CODE: {
|
|
|
52
54
|
readonly INSUFFICIENT_BALANCE_FOR_ORDER_COST_LINEAR: 130080;
|
|
53
55
|
readonly SAME_SLTP_MODE_LINEAR: 130150;
|
|
54
56
|
readonly RISK_ID_NOT_MODIFIED: 134026;
|
|
57
|
+
readonly CONTRACT_ORDER_NOT_EXISTS: 140001;
|
|
58
|
+
readonly CONTRACT_INSUFFICIENT_BALANCE: 140007;
|
|
59
|
+
readonly CONTRACT_POSITION_MODE_NOT_MODIFIED: 140025;
|
|
60
|
+
readonly CONTRACT_MARGIN_MODE_NOT_MODIFIED: 140026;
|
|
61
|
+
readonly CONTRACT_RISK_LIMIT_INFO_NOT_EXISTS: 140031;
|
|
62
|
+
readonly CONTRACT_SET_LEVERAGE_NOT_MODIFIED: 140043;
|
|
55
63
|
/** E.g. USDC Options trading, trying to access a symbol that is no longer active */
|
|
56
64
|
readonly CONTRACT_NAME_NOT_EXIST: 3100111;
|
|
57
65
|
readonly ORDER_NOT_EXIST: 3100136;
|
package/lib/constants/enum.js
CHANGED
|
@@ -46,6 +46,8 @@ exports.API_ERROR_CODE = {
|
|
|
46
46
|
RISK_LIMIT_NOT_EXISTS: 30090,
|
|
47
47
|
LEVERAGE_NOT_MODIFIED: 34036,
|
|
48
48
|
SAME_SLTP_MODE: 37002,
|
|
49
|
+
COPY_TRADE_NOT_OPEN_ORDER: 39426,
|
|
50
|
+
QTY_EXCEEDS_MAX_LIMIT: 130006,
|
|
49
51
|
ORDER_NOT_FOUND_OR_TOO_LATE_LINEAR: 130010,
|
|
50
52
|
ORDER_COST_NOT_AVAILABLE: 130021,
|
|
51
53
|
CANNOT_SET_LINEAR_TRADING_STOP_FOR_ZERO_POS: 130024,
|
|
@@ -55,6 +57,12 @@ exports.API_ERROR_CODE = {
|
|
|
55
57
|
INSUFFICIENT_BALANCE_FOR_ORDER_COST_LINEAR: 130080,
|
|
56
58
|
SAME_SLTP_MODE_LINEAR: 130150,
|
|
57
59
|
RISK_ID_NOT_MODIFIED: 134026,
|
|
60
|
+
CONTRACT_ORDER_NOT_EXISTS: 140001,
|
|
61
|
+
CONTRACT_INSUFFICIENT_BALANCE: 140007,
|
|
62
|
+
CONTRACT_POSITION_MODE_NOT_MODIFIED: 140025,
|
|
63
|
+
CONTRACT_MARGIN_MODE_NOT_MODIFIED: 140026,
|
|
64
|
+
CONTRACT_RISK_LIMIT_INFO_NOT_EXISTS: 140031,
|
|
65
|
+
CONTRACT_SET_LEVERAGE_NOT_MODIFIED: 140043,
|
|
58
66
|
/** E.g. USDC Options trading, trying to access a symbol that is no longer active */
|
|
59
67
|
CONTRACT_NAME_NOT_EXIST: 3100111,
|
|
60
68
|
ORDER_NOT_EXIST: 3100136,
|
|
@@ -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,oB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RateHistoryRequest, UMInstrumentInfoRequest, UMOpenInterestRequest, UMOptionDeliveryPriceRequest, UMPublicTradesRequest, ContractOrderRequest, ContractHistoricOrdersRequest, ContractCancelOrderRequest, ContractModifyOrderRequest, ContractActiveOrdersRequest, ContractPositionsRequest, ContractSetAutoAddMarginRequest, ContractSetMarginSwitchRequest, ContractSetPositionModeRequest, ContractSetTPSLRequest, ContractUserExecutionHistoryRequest, ContractClosedPNLRequest, ContractWalletFundRecordRequest } from './types';
|
|
2
|
+
import BaseRestClient from './util/BaseRestClient';
|
|
3
|
+
/**
|
|
4
|
+
* REST API client for Derivatives V3 Contract APIs
|
|
5
|
+
*/
|
|
6
|
+
export declare class ContractClient extends BaseRestClient {
|
|
7
|
+
getClientType(): "v3";
|
|
8
|
+
fetchServerTime(): Promise<number>;
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* Market Data Endpoints : these seem exactly the same as the unified margin market data endpoints
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
/** Query order book info. Each side has a depth of 25 orders. */
|
|
15
|
+
getOrderBook(symbol: string, category: string, limit?: number): Promise<APIResponseV3<any>>;
|
|
16
|
+
/** Get candles/klines */
|
|
17
|
+
getCandles(params: UMCandlesRequest): Promise<APIResponseV3<any>>;
|
|
18
|
+
/** Get a symbol price/statistics ticker */
|
|
19
|
+
getSymbolTicker(category: UMCategory, symbol?: string): Promise<APIResponseV3<any>>;
|
|
20
|
+
/** Get trading rules per symbol/contract, incl price/amount/value/leverage filters */
|
|
21
|
+
getInstrumentInfo(params: UMInstrumentInfoRequest): Promise<APIResponseV3<any>>;
|
|
22
|
+
/** Query mark price kline (like getCandles() but for mark price). */
|
|
23
|
+
getMarkPriceCandles(params: UMCandlesRequest): Promise<APIResponseV3<any>>;
|
|
24
|
+
/** Query Index Price Kline */
|
|
25
|
+
getIndexPriceCandles(params: UMCandlesRequest): Promise<APIResponseV3<any>>;
|
|
26
|
+
/**
|
|
27
|
+
* The funding rate is generated every 8 hours at 00:00 UTC, 08:00 UTC and 16:00 UTC.
|
|
28
|
+
* For example, if a request is sent at 12:00 UTC, the funding rate generated earlier that day at 08:00 UTC will be sent.
|
|
29
|
+
*/
|
|
30
|
+
getFundingRateHistory(params: UMFundingRateHistoryRequest): Promise<APIResponseV3<any>>;
|
|
31
|
+
/** Get Risk Limit */
|
|
32
|
+
getRiskLimit(category: UMCategory, symbol: string): Promise<APIResponseV3<any>>;
|
|
33
|
+
/** Get option delivery price */
|
|
34
|
+
getOptionDeliveryPrice(params: UMOptionDeliveryPriceRequest): Promise<APIResponseV3<any>>;
|
|
35
|
+
/** Get public trading history */
|
|
36
|
+
getTrades(params: UMPublicTradesRequest): Promise<APIResponseV3<any>>;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the total amount of unsettled contracts.
|
|
39
|
+
* In other words, the total number of contracts held in open positions.
|
|
40
|
+
*/
|
|
41
|
+
getOpenInterest(params: UMOpenInterestRequest): Promise<APIResponseV3<any>>;
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* Contract Account Endpoints
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
/** -> Order API */
|
|
48
|
+
/** Place an order */
|
|
49
|
+
submitOrder(params: ContractOrderRequest): Promise<APIResponseV3<any>>;
|
|
50
|
+
/** Query order history. As order creation/cancellation is asynchronous, the data returned from the interface may be delayed. To access order information in real-time, call getActiveOrders() */
|
|
51
|
+
getHistoricOrders(params: ContractHistoricOrdersRequest): Promise<APIResponseV3<any>>;
|
|
52
|
+
/** Cancel order */
|
|
53
|
+
cancelOrder(params: ContractCancelOrderRequest): Promise<APIResponseV3<any>>;
|
|
54
|
+
/** Cancel all orders */
|
|
55
|
+
cancelAllOrders(symbol: string): Promise<APIResponseV3<any>>;
|
|
56
|
+
/** Replace order : Active order parameters (such as quantity, price) and stop order parameters cannot be modified in one request at the same time. Please request modification separately. */
|
|
57
|
+
modifyOrder(params: ContractModifyOrderRequest): Promise<APIResponseV3<any>>;
|
|
58
|
+
/** Query Open Order(s) (real-time) */
|
|
59
|
+
getActiveOrders(params: ContractActiveOrdersRequest): Promise<APIResponseV3<any>>;
|
|
60
|
+
/** -> Positions API */
|
|
61
|
+
/**
|
|
62
|
+
* Query my positions real-time. Accessing personal list of positions.
|
|
63
|
+
* Either symbol or settleCoin is required.
|
|
64
|
+
* Users can access their position holding information through this interface, such as the number of position holdings and wallet balance.
|
|
65
|
+
*/
|
|
66
|
+
getPositions(params?: ContractPositionsRequest): Promise<APIResponseV3<any>>;
|
|
67
|
+
/** Set auto add margin, or Auto-Margin Replenishment. */
|
|
68
|
+
setAutoAddMargin(params: ContractSetAutoAddMarginRequest): Promise<APIResponseV3<any>>;
|
|
69
|
+
/** Switch cross margin mode/isolated margin mode */
|
|
70
|
+
setMarginSwitch(params: ContractSetMarginSwitchRequest): Promise<APIResponseV3<any>>;
|
|
71
|
+
/** Supports switching between One-Way Mode and Hedge Mode at the coin level. */
|
|
72
|
+
setPositionMode(params: ContractSetPositionModeRequest): Promise<APIResponseV3<any>>;
|
|
73
|
+
/**
|
|
74
|
+
* Switch mode between Full or Partial
|
|
75
|
+
*/
|
|
76
|
+
setTPSLMode(symbol: string, tpSlMode: 'Full' | 'Partial'): Promise<APIResponseV3<any>>;
|
|
77
|
+
/** Leverage setting. */
|
|
78
|
+
setLeverage(symbol: string, buyLeverage: string, sellLeverage: string): Promise<APIResponseV3<any>>;
|
|
79
|
+
/**
|
|
80
|
+
* Set take profit, stop loss, and trailing stop for your open position.
|
|
81
|
+
* If using partial mode, TP/SL/TS orders will not close your entire position.
|
|
82
|
+
*/
|
|
83
|
+
setTPSL(params: ContractSetTPSLRequest): Promise<APIResponseV3<any>>;
|
|
84
|
+
/** Set risk limit */
|
|
85
|
+
setRiskLimit(symbol: string, riskId: number,
|
|
86
|
+
/** 0-one-way, 1-buy side, 2-sell side */
|
|
87
|
+
positionIdx: 0 | 1 | 2): Promise<APIResponseV3<any>>;
|
|
88
|
+
/**
|
|
89
|
+
* Get user's trading records.
|
|
90
|
+
* The results are ordered in descending order (the first item is the latest). Returns records up to 2 years old.
|
|
91
|
+
*/
|
|
92
|
+
getUserExecutionHistory(params: ContractUserExecutionHistoryRequest): Promise<APIResponseV3<any>>;
|
|
93
|
+
/**
|
|
94
|
+
* Get user's closed profit and loss records.
|
|
95
|
+
* The results are ordered in descending order (the first item is the latest).
|
|
96
|
+
*/
|
|
97
|
+
getClosedProfitAndLoss(params: ContractClosedPNLRequest): Promise<APIResponseV3<any>>;
|
|
98
|
+
/** Get the information of open interest limit. */
|
|
99
|
+
getOpenInterestLimitInfo(symbol: string): Promise<APIResponseV3<any>>;
|
|
100
|
+
/** -> Account API */
|
|
101
|
+
/** Query wallet balance */
|
|
102
|
+
getBalances(coin?: string): Promise<APIResponseV3<any>>;
|
|
103
|
+
/** Get user trading fee rate */
|
|
104
|
+
getTradingFeeRate(symbol?: string): Promise<APIResponseV3<any>>;
|
|
105
|
+
/**
|
|
106
|
+
* Get wallet fund records.
|
|
107
|
+
* This endpoint also shows exchanges from the Asset Exchange, where the types for the exchange are ExchangeOrderWithdraw and ExchangeOrderDeposit.
|
|
108
|
+
* This endpoint returns incomplete information for transfers involving the derivatives wallet.
|
|
109
|
+
* Use the account asset API for creating and querying internal transfers.
|
|
110
|
+
*/
|
|
111
|
+
getWalletFundRecords(params?: ContractWalletFundRecordRequest): Promise<APIResponseV3<any>>;
|
|
112
|
+
/**
|
|
113
|
+
*
|
|
114
|
+
* API Data Endpoints
|
|
115
|
+
*
|
|
116
|
+
*/
|
|
117
|
+
getServerTime(): Promise<APIResponseWithTime>;
|
|
118
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
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
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ContractClient = void 0;
|
|
16
|
+
const util_1 = require("./util");
|
|
17
|
+
const BaseRestClient_1 = __importDefault(require("./util/BaseRestClient"));
|
|
18
|
+
/**
|
|
19
|
+
* REST API client for Derivatives V3 Contract APIs
|
|
20
|
+
*/
|
|
21
|
+
class ContractClient extends BaseRestClient_1.default {
|
|
22
|
+
getClientType() {
|
|
23
|
+
// Follows the same authentication mechanism as other v3 APIs (e.g. USDC)
|
|
24
|
+
return util_1.REST_CLIENT_TYPE_ENUM.v3;
|
|
25
|
+
}
|
|
26
|
+
fetchServerTime() {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const res = yield this.getServerTime();
|
|
29
|
+
return Number(res.time_now);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* Market Data Endpoints : these seem exactly the same as the unified margin market data endpoints
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
/** Query order book info. Each side has a depth of 25 orders. */
|
|
38
|
+
getOrderBook(symbol, category, limit) {
|
|
39
|
+
return this.get('/derivatives/v3/public/order-book/L2', {
|
|
40
|
+
category,
|
|
41
|
+
symbol,
|
|
42
|
+
limit,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/** Get candles/klines */
|
|
46
|
+
getCandles(params) {
|
|
47
|
+
return this.get('/derivatives/v3/public/kline', params);
|
|
48
|
+
}
|
|
49
|
+
/** Get a symbol price/statistics ticker */
|
|
50
|
+
getSymbolTicker(category, symbol) {
|
|
51
|
+
return this.get('/derivatives/v3/public/tickers', { category, symbol });
|
|
52
|
+
}
|
|
53
|
+
/** Get trading rules per symbol/contract, incl price/amount/value/leverage filters */
|
|
54
|
+
getInstrumentInfo(params) {
|
|
55
|
+
return this.get('/derivatives/v3/public/instruments-info', params);
|
|
56
|
+
}
|
|
57
|
+
/** Query mark price kline (like getCandles() but for mark price). */
|
|
58
|
+
getMarkPriceCandles(params) {
|
|
59
|
+
return this.get('/derivatives/v3/public/mark-price-kline', params);
|
|
60
|
+
}
|
|
61
|
+
/** Query Index Price Kline */
|
|
62
|
+
getIndexPriceCandles(params) {
|
|
63
|
+
return this.get('/derivatives/v3/public/index-price-kline', params);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The funding rate is generated every 8 hours at 00:00 UTC, 08:00 UTC and 16:00 UTC.
|
|
67
|
+
* For example, if a request is sent at 12:00 UTC, the funding rate generated earlier that day at 08:00 UTC will be sent.
|
|
68
|
+
*/
|
|
69
|
+
getFundingRateHistory(params) {
|
|
70
|
+
return this.get('/derivatives/v3/public/funding/history-funding-rate', params);
|
|
71
|
+
}
|
|
72
|
+
/** Get Risk Limit */
|
|
73
|
+
getRiskLimit(category, symbol) {
|
|
74
|
+
return this.get('/derivatives/v3/public/risk-limit/list', {
|
|
75
|
+
category,
|
|
76
|
+
symbol,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/** Get option delivery price */
|
|
80
|
+
getOptionDeliveryPrice(params) {
|
|
81
|
+
return this.get('/derivatives/v3/public/delivery-price', params);
|
|
82
|
+
}
|
|
83
|
+
/** Get public trading history */
|
|
84
|
+
getTrades(params) {
|
|
85
|
+
return this.get('/derivatives/v3/public/recent-trade', params);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Gets the total amount of unsettled contracts.
|
|
89
|
+
* In other words, the total number of contracts held in open positions.
|
|
90
|
+
*/
|
|
91
|
+
getOpenInterest(params) {
|
|
92
|
+
return this.get('/derivatives/v3/public/open-interest', params);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
* Contract Account Endpoints
|
|
97
|
+
*
|
|
98
|
+
*/
|
|
99
|
+
/** -> Order API */
|
|
100
|
+
/** Place an order */
|
|
101
|
+
submitOrder(params) {
|
|
102
|
+
return this.postPrivate('/contract/v3/private/order/create', params);
|
|
103
|
+
}
|
|
104
|
+
/** Query order history. As order creation/cancellation is asynchronous, the data returned from the interface may be delayed. To access order information in real-time, call getActiveOrders() */
|
|
105
|
+
getHistoricOrders(params) {
|
|
106
|
+
return this.getPrivate('/contract/v3/private/order/list', params);
|
|
107
|
+
}
|
|
108
|
+
/** Cancel order */
|
|
109
|
+
cancelOrder(params) {
|
|
110
|
+
return this.postPrivate('/contract/v3/private/order/cancel', params);
|
|
111
|
+
}
|
|
112
|
+
/** Cancel all orders */
|
|
113
|
+
cancelAllOrders(symbol) {
|
|
114
|
+
return this.postPrivate('/contract/v3/private/order/cancel-all', {
|
|
115
|
+
symbol,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/** Replace order : Active order parameters (such as quantity, price) and stop order parameters cannot be modified in one request at the same time. Please request modification separately. */
|
|
119
|
+
modifyOrder(params) {
|
|
120
|
+
return this.postPrivate('/contract/v3/private/order/replace', params);
|
|
121
|
+
}
|
|
122
|
+
/** Query Open Order(s) (real-time) */
|
|
123
|
+
getActiveOrders(params) {
|
|
124
|
+
return this.getPrivate('/contract/v3/private/order/unfilled-orders', params);
|
|
125
|
+
}
|
|
126
|
+
/** -> Positions API */
|
|
127
|
+
/**
|
|
128
|
+
* Query my positions real-time. Accessing personal list of positions.
|
|
129
|
+
* Either symbol or settleCoin is required.
|
|
130
|
+
* Users can access their position holding information through this interface, such as the number of position holdings and wallet balance.
|
|
131
|
+
*/
|
|
132
|
+
getPositions(params) {
|
|
133
|
+
return this.getPrivate('/contract/v3/private/position/list', params);
|
|
134
|
+
}
|
|
135
|
+
/** Set auto add margin, or Auto-Margin Replenishment. */
|
|
136
|
+
setAutoAddMargin(params) {
|
|
137
|
+
return this.postPrivate('/contract/v3/private/position/set-auto-add-margin', params);
|
|
138
|
+
}
|
|
139
|
+
/** Switch cross margin mode/isolated margin mode */
|
|
140
|
+
setMarginSwitch(params) {
|
|
141
|
+
return this.postPrivate('/contract/v3/private/position/switch-isolated', params);
|
|
142
|
+
}
|
|
143
|
+
/** Supports switching between One-Way Mode and Hedge Mode at the coin level. */
|
|
144
|
+
setPositionMode(params) {
|
|
145
|
+
return this.postPrivate('/contract/v3/private/position/switch-mode', params);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Switch mode between Full or Partial
|
|
149
|
+
*/
|
|
150
|
+
setTPSLMode(symbol, tpSlMode) {
|
|
151
|
+
return this.postPrivate('/contract/v3/private/position/switch-tpsl-mode', {
|
|
152
|
+
symbol,
|
|
153
|
+
tpSlMode,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/** Leverage setting. */
|
|
157
|
+
setLeverage(symbol, buyLeverage, sellLeverage) {
|
|
158
|
+
return this.postPrivate('/contract/v3/private/position/set-leverage', {
|
|
159
|
+
symbol,
|
|
160
|
+
buyLeverage,
|
|
161
|
+
sellLeverage,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Set take profit, stop loss, and trailing stop for your open position.
|
|
166
|
+
* If using partial mode, TP/SL/TS orders will not close your entire position.
|
|
167
|
+
*/
|
|
168
|
+
setTPSL(params) {
|
|
169
|
+
return this.postPrivate('/contract/v3/private/position/trading-stop', params);
|
|
170
|
+
}
|
|
171
|
+
/** Set risk limit */
|
|
172
|
+
setRiskLimit(symbol, riskId,
|
|
173
|
+
/** 0-one-way, 1-buy side, 2-sell side */
|
|
174
|
+
positionIdx) {
|
|
175
|
+
return this.postPrivate('/contract/v3/private/position/set-risk-limit', {
|
|
176
|
+
symbol,
|
|
177
|
+
riskId,
|
|
178
|
+
positionIdx,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Get user's trading records.
|
|
183
|
+
* The results are ordered in descending order (the first item is the latest). Returns records up to 2 years old.
|
|
184
|
+
*/
|
|
185
|
+
getUserExecutionHistory(params) {
|
|
186
|
+
return this.getPrivate('/contract/v3/private/execution/list', params);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Get user's closed profit and loss records.
|
|
190
|
+
* The results are ordered in descending order (the first item is the latest).
|
|
191
|
+
*/
|
|
192
|
+
getClosedProfitAndLoss(params) {
|
|
193
|
+
return this.getPrivate('/contract/v3/private/position/closed-pnl', params);
|
|
194
|
+
}
|
|
195
|
+
/** Get the information of open interest limit. */
|
|
196
|
+
getOpenInterestLimitInfo(symbol) {
|
|
197
|
+
return this.getPrivate('/contract/v3/private/position/closed-pnl', {
|
|
198
|
+
symbol,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
/** -> Account API */
|
|
202
|
+
/** Query wallet balance */
|
|
203
|
+
getBalances(coin) {
|
|
204
|
+
return this.getPrivate('/contract/v3/private/account/wallet/balance', {
|
|
205
|
+
coin,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
/** Get user trading fee rate */
|
|
209
|
+
getTradingFeeRate(symbol) {
|
|
210
|
+
return this.getPrivate('/contract/v3/private/account/fee-rate', {
|
|
211
|
+
symbol,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Get wallet fund records.
|
|
216
|
+
* This endpoint also shows exchanges from the Asset Exchange, where the types for the exchange are ExchangeOrderWithdraw and ExchangeOrderDeposit.
|
|
217
|
+
* This endpoint returns incomplete information for transfers involving the derivatives wallet.
|
|
218
|
+
* Use the account asset API for creating and querying internal transfers.
|
|
219
|
+
*/
|
|
220
|
+
getWalletFundRecords(params) {
|
|
221
|
+
return this.getPrivate('/contract/v3/private/account/wallet/fund-records', params);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
*
|
|
225
|
+
* API Data Endpoints
|
|
226
|
+
*
|
|
227
|
+
*/
|
|
228
|
+
getServerTime() {
|
|
229
|
+
return this.get('/v2/public/time');
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
exports.ContractClient = ContractClient;
|
|
233
|
+
//# sourceMappingURL=contract-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-client.js","sourceRoot":"","sources":["../src/contract-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAwBA,iCAA+C;AAC/C,2EAAmD;AAEnD;;GAEG;AACH,MAAa,cAAe,SAAQ,wBAAc;IAChD,aAAa;QACX,yEAAyE;QACzE,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,iEAAiE;IACjE,YAAY,CACV,MAAc,EACd,QAAgB,EAChB,KAAc;QAEd,OAAO,IAAI,CAAC,GAAG,CAAC,sCAAsC,EAAE;YACtD,QAAQ;YACR,MAAM;YACN,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAED,yBAAyB;IACzB,UAAU,CAAC,MAAwB;QACjC,OAAO,IAAI,CAAC,GAAG,CAAC,8BAA8B,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC;IAED,2CAA2C;IAC3C,eAAe,CACb,QAAoB,EACpB,MAAe;QAEf,OAAO,IAAI,CAAC,GAAG,CAAC,gCAAgC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,sFAAsF;IACtF,iBAAiB,CACf,MAA+B;QAE/B,OAAO,IAA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F;AAtTD,wCAsTC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from './spot-client-v3';
|
|
|
8
8
|
export * from './usdc-option-client';
|
|
9
9
|
export * from './usdc-perpetual-client';
|
|
10
10
|
export * from './unified-margin-client';
|
|
11
|
+
export * from './contract-client';
|
|
11
12
|
export * from './websocket-client';
|
|
12
13
|
export * from './util/logger';
|
|
13
14
|
export * from './util';
|
package/lib/index.js
CHANGED
|
@@ -20,6 +20,7 @@ __exportStar(require("./spot-client-v3"), exports);
|
|
|
20
20
|
__exportStar(require("./usdc-option-client"), exports);
|
|
21
21
|
__exportStar(require("./usdc-perpetual-client"), exports);
|
|
22
22
|
__exportStar(require("./unified-margin-client"), exports);
|
|
23
|
+
__exportStar(require("./contract-client"), exports);
|
|
23
24
|
__exportStar(require("./websocket-client"), exports);
|
|
24
25
|
__exportStar(require("./util/logger"), exports);
|
|
25
26
|
__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,yDAAuC;AACvC,wDAAsC;AACtC,mDAAiC;AACjC,2DAAyC;AACzC,kDAAgC;AAChC,gDAA8B;AAC9B,mDAAiC;AACjC,uDAAqC;AACrC,0DAAwC;AACxC,0DAAwC;AACxC,qDAAmC;AACnC,gDAA8B;AAC9B,yCAAuB;AACvB,0CAAwB;AACxB,mDAAiC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAuC;AACvC,wDAAsC;AACtC,mDAAiC;AACjC,2DAAyC;AACzC,kDAAgC;AAChC,gDAA8B;AAC9B,mDAAiC;AACjC,uDAAqC;AACrC,0DAAwC;AACxC,0DAAwC;AACxC,oDAAkC;AAClC,qDAAmC;AACnC,gDAA8B;AAC9B,yCAAuB;AACvB,0CAAwB;AACxB,mDAAiC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { OrderSide } from '../shared';
|
|
2
|
+
import { UMOrderType } from './unified-margin';
|
|
3
|
+
import { USDCOrderFilter, USDCTimeInForce } from './usdc-shared';
|
|
4
|
+
export interface ContractOrderRequest {
|
|
5
|
+
symbol: string;
|
|
6
|
+
side: OrderSide;
|
|
7
|
+
positionIdx?: '0' | '1' | '2';
|
|
8
|
+
orderType: UMOrderType;
|
|
9
|
+
qty: string;
|
|
10
|
+
price?: string;
|
|
11
|
+
triggerDirection?: '1' | '2';
|
|
12
|
+
triggerPrice?: string;
|
|
13
|
+
triggerBy?: string;
|
|
14
|
+
tpTriggerBy?: string;
|
|
15
|
+
slTriggerBy?: string;
|
|
16
|
+
timeInForce: USDCTimeInForce;
|
|
17
|
+
orderLinkId?: string;
|
|
18
|
+
takeProfit?: number;
|
|
19
|
+
stopLoss?: number;
|
|
20
|
+
reduceOnly?: boolean;
|
|
21
|
+
closeOnTrigger?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface ContractHistoricOrdersRequest {
|
|
24
|
+
orderId?: string;
|
|
25
|
+
orderLinkId?: string;
|
|
26
|
+
symbol: string;
|
|
27
|
+
orderStatus?: string;
|
|
28
|
+
orderFilter?: USDCOrderFilter;
|
|
29
|
+
limit?: number;
|
|
30
|
+
cursor?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ContractCancelOrderRequest {
|
|
33
|
+
symbol: string;
|
|
34
|
+
orderId?: string;
|
|
35
|
+
orderLinkId?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface ContractModifyOrderRequest {
|
|
38
|
+
orderId?: string;
|
|
39
|
+
orderLinkId?: string;
|
|
40
|
+
symbol: string;
|
|
41
|
+
qty?: string;
|
|
42
|
+
price?: string;
|
|
43
|
+
takeProfit?: number;
|
|
44
|
+
stopLoss?: number;
|
|
45
|
+
tpTriggerBy?: string;
|
|
46
|
+
slTriggerBy?: string;
|
|
47
|
+
triggerBy?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface ContractActiveOrdersRequest {
|
|
50
|
+
symbol?: string;
|
|
51
|
+
orderId?: string;
|
|
52
|
+
orderLinkId?: string;
|
|
53
|
+
settleCoin?: string;
|
|
54
|
+
orderFilter?: USDCOrderFilter;
|
|
55
|
+
limit?: number;
|
|
56
|
+
}
|
|
57
|
+
export interface ContractPositionsRequest {
|
|
58
|
+
symbol?: string;
|
|
59
|
+
settleCoin?: string;
|
|
60
|
+
dataFilter?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface ContractSetAutoAddMarginRequest {
|
|
63
|
+
symbol: string;
|
|
64
|
+
side: 'Buy' | 'Sell';
|
|
65
|
+
autoAddMargin: 1 | 0;
|
|
66
|
+
positionIdx?: 0 | 1 | 2;
|
|
67
|
+
}
|
|
68
|
+
export interface ContractSetMarginSwitchRequest {
|
|
69
|
+
symbol: string;
|
|
70
|
+
tradeMode: 0 | 1;
|
|
71
|
+
buyLeverage: string;
|
|
72
|
+
sellLeverage: string;
|
|
73
|
+
}
|
|
74
|
+
export interface ContractSetPositionModeRequest {
|
|
75
|
+
symbol?: string;
|
|
76
|
+
coin?: string;
|
|
77
|
+
mode: 0 | 3;
|
|
78
|
+
}
|
|
79
|
+
export interface ContractSetTPSLRequest {
|
|
80
|
+
symbol: string;
|
|
81
|
+
takeProfit?: string;
|
|
82
|
+
stopLoss?: string;
|
|
83
|
+
activePrice?: string;
|
|
84
|
+
trailingStop?: string;
|
|
85
|
+
tpTriggerBy?: string;
|
|
86
|
+
slTriggerBy?: string;
|
|
87
|
+
slSize?: string;
|
|
88
|
+
tpSize?: string;
|
|
89
|
+
/** 0-one-way, 1-buy side, 2-sell side */
|
|
90
|
+
positionIdx?: 0 | 1 | 2;
|
|
91
|
+
}
|
|
92
|
+
export interface ContractUserExecutionHistoryRequest {
|
|
93
|
+
symbol: string;
|
|
94
|
+
orderId?: string;
|
|
95
|
+
startTime?: number;
|
|
96
|
+
endTime?: number;
|
|
97
|
+
execType?: 'Trade' | 'AdlTrade' | 'Funding' | 'BustTrade';
|
|
98
|
+
limit?: number;
|
|
99
|
+
cursor?: string;
|
|
100
|
+
}
|
|
101
|
+
export interface ContractClosedPNLRequest {
|
|
102
|
+
symbol: string;
|
|
103
|
+
startTime?: number;
|
|
104
|
+
endTime?: number;
|
|
105
|
+
limit?: number;
|
|
106
|
+
cursor?: string;
|
|
107
|
+
}
|
|
108
|
+
export interface ContractWalletFundRecordRequest {
|
|
109
|
+
startTime?: string;
|
|
110
|
+
endTime?: string;
|
|
111
|
+
coin?: string;
|
|
112
|
+
walletFundType?: string;
|
|
113
|
+
limit?: string;
|
|
114
|
+
cursor?: string;
|
|
115
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../src/types/request/contract.ts"],"names":[],"mappings":""}
|
|
@@ -19,4 +19,5 @@ __exportStar(require("./usdc-perp"), exports);
|
|
|
19
19
|
__exportStar(require("./usdc-options"), exports);
|
|
20
20
|
__exportStar(require("./usdc-shared"), exports);
|
|
21
21
|
__exportStar(require("./unified-margin"), exports);
|
|
22
|
+
__exportStar(require("./contract"), exports);
|
|
22
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/request/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAgC;AAChC,iDAA+B;AAC/B,2CAAyB;AACzB,4CAA0B;AAC1B,yCAAuB;AACvB,8CAA4B;AAC5B,iDAA+B;AAC/B,gDAA8B;AAC9B,mDAAiC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/request/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAgC;AAChC,iDAA+B;AAC/B,2CAAyB;AACzB,4CAA0B;AAC1B,yCAAuB;AACvB,8CAA4B;AAC5B,iDAA+B;AAC/B,gDAA8B;AAC9B,mDAAiC;AACjC,6CAA2B"}
|
|
@@ -13,4 +13,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
__exportStar(require("./shared"), exports);
|
|
14
14
|
__exportStar(require("./spot"), exports);
|
|
15
15
|
__exportStar(require("./usdt-perp"), exports);
|
|
16
|
+
__exportStar(require("./unified-margin"), exports);
|
|
16
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/response/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAyB;AACzB,yCAAuB;AACvB,8CAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/response/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAyB;AACzB,yCAAuB;AACvB,8CAA4B;AAC5B,mDAAiC"}
|