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/contract-client.d.ts
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { APIResponseV3, APIResponseWithTime, ContractActiveOrdersRequest, ContractCancelOrderRequest, ContractClosedPNLRequest, ContractHistoricOrder, ContractHistoricOrdersRequest, ContractListResult, ContractModifyOrderRequest, ContractOrderRequest, ContractPositionsRequest, ContractSetAutoAddMarginRequest, ContractSetMarginSwitchRequest, ContractSetPositionModeRequest, ContractSetTPSLRequest, ContractSymbolTicker, ContractUserExecutionHistoryRequest, ContractWalletFundRecordRequest, PaginatedResult, UMCandlesRequest, UMCategory, UMFundingRateHistoryRequest, UMInstrumentInfoRequest, UMOpenInterestRequest, UMOptionDeliveryPriceRequest, UMPublicTradesRequest } from './types';
|
|
2
|
-
import BaseRestClient from './util/BaseRestClient';
|
|
3
|
-
/**
|
|
4
|
-
* REST API client for Derivatives V3 Contract APIs
|
|
5
|
-
* @deprecated WARNING
|
|
6
|
-
* These endpoints are being switched off gradually and are expected to be completely turned off by the end of 2024.
|
|
7
|
-
* They may stop working at any point before then.
|
|
8
|
-
* Please update your code as soon as possible to use the V5 APIs instead.
|
|
9
|
-
*/
|
|
10
|
-
export declare class ContractClient extends BaseRestClient {
|
|
11
|
-
getClientType(): "v3";
|
|
12
|
-
fetchServerTime(): Promise<number>;
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* Market Data Endpoints : these seem exactly the same as the unified margin market data endpoints
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
18
|
-
/** Query order book info. Each side has a depth of 25 orders. */
|
|
19
|
-
getOrderBook(symbol: string, category?: string, limit?: number): Promise<APIResponseV3<any>>;
|
|
20
|
-
/** Get candles/klines */
|
|
21
|
-
getCandles(params: UMCandlesRequest): Promise<APIResponseV3<any>>;
|
|
22
|
-
/** Get a symbol price/statistics ticker */
|
|
23
|
-
getSymbolTicker(category: UMCategory | '', symbol?: string): Promise<APIResponseV3<ContractListResult<ContractSymbolTicker>>>;
|
|
24
|
-
/** Get trading rules per symbol/contract, incl price/amount/value/leverage filters */
|
|
25
|
-
getInstrumentInfo(params: UMInstrumentInfoRequest): Promise<APIResponseV3<any>>;
|
|
26
|
-
/** Query mark price kline (like getCandles() but for mark price). */
|
|
27
|
-
getMarkPriceCandles(params: UMCandlesRequest): Promise<APIResponseV3<any>>;
|
|
28
|
-
/** Query Index Price Kline */
|
|
29
|
-
getIndexPriceCandles(params: UMCandlesRequest): Promise<APIResponseV3<any>>;
|
|
30
|
-
/**
|
|
31
|
-
* The funding rate is generated every 8 hours at 00:00 UTC, 08:00 UTC and 16:00 UTC.
|
|
32
|
-
* 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.
|
|
33
|
-
*/
|
|
34
|
-
getFundingRateHistory(params: UMFundingRateHistoryRequest): Promise<APIResponseV3<any>>;
|
|
35
|
-
/** Get Risk Limit */
|
|
36
|
-
getRiskLimit(category: UMCategory, symbol: string): Promise<APIResponseV3<any>>;
|
|
37
|
-
/** Get option delivery price */
|
|
38
|
-
getOptionDeliveryPrice(params: UMOptionDeliveryPriceRequest): Promise<APIResponseV3<any>>;
|
|
39
|
-
/** Get public trading history */
|
|
40
|
-
getTrades(params: UMPublicTradesRequest): Promise<APIResponseV3<any>>;
|
|
41
|
-
/**
|
|
42
|
-
* Gets the total amount of unsettled contracts.
|
|
43
|
-
* In other words, the total number of contracts held in open positions.
|
|
44
|
-
*/
|
|
45
|
-
getOpenInterest(params: UMOpenInterestRequest): Promise<APIResponseV3<any>>;
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
48
|
-
* Contract Account Endpoints
|
|
49
|
-
*
|
|
50
|
-
*/
|
|
51
|
-
/** -> Order API */
|
|
52
|
-
/** Place an order */
|
|
53
|
-
submitOrder(params: ContractOrderRequest): Promise<APIResponseV3<any>>;
|
|
54
|
-
/**
|
|
55
|
-
* Query order history.
|
|
56
|
-
*
|
|
57
|
-
* As order creation/cancellation is asynchronous, the data returned from the interface may be delayed.
|
|
58
|
-
* To access order information in real-time, call getActiveOrders().
|
|
59
|
-
*/
|
|
60
|
-
getHistoricOrders(params: ContractHistoricOrdersRequest): Promise<APIResponseV3<PaginatedResult<ContractHistoricOrder>>>;
|
|
61
|
-
/** Cancel order */
|
|
62
|
-
cancelOrder(params: ContractCancelOrderRequest): Promise<APIResponseV3<any>>;
|
|
63
|
-
/** Cancel all orders */
|
|
64
|
-
cancelAllOrders(symbol: string): Promise<APIResponseV3<any>>;
|
|
65
|
-
/**
|
|
66
|
-
* Replace order
|
|
67
|
-
*
|
|
68
|
-
* Active order parameters (such as quantity, price) and stop order parameters
|
|
69
|
-
* cannot be modified in one request at the same time.
|
|
70
|
-
*
|
|
71
|
-
* Please request modification separately.
|
|
72
|
-
*/
|
|
73
|
-
modifyOrder(params: ContractModifyOrderRequest): Promise<APIResponseV3<any>>;
|
|
74
|
-
/** Query Open Order(s) (real-time) */
|
|
75
|
-
getActiveOrders(params: ContractActiveOrdersRequest): Promise<APIResponseV3<any>>;
|
|
76
|
-
/** -> Positions API */
|
|
77
|
-
/**
|
|
78
|
-
* Query my positions real-time. Accessing personal list of positions.
|
|
79
|
-
* Either symbol or settleCoin is required.
|
|
80
|
-
* Users can access their position holding information through this interface, such as the number of position holdings and wallet balance.
|
|
81
|
-
*/
|
|
82
|
-
getPositions(params?: ContractPositionsRequest): Promise<APIResponseV3<any>>;
|
|
83
|
-
/** Set auto add margin, or Auto-Margin Replenishment. */
|
|
84
|
-
setAutoAddMargin(params: ContractSetAutoAddMarginRequest): Promise<APIResponseV3<any>>;
|
|
85
|
-
/** Switch cross margin mode/isolated margin mode */
|
|
86
|
-
setMarginSwitch(params: ContractSetMarginSwitchRequest): Promise<APIResponseV3<any>>;
|
|
87
|
-
/** Supports switching between One-Way Mode and Hedge Mode at the coin level. */
|
|
88
|
-
setPositionMode(params: ContractSetPositionModeRequest): Promise<APIResponseV3<any>>;
|
|
89
|
-
/**
|
|
90
|
-
* Switch mode between Full or Partial
|
|
91
|
-
*/
|
|
92
|
-
setTPSLMode(symbol: string, tpSlMode: 'Full' | 'Partial'): Promise<APIResponseV3<any>>;
|
|
93
|
-
/** Leverage setting. */
|
|
94
|
-
setLeverage(symbol: string, buyLeverage: string, sellLeverage: string): Promise<APIResponseV3<any>>;
|
|
95
|
-
/**
|
|
96
|
-
* Set take profit, stop loss, and trailing stop for your open position.
|
|
97
|
-
* If using partial mode, TP/SL/TS orders will not close your entire position.
|
|
98
|
-
*/
|
|
99
|
-
setTPSL(params: ContractSetTPSLRequest): Promise<APIResponseV3<any>>;
|
|
100
|
-
/** Set risk limit */
|
|
101
|
-
setRiskLimit(symbol: string, riskId: number,
|
|
102
|
-
/** 0-one-way, 1-buy side, 2-sell side */
|
|
103
|
-
positionIdx: 0 | 1 | 2): Promise<APIResponseV3<any>>;
|
|
104
|
-
/**
|
|
105
|
-
* Get user's trading records.
|
|
106
|
-
* The results are ordered in descending order (the first item is the latest). Returns records up to 2 years old.
|
|
107
|
-
*/
|
|
108
|
-
getUserExecutionHistory(params: ContractUserExecutionHistoryRequest): Promise<APIResponseV3<any>>;
|
|
109
|
-
/**
|
|
110
|
-
* Get user's closed profit and loss records.
|
|
111
|
-
* The results are ordered in descending order (the first item is the latest).
|
|
112
|
-
*/
|
|
113
|
-
getClosedProfitAndLoss(params: ContractClosedPNLRequest): Promise<APIResponseV3<any>>;
|
|
114
|
-
/** Get the information of open interest limit. */
|
|
115
|
-
getOpenInterestLimitInfo(symbol: string): Promise<APIResponseV3<any>>;
|
|
116
|
-
/** -> Account API */
|
|
117
|
-
/** Query wallet balance */
|
|
118
|
-
getBalances(coin?: string): Promise<APIResponseV3<any>>;
|
|
119
|
-
/** Get user trading fee rate */
|
|
120
|
-
getTradingFeeRate(symbol?: string): Promise<APIResponseV3<any>>;
|
|
121
|
-
/**
|
|
122
|
-
* Get wallet fund records.
|
|
123
|
-
* This endpoint also shows exchanges from the Asset Exchange,
|
|
124
|
-
* where the types for the exchange are ExchangeOrderWithdraw and ExchangeOrderDeposit.
|
|
125
|
-
*
|
|
126
|
-
* This endpoint returns incomplete information for transfers involving the derivatives wallet.
|
|
127
|
-
* Use the account asset API for creating and querying internal transfers.
|
|
128
|
-
*/
|
|
129
|
-
getWalletFundRecords(params?: ContractWalletFundRecordRequest): Promise<APIResponseV3<any>>;
|
|
130
|
-
/**
|
|
131
|
-
*
|
|
132
|
-
* API Data Endpoints
|
|
133
|
-
*
|
|
134
|
-
*/
|
|
135
|
-
getServerTime(): Promise<APIResponseWithTime>;
|
|
136
|
-
}
|
package/lib/contract-client.js
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
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
|
-
* @deprecated WARNING
|
|
21
|
-
* These endpoints are being switched off gradually and are expected to be completely turned off by the end of 2024.
|
|
22
|
-
* They may stop working at any point before then.
|
|
23
|
-
* Please update your code as soon as possible to use the V5 APIs instead.
|
|
24
|
-
*/
|
|
25
|
-
class ContractClient extends BaseRestClient_1.default {
|
|
26
|
-
getClientType() {
|
|
27
|
-
// Follows the same authentication mechanism as other v3 APIs (e.g. USDC)
|
|
28
|
-
return util_1.REST_CLIENT_TYPE_ENUM.v3;
|
|
29
|
-
}
|
|
30
|
-
fetchServerTime() {
|
|
31
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
const res = yield this.getServerTime();
|
|
33
|
-
return Number(res.time_now);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
* Market Data Endpoints : these seem exactly the same as the unified margin market data endpoints
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
|
-
/** Query order book info. Each side has a depth of 25 orders. */
|
|
42
|
-
getOrderBook(symbol, category, limit) {
|
|
43
|
-
return this.get('/derivatives/v3/public/order-book/L2', {
|
|
44
|
-
category,
|
|
45
|
-
symbol,
|
|
46
|
-
limit,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
/** Get candles/klines */
|
|
50
|
-
getCandles(params) {
|
|
51
|
-
return this.get('/derivatives/v3/public/kline', params);
|
|
52
|
-
}
|
|
53
|
-
/** Get a symbol price/statistics ticker */
|
|
54
|
-
getSymbolTicker(category, symbol) {
|
|
55
|
-
return this.get('/derivatives/v3/public/tickers', { category, symbol });
|
|
56
|
-
}
|
|
57
|
-
/** Get trading rules per symbol/contract, incl price/amount/value/leverage filters */
|
|
58
|
-
getInstrumentInfo(params) {
|
|
59
|
-
return this.get('/derivatives/v3/public/instruments-info', params);
|
|
60
|
-
}
|
|
61
|
-
/** Query mark price kline (like getCandles() but for mark price). */
|
|
62
|
-
getMarkPriceCandles(params) {
|
|
63
|
-
return this.get('/derivatives/v3/public/mark-price-kline', params);
|
|
64
|
-
}
|
|
65
|
-
/** Query Index Price Kline */
|
|
66
|
-
getIndexPriceCandles(params) {
|
|
67
|
-
return this.get('/derivatives/v3/public/index-price-kline', params);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* The funding rate is generated every 8 hours at 00:00 UTC, 08:00 UTC and 16:00 UTC.
|
|
71
|
-
* 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.
|
|
72
|
-
*/
|
|
73
|
-
getFundingRateHistory(params) {
|
|
74
|
-
return this.get('/derivatives/v3/public/funding/history-funding-rate', params);
|
|
75
|
-
}
|
|
76
|
-
/** Get Risk Limit */
|
|
77
|
-
getRiskLimit(category, symbol) {
|
|
78
|
-
return this.get('/derivatives/v3/public/risk-limit/list', {
|
|
79
|
-
category,
|
|
80
|
-
symbol,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
/** Get option delivery price */
|
|
84
|
-
getOptionDeliveryPrice(params) {
|
|
85
|
-
return this.get('/derivatives/v3/public/delivery-price', params);
|
|
86
|
-
}
|
|
87
|
-
/** Get public trading history */
|
|
88
|
-
getTrades(params) {
|
|
89
|
-
return this.get('/derivatives/v3/public/recent-trade', params);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Gets the total amount of unsettled contracts.
|
|
93
|
-
* In other words, the total number of contracts held in open positions.
|
|
94
|
-
*/
|
|
95
|
-
getOpenInterest(params) {
|
|
96
|
-
return this.get('/derivatives/v3/public/open-interest', params);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
*
|
|
100
|
-
* Contract Account Endpoints
|
|
101
|
-
*
|
|
102
|
-
*/
|
|
103
|
-
/** -> Order API */
|
|
104
|
-
/** Place an order */
|
|
105
|
-
submitOrder(params) {
|
|
106
|
-
return this.postPrivate('/contract/v3/private/order/create', params);
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Query order history.
|
|
110
|
-
*
|
|
111
|
-
* As order creation/cancellation is asynchronous, the data returned from the interface may be delayed.
|
|
112
|
-
* To access order information in real-time, call getActiveOrders().
|
|
113
|
-
*/
|
|
114
|
-
getHistoricOrders(params) {
|
|
115
|
-
return this.getPrivate('/contract/v3/private/order/list', params);
|
|
116
|
-
}
|
|
117
|
-
/** Cancel order */
|
|
118
|
-
cancelOrder(params) {
|
|
119
|
-
return this.postPrivate('/contract/v3/private/order/cancel', params);
|
|
120
|
-
}
|
|
121
|
-
/** Cancel all orders */
|
|
122
|
-
cancelAllOrders(symbol) {
|
|
123
|
-
return this.postPrivate('/contract/v3/private/order/cancel-all', {
|
|
124
|
-
symbol,
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Replace order
|
|
129
|
-
*
|
|
130
|
-
* Active order parameters (such as quantity, price) and stop order parameters
|
|
131
|
-
* cannot be modified in one request at the same time.
|
|
132
|
-
*
|
|
133
|
-
* Please request modification separately.
|
|
134
|
-
*/
|
|
135
|
-
modifyOrder(params) {
|
|
136
|
-
return this.postPrivate('/contract/v3/private/order/replace', params);
|
|
137
|
-
}
|
|
138
|
-
/** Query Open Order(s) (real-time) */
|
|
139
|
-
getActiveOrders(params) {
|
|
140
|
-
return this.getPrivate('/contract/v3/private/order/unfilled-orders', params);
|
|
141
|
-
}
|
|
142
|
-
/** -> Positions API */
|
|
143
|
-
/**
|
|
144
|
-
* Query my positions real-time. Accessing personal list of positions.
|
|
145
|
-
* Either symbol or settleCoin is required.
|
|
146
|
-
* Users can access their position holding information through this interface, such as the number of position holdings and wallet balance.
|
|
147
|
-
*/
|
|
148
|
-
getPositions(params) {
|
|
149
|
-
return this.getPrivate('/contract/v3/private/position/list', params);
|
|
150
|
-
}
|
|
151
|
-
/** Set auto add margin, or Auto-Margin Replenishment. */
|
|
152
|
-
setAutoAddMargin(params) {
|
|
153
|
-
return this.postPrivate('/contract/v3/private/position/set-auto-add-margin', params);
|
|
154
|
-
}
|
|
155
|
-
/** Switch cross margin mode/isolated margin mode */
|
|
156
|
-
setMarginSwitch(params) {
|
|
157
|
-
return this.postPrivate('/contract/v3/private/position/switch-isolated', params);
|
|
158
|
-
}
|
|
159
|
-
/** Supports switching between One-Way Mode and Hedge Mode at the coin level. */
|
|
160
|
-
setPositionMode(params) {
|
|
161
|
-
return this.postPrivate('/contract/v3/private/position/switch-mode', params);
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Switch mode between Full or Partial
|
|
165
|
-
*/
|
|
166
|
-
setTPSLMode(symbol, tpSlMode) {
|
|
167
|
-
return this.postPrivate('/contract/v3/private/position/switch-tpsl-mode', {
|
|
168
|
-
symbol,
|
|
169
|
-
tpSlMode,
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
/** Leverage setting. */
|
|
173
|
-
setLeverage(symbol, buyLeverage, sellLeverage) {
|
|
174
|
-
return this.postPrivate('/contract/v3/private/position/set-leverage', {
|
|
175
|
-
symbol,
|
|
176
|
-
buyLeverage,
|
|
177
|
-
sellLeverage,
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Set take profit, stop loss, and trailing stop for your open position.
|
|
182
|
-
* If using partial mode, TP/SL/TS orders will not close your entire position.
|
|
183
|
-
*/
|
|
184
|
-
setTPSL(params) {
|
|
185
|
-
return this.postPrivate('/contract/v3/private/position/trading-stop', params);
|
|
186
|
-
}
|
|
187
|
-
/** Set risk limit */
|
|
188
|
-
setRiskLimit(symbol, riskId,
|
|
189
|
-
/** 0-one-way, 1-buy side, 2-sell side */
|
|
190
|
-
positionIdx) {
|
|
191
|
-
return this.postPrivate('/contract/v3/private/position/set-risk-limit', {
|
|
192
|
-
symbol,
|
|
193
|
-
riskId,
|
|
194
|
-
positionIdx,
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Get user's trading records.
|
|
199
|
-
* The results are ordered in descending order (the first item is the latest). Returns records up to 2 years old.
|
|
200
|
-
*/
|
|
201
|
-
getUserExecutionHistory(params) {
|
|
202
|
-
return this.getPrivate('/contract/v3/private/execution/list', params);
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Get user's closed profit and loss records.
|
|
206
|
-
* The results are ordered in descending order (the first item is the latest).
|
|
207
|
-
*/
|
|
208
|
-
getClosedProfitAndLoss(params) {
|
|
209
|
-
return this.getPrivate('/contract/v3/private/position/closed-pnl', params);
|
|
210
|
-
}
|
|
211
|
-
/** Get the information of open interest limit. */
|
|
212
|
-
getOpenInterestLimitInfo(symbol) {
|
|
213
|
-
return this.getPrivate('/contract/v3/private/position/limit-info', {
|
|
214
|
-
symbol,
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
/** -> Account API */
|
|
218
|
-
/** Query wallet balance */
|
|
219
|
-
getBalances(coin) {
|
|
220
|
-
return this.getPrivate('/contract/v3/private/account/wallet/balance', {
|
|
221
|
-
coin,
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
/** Get user trading fee rate */
|
|
225
|
-
getTradingFeeRate(symbol) {
|
|
226
|
-
return this.getPrivate('/contract/v3/private/account/fee-rate', {
|
|
227
|
-
symbol,
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Get wallet fund records.
|
|
232
|
-
* This endpoint also shows exchanges from the Asset Exchange,
|
|
233
|
-
* where the types for the exchange are ExchangeOrderWithdraw and ExchangeOrderDeposit.
|
|
234
|
-
*
|
|
235
|
-
* This endpoint returns incomplete information for transfers involving the derivatives wallet.
|
|
236
|
-
* Use the account asset API for creating and querying internal transfers.
|
|
237
|
-
*/
|
|
238
|
-
getWalletFundRecords(params) {
|
|
239
|
-
return this.getPrivate('/contract/v3/private/account/wallet/fund-records', params);
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
*
|
|
243
|
-
* API Data Endpoints
|
|
244
|
-
*
|
|
245
|
-
*/
|
|
246
|
-
getServerTime() {
|
|
247
|
-
return this.get('/v2/public/time');
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
exports.ContractClient = ContractClient;
|
|
251
|
-
//# sourceMappingURL=contract-client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contract-client.js","sourceRoot":"","sources":["../src/contract-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AA6BA,iCAA+C;AAC/C,2EAAmD;AAEnD;;;;;;GAMG;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,QAAiB,EACjB,KAAc;QAEd,OAAO,IAAI,CAAC,GAAG,CAAC,sCAAsC,EAAE;YACtD,QAAQ;YACR,MAAM;YACN,KAAK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CAAC;IACL,CAAC;IAED,gCAAgC;IAChC,iBAAiB,CAAC,MAAe;QAC/B,OAAO,IAAI,CAAC,UAAU,CAAC,uCAAuC,EAAE;YAC9D,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,oBAAoB,CAClB,MAAwC;QAExC,OAAO,IAAI,CAAC,UAAU,CACpB,kDAAkD,EAClD,MAAM,CACP,CAAC;IACJ,CAAC;IAED;;;;OAIG;IAEH,aAAa;QACX,OAAO,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;CACF;AApUD,wCAoUC"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { APIResponseV3, APIResponseWithTime, CopyTradingCancelOrderRequest, CopyTradingCloseOrderRequest, CopyTradingOrderListRequest, CopyTradingOrderRequest, CopyTradingTradingStopRequest, CopyTradingTransferRequest } from './types';
|
|
2
|
-
import BaseRestClient from './util/BaseRestClient';
|
|
3
|
-
/**
|
|
4
|
-
* REST API client for USDC Perpetual APIs
|
|
5
|
-
* @deprecated WARNING
|
|
6
|
-
* These endpoints are being switched off gradually and are expected to be completely turned off by the end of 2024.
|
|
7
|
-
* They may stop working at any point before then.
|
|
8
|
-
* Please update your code as soon as possible to use the V5 APIs instead.
|
|
9
|
-
*/
|
|
10
|
-
export declare class CopyTradingClient extends BaseRestClient {
|
|
11
|
-
getClientType(): "v3";
|
|
12
|
-
fetchServerTime(): Promise<number>;
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* Market Data Endpoints
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
18
|
-
getSymbols(): Promise<APIResponseV3<any>>;
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
* Account Data Endpoints
|
|
22
|
-
*
|
|
23
|
-
*/
|
|
24
|
-
/** -> Order API */
|
|
25
|
-
/** Create order */
|
|
26
|
-
submitOrder(params: CopyTradingOrderRequest): Promise<APIResponseV3<any>>;
|
|
27
|
-
/** Set Trading Stop */
|
|
28
|
-
setTradingStop(params: CopyTradingTradingStopRequest): Promise<APIResponseV3<any>>;
|
|
29
|
-
/** Query Order List */
|
|
30
|
-
getActiveOrders(params?: CopyTradingOrderListRequest): Promise<APIResponseV3<any>>;
|
|
31
|
-
/** Cancel order */
|
|
32
|
-
cancelOrder(params: CopyTradingCancelOrderRequest): Promise<APIResponseV3<any>>;
|
|
33
|
-
/** Close Order.
|
|
34
|
-
* This endpoint's rate_limit will decrease by 10 per request;
|
|
35
|
-
* ie, one request to this endpoint consumes 10 from the limit allowed per minute.
|
|
36
|
-
*/
|
|
37
|
-
closeOrder(params: CopyTradingCloseOrderRequest): Promise<APIResponseV3<any>>;
|
|
38
|
-
/** -> Positions API */
|
|
39
|
-
/** Position List */
|
|
40
|
-
getPositions(symbol?: string): Promise<APIResponseV3<any>>;
|
|
41
|
-
/** Close Position */
|
|
42
|
-
closePosition(symbol: string, positionIdx: string): Promise<APIResponseV3<any>>;
|
|
43
|
-
/** Only integers can be set to set the leverage */
|
|
44
|
-
setLeverage(symbol: string, buyLeverage: string, sellLeverage: string): Promise<APIResponseV3<any>>;
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
* Wallet Data Endpoints
|
|
48
|
-
*
|
|
49
|
-
*/
|
|
50
|
-
/** Get Wallet Balance */
|
|
51
|
-
getBalances(): Promise<APIResponseV3<any>>;
|
|
52
|
-
/** Transfer */
|
|
53
|
-
transfer(params: CopyTradingTransferRequest): Promise<APIResponseV3<any>>;
|
|
54
|
-
/**
|
|
55
|
-
*
|
|
56
|
-
* API Data Endpoints
|
|
57
|
-
*
|
|
58
|
-
*/
|
|
59
|
-
getServerTime(): Promise<APIResponseWithTime>;
|
|
60
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
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.CopyTradingClient = void 0;
|
|
16
|
-
const util_1 = require("./util");
|
|
17
|
-
const BaseRestClient_1 = __importDefault(require("./util/BaseRestClient"));
|
|
18
|
-
/**
|
|
19
|
-
* REST API client for USDC Perpetual APIs
|
|
20
|
-
* @deprecated WARNING
|
|
21
|
-
* These endpoints are being switched off gradually and are expected to be completely turned off by the end of 2024.
|
|
22
|
-
* They may stop working at any point before then.
|
|
23
|
-
* Please update your code as soon as possible to use the V5 APIs instead.
|
|
24
|
-
*/
|
|
25
|
-
class CopyTradingClient extends BaseRestClient_1.default {
|
|
26
|
-
getClientType() {
|
|
27
|
-
// Follows the same authentication mechanism as USDC APIs
|
|
28
|
-
return util_1.REST_CLIENT_TYPE_ENUM.v3;
|
|
29
|
-
}
|
|
30
|
-
fetchServerTime() {
|
|
31
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
const res = yield this.getServerTime();
|
|
33
|
-
return Number(res.time_now);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
* Market Data Endpoints
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
|
-
getSymbols() {
|
|
42
|
-
return this.get('/contract/v3/public/copytrading/symbol/list');
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
*
|
|
46
|
-
* Account Data Endpoints
|
|
47
|
-
*
|
|
48
|
-
*/
|
|
49
|
-
/** -> Order API */
|
|
50
|
-
/** Create order */
|
|
51
|
-
submitOrder(params) {
|
|
52
|
-
return this.postPrivate('/contract/v3/private/copytrading/order/create', params);
|
|
53
|
-
}
|
|
54
|
-
/** Set Trading Stop */
|
|
55
|
-
setTradingStop(params) {
|
|
56
|
-
return this.postPrivate('/contract/v3/private/copytrading/order/trading-stop', params);
|
|
57
|
-
}
|
|
58
|
-
/** Query Order List */
|
|
59
|
-
getActiveOrders(params) {
|
|
60
|
-
return this.getPrivate('/contract/v3/private/copytrading/order/list', params);
|
|
61
|
-
}
|
|
62
|
-
/** Cancel order */
|
|
63
|
-
cancelOrder(params) {
|
|
64
|
-
return this.postPrivate('/contract/v3/private/copytrading/order/cancel', params);
|
|
65
|
-
}
|
|
66
|
-
/** Close Order.
|
|
67
|
-
* This endpoint's rate_limit will decrease by 10 per request;
|
|
68
|
-
* ie, one request to this endpoint consumes 10 from the limit allowed per minute.
|
|
69
|
-
*/
|
|
70
|
-
closeOrder(params) {
|
|
71
|
-
return this.postPrivate('/contract/v3/private/copytrading/order/close', params);
|
|
72
|
-
}
|
|
73
|
-
/** -> Positions API */
|
|
74
|
-
/** Position List */
|
|
75
|
-
getPositions(symbol) {
|
|
76
|
-
return this.getPrivate('/contract/v3/private/copytrading/position/list', {
|
|
77
|
-
symbol,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
/** Close Position */
|
|
81
|
-
closePosition(symbol, positionIdx) {
|
|
82
|
-
return this.postPrivate('/contract/v3/private/copytrading/position/close', {
|
|
83
|
-
symbol,
|
|
84
|
-
positionIdx,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
/** Only integers can be set to set the leverage */
|
|
88
|
-
setLeverage(symbol, buyLeverage, sellLeverage) {
|
|
89
|
-
return this.postPrivate('/contract/v3/private/copytrading/position/set-leverage', { symbol, buyLeverage, sellLeverage });
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
*
|
|
93
|
-
* Wallet Data Endpoints
|
|
94
|
-
*
|
|
95
|
-
*/
|
|
96
|
-
/** Get Wallet Balance */
|
|
97
|
-
getBalances() {
|
|
98
|
-
return this.getPrivate('/contract/v3/private/copytrading/wallet/balance');
|
|
99
|
-
}
|
|
100
|
-
/** Transfer */
|
|
101
|
-
transfer(params) {
|
|
102
|
-
return this.postPrivate('/contract/v3/private/copytrading/wallet/transfer', params);
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
*
|
|
106
|
-
* API Data Endpoints
|
|
107
|
-
*
|
|
108
|
-
*/
|
|
109
|
-
getServerTime() {
|
|
110
|
-
return this.get('/v2/public/time');
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
exports.CopyTradingClient = CopyTradingClient;
|
|
114
|
-
//# sourceMappingURL=copy-trading-client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"copy-trading-client.js","sourceRoot":"","sources":["../src/copy-trading-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAWA,iCAA+C;AAC/C,2EAAmD;AAEnD;;;;;;GAMG;AACH,MAAa,iBAAkB,SAAQ,wBAAc;IACnD,aAAa;QACX,yDAAyD;QACzD,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,UAAU;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IAED;;;;OAIG;IAEH,mBAAmB;IAEnB,mBAAmB;IACnB,WAAW,CAAC,MAA+B;QACzC,OAAO,IAAI,CAAC,WAAW,CACrB,+CAA+C,EAC/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