Merge pull request #293 from tiagosiebler/next
v3.7.4: feat(#251, #291) add optional endpoint rate limit parsing, add deprecation warnings for v1/v2 rest clients, improve v5 types, bump dependencies
This commit is contained in:
@@ -155,6 +155,12 @@ const restClientOptions = {
|
|||||||
|
|
||||||
/** Default: true. whether to try and post-process request exceptions. */
|
/** Default: true. whether to try and post-process request exceptions. */
|
||||||
parse_exceptions?: boolean;
|
parse_exceptions?: boolean;
|
||||||
|
|
||||||
|
/** Default: false. Enable to parse/include per-API/endpoint rate limits in responses. */
|
||||||
|
parseAPIRateLimits?: boolean;
|
||||||
|
|
||||||
|
/** Default: false. Enable to throw error if rate limit parser fails */
|
||||||
|
throwOnFailedRateLimitParse?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const API_KEY = 'xxx';
|
const API_KEY = 'xxx';
|
||||||
|
|||||||
897
package-lock.json
generated
897
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "bybit-api",
|
"name": "bybit-api",
|
||||||
"version": "3.7.3",
|
"version": "3.7.4",
|
||||||
"description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.",
|
"description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ import BaseRestClient from './util/BaseRestClient';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* REST API client for Account Asset APIs
|
* REST API client for Account Asset APIs
|
||||||
|
*
|
||||||
|
* @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet
|
||||||
|
* will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability.
|
||||||
|
* Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP.
|
||||||
*/
|
*/
|
||||||
export class AccountAssetClient extends BaseRestClient {
|
export class AccountAssetClient extends BaseRestClient {
|
||||||
getClientType() {
|
getClientType() {
|
||||||
@@ -35,29 +39,29 @@ export class AccountAssetClient extends BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
createInternalTransfer(
|
createInternalTransfer(
|
||||||
params: InternalTransferRequest
|
params: InternalTransferRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('/asset/v1/private/transfer', params);
|
return this.postPrivate('/asset/v1/private/transfer', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
createSubAccountTransfer(
|
createSubAccountTransfer(
|
||||||
params: SubAccountTransferRequest
|
params: SubAccountTransferRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('/asset/v1/private/sub-member/transfer', params);
|
return this.postPrivate('/asset/v1/private/sub-member/transfer', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getInternalTransfers(
|
getInternalTransfers(
|
||||||
params?: TransferQueryRequest
|
params?: TransferQueryRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('/asset/v1/private/transfer/list', params);
|
return this.getPrivate('/asset/v1/private/transfer/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubAccountTransfers(
|
getSubAccountTransfers(
|
||||||
params?: TransferQueryRequest
|
params?: TransferQueryRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate(
|
return this.getPrivate(
|
||||||
'/asset/v1/private/sub-member/transfer/list',
|
'/asset/v1/private/sub-member/transfer/list',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,19 +70,19 @@ export class AccountAssetClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enableUniversalTransfer(
|
enableUniversalTransfer(
|
||||||
params?: EnableUniversalTransferRequest
|
params?: EnableUniversalTransferRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('/asset/v1/private/transferable-subs/save', params);
|
return this.postPrivate('/asset/v1/private/transferable-subs/save', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
createUniversalTransfer(
|
createUniversalTransfer(
|
||||||
params: UniversalTransferRequest
|
params: UniversalTransferRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('/asset/v1/private/universal/transfer', params);
|
return this.postPrivate('/asset/v1/private/universal/transfer', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUniversalTransfers(
|
getUniversalTransfers(
|
||||||
params?: TransferQueryRequest
|
params?: TransferQueryRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('/asset/v1/private/universal/transfer/list', params);
|
return this.getPrivate('/asset/v1/private/universal/transfer/list', params);
|
||||||
}
|
}
|
||||||
@@ -90,19 +94,19 @@ export class AccountAssetClient extends BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
getSupportedDepositList(
|
getSupportedDepositList(
|
||||||
params?: SupportedDepositListRequest
|
params?: SupportedDepositListRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.get('/asset/v1/public/deposit/allowed-deposit-list', params);
|
return this.get('/asset/v1/public/deposit/allowed-deposit-list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getDepositRecords(
|
getDepositRecords(
|
||||||
params?: DepositRecordsRequest
|
params?: DepositRecordsRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('/asset/v1/private/deposit/record/query', params);
|
return this.getPrivate('/asset/v1/private/deposit/record/query', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWithdrawRecords(
|
getWithdrawRecords(
|
||||||
params?: WithdrawalRecordsRequest
|
params?: WithdrawalRecordsRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('/asset/v1/private/withdraw/record/query', params);
|
return this.getPrivate('/asset/v1/private/withdraw/record/query', params);
|
||||||
}
|
}
|
||||||
@@ -112,13 +116,13 @@ export class AccountAssetClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getAssetInformation(
|
getAssetInformation(
|
||||||
params?: AccountAssetInformationRequest
|
params?: AccountAssetInformationRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('/asset/v1/private/asset-info/query', params);
|
return this.getPrivate('/asset/v1/private/asset-info/query', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
submitWithdrawal(
|
submitWithdrawal(
|
||||||
params: WithdrawalRequest
|
params: WithdrawalRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('/asset/v1/private/withdraw', params);
|
return this.postPrivate('/asset/v1/private/withdraw', params);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ import BaseRestClient from './util/BaseRestClient';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* REST API client for Inverse Perpetual Futures APIs (v2)
|
* REST API client for Inverse Perpetual Futures APIs (v2)
|
||||||
|
*
|
||||||
|
* @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet
|
||||||
|
* will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability.
|
||||||
|
* Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP.
|
||||||
*/
|
*/
|
||||||
export class InverseClient extends BaseRestClient {
|
export class InverseClient extends BaseRestClient {
|
||||||
getClientType() {
|
getClientType() {
|
||||||
@@ -54,7 +58,7 @@ export class InverseClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getKline(
|
getKline(
|
||||||
params: SymbolIntervalFromLimitParam
|
params: SymbolIntervalFromLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('v2/public/kline/list', params);
|
return this.get('v2/public/kline/list', params);
|
||||||
}
|
}
|
||||||
@@ -63,7 +67,7 @@ export class InverseClient extends BaseRestClient {
|
|||||||
* Get latest information for symbol
|
* Get latest information for symbol
|
||||||
*/
|
*/
|
||||||
getTickers(
|
getTickers(
|
||||||
params?: Partial<SymbolParam>
|
params?: Partial<SymbolParam>,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('v2/public/tickers', params);
|
return this.get('v2/public/tickers', params);
|
||||||
}
|
}
|
||||||
@@ -77,19 +81,19 @@ export class InverseClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getMarkPriceKline(
|
getMarkPriceKline(
|
||||||
params: SymbolIntervalFromLimitParam
|
params: SymbolIntervalFromLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('v2/public/mark-price-kline', params);
|
return this.get('v2/public/mark-price-kline', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getIndexPriceKline(
|
getIndexPriceKline(
|
||||||
params: SymbolIntervalFromLimitParam
|
params: SymbolIntervalFromLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('v2/public/index-price-kline', params);
|
return this.get('v2/public/index-price-kline', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPremiumIndexKline(
|
getPremiumIndexKline(
|
||||||
params: SymbolIntervalFromLimitParam
|
params: SymbolIntervalFromLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('v2/public/premium-index-kline', params);
|
return this.get('v2/public/premium-index-kline', params);
|
||||||
}
|
}
|
||||||
@@ -101,19 +105,19 @@ export class InverseClient extends BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
getOpenInterest(
|
getOpenInterest(
|
||||||
params: SymbolPeriodLimitParam
|
params: SymbolPeriodLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('v2/public/open-interest', params);
|
return this.get('v2/public/open-interest', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLatestBigDeal(
|
getLatestBigDeal(
|
||||||
params: SymbolLimitParam
|
params: SymbolLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('v2/public/big-deal', params);
|
return this.get('v2/public/big-deal', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLongShortRatio(
|
getLongShortRatio(
|
||||||
params: SymbolPeriodLimitParam
|
params: SymbolPeriodLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('v2/public/account-ratio', params);
|
return this.get('v2/public/account-ratio', params);
|
||||||
}
|
}
|
||||||
@@ -135,25 +139,25 @@ export class InverseClient extends BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
getWalletBalance(
|
getWalletBalance(
|
||||||
params?: Partial<CoinParam>
|
params?: Partial<CoinParam>,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/wallet/balance', params);
|
return this.getPrivate('v2/private/wallet/balance', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWalletFundRecords(
|
getWalletFundRecords(
|
||||||
params?: WalletFundRecordsReq
|
params?: WalletFundRecordsReq,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/wallet/fund/records', params);
|
return this.getPrivate('v2/private/wallet/fund/records', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWithdrawRecords(
|
getWithdrawRecords(
|
||||||
params?: WithdrawRecordsReq
|
params?: WithdrawRecordsReq,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/wallet/withdraw/list', params);
|
return this.getPrivate('v2/private/wallet/withdraw/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAssetExchangeRecords(
|
getAssetExchangeRecords(
|
||||||
params?: AssetExchangeRecordsReq
|
params?: AssetExchangeRecordsReq,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/exchange-order/list', params);
|
return this.getPrivate('v2/private/exchange-order/list', params);
|
||||||
}
|
}
|
||||||
@@ -183,37 +187,37 @@ export class InverseClient extends BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
placeActiveOrder(
|
placeActiveOrder(
|
||||||
orderRequest: InverseOrderRequest
|
orderRequest: InverseOrderRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/order/create', orderRequest);
|
return this.postPrivate('v2/private/order/create', orderRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
getActiveOrderList(
|
getActiveOrderList(
|
||||||
params: InverseActiveOrdersRequest
|
params: InverseActiveOrdersRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/order/list', params);
|
return this.getPrivate('v2/private/order/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelActiveOrder(
|
cancelActiveOrder(
|
||||||
params: InverseCancelOrderRequest
|
params: InverseCancelOrderRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/order/cancel', params);
|
return this.postPrivate('v2/private/order/cancel', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelAllActiveOrders(
|
cancelAllActiveOrders(
|
||||||
params: SymbolParam
|
params: SymbolParam,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/order/cancelAll', params);
|
return this.postPrivate('v2/private/order/cancelAll', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceActiveOrder(
|
replaceActiveOrder(
|
||||||
params: InverseReplaceOrderRequest
|
params: InverseReplaceOrderRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/order/replace', params);
|
return this.postPrivate('v2/private/order/replace', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
queryActiveOrder(
|
queryActiveOrder(
|
||||||
params: InverseGetOrderRequest
|
params: InverseGetOrderRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/order', params);
|
return this.getPrivate('v2/private/order', params);
|
||||||
}
|
}
|
||||||
@@ -223,38 +227,38 @@ export class InverseClient extends BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
placeConditionalOrder(
|
placeConditionalOrder(
|
||||||
params: InverseConditionalOrderRequest
|
params: InverseConditionalOrderRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/stop-order/create', params);
|
return this.postPrivate('v2/private/stop-order/create', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** get conditional order list. This may see delays, use queryConditionalOrder() for real-time queries */
|
/** get conditional order list. This may see delays, use queryConditionalOrder() for real-time queries */
|
||||||
getConditionalOrder(
|
getConditionalOrder(
|
||||||
params: InverseActiveConditionalOrderRequest
|
params: InverseActiveConditionalOrderRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/stop-order/list', params);
|
return this.getPrivate('v2/private/stop-order/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelConditionalOrder(
|
cancelConditionalOrder(
|
||||||
params: InverseCancelConditionalOrderRequest
|
params: InverseCancelConditionalOrderRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/stop-order/cancel', params);
|
return this.postPrivate('v2/private/stop-order/cancel', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelAllConditionalOrders(
|
cancelAllConditionalOrders(
|
||||||
params: SymbolParam
|
params: SymbolParam,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/stop-order/cancelAll', params);
|
return this.postPrivate('v2/private/stop-order/cancelAll', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceConditionalOrder(
|
replaceConditionalOrder(
|
||||||
params: InverseReplaceConditionalOrderRequest
|
params: InverseReplaceConditionalOrderRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/stop-order/replace', params);
|
return this.postPrivate('v2/private/stop-order/replace', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
queryConditionalOrder(
|
queryConditionalOrder(
|
||||||
params: InverseGetOrderRequest
|
params: InverseGetOrderRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/stop-order', params);
|
return this.getPrivate('v2/private/stop-order', params);
|
||||||
}
|
}
|
||||||
@@ -264,49 +268,49 @@ export class InverseClient extends BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
getPosition(
|
getPosition(
|
||||||
params?: Partial<SymbolParam>
|
params?: Partial<SymbolParam>,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/position/list', params);
|
return this.getPrivate('v2/private/position/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
changePositionMargin(
|
changePositionMargin(
|
||||||
params: InverseChangePositionMarginRequest
|
params: InverseChangePositionMarginRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('position/change-position-margin', params);
|
return this.postPrivate('position/change-position-margin', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTradingStop(
|
setTradingStop(
|
||||||
params: InverseSetTradingStopRequest
|
params: InverseSetTradingStopRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/position/trading-stop', params);
|
return this.postPrivate('v2/private/position/trading-stop', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
setUserLeverage(
|
setUserLeverage(
|
||||||
params: InverseSetLeverageRequest
|
params: InverseSetLeverageRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/position/leverage/save', params);
|
return this.postPrivate('v2/private/position/leverage/save', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTradeRecords(
|
getTradeRecords(
|
||||||
params: InverseGetTradeRecordsRequest
|
params: InverseGetTradeRecordsRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/execution/list', params);
|
return this.getPrivate('v2/private/execution/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getClosedPnl(
|
getClosedPnl(
|
||||||
params: InverseGetClosedPnlRequest
|
params: InverseGetClosedPnlRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/trade/closed-pnl/list', params);
|
return this.getPrivate('v2/private/trade/closed-pnl/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
setSlTpPositionMode(
|
setSlTpPositionMode(
|
||||||
params: InverseSetSlTpPositionModeRequest
|
params: InverseSetSlTpPositionModeRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/tpsl/switch-mode', params);
|
return this.postPrivate('v2/private/tpsl/switch-mode', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
setMarginType(
|
setMarginType(
|
||||||
params: InverseSetMarginTypeRequest
|
params: InverseSetMarginTypeRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/position/switch-isolated', params);
|
return this.postPrivate('v2/private/position/switch-isolated', params);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ import BaseRestClient from './util/BaseRestClient';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* REST API client for Inverse Futures APIs (e.g. quarterly futures) (v2)
|
* REST API client for Inverse Futures APIs (e.g. quarterly futures) (v2)
|
||||||
|
*
|
||||||
|
* @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet
|
||||||
|
* will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability.
|
||||||
|
* Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP.
|
||||||
*/
|
*/
|
||||||
export class InverseFuturesClient extends BaseRestClient {
|
export class InverseFuturesClient extends BaseRestClient {
|
||||||
getClientType() {
|
getClientType() {
|
||||||
@@ -38,7 +42,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getKline(
|
getKline(
|
||||||
params: SymbolIntervalFromLimitParam
|
params: SymbolIntervalFromLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('v2/public/kline/list', params);
|
return this.get('v2/public/kline/list', params);
|
||||||
}
|
}
|
||||||
@@ -47,7 +51,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
* Get latest information for symbol
|
* Get latest information for symbol
|
||||||
*/
|
*/
|
||||||
getTickers(
|
getTickers(
|
||||||
params?: Partial<SymbolParam>
|
params?: Partial<SymbolParam>,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('v2/public/tickers', params);
|
return this.get('v2/public/tickers', params);
|
||||||
}
|
}
|
||||||
@@ -64,19 +68,19 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getMarkPriceKline(
|
getMarkPriceKline(
|
||||||
params: SymbolIntervalFromLimitParam
|
params: SymbolIntervalFromLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('v2/public/mark-price-kline', params);
|
return this.get('v2/public/mark-price-kline', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getIndexPriceKline(
|
getIndexPriceKline(
|
||||||
params: SymbolIntervalFromLimitParam
|
params: SymbolIntervalFromLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('v2/public/index-price-kline', params);
|
return this.get('v2/public/index-price-kline', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPremiumIndexKline(
|
getPremiumIndexKline(
|
||||||
params: SymbolIntervalFromLimitParam
|
params: SymbolIntervalFromLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('v2/public/premium-index-kline', params);
|
return this.get('v2/public/premium-index-kline', params);
|
||||||
}
|
}
|
||||||
@@ -88,19 +92,19 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
getOpenInterest(
|
getOpenInterest(
|
||||||
params: SymbolPeriodLimitParam
|
params: SymbolPeriodLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('v2/public/open-interest', params);
|
return this.get('v2/public/open-interest', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLatestBigDeal(
|
getLatestBigDeal(
|
||||||
params: SymbolLimitParam
|
params: SymbolLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('v2/public/big-deal', params);
|
return this.get('v2/public/big-deal', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLongShortRatio(
|
getLongShortRatio(
|
||||||
params: SymbolPeriodLimitParam
|
params: SymbolPeriodLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('v2/public/account-ratio', params);
|
return this.get('v2/public/account-ratio', params);
|
||||||
}
|
}
|
||||||
@@ -122,25 +126,25 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
getWalletBalance(
|
getWalletBalance(
|
||||||
params?: Partial<CoinParam>
|
params?: Partial<CoinParam>,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/wallet/balance', params);
|
return this.getPrivate('v2/private/wallet/balance', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWalletFundRecords(
|
getWalletFundRecords(
|
||||||
params?: WalletFundRecordsReq
|
params?: WalletFundRecordsReq,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/wallet/fund/records', params);
|
return this.getPrivate('v2/private/wallet/fund/records', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWithdrawRecords(
|
getWithdrawRecords(
|
||||||
params?: WithdrawRecordsReq
|
params?: WithdrawRecordsReq,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/wallet/withdraw/list', params);
|
return this.getPrivate('v2/private/wallet/withdraw/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAssetExchangeRecords(
|
getAssetExchangeRecords(
|
||||||
params?: AssetExchangeRecordsReq
|
params?: AssetExchangeRecordsReq,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/exchange-order/list', params);
|
return this.getPrivate('v2/private/exchange-order/list', params);
|
||||||
}
|
}
|
||||||
@@ -204,7 +208,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cancelAllActiveOrders(
|
cancelAllActiveOrders(
|
||||||
params: SymbolParam
|
params: SymbolParam,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('futures/private/order/cancelAll', params);
|
return this.postPrivate('futures/private/order/cancelAll', params);
|
||||||
}
|
}
|
||||||
@@ -266,7 +270,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cancelAllConditionalOrders(
|
cancelAllConditionalOrders(
|
||||||
params: SymbolParam
|
params: SymbolParam,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('futures/private/stop-order/cancelAll', params);
|
return this.postPrivate('futures/private/stop-order/cancelAll', params);
|
||||||
}
|
}
|
||||||
@@ -298,7 +302,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
* Get position list
|
* Get position list
|
||||||
*/
|
*/
|
||||||
getPosition(
|
getPosition(
|
||||||
params?: Partial<SymbolParam>
|
params?: Partial<SymbolParam>,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('futures/private/position/list', params);
|
return this.getPrivate('futures/private/position/list', params);
|
||||||
}
|
}
|
||||||
@@ -309,7 +313,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
}): Promise<APIResponseWithTime<any>> {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'futures/private/position/change-position-margin',
|
'futures/private/position/change-position-margin',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ import BaseRestClient from './util/BaseRestClient';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* REST API client for linear/USD perpetual futures APIs (v2)
|
* REST API client for linear/USD perpetual futures APIs (v2)
|
||||||
|
*
|
||||||
|
* @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet
|
||||||
|
* will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability.
|
||||||
|
* Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP.
|
||||||
*/
|
*/
|
||||||
export class LinearClient extends BaseRestClient {
|
export class LinearClient extends BaseRestClient {
|
||||||
getClientType() {
|
getClientType() {
|
||||||
@@ -64,7 +68,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getKline(
|
getKline(
|
||||||
params: SymbolIntervalFromLimitParam
|
params: SymbolIntervalFromLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('public/linear/kline', params);
|
return this.get('public/linear/kline', params);
|
||||||
}
|
}
|
||||||
@@ -73,7 +77,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
* Get latest information for symbol
|
* Get latest information for symbol
|
||||||
*/
|
*/
|
||||||
getTickers(
|
getTickers(
|
||||||
params?: Partial<SymbolParam>
|
params?: Partial<SymbolParam>,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('v2/public/tickers', params);
|
return this.get('v2/public/tickers', params);
|
||||||
}
|
}
|
||||||
@@ -91,19 +95,19 @@ export class LinearClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getMarkPriceKline(
|
getMarkPriceKline(
|
||||||
params: SymbolIntervalFromLimitParam
|
params: SymbolIntervalFromLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('public/linear/mark-price-kline', params);
|
return this.get('public/linear/mark-price-kline', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getIndexPriceKline(
|
getIndexPriceKline(
|
||||||
params: SymbolIntervalFromLimitParam
|
params: SymbolIntervalFromLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('public/linear/index-price-kline', params);
|
return this.get('public/linear/index-price-kline', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPremiumIndexKline(
|
getPremiumIndexKline(
|
||||||
params: SymbolIntervalFromLimitParam
|
params: SymbolIntervalFromLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('public/linear/premium-index-kline', params);
|
return this.get('public/linear/premium-index-kline', params);
|
||||||
}
|
}
|
||||||
@@ -115,19 +119,19 @@ export class LinearClient extends BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
getOpenInterest(
|
getOpenInterest(
|
||||||
params: SymbolPeriodLimitParam
|
params: SymbolPeriodLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('v2/public/open-interest', params);
|
return this.get('v2/public/open-interest', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLatestBigDeal(
|
getLatestBigDeal(
|
||||||
params: SymbolLimitParam
|
params: SymbolLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('v2/public/big-deal', params);
|
return this.get('v2/public/big-deal', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLongShortRatio(
|
getLongShortRatio(
|
||||||
params: SymbolPeriodLimitParam
|
params: SymbolPeriodLimitParam,
|
||||||
): Promise<APIResponseWithTime<any[]>> {
|
): Promise<APIResponseWithTime<any[]>> {
|
||||||
return this.get('v2/public/account-ratio', params);
|
return this.get('v2/public/account-ratio', params);
|
||||||
}
|
}
|
||||||
@@ -149,25 +153,25 @@ export class LinearClient extends BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
getWalletBalance(
|
getWalletBalance(
|
||||||
params?: Partial<CoinParam>
|
params?: Partial<CoinParam>,
|
||||||
): Promise<APIResponseWithTime<WalletBalances>> {
|
): Promise<APIResponseWithTime<WalletBalances>> {
|
||||||
return this.getPrivate('v2/private/wallet/balance', params);
|
return this.getPrivate('v2/private/wallet/balance', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWalletFundRecords(
|
getWalletFundRecords(
|
||||||
params?: WalletFundRecordsReq
|
params?: WalletFundRecordsReq,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/wallet/fund/records', params);
|
return this.getPrivate('v2/private/wallet/fund/records', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWithdrawRecords(
|
getWithdrawRecords(
|
||||||
params?: WithdrawRecordsReq
|
params?: WithdrawRecordsReq,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/wallet/withdraw/list', params);
|
return this.getPrivate('v2/private/wallet/withdraw/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAssetExchangeRecords(
|
getAssetExchangeRecords(
|
||||||
params?: AssetExchangeRecordsReq
|
params?: AssetExchangeRecordsReq,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/exchange-order/list', params);
|
return this.getPrivate('v2/private/exchange-order/list', params);
|
||||||
}
|
}
|
||||||
@@ -193,37 +197,37 @@ export class LinearClient extends BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
placeActiveOrder(
|
placeActiveOrder(
|
||||||
params: NewLinearOrder
|
params: NewLinearOrder,
|
||||||
): Promise<APIResponseWithTime<LinearOrder | null>> {
|
): Promise<APIResponseWithTime<LinearOrder | null>> {
|
||||||
return this.postPrivate('private/linear/order/create', params);
|
return this.postPrivate('private/linear/order/create', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getActiveOrderList(
|
getActiveOrderList(
|
||||||
params: LinearGetOrdersRequest
|
params: LinearGetOrdersRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('private/linear/order/list', params);
|
return this.getPrivate('private/linear/order/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelActiveOrder(
|
cancelActiveOrder(
|
||||||
params: LinearCancelOrderRequest
|
params: LinearCancelOrderRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/order/cancel', params);
|
return this.postPrivate('private/linear/order/cancel', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelAllActiveOrders(
|
cancelAllActiveOrders(
|
||||||
params: SymbolParam
|
params: SymbolParam,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/order/cancel-all', params);
|
return this.postPrivate('private/linear/order/cancel-all', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceActiveOrder(
|
replaceActiveOrder(
|
||||||
params: LinearReplaceOrderRequest
|
params: LinearReplaceOrderRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/order/replace', params);
|
return this.postPrivate('private/linear/order/replace', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
queryActiveOrder(
|
queryActiveOrder(
|
||||||
params: LinearGetOrderRequest
|
params: LinearGetOrderRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('private/linear/order/search', params);
|
return this.getPrivate('private/linear/order/search', params);
|
||||||
}
|
}
|
||||||
@@ -233,37 +237,37 @@ export class LinearClient extends BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
placeConditionalOrder(
|
placeConditionalOrder(
|
||||||
params: LinearConditionalOrderRequest
|
params: LinearConditionalOrderRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/stop-order/create', params);
|
return this.postPrivate('private/linear/stop-order/create', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getConditionalOrder(
|
getConditionalOrder(
|
||||||
params: LinearGetConditionalOrderRequest
|
params: LinearGetConditionalOrderRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('private/linear/stop-order/list', params);
|
return this.getPrivate('private/linear/stop-order/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelConditionalOrder(
|
cancelConditionalOrder(
|
||||||
params: LinearCancelConditionalOrderRequest
|
params: LinearCancelConditionalOrderRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/stop-order/cancel', params);
|
return this.postPrivate('private/linear/stop-order/cancel', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelAllConditionalOrders(
|
cancelAllConditionalOrders(
|
||||||
params: SymbolParam
|
params: SymbolParam,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/stop-order/cancel-all', params);
|
return this.postPrivate('private/linear/stop-order/cancel-all', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceConditionalOrder(
|
replaceConditionalOrder(
|
||||||
params: LinearReplaceConditionalOrderRequest
|
params: LinearReplaceConditionalOrderRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/stop-order/replace', params);
|
return this.postPrivate('private/linear/stop-order/replace', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
queryConditionalOrder(
|
queryConditionalOrder(
|
||||||
params: LinearQueryConditionalOrderRequest
|
params: LinearQueryConditionalOrderRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('private/linear/stop-order/search', params);
|
return this.getPrivate('private/linear/stop-order/search', params);
|
||||||
}
|
}
|
||||||
@@ -275,26 +279,26 @@ export class LinearClient extends BaseRestClient {
|
|||||||
getPosition(): Promise<APIResponseWithTime<PerpPositionRoot[]>>;
|
getPosition(): Promise<APIResponseWithTime<PerpPositionRoot[]>>;
|
||||||
|
|
||||||
getPosition(
|
getPosition(
|
||||||
params: Partial<SymbolParam>
|
params: Partial<SymbolParam>,
|
||||||
): Promise<APIResponseWithTime<PerpPosition[]>>;
|
): Promise<APIResponseWithTime<PerpPosition[]>>;
|
||||||
|
|
||||||
getPosition(
|
getPosition(
|
||||||
params?: Partial<SymbolParam>
|
params?: Partial<SymbolParam>,
|
||||||
): Promise<APIResponseWithTime<PerpPosition[] | PerpPositionRoot[]>> {
|
): Promise<APIResponseWithTime<PerpPosition[] | PerpPositionRoot[]>> {
|
||||||
return this.getPrivate('private/linear/position/list', params);
|
return this.getPrivate('private/linear/position/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
setAutoAddMargin(
|
setAutoAddMargin(
|
||||||
params?: LinearSetAutoAddMarginRequest
|
params?: LinearSetAutoAddMarginRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'private/linear/position/set-auto-add-margin',
|
'private/linear/position/set-auto-add-margin',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
setMarginSwitch(
|
setMarginSwitch(
|
||||||
params?: LinearSetMarginSwitchRequest
|
params?: LinearSetMarginSwitchRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/position/switch-isolated', params);
|
return this.postPrivate('private/linear/position/switch-isolated', params);
|
||||||
}
|
}
|
||||||
@@ -303,7 +307,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
* Switch between one-way vs hedge mode. Use `linearPositionModeEnum` for the mode parameter.
|
* Switch between one-way vs hedge mode. Use `linearPositionModeEnum` for the mode parameter.
|
||||||
*/
|
*/
|
||||||
setPositionMode(
|
setPositionMode(
|
||||||
params: LinearSetPositionModeRequest
|
params: LinearSetPositionModeRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/position/switch-mode', params);
|
return this.postPrivate('private/linear/position/switch-mode', params);
|
||||||
}
|
}
|
||||||
@@ -313,46 +317,46 @@ export class LinearClient extends BaseRestClient {
|
|||||||
* This is set with the setTradingStop() method. Use `positionTpSlModeEnum` for the tp_sl_mode parameter.
|
* This is set with the setTradingStop() method. Use `positionTpSlModeEnum` for the tp_sl_mode parameter.
|
||||||
*/
|
*/
|
||||||
setPositionTpSlMode(
|
setPositionTpSlMode(
|
||||||
params: LinearSetPositionTpSlModeRequest
|
params: LinearSetPositionTpSlModeRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/tpsl/switch-mode', params);
|
return this.postPrivate('private/linear/tpsl/switch-mode', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
setAddReduceMargin(
|
setAddReduceMargin(
|
||||||
params?: LinearSetAddReduceMarginRequest
|
params?: LinearSetAddReduceMarginRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/position/add-margin', params);
|
return this.postPrivate('private/linear/position/add-margin', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
setUserLeverage(
|
setUserLeverage(
|
||||||
params: LinearSetUserLeverageRequest
|
params: LinearSetUserLeverageRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/position/set-leverage', params);
|
return this.postPrivate('private/linear/position/set-leverage', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTradingStop(
|
setTradingStop(
|
||||||
params: LinearSetTradingStopRequest
|
params: LinearSetTradingStopRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/position/trading-stop', params);
|
return this.postPrivate('private/linear/position/trading-stop', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTradeRecords(
|
getTradeRecords(
|
||||||
params: LinearGetTradeRecordsRequest
|
params: LinearGetTradeRecordsRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('private/linear/trade/execution/list', params);
|
return this.getPrivate('private/linear/trade/execution/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getHistoryTradeRecords(
|
getHistoryTradeRecords(
|
||||||
params: LinearGetHistoryTradeRecordsRequest
|
params: LinearGetHistoryTradeRecordsRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate(
|
return this.getPrivate(
|
||||||
'/private/linear/trade/execution/history-list',
|
'/private/linear/trade/execution/history-list',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getClosedPnl(
|
getClosedPnl(
|
||||||
params: LinearGetClosedPnlRequest
|
params: LinearGetClosedPnlRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('private/linear/trade/closed-pnl/list', params);
|
return this.getPrivate('private/linear/trade/closed-pnl/list', params);
|
||||||
}
|
}
|
||||||
@@ -366,7 +370,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setRiskLimit(
|
setRiskLimit(
|
||||||
params: LinearSetRiskLimitRequest
|
params: LinearSetRiskLimitRequest,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/position/set-risk', params);
|
return this.postPrivate('private/linear/position/set-risk', params);
|
||||||
}
|
}
|
||||||
@@ -376,7 +380,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
getPredictedFundingFee(
|
getPredictedFundingFee(
|
||||||
params: SymbolParam
|
params: SymbolParam,
|
||||||
): Promise<APIResponseWithTime<any>> {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('private/linear/funding/predicted-funding', params);
|
return this.getPrivate('private/linear/funding/predicted-funding', params);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ import {
|
|||||||
WithdrawParamsV5,
|
WithdrawParamsV5,
|
||||||
WithdrawalRecordV5,
|
WithdrawalRecordV5,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
import { REST_CLIENT_TYPE_ENUM } from './util';
|
import { REST_CLIENT_TYPE_ENUM } from './util';
|
||||||
import BaseRestClient from './util/BaseRestClient';
|
import BaseRestClient from './util/BaseRestClient';
|
||||||
|
|
||||||
@@ -248,6 +249,22 @@ export class RestClientV5 extends BaseRestClient {
|
|||||||
return this.get('/v5/market/orderbook', params);
|
return this.get('/v5/market/orderbook', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTickers(
|
||||||
|
params: GetTickersParamsV5<'linear' | 'inverse'>,
|
||||||
|
): Promise<
|
||||||
|
APIResponseV3WithTime<
|
||||||
|
CategoryListV5<TickerLinearInverseV5[], 'linear' | 'inverse'>
|
||||||
|
>
|
||||||
|
>;
|
||||||
|
|
||||||
|
getTickers(
|
||||||
|
params: GetTickersParamsV5<'option'>,
|
||||||
|
): Promise<APIResponseV3WithTime<CategoryListV5<TickerOptionV5[], 'option'>>>;
|
||||||
|
|
||||||
|
getTickers(
|
||||||
|
params: GetTickersParamsV5<'spot'>,
|
||||||
|
): Promise<APIResponseV3WithTime<CategoryListV5<TickerSpotV5[], 'spot'>>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query the latest price snapshot, best bid/ask price, and trading volume in the last 24 hours.
|
* Query the latest price snapshot, best bid/ask price, and trading volume in the last 24 hours.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -14,8 +14,11 @@ import BaseRestClient from './util/BaseRestClient';
|
|||||||
import { REST_CLIENT_TYPE_ENUM } from './util/requestUtils';
|
import { REST_CLIENT_TYPE_ENUM } from './util/requestUtils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use SpotV3Client instead, which leverages the newer v3 APIs
|
|
||||||
* REST API client for Spot APIs (v1)
|
* REST API client for Spot APIs (v1)
|
||||||
|
*
|
||||||
|
* @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet
|
||||||
|
* will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability.
|
||||||
|
* Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP.
|
||||||
*/
|
*/
|
||||||
export class SpotClient extends BaseRestClient {
|
export class SpotClient extends BaseRestClient {
|
||||||
getClientType() {
|
getClientType() {
|
||||||
@@ -51,7 +54,7 @@ export class SpotClient extends BaseRestClient {
|
|||||||
getMergedOrderBook(
|
getMergedOrderBook(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
scale?: number,
|
scale?: number,
|
||||||
limit?: number
|
limit?: number,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.get('/spot/quote/v1/depth/merged', {
|
return this.get('/spot/quote/v1/depth/merged', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -72,7 +75,7 @@ export class SpotClient extends BaseRestClient {
|
|||||||
interval: KlineInterval,
|
interval: KlineInterval,
|
||||||
limit?: number,
|
limit?: number,
|
||||||
startTime?: number,
|
startTime?: number,
|
||||||
endTime?: number
|
endTime?: number,
|
||||||
): Promise<APIResponse<any[]>> {
|
): Promise<APIResponse<any[]>> {
|
||||||
return this.get('/spot/quote/v1/kline', {
|
return this.get('/spot/quote/v1/kline', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -92,7 +95,7 @@ export class SpotClient extends BaseRestClient {
|
|||||||
getLastTradedPrice(symbol: string): Promise<APIResponse<SpotLastPrice>>;
|
getLastTradedPrice(symbol: string): Promise<APIResponse<SpotLastPrice>>;
|
||||||
|
|
||||||
getLastTradedPrice(
|
getLastTradedPrice(
|
||||||
symbol?: string
|
symbol?: string,
|
||||||
): Promise<APIResponse<SpotLastPrice | SpotLastPrice[]>> {
|
): Promise<APIResponse<SpotLastPrice | SpotLastPrice[]>> {
|
||||||
return this.get('/spot/quote/v1/ticker/price', { symbol });
|
return this.get('/spot/quote/v1/ticker/price', { symbol });
|
||||||
}
|
}
|
||||||
@@ -135,7 +138,7 @@ export class SpotClient extends BaseRestClient {
|
|||||||
getOpenOrders(
|
getOpenOrders(
|
||||||
symbol?: string,
|
symbol?: string,
|
||||||
orderId?: string,
|
orderId?: string,
|
||||||
limit?: number
|
limit?: number,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/spot/v1/open-orders', {
|
return this.getPrivate('/spot/v1/open-orders', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -147,7 +150,7 @@ export class SpotClient extends BaseRestClient {
|
|||||||
getPastOrders(
|
getPastOrders(
|
||||||
symbol?: string,
|
symbol?: string,
|
||||||
orderId?: string,
|
orderId?: string,
|
||||||
limit?: number
|
limit?: number,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/spot/v1/history-orders', {
|
return this.getPrivate('/spot/v1/history-orders', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -160,7 +163,7 @@ export class SpotClient extends BaseRestClient {
|
|||||||
symbol?: string,
|
symbol?: string,
|
||||||
limit?: number,
|
limit?: number,
|
||||||
fromId?: number,
|
fromId?: number,
|
||||||
toId?: number
|
toId?: number,
|
||||||
): Promise<APIResponse<any>> {
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/spot/v1/myTrades', {
|
return this.getPrivate('/spot/v1/myTrades', {
|
||||||
symbol,
|
symbol,
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ export interface GetOrderbookParamsV5 {
|
|||||||
limit?: number;
|
limit?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetTickersParamsV5 {
|
export interface GetTickersParamsV5<TCategory = CategoryV5> {
|
||||||
category: CategoryV5;
|
category: TCategory;
|
||||||
symbol?: string;
|
symbol?: string;
|
||||||
baseCoin?: string;
|
baseCoin?: string;
|
||||||
expDate?: string;
|
expDate?: string;
|
||||||
|
|||||||
@@ -61,18 +61,33 @@ export interface APIResponse<T> {
|
|||||||
result: T;
|
result: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface APIRateLimit {
|
||||||
|
/** Remaining requests to this endpoint before the next reset */
|
||||||
|
remainingRequests: number;
|
||||||
|
/** Max requests for this endpoint per rollowing window (before next reset) */
|
||||||
|
maxRequests: number;
|
||||||
|
/**
|
||||||
|
* Timestamp when the rate limit resets if you have exceeded your current maxRequests.
|
||||||
|
* Otherwise, this is approximately your current timestamp.
|
||||||
|
*/
|
||||||
|
resetAtTimestamp: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface APIResponseV3<T> {
|
export interface APIResponseV3<T> {
|
||||||
retCode: number;
|
retCode: number;
|
||||||
retMsg: 'OK' | string;
|
retMsg: 'OK' | string;
|
||||||
result: T;
|
result: T;
|
||||||
|
/**
|
||||||
|
* These are per-UID per-endpoint rate limits, automatically parsed from response headers if available.
|
||||||
|
*
|
||||||
|
* Note:
|
||||||
|
* - this is primarily for V5 (or newer) APIs.
|
||||||
|
* - these rate limits are per-endpoint per-account, so will not appear for public API calls
|
||||||
|
*/
|
||||||
|
rateLimitApi?: APIRateLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface APIResponseV3WithTime<T> {
|
export type APIResponseV3WithTime<T> = APIResponseV3<T> & { time: number };
|
||||||
retCode: number;
|
|
||||||
retMsg: 'OK' | string;
|
|
||||||
result: T;
|
|
||||||
time: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface APIResponseWithTime<T = {}> extends APIResponse<T> {
|
export interface APIResponseWithTime<T = {}> extends APIResponse<T> {
|
||||||
/** UTC timestamp */
|
/** UTC timestamp */
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ import BaseRestClient from './util/BaseRestClient';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* REST API client for USDC Option APIs
|
* REST API client for USDC Option APIs
|
||||||
|
*
|
||||||
|
* @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet
|
||||||
|
* will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability.
|
||||||
|
* Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP.
|
||||||
*/
|
*/
|
||||||
export class USDCOptionClient extends BaseRestClient {
|
export class USDCOptionClient extends BaseRestClient {
|
||||||
getClientType() {
|
getClientType() {
|
||||||
@@ -49,7 +53,7 @@ export class USDCOptionClient extends BaseRestClient {
|
|||||||
|
|
||||||
/** Fetch trading rules (such as min/max qty). Query for all if blank. */
|
/** Fetch trading rules (such as min/max qty). Query for all if blank. */
|
||||||
getContractInfo(
|
getContractInfo(
|
||||||
params?: USDCOptionsContractInfoRequest
|
params?: USDCOptionsContractInfoRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.get('/option/usdc/openapi/public/v1/symbols', params);
|
return this.get('/option/usdc/openapi/public/v1/symbols', params);
|
||||||
}
|
}
|
||||||
@@ -61,18 +65,18 @@ export class USDCOptionClient extends BaseRestClient {
|
|||||||
|
|
||||||
/** Get delivery information */
|
/** Get delivery information */
|
||||||
getDeliveryPrice(
|
getDeliveryPrice(
|
||||||
params?: USDCOptionsDeliveryPriceRequest
|
params?: USDCOptionsDeliveryPriceRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.get('/option/usdc/openapi/public/v1/delivery-price', params);
|
return this.get('/option/usdc/openapi/public/v1/delivery-price', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returned records are Taker Buy in default. */
|
/** Returned records are Taker Buy in default. */
|
||||||
getLast500Trades(
|
getLast500Trades(
|
||||||
params: USDCOptionsRecentTradesRequest
|
params: USDCOptionsRecentTradesRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.get(
|
return this.get(
|
||||||
'/option/usdc/openapi/public/v1/query-trade-latest',
|
'/option/usdc/openapi/public/v1/query-trade-latest',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,11 +88,11 @@ export class USDCOptionClient extends BaseRestClient {
|
|||||||
* Both startTime & endTime entered together or both are left blank
|
* Both startTime & endTime entered together or both are left blank
|
||||||
*/
|
*/
|
||||||
getHistoricalVolatility(
|
getHistoricalVolatility(
|
||||||
params?: USDCOptionsHistoricalVolatilityRequest
|
params?: USDCOptionsHistoricalVolatilityRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.get(
|
return this.get(
|
||||||
'/option/usdc/openapi/public/v1/query-historical-volatility',
|
'/option/usdc/openapi/public/v1/query-historical-volatility',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +112,7 @@ export class USDCOptionClient extends BaseRestClient {
|
|||||||
submitOrder(params: USDCOptionsOrderRequest): Promise<APIResponseV3<any>> {
|
submitOrder(params: USDCOptionsOrderRequest): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/place-order',
|
'/option/usdc/openapi/private/v1/place-order',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,91 +120,91 @@ export class USDCOptionClient extends BaseRestClient {
|
|||||||
* Each request supports a max. of four orders. The reduceOnly parameter should be separate and unique for each order in the request.
|
* Each request supports a max. of four orders. The reduceOnly parameter should be separate and unique for each order in the request.
|
||||||
*/
|
*/
|
||||||
batchSubmitOrders(
|
batchSubmitOrders(
|
||||||
orderRequest: USDCOptionsOrderRequest[]
|
orderRequest: USDCOptionsOrderRequest[],
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/batch-place-orders',
|
'/option/usdc/openapi/private/v1/batch-place-orders',
|
||||||
{ orderRequest }
|
{ orderRequest },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For Options, at least one of the three parameters — price, quantity or implied volatility — must be input. */
|
/** For Options, at least one of the three parameters — price, quantity or implied volatility — must be input. */
|
||||||
modifyOrder(
|
modifyOrder(
|
||||||
params: USDCOptionsModifyOrderRequest
|
params: USDCOptionsModifyOrderRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/replace-order',
|
'/option/usdc/openapi/private/v1/replace-order',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Each request supports a max. of four orders. The reduceOnly parameter should be separate and unique for each order in the request. */
|
/** Each request supports a max. of four orders. The reduceOnly parameter should be separate and unique for each order in the request. */
|
||||||
batchModifyOrders(
|
batchModifyOrders(
|
||||||
replaceOrderRequest: USDCOptionsModifyOrderRequest[]
|
replaceOrderRequest: USDCOptionsModifyOrderRequest[],
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/batch-replace-orders',
|
'/option/usdc/openapi/private/v1/batch-replace-orders',
|
||||||
{ replaceOrderRequest }
|
{ replaceOrderRequest },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Cancel order */
|
/** Cancel order */
|
||||||
cancelOrder(
|
cancelOrder(
|
||||||
params: USDCOptionsCancelOrderRequest
|
params: USDCOptionsCancelOrderRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/cancel-order',
|
'/option/usdc/openapi/private/v1/cancel-order',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Batch cancel orders */
|
/** Batch cancel orders */
|
||||||
batchCancelOrders(
|
batchCancelOrders(
|
||||||
cancelRequest: USDCOptionsCancelOrderRequest[]
|
cancelRequest: USDCOptionsCancelOrderRequest[],
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/batch-cancel-orders',
|
'/option/usdc/openapi/private/v1/batch-cancel-orders',
|
||||||
{ cancelRequest }
|
{ cancelRequest },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is used to cancel all active orders. The real-time response indicates whether the request is successful, depending on retCode. */
|
/** This is used to cancel all active orders. The real-time response indicates whether the request is successful, depending on retCode. */
|
||||||
cancelActiveOrders(
|
cancelActiveOrders(
|
||||||
params?: USDCOptionsCancelAllOrdersRequest
|
params?: USDCOptionsCancelAllOrdersRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/cancel-all',
|
'/option/usdc/openapi/private/v1/cancel-all',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Query Unfilled/Partially Filled Orders(real-time), up to last 7 days of partially filled/unfilled orders */
|
/** Query Unfilled/Partially Filled Orders(real-time), up to last 7 days of partially filled/unfilled orders */
|
||||||
getActiveRealtimeOrders(
|
getActiveRealtimeOrders(
|
||||||
params?: USDCOptionsActiveOrdersRealtimeRequest
|
params?: USDCOptionsActiveOrdersRealtimeRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.getPrivate(
|
return this.getPrivate(
|
||||||
'/option/usdc/openapi/private/v1/trade/query-active-orders',
|
'/option/usdc/openapi/private/v1/trade/query-active-orders',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Query Unfilled/Partially Filled Orders */
|
/** Query Unfilled/Partially Filled Orders */
|
||||||
getActiveOrders(
|
getActiveOrders(
|
||||||
params: USDCOptionsActiveOrdersRequest
|
params: USDCOptionsActiveOrdersRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-active-orders',
|
'/option/usdc/openapi/private/v1/query-active-orders',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Query order history. The endpoint only supports up to 30 days of queried records */
|
/** Query order history. The endpoint only supports up to 30 days of queried records */
|
||||||
getHistoricOrders(
|
getHistoricOrders(
|
||||||
params: USDCOptionsHistoricOrdersRequest
|
params: USDCOptionsHistoricOrdersRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-order-history',
|
'/option/usdc/openapi/private/v1/query-order-history',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,11 +214,11 @@ export class USDCOptionClient extends BaseRestClient {
|
|||||||
* An error will be returned if startTime is more than 30 days.
|
* An error will be returned if startTime is more than 30 days.
|
||||||
*/
|
*/
|
||||||
getOrderExecutionHistory(
|
getOrderExecutionHistory(
|
||||||
params: USDCOptionsOrderExecutionRequest
|
params: USDCOptionsOrderExecutionRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/execution-list',
|
'/option/usdc/openapi/private/v1/execution-list',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,18 +226,18 @@ export class USDCOptionClient extends BaseRestClient {
|
|||||||
|
|
||||||
/** The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
|
/** The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
|
||||||
getTransactionLog(
|
getTransactionLog(
|
||||||
params: USDCTransactionLogRequest
|
params: USDCTransactionLogRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-transaction-log',
|
'/option/usdc/openapi/private/v1/query-transaction-log',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Wallet info for USDC account. */
|
/** Wallet info for USDC account. */
|
||||||
getBalances(): Promise<APIResponseV3<any>> {
|
getBalances(): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-wallet-balance'
|
'/option/usdc/openapi/private/v1/query-wallet-balance',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +245,7 @@ export class USDCOptionClient extends BaseRestClient {
|
|||||||
getAssetInfo(baseCoin?: string): Promise<APIResponseV3<any>> {
|
getAssetInfo(baseCoin?: string): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-asset-info',
|
'/option/usdc/openapi/private/v1/query-asset-info',
|
||||||
{ baseCoin }
|
{ baseCoin },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,18 +256,18 @@ export class USDCOptionClient extends BaseRestClient {
|
|||||||
* Rest API returns the result of checking prerequisites. You could get the real status of margin mode change by subscribing margin mode.
|
* Rest API returns the result of checking prerequisites. You could get the real status of margin mode change by subscribing margin mode.
|
||||||
*/
|
*/
|
||||||
setMarginMode(
|
setMarginMode(
|
||||||
newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN'
|
newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN',
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/private/asset/account/setMarginMode',
|
'/option/usdc/private/asset/account/setMarginMode',
|
||||||
{ setMarginMode: newMarginMode }
|
{ setMarginMode: newMarginMode },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Query margin mode for USDC account. */
|
/** Query margin mode for USDC account. */
|
||||||
getMarginMode(): Promise<APIResponseV3<any>> {
|
getMarginMode(): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-margin-info'
|
'/option/usdc/openapi/private/v1/query-margin-info',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,27 +277,27 @@ export class USDCOptionClient extends BaseRestClient {
|
|||||||
getPositions(params: USDCPositionsRequest): Promise<APIResponseV3<any>> {
|
getPositions(params: USDCPositionsRequest): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-position',
|
'/option/usdc/openapi/private/v1/query-position',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Query Delivery History */
|
/** Query Delivery History */
|
||||||
getDeliveryHistory(
|
getDeliveryHistory(
|
||||||
params: USDCOptionsDeliveryHistoryRequest
|
params: USDCOptionsDeliveryHistoryRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-delivery-list',
|
'/option/usdc/openapi/private/v1/query-delivery-list',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Query Positions Info Upon Expiry */
|
/** Query Positions Info Upon Expiry */
|
||||||
getPositionsInfoUponExpiry(
|
getPositionsInfoUponExpiry(
|
||||||
params?: USDCOptionsPositionsInfoExpiryRequest
|
params?: USDCOptionsPositionsInfoExpiryRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-position-exp-date',
|
'/option/usdc/openapi/private/v1/query-position-exp-date',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,7 +307,7 @@ export class USDCOptionClient extends BaseRestClient {
|
|||||||
modifyMMP(params: USDCOptionsModifyMMPRequest): Promise<APIResponseV3<any>> {
|
modifyMMP(params: USDCOptionsModifyMMPRequest): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/mmp-modify',
|
'/option/usdc/openapi/private/v1/mmp-modify',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ import BaseRestClient from './util/BaseRestClient';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* REST API client for USDC Perpetual APIs
|
* REST API client for USDC Perpetual APIs
|
||||||
|
*
|
||||||
|
* @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet
|
||||||
|
* will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability.
|
||||||
|
* Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP.
|
||||||
*/
|
*/
|
||||||
export class USDCPerpetualClient extends BaseRestClient {
|
export class USDCPerpetualClient extends BaseRestClient {
|
||||||
getClientType() {
|
getClientType() {
|
||||||
@@ -47,7 +51,7 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
|
|
||||||
/** Fetch trading rules (such as min/max qty). Query for all if blank. */
|
/** Fetch trading rules (such as min/max qty). Query for all if blank. */
|
||||||
getContractInfo(
|
getContractInfo(
|
||||||
params?: USDCSymbolDirectionLimit
|
params?: USDCSymbolDirectionLimit,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.get('/perpetual/usdc/openapi/public/v1/symbols', params);
|
return this.get('/perpetual/usdc/openapi/public/v1/symbols', params);
|
||||||
}
|
}
|
||||||
@@ -64,48 +68,48 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
getMarkPrice(params: USDCKlineRequest): Promise<APIResponseV3<any>> {
|
getMarkPrice(params: USDCKlineRequest): Promise<APIResponseV3<any>> {
|
||||||
return this.get(
|
return this.get(
|
||||||
'/perpetual/usdc/openapi/public/v1/mark-price-kline',
|
'/perpetual/usdc/openapi/public/v1/mark-price-kline',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getIndexPrice(params: USDCKlineRequest): Promise<APIResponseV3<any>> {
|
getIndexPrice(params: USDCKlineRequest): Promise<APIResponseV3<any>> {
|
||||||
return this.get(
|
return this.get(
|
||||||
'/perpetual/usdc/openapi/public/v1/index-price-kline',
|
'/perpetual/usdc/openapi/public/v1/index-price-kline',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getIndexPremium(params: USDCKlineRequest): Promise<APIResponseV3<any>> {
|
getIndexPremium(params: USDCKlineRequest): Promise<APIResponseV3<any>> {
|
||||||
return this.get(
|
return this.get(
|
||||||
'/perpetual/usdc/openapi/public/v1/premium-index-kline',
|
'/perpetual/usdc/openapi/public/v1/premium-index-kline',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getOpenInterest(
|
getOpenInterest(
|
||||||
params: USDCOpenInterestRequest
|
params: USDCOpenInterestRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.get('/perpetual/usdc/openapi/public/v1/open-interest', params);
|
return this.get('/perpetual/usdc/openapi/public/v1/open-interest', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLargeOrders(
|
getLargeOrders(
|
||||||
params: SymbolLimitParam<string>
|
params: SymbolLimitParam<string>,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.get('/perpetual/usdc/openapi/public/v1/big-deal', params);
|
return this.get('/perpetual/usdc/openapi/public/v1/big-deal', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLongShortRatio(
|
getLongShortRatio(
|
||||||
params: SymbolPeriodLimitParam<string>
|
params: SymbolPeriodLimitParam<string>,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.get('/perpetual/usdc/openapi/public/v1/account-ratio', params);
|
return this.get('/perpetual/usdc/openapi/public/v1/account-ratio', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLast500Trades(
|
getLast500Trades(
|
||||||
params: USDCLast500TradesRequest
|
params: USDCLast500TradesRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.get(
|
return this.get(
|
||||||
'/option/usdc/openapi/public/v1/query-trade-latest',
|
'/option/usdc/openapi/public/v1/query-trade-latest',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +129,7 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
submitOrder(params: USDCPerpOrderRequest): Promise<APIResponseV3<any>> {
|
submitOrder(params: USDCPerpOrderRequest): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/perpetual/usdc/openapi/private/v1/place-order',
|
'/perpetual/usdc/openapi/private/v1/place-order',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +137,7 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
modifyOrder(params: USDCPerpModifyOrderRequest): Promise<APIResponseV3<any>> {
|
modifyOrder(params: USDCPerpModifyOrderRequest): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/perpetual/usdc/openapi/private/v1/replace-order',
|
'/perpetual/usdc/openapi/private/v1/replace-order',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,14 +145,14 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
cancelOrder(params: USDCPerpCancelOrderRequest): Promise<APIResponseV3<any>> {
|
cancelOrder(params: USDCPerpCancelOrderRequest): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/perpetual/usdc/openapi/private/v1/cancel-order',
|
'/perpetual/usdc/openapi/private/v1/cancel-order',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Cancel all active orders. The real-time response indicates whether the request is successful, depending on retCode. */
|
/** Cancel all active orders. The real-time response indicates whether the request is successful, depending on retCode. */
|
||||||
cancelActiveOrders(
|
cancelActiveOrders(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
orderFilter: USDCOrderFilter
|
orderFilter: USDCOrderFilter,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate('/perpetual/usdc/openapi/private/v1/cancel-all', {
|
return this.postPrivate('/perpetual/usdc/openapi/private/v1/cancel-all', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -158,31 +162,31 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
|
|
||||||
/** Query Unfilled/Partially Filled Orders */
|
/** Query Unfilled/Partially Filled Orders */
|
||||||
getActiveOrders(
|
getActiveOrders(
|
||||||
params: USDCPerpActiveOrdersRequest
|
params: USDCPerpActiveOrdersRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-active-orders',
|
'/option/usdc/openapi/private/v1/query-active-orders',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Query order history. The endpoint only supports up to 30 days of queried records */
|
/** Query order history. The endpoint only supports up to 30 days of queried records */
|
||||||
getHistoricOrders(
|
getHistoricOrders(
|
||||||
params: USDCPerpHistoricOrdersRequest
|
params: USDCPerpHistoricOrdersRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-order-history',
|
'/option/usdc/openapi/private/v1/query-order-history',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Query trade history. The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
|
/** Query trade history. The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
|
||||||
getOrderExecutionHistory(
|
getOrderExecutionHistory(
|
||||||
params: USDCPerpActiveOrdersRequest
|
params: USDCPerpActiveOrdersRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/execution-list',
|
'/option/usdc/openapi/private/v1/execution-list',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,18 +194,18 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
|
|
||||||
/** The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
|
/** The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */
|
||||||
getTransactionLog(
|
getTransactionLog(
|
||||||
params: USDCTransactionLogRequest
|
params: USDCTransactionLogRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-transaction-log',
|
'/option/usdc/openapi/private/v1/query-transaction-log',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Wallet info for USDC account. */
|
/** Wallet info for USDC account. */
|
||||||
getBalances(): Promise<APIResponseV3<any>> {
|
getBalances(): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-wallet-balance'
|
'/option/usdc/openapi/private/v1/query-wallet-balance',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +213,7 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
getAssetInfo(baseCoin?: string): Promise<APIResponseV3<any>> {
|
getAssetInfo(baseCoin?: string): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-asset-info',
|
'/option/usdc/openapi/private/v1/query-asset-info',
|
||||||
{ baseCoin }
|
{ baseCoin },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,18 +224,18 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
* Rest API returns the result of checking prerequisites. You could get the real status of margin mode change by subscribing margin mode.
|
* Rest API returns the result of checking prerequisites. You could get the real status of margin mode change by subscribing margin mode.
|
||||||
*/
|
*/
|
||||||
setMarginMode(
|
setMarginMode(
|
||||||
newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN'
|
newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN',
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/private/asset/account/setMarginMode',
|
'/option/usdc/private/asset/account/setMarginMode',
|
||||||
{ setMarginMode: newMarginMode }
|
{ setMarginMode: newMarginMode },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Query margin mode for USDC account. */
|
/** Query margin mode for USDC account. */
|
||||||
getMarginMode(): Promise<APIResponseV3<any>> {
|
getMarginMode(): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-margin-info'
|
'/option/usdc/openapi/private/v1/query-margin-info',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +245,7 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
getPositions(params: USDCPositionsRequest): Promise<APIResponseV3<any>> {
|
getPositions(params: USDCPositionsRequest): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/query-position',
|
'/option/usdc/openapi/private/v1/query-position',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,17 +253,17 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
setLeverage(symbol: string, leverage: string): Promise<APIResponseV3<any>> {
|
setLeverage(symbol: string, leverage: string): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/perpetual/usdc/openapi/private/v1/position/leverage/save',
|
'/perpetual/usdc/openapi/private/v1/position/leverage/save',
|
||||||
{ symbol, leverage }
|
{ symbol, leverage },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Query Settlement History */
|
/** Query Settlement History */
|
||||||
getSettlementHistory(
|
getSettlementHistory(
|
||||||
params?: USDCSymbolDirectionLimitCursor
|
params?: USDCSymbolDirectionLimitCursor,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/option/usdc/openapi/private/v1/session-settlement',
|
'/option/usdc/openapi/private/v1/session-settlement',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,7 +275,7 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
'/perpetual/usdc/openapi/public/v1/risk-limit/list',
|
'/perpetual/usdc/openapi/public/v1/risk-limit/list',
|
||||||
{
|
{
|
||||||
symbol,
|
symbol,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,7 +283,7 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
setRiskLimit(symbol: string, riskId: number): Promise<APIResponseV3<any>> {
|
setRiskLimit(symbol: string, riskId: number): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/perpetual/usdc/openapi/private/v1/position/set-risk-limit',
|
'/perpetual/usdc/openapi/private/v1/position/set-risk-limit',
|
||||||
{ symbol, riskId }
|
{ symbol, riskId },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,7 +300,7 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
getPredictedFundingRate(symbol: string): Promise<APIResponseV3<any>> {
|
getPredictedFundingRate(symbol: string): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/perpetual/usdc/openapi/private/v1/predicted-funding',
|
'/perpetual/usdc/openapi/private/v1/predicted-funding',
|
||||||
{ symbol }
|
{ symbol },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
RestClientOptions,
|
RestClientOptions,
|
||||||
RestClientType,
|
RestClientType,
|
||||||
getRestBaseUrl,
|
getRestBaseUrl,
|
||||||
|
parseRateLimitHeaders,
|
||||||
serializeParams,
|
serializeParams,
|
||||||
} from './requestUtils';
|
} from './requestUtils';
|
||||||
import { signMessage } from './node-support';
|
import { signMessage } from './node-support';
|
||||||
@@ -98,7 +99,7 @@ export default abstract class BaseRestClient {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an instance of the REST client. Pass API credentials in the object in the first parameter.
|
* Create an instance of the REST client. Pass API credentials in the object in the first parameter.
|
||||||
* @param {RestClientOptions} [restClientOptions={}] options to configure REST API connectivity
|
* @param {RestClientOptions} [restOptions={}] options to configure REST API connectivity
|
||||||
* @param {AxiosRequestConfig} [networkOptions={}] HTTP networking options for axios
|
* @param {AxiosRequestConfig} [networkOptions={}] HTTP networking options for axios
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
@@ -323,7 +324,17 @@ export default abstract class BaseRestClient {
|
|||||||
return axios(options)
|
return axios(options)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.status == 200) {
|
if (response.status == 200) {
|
||||||
return response.data;
|
const perAPIRateLimits = this.options.parseAPIRateLimits
|
||||||
|
? parseRateLimitHeaders(
|
||||||
|
response.headers,
|
||||||
|
this.options.throwOnFailedRateLimitParse === true,
|
||||||
|
)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
return {
|
||||||
|
rateLimitApi: perAPIRateLimits,
|
||||||
|
...response.data,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
throw response;
|
throw response;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { APIRateLimit } from '../types';
|
||||||
import { WebsocketSucceededTopicSubscriptionConfirmationEvent } from '../types/ws-events/succeeded-topic-subscription-confirmation';
|
import { WebsocketSucceededTopicSubscriptionConfirmationEvent } from '../types/ws-events/succeeded-topic-subscription-confirmation';
|
||||||
import { WebsocketTopicSubscriptionConfirmationEvent } from '../types/ws-events/topic-subscription-confirmation';
|
import { WebsocketTopicSubscriptionConfirmationEvent } from '../types/ws-events/topic-subscription-confirmation';
|
||||||
|
|
||||||
@@ -46,6 +47,12 @@ export interface RestClientOptions {
|
|||||||
|
|
||||||
/** Default: true. whether to try and post-process request exceptions. */
|
/** Default: true. whether to try and post-process request exceptions. */
|
||||||
parse_exceptions?: boolean;
|
parse_exceptions?: boolean;
|
||||||
|
|
||||||
|
/** Default: false. Enable to parse/include per-API/endpoint rate limits in responses. */
|
||||||
|
parseAPIRateLimits?: boolean;
|
||||||
|
|
||||||
|
/** Default: false. Enable to throw error if rate limit parser fails */
|
||||||
|
throwOnFailedRateLimitParse?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -169,3 +176,54 @@ export const REST_CLIENT_TYPE_ENUM = {
|
|||||||
|
|
||||||
export type RestClientType =
|
export type RestClientType =
|
||||||
(typeof REST_CLIENT_TYPE_ENUM)[keyof typeof REST_CLIENT_TYPE_ENUM];
|
(typeof REST_CLIENT_TYPE_ENUM)[keyof typeof REST_CLIENT_TYPE_ENUM];
|
||||||
|
|
||||||
|
/** Parse V5 rate limit response headers, if enabled */
|
||||||
|
export function parseRateLimitHeaders(
|
||||||
|
headers: Record<string, string | undefined> = {},
|
||||||
|
throwOnFailedRateLimitParse: boolean,
|
||||||
|
): APIRateLimit | undefined {
|
||||||
|
try {
|
||||||
|
const remaining = headers['x-bapi-limit-status'];
|
||||||
|
const max = headers['x-bapi-limit'];
|
||||||
|
const resetAt = headers['x-bapi-limit-reset-timestamp'];
|
||||||
|
|
||||||
|
if (
|
||||||
|
typeof remaining === 'undefined' ||
|
||||||
|
typeof max === 'undefined' ||
|
||||||
|
typeof resetAt === 'undefined'
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const result: APIRateLimit = {
|
||||||
|
remainingRequests: Number(remaining),
|
||||||
|
maxRequests: Number(max),
|
||||||
|
resetAtTimestamp: Number(resetAt),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (
|
||||||
|
isNaN(result.remainingRequests) ||
|
||||||
|
isNaN(result.maxRequests) ||
|
||||||
|
isNaN(result.resetAtTimestamp)
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} catch (e) {
|
||||||
|
if (throwOnFailedRateLimitParse) {
|
||||||
|
console.log(
|
||||||
|
new Date(),
|
||||||
|
'parseRateLimitHeaders()',
|
||||||
|
'Failed to parse rate limit headers',
|
||||||
|
{
|
||||||
|
headers,
|
||||||
|
exception: e,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { InverseFuturesClient } from '../../src/inverse-futures-client';
|
|||||||
import { getTestProxy } from '../proxy.util';
|
import { getTestProxy } from '../proxy.util';
|
||||||
import { successResponseList, successResponseObject } from '../response.util';
|
import { successResponseList, successResponseObject } from '../response.util';
|
||||||
|
|
||||||
describe('Private Inverse-Futures REST API GET Endpoints', () => {
|
describe.skip('Private Inverse-Futures REST API GET Endpoints', () => {
|
||||||
const API_KEY = process.env.API_KEY_COM;
|
const API_KEY = process.env.API_KEY_COM;
|
||||||
const API_SECRET = process.env.API_SECRET_COM;
|
const API_SECRET = process.env.API_SECRET_COM;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { API_ERROR_CODE, InverseFuturesClient } from '../../src';
|
|||||||
import { getTestProxy } from '../proxy.util';
|
import { getTestProxy } from '../proxy.util';
|
||||||
import { successResponseObject } from '../response.util';
|
import { successResponseObject } from '../response.util';
|
||||||
|
|
||||||
describe('Private Inverse-Futures REST API POST Endpoints', () => {
|
describe.skip('Private Inverse-Futures REST API POST Endpoints', () => {
|
||||||
const API_KEY = process.env.API_KEY_COM;
|
const API_KEY = process.env.API_KEY_COM;
|
||||||
const API_SECRET = process.env.API_SECRET_COM;
|
const API_SECRET = process.env.API_SECRET_COM;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
successResponseObject,
|
successResponseObject,
|
||||||
} from '../response.util';
|
} from '../response.util';
|
||||||
|
|
||||||
describe('Public Inverse-Futures REST API Endpoints', () => {
|
describe.skip('Public Inverse-Futures REST API Endpoints', () => {
|
||||||
const api = new InverseFuturesClient({}, getTestProxy());
|
const api = new InverseFuturesClient({}, getTestProxy());
|
||||||
|
|
||||||
const symbol = 'BTCUSD';
|
const symbol = 'BTCUSD';
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { InverseClient } from '../../src/';
|
|||||||
import { getTestProxy } from '../proxy.util';
|
import { getTestProxy } from '../proxy.util';
|
||||||
import { successResponseList, successResponseObject } from '../response.util';
|
import { successResponseList, successResponseObject } from '../response.util';
|
||||||
|
|
||||||
describe('Private Inverse REST API GET Endpoints', () => {
|
describe.skip('Private Inverse REST API GET Endpoints', () => {
|
||||||
const API_KEY = process.env.API_KEY_COM;
|
const API_KEY = process.env.API_KEY_COM;
|
||||||
const API_SECRET = process.env.API_SECRET_COM;
|
const API_SECRET = process.env.API_SECRET_COM;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { InverseClient } from '../../src/inverse-client';
|
|||||||
import { getTestProxy } from '../proxy.util';
|
import { getTestProxy } from '../proxy.util';
|
||||||
import { successResponseObject } from '../response.util';
|
import { successResponseObject } from '../response.util';
|
||||||
|
|
||||||
describe('Private Inverse REST API POST Endpoints', () => {
|
describe.skip('Private Inverse REST API POST Endpoints', () => {
|
||||||
const API_KEY = process.env.API_KEY_COM;
|
const API_KEY = process.env.API_KEY_COM;
|
||||||
const API_SECRET = process.env.API_SECRET_COM;
|
const API_SECRET = process.env.API_SECRET_COM;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
successResponseObject,
|
successResponseObject,
|
||||||
} from '../response.util';
|
} from '../response.util';
|
||||||
|
|
||||||
describe('Public Inverse REST API Endpoints', () => {
|
describe.skip('Public Inverse REST API Endpoints', () => {
|
||||||
const api = new InverseClient({}, getTestProxy());
|
const api = new InverseClient({}, getTestProxy());
|
||||||
|
|
||||||
const symbol = 'BTCUSD';
|
const symbol = 'BTCUSD';
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
waitForSocketEvent,
|
waitForSocketEvent,
|
||||||
} from '../ws.util';
|
} from '../ws.util';
|
||||||
|
|
||||||
describe('Private Inverse Perps Websocket Client', () => {
|
describe.skip('Private Inverse Perps Websocket Client', () => {
|
||||||
const API_KEY = process.env.API_KEY_COM;
|
const API_KEY = process.env.API_KEY_COM;
|
||||||
const API_SECRET = process.env.API_SECRET_COM;
|
const API_SECRET = process.env.API_SECRET_COM;
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ describe('Private Inverse Perps Websocket Client', () => {
|
|||||||
key: 'bad',
|
key: 'bad',
|
||||||
secret: 'bad',
|
secret: 'bad',
|
||||||
},
|
},
|
||||||
getSilentLogger('expect401')
|
getSilentLogger('expect401'),
|
||||||
);
|
);
|
||||||
|
|
||||||
const wsOpenPromise = waitForSocketEvent(badClient, 'open', 2500);
|
const wsOpenPromise = waitForSocketEvent(badClient, 'open', 2500);
|
||||||
@@ -55,7 +55,7 @@ describe('Private Inverse Perps Websocket Client', () => {
|
|||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
wsClient = new WebsocketClient(
|
wsClient = new WebsocketClient(
|
||||||
wsClientOptions,
|
wsClientOptions,
|
||||||
getSilentLogger('expectSuccess')
|
getSilentLogger('expectSuccess'),
|
||||||
);
|
);
|
||||||
wsClient.connectPrivate();
|
wsClient.connectPrivate();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
waitForSocketEvent,
|
waitForSocketEvent,
|
||||||
} from '../ws.util';
|
} from '../ws.util';
|
||||||
|
|
||||||
describe('Public Inverse Perps Websocket Client', () => {
|
describe.skip('Public Inverse Perps Websocket Client', () => {
|
||||||
let wsClient: WebsocketClient;
|
let wsClient: WebsocketClient;
|
||||||
|
|
||||||
const wsClientOptions: WSClientConfigurableOptions = {
|
const wsClientOptions: WSClientConfigurableOptions = {
|
||||||
@@ -66,7 +66,7 @@ describe('Public Inverse Perps Websocket Client', () => {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(
|
console.error(
|
||||||
`Wait for "${wsTopic}" subscription response exception: `,
|
`Wait for "${wsTopic}" subscription response exception: `,
|
||||||
e
|
e,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { LinearClient } from '../../src/linear-client';
|
|||||||
import { getTestProxy } from '../proxy.util';
|
import { getTestProxy } from '../proxy.util';
|
||||||
import { successResponseList, successResponseObject } from '../response.util';
|
import { successResponseList, successResponseObject } from '../response.util';
|
||||||
|
|
||||||
describe('Private Linear REST API GET Endpoints', () => {
|
describe.skip('Private Linear REST API GET Endpoints', () => {
|
||||||
const API_KEY = process.env.API_KEY_COM;
|
const API_KEY = process.env.API_KEY_COM;
|
||||||
const API_SECRET = process.env.API_SECRET_COM;
|
const API_SECRET = process.env.API_SECRET_COM;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { LinearClient } from '../../src';
|
|||||||
import { getTestProxy } from '../proxy.util';
|
import { getTestProxy } from '../proxy.util';
|
||||||
import { successResponseObject } from '../response.util';
|
import { successResponseObject } from '../response.util';
|
||||||
|
|
||||||
describe('Private Linear REST API POST Endpoints', () => {
|
describe.skip('Private Linear REST API POST Endpoints', () => {
|
||||||
const API_KEY = process.env.API_KEY_COM;
|
const API_KEY = process.env.API_KEY_COM;
|
||||||
const API_SECRET = process.env.API_SECRET_COM;
|
const API_SECRET = process.env.API_SECRET_COM;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
successResponseObject,
|
successResponseObject,
|
||||||
} from '../response.util';
|
} from '../response.util';
|
||||||
|
|
||||||
describe('Public Linear REST API Endpoints', () => {
|
describe.skip('Public Linear REST API Endpoints', () => {
|
||||||
const api = new LinearClient({}, getTestProxy());
|
const api = new LinearClient({}, getTestProxy());
|
||||||
|
|
||||||
const symbol = 'BTCUSDT';
|
const symbol = 'BTCUSDT';
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
waitForSocketEvent,
|
waitForSocketEvent,
|
||||||
} from '../ws.util';
|
} from '../ws.util';
|
||||||
|
|
||||||
describe('Private Linear Perps Websocket Client', () => {
|
describe.skip('Private Linear Perps Websocket Client', () => {
|
||||||
const API_KEY = process.env.API_KEY_COM;
|
const API_KEY = process.env.API_KEY_COM;
|
||||||
const API_SECRET = process.env.API_SECRET_COM;
|
const API_SECRET = process.env.API_SECRET_COM;
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ describe('Private Linear Perps Websocket Client', () => {
|
|||||||
key: 'bad',
|
key: 'bad',
|
||||||
secret: 'bad',
|
secret: 'bad',
|
||||||
},
|
},
|
||||||
getSilentLogger('expect401')
|
getSilentLogger('expect401'),
|
||||||
);
|
);
|
||||||
|
|
||||||
const wsOpenPromise = waitForSocketEvent(badClient, 'open', 2500);
|
const wsOpenPromise = waitForSocketEvent(badClient, 'open', 2500);
|
||||||
@@ -59,7 +59,7 @@ describe('Private Linear Perps Websocket Client', () => {
|
|||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
wsClient = new WebsocketClient(
|
wsClient = new WebsocketClient(
|
||||||
wsClientOptions,
|
wsClientOptions,
|
||||||
getSilentLogger('expectSuccess')
|
getSilentLogger('expectSuccess'),
|
||||||
);
|
);
|
||||||
wsClient.connectPrivate();
|
wsClient.connectPrivate();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
waitForSocketEvent,
|
waitForSocketEvent,
|
||||||
} from '../ws.util';
|
} from '../ws.util';
|
||||||
|
|
||||||
describe('Public Linear Perps Websocket Client', () => {
|
describe.skip('Public Linear Perps Websocket Client', () => {
|
||||||
let wsClient: WebsocketClient;
|
let wsClient: WebsocketClient;
|
||||||
|
|
||||||
const wsClientOptions: WSClientConfigurableOptions = {
|
const wsClientOptions: WSClientConfigurableOptions = {
|
||||||
|
|||||||
Reference in New Issue
Block a user