feat(): add deprecation warnings for v1/v2 REST clients

This commit is contained in:
tiagosiebler
2023-10-30 12:22:04 +00:00
parent 234e674a57
commit 7460cf4b5c
7 changed files with 208 additions and 181 deletions

View File

@@ -17,6 +17,10 @@ import BaseRestClient from './util/BaseRestClient';
/**
* 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 {
getClientType() {
@@ -35,29 +39,29 @@ export class AccountAssetClient extends BaseRestClient {
*/
createInternalTransfer(
params: InternalTransferRequest
params: InternalTransferRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('/asset/v1/private/transfer', params);
}
createSubAccountTransfer(
params: SubAccountTransferRequest
params: SubAccountTransferRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('/asset/v1/private/sub-member/transfer', params);
}
getInternalTransfers(
params?: TransferQueryRequest
params?: TransferQueryRequest,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('/asset/v1/private/transfer/list', params);
}
getSubAccountTransfers(
params?: TransferQueryRequest
params?: TransferQueryRequest,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate(
'/asset/v1/private/sub-member/transfer/list',
params
params,
);
}
@@ -66,19 +70,19 @@ export class AccountAssetClient extends BaseRestClient {
}
enableUniversalTransfer(
params?: EnableUniversalTransferRequest
params?: EnableUniversalTransferRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('/asset/v1/private/transferable-subs/save', params);
}
createUniversalTransfer(
params: UniversalTransferRequest
params: UniversalTransferRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('/asset/v1/private/universal/transfer', params);
}
getUniversalTransfers(
params?: TransferQueryRequest
params?: TransferQueryRequest,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('/asset/v1/private/universal/transfer/list', params);
}
@@ -90,19 +94,19 @@ export class AccountAssetClient extends BaseRestClient {
*/
getSupportedDepositList(
params?: SupportedDepositListRequest
params?: SupportedDepositListRequest,
): Promise<APIResponseWithTime<any>> {
return this.get('/asset/v1/public/deposit/allowed-deposit-list', params);
}
getDepositRecords(
params?: DepositRecordsRequest
params?: DepositRecordsRequest,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('/asset/v1/private/deposit/record/query', params);
}
getWithdrawRecords(
params?: WithdrawalRecordsRequest
params?: WithdrawalRecordsRequest,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('/asset/v1/private/withdraw/record/query', params);
}
@@ -112,13 +116,13 @@ export class AccountAssetClient extends BaseRestClient {
}
getAssetInformation(
params?: AccountAssetInformationRequest
params?: AccountAssetInformationRequest,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('/asset/v1/private/asset-info/query', params);
}
submitWithdrawal(
params: WithdrawalRequest
params: WithdrawalRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('/asset/v1/private/withdraw', params);
}

View File

@@ -32,6 +32,10 @@ import BaseRestClient from './util/BaseRestClient';
/**
* 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 {
getClientType() {
@@ -54,7 +58,7 @@ export class InverseClient extends BaseRestClient {
}
getKline(
params: SymbolIntervalFromLimitParam
params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/kline/list', params);
}
@@ -63,7 +67,7 @@ export class InverseClient extends BaseRestClient {
* Get latest information for symbol
*/
getTickers(
params?: Partial<SymbolParam>
params?: Partial<SymbolParam>,
): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/tickers', params);
}
@@ -77,19 +81,19 @@ export class InverseClient extends BaseRestClient {
}
getMarkPriceKline(
params: SymbolIntervalFromLimitParam
params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/mark-price-kline', params);
}
getIndexPriceKline(
params: SymbolIntervalFromLimitParam
params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/index-price-kline', params);
}
getPremiumIndexKline(
params: SymbolIntervalFromLimitParam
params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/premium-index-kline', params);
}
@@ -101,19 +105,19 @@ export class InverseClient extends BaseRestClient {
*/
getOpenInterest(
params: SymbolPeriodLimitParam
params: SymbolPeriodLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/open-interest', params);
}
getLatestBigDeal(
params: SymbolLimitParam
params: SymbolLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/big-deal', params);
}
getLongShortRatio(
params: SymbolPeriodLimitParam
params: SymbolPeriodLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/account-ratio', params);
}
@@ -135,25 +139,25 @@ export class InverseClient extends BaseRestClient {
*/
getWalletBalance(
params?: Partial<CoinParam>
params?: Partial<CoinParam>,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/wallet/balance', params);
}
getWalletFundRecords(
params?: WalletFundRecordsReq
params?: WalletFundRecordsReq,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/wallet/fund/records', params);
}
getWithdrawRecords(
params?: WithdrawRecordsReq
params?: WithdrawRecordsReq,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/wallet/withdraw/list', params);
}
getAssetExchangeRecords(
params?: AssetExchangeRecordsReq
params?: AssetExchangeRecordsReq,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/exchange-order/list', params);
}
@@ -183,37 +187,37 @@ export class InverseClient extends BaseRestClient {
*/
placeActiveOrder(
orderRequest: InverseOrderRequest
orderRequest: InverseOrderRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/order/create', orderRequest);
}
getActiveOrderList(
params: InverseActiveOrdersRequest
params: InverseActiveOrdersRequest,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/order/list', params);
}
cancelActiveOrder(
params: InverseCancelOrderRequest
params: InverseCancelOrderRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/order/cancel', params);
}
cancelAllActiveOrders(
params: SymbolParam
params: SymbolParam,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/order/cancelAll', params);
}
replaceActiveOrder(
params: InverseReplaceOrderRequest
params: InverseReplaceOrderRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/order/replace', params);
}
queryActiveOrder(
params: InverseGetOrderRequest
params: InverseGetOrderRequest,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/order', params);
}
@@ -223,38 +227,38 @@ export class InverseClient extends BaseRestClient {
*/
placeConditionalOrder(
params: InverseConditionalOrderRequest
params: InverseConditionalOrderRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/stop-order/create', params);
}
/** get conditional order list. This may see delays, use queryConditionalOrder() for real-time queries */
getConditionalOrder(
params: InverseActiveConditionalOrderRequest
params: InverseActiveConditionalOrderRequest,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/stop-order/list', params);
}
cancelConditionalOrder(
params: InverseCancelConditionalOrderRequest
params: InverseCancelConditionalOrderRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/stop-order/cancel', params);
}
cancelAllConditionalOrders(
params: SymbolParam
params: SymbolParam,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/stop-order/cancelAll', params);
}
replaceConditionalOrder(
params: InverseReplaceConditionalOrderRequest
params: InverseReplaceConditionalOrderRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/stop-order/replace', params);
}
queryConditionalOrder(
params: InverseGetOrderRequest
params: InverseGetOrderRequest,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/stop-order', params);
}
@@ -264,49 +268,49 @@ export class InverseClient extends BaseRestClient {
*/
getPosition(
params?: Partial<SymbolParam>
params?: Partial<SymbolParam>,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/position/list', params);
}
changePositionMargin(
params: InverseChangePositionMarginRequest
params: InverseChangePositionMarginRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('position/change-position-margin', params);
}
setTradingStop(
params: InverseSetTradingStopRequest
params: InverseSetTradingStopRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/position/trading-stop', params);
}
setUserLeverage(
params: InverseSetLeverageRequest
params: InverseSetLeverageRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/position/leverage/save', params);
}
getTradeRecords(
params: InverseGetTradeRecordsRequest
params: InverseGetTradeRecordsRequest,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/execution/list', params);
}
getClosedPnl(
params: InverseGetClosedPnlRequest
params: InverseGetClosedPnlRequest,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/trade/closed-pnl/list', params);
}
setSlTpPositionMode(
params: InverseSetSlTpPositionModeRequest
params: InverseSetSlTpPositionModeRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/tpsl/switch-mode', params);
}
setMarginType(
params: InverseSetMarginTypeRequest
params: InverseSetMarginTypeRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/position/switch-isolated', params);
}

View File

@@ -16,6 +16,10 @@ import BaseRestClient from './util/BaseRestClient';
/**
* 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 {
getClientType() {
@@ -38,7 +42,7 @@ export class InverseFuturesClient extends BaseRestClient {
}
getKline(
params: SymbolIntervalFromLimitParam
params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/kline/list', params);
}
@@ -47,7 +51,7 @@ export class InverseFuturesClient extends BaseRestClient {
* Get latest information for symbol
*/
getTickers(
params?: Partial<SymbolParam>
params?: Partial<SymbolParam>,
): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/tickers', params);
}
@@ -64,19 +68,19 @@ export class InverseFuturesClient extends BaseRestClient {
}
getMarkPriceKline(
params: SymbolIntervalFromLimitParam
params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/mark-price-kline', params);
}
getIndexPriceKline(
params: SymbolIntervalFromLimitParam
params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/index-price-kline', params);
}
getPremiumIndexKline(
params: SymbolIntervalFromLimitParam
params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/premium-index-kline', params);
}
@@ -88,19 +92,19 @@ export class InverseFuturesClient extends BaseRestClient {
*/
getOpenInterest(
params: SymbolPeriodLimitParam
params: SymbolPeriodLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/open-interest', params);
}
getLatestBigDeal(
params: SymbolLimitParam
params: SymbolLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/big-deal', params);
}
getLongShortRatio(
params: SymbolPeriodLimitParam
params: SymbolPeriodLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/account-ratio', params);
}
@@ -122,25 +126,25 @@ export class InverseFuturesClient extends BaseRestClient {
*/
getWalletBalance(
params?: Partial<CoinParam>
params?: Partial<CoinParam>,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/wallet/balance', params);
}
getWalletFundRecords(
params?: WalletFundRecordsReq
params?: WalletFundRecordsReq,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/wallet/fund/records', params);
}
getWithdrawRecords(
params?: WithdrawRecordsReq
params?: WithdrawRecordsReq,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/wallet/withdraw/list', params);
}
getAssetExchangeRecords(
params?: AssetExchangeRecordsReq
params?: AssetExchangeRecordsReq,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/exchange-order/list', params);
}
@@ -204,7 +208,7 @@ export class InverseFuturesClient extends BaseRestClient {
}
cancelAllActiveOrders(
params: SymbolParam
params: SymbolParam,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('futures/private/order/cancelAll', params);
}
@@ -266,7 +270,7 @@ export class InverseFuturesClient extends BaseRestClient {
}
cancelAllConditionalOrders(
params: SymbolParam
params: SymbolParam,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('futures/private/stop-order/cancelAll', params);
}
@@ -298,7 +302,7 @@ export class InverseFuturesClient extends BaseRestClient {
* Get position list
*/
getPosition(
params?: Partial<SymbolParam>
params?: Partial<SymbolParam>,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('futures/private/position/list', params);
}
@@ -309,7 +313,7 @@ export class InverseFuturesClient extends BaseRestClient {
}): Promise<APIResponseWithTime<any>> {
return this.postPrivate(
'futures/private/position/change-position-margin',
params
params,
);
}

View File

@@ -42,6 +42,10 @@ import BaseRestClient from './util/BaseRestClient';
/**
* 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 {
getClientType() {
@@ -64,7 +68,7 @@ export class LinearClient extends BaseRestClient {
}
getKline(
params: SymbolIntervalFromLimitParam
params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('public/linear/kline', params);
}
@@ -73,7 +77,7 @@ export class LinearClient extends BaseRestClient {
* Get latest information for symbol
*/
getTickers(
params?: Partial<SymbolParam>
params?: Partial<SymbolParam>,
): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/tickers', params);
}
@@ -91,19 +95,19 @@ export class LinearClient extends BaseRestClient {
}
getMarkPriceKline(
params: SymbolIntervalFromLimitParam
params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('public/linear/mark-price-kline', params);
}
getIndexPriceKline(
params: SymbolIntervalFromLimitParam
params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('public/linear/index-price-kline', params);
}
getPremiumIndexKline(
params: SymbolIntervalFromLimitParam
params: SymbolIntervalFromLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('public/linear/premium-index-kline', params);
}
@@ -115,19 +119,19 @@ export class LinearClient extends BaseRestClient {
*/
getOpenInterest(
params: SymbolPeriodLimitParam
params: SymbolPeriodLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/open-interest', params);
}
getLatestBigDeal(
params: SymbolLimitParam
params: SymbolLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/big-deal', params);
}
getLongShortRatio(
params: SymbolPeriodLimitParam
params: SymbolPeriodLimitParam,
): Promise<APIResponseWithTime<any[]>> {
return this.get('v2/public/account-ratio', params);
}
@@ -149,25 +153,25 @@ export class LinearClient extends BaseRestClient {
*/
getWalletBalance(
params?: Partial<CoinParam>
params?: Partial<CoinParam>,
): Promise<APIResponseWithTime<WalletBalances>> {
return this.getPrivate('v2/private/wallet/balance', params);
}
getWalletFundRecords(
params?: WalletFundRecordsReq
params?: WalletFundRecordsReq,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/wallet/fund/records', params);
}
getWithdrawRecords(
params?: WithdrawRecordsReq
params?: WithdrawRecordsReq,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/wallet/withdraw/list', params);
}
getAssetExchangeRecords(
params?: AssetExchangeRecordsReq
params?: AssetExchangeRecordsReq,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/exchange-order/list', params);
}
@@ -193,37 +197,37 @@ export class LinearClient extends BaseRestClient {
*/
placeActiveOrder(
params: NewLinearOrder
params: NewLinearOrder,
): Promise<APIResponseWithTime<LinearOrder | null>> {
return this.postPrivate('private/linear/order/create', params);
}
getActiveOrderList(
params: LinearGetOrdersRequest
params: LinearGetOrdersRequest,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('private/linear/order/list', params);
}
cancelActiveOrder(
params: LinearCancelOrderRequest
params: LinearCancelOrderRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/order/cancel', params);
}
cancelAllActiveOrders(
params: SymbolParam
params: SymbolParam,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/order/cancel-all', params);
}
replaceActiveOrder(
params: LinearReplaceOrderRequest
params: LinearReplaceOrderRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/order/replace', params);
}
queryActiveOrder(
params: LinearGetOrderRequest
params: LinearGetOrderRequest,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('private/linear/order/search', params);
}
@@ -233,37 +237,37 @@ export class LinearClient extends BaseRestClient {
*/
placeConditionalOrder(
params: LinearConditionalOrderRequest
params: LinearConditionalOrderRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/stop-order/create', params);
}
getConditionalOrder(
params: LinearGetConditionalOrderRequest
params: LinearGetConditionalOrderRequest,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('private/linear/stop-order/list', params);
}
cancelConditionalOrder(
params: LinearCancelConditionalOrderRequest
params: LinearCancelConditionalOrderRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/stop-order/cancel', params);
}
cancelAllConditionalOrders(
params: SymbolParam
params: SymbolParam,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/stop-order/cancel-all', params);
}
replaceConditionalOrder(
params: LinearReplaceConditionalOrderRequest
params: LinearReplaceConditionalOrderRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/stop-order/replace', params);
}
queryConditionalOrder(
params: LinearQueryConditionalOrderRequest
params: LinearQueryConditionalOrderRequest,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('private/linear/stop-order/search', params);
}
@@ -275,26 +279,26 @@ export class LinearClient extends BaseRestClient {
getPosition(): Promise<APIResponseWithTime<PerpPositionRoot[]>>;
getPosition(
params: Partial<SymbolParam>
params: Partial<SymbolParam>,
): Promise<APIResponseWithTime<PerpPosition[]>>;
getPosition(
params?: Partial<SymbolParam>
params?: Partial<SymbolParam>,
): Promise<APIResponseWithTime<PerpPosition[] | PerpPositionRoot[]>> {
return this.getPrivate('private/linear/position/list', params);
}
setAutoAddMargin(
params?: LinearSetAutoAddMarginRequest
params?: LinearSetAutoAddMarginRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate(
'private/linear/position/set-auto-add-margin',
params
params,
);
}
setMarginSwitch(
params?: LinearSetMarginSwitchRequest
params?: LinearSetMarginSwitchRequest,
): Promise<APIResponseWithTime<any>> {
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.
*/
setPositionMode(
params: LinearSetPositionModeRequest
params: LinearSetPositionModeRequest,
): Promise<APIResponseWithTime<any>> {
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.
*/
setPositionTpSlMode(
params: LinearSetPositionTpSlModeRequest
params: LinearSetPositionTpSlModeRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/tpsl/switch-mode', params);
}
setAddReduceMargin(
params?: LinearSetAddReduceMarginRequest
params?: LinearSetAddReduceMarginRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/position/add-margin', params);
}
setUserLeverage(
params: LinearSetUserLeverageRequest
params: LinearSetUserLeverageRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/position/set-leverage', params);
}
setTradingStop(
params: LinearSetTradingStopRequest
params: LinearSetTradingStopRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/position/trading-stop', params);
}
getTradeRecords(
params: LinearGetTradeRecordsRequest
params: LinearGetTradeRecordsRequest,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('private/linear/trade/execution/list', params);
}
getHistoryTradeRecords(
params: LinearGetHistoryTradeRecordsRequest
params: LinearGetHistoryTradeRecordsRequest,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate(
'/private/linear/trade/execution/history-list',
params
params,
);
}
getClosedPnl(
params: LinearGetClosedPnlRequest
params: LinearGetClosedPnlRequest,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('private/linear/trade/closed-pnl/list', params);
}
@@ -366,7 +370,7 @@ export class LinearClient extends BaseRestClient {
}
setRiskLimit(
params: LinearSetRiskLimitRequest
params: LinearSetRiskLimitRequest,
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('private/linear/position/set-risk', params);
}
@@ -376,7 +380,7 @@ export class LinearClient extends BaseRestClient {
*/
getPredictedFundingFee(
params: SymbolParam
params: SymbolParam,
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('private/linear/funding/predicted-funding', params);
}

View File

@@ -14,8 +14,11 @@ import BaseRestClient from './util/BaseRestClient';
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)
*
* @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 {
getClientType() {
@@ -51,7 +54,7 @@ export class SpotClient extends BaseRestClient {
getMergedOrderBook(
symbol: string,
scale?: number,
limit?: number
limit?: number,
): Promise<APIResponse<any>> {
return this.get('/spot/quote/v1/depth/merged', {
symbol,
@@ -72,7 +75,7 @@ export class SpotClient extends BaseRestClient {
interval: KlineInterval,
limit?: number,
startTime?: number,
endTime?: number
endTime?: number,
): Promise<APIResponse<any[]>> {
return this.get('/spot/quote/v1/kline', {
symbol,
@@ -92,7 +95,7 @@ export class SpotClient extends BaseRestClient {
getLastTradedPrice(symbol: string): Promise<APIResponse<SpotLastPrice>>;
getLastTradedPrice(
symbol?: string
symbol?: string,
): Promise<APIResponse<SpotLastPrice | SpotLastPrice[]>> {
return this.get('/spot/quote/v1/ticker/price', { symbol });
}
@@ -135,7 +138,7 @@ export class SpotClient extends BaseRestClient {
getOpenOrders(
symbol?: string,
orderId?: string,
limit?: number
limit?: number,
): Promise<APIResponse<any>> {
return this.getPrivate('/spot/v1/open-orders', {
symbol,
@@ -147,7 +150,7 @@ export class SpotClient extends BaseRestClient {
getPastOrders(
symbol?: string,
orderId?: string,
limit?: number
limit?: number,
): Promise<APIResponse<any>> {
return this.getPrivate('/spot/v1/history-orders', {
symbol,
@@ -160,7 +163,7 @@ export class SpotClient extends BaseRestClient {
symbol?: string,
limit?: number,
fromId?: number,
toId?: number
toId?: number,
): Promise<APIResponse<any>> {
return this.getPrivate('/spot/v1/myTrades', {
symbol,

View File

@@ -25,6 +25,10 @@ import BaseRestClient from './util/BaseRestClient';
/**
* 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 {
getClientType() {
@@ -49,7 +53,7 @@ export class USDCOptionClient extends BaseRestClient {
/** Fetch trading rules (such as min/max qty). Query for all if blank. */
getContractInfo(
params?: USDCOptionsContractInfoRequest
params?: USDCOptionsContractInfoRequest,
): Promise<APIResponseV3<any>> {
return this.get('/option/usdc/openapi/public/v1/symbols', params);
}
@@ -61,18 +65,18 @@ export class USDCOptionClient extends BaseRestClient {
/** Get delivery information */
getDeliveryPrice(
params?: USDCOptionsDeliveryPriceRequest
params?: USDCOptionsDeliveryPriceRequest,
): Promise<APIResponseV3<any>> {
return this.get('/option/usdc/openapi/public/v1/delivery-price', params);
}
/** Returned records are Taker Buy in default. */
getLast500Trades(
params: USDCOptionsRecentTradesRequest
params: USDCOptionsRecentTradesRequest,
): Promise<APIResponseV3<any>> {
return this.get(
'/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
*/
getHistoricalVolatility(
params?: USDCOptionsHistoricalVolatilityRequest
params?: USDCOptionsHistoricalVolatilityRequest,
): Promise<APIResponseV3<any>> {
return this.get(
'/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>> {
return this.postPrivate(
'/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.
*/
batchSubmitOrders(
orderRequest: USDCOptionsOrderRequest[]
orderRequest: USDCOptionsOrderRequest[],
): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/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. */
modifyOrder(
params: USDCOptionsModifyOrderRequest
params: USDCOptionsModifyOrderRequest,
): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/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. */
batchModifyOrders(
replaceOrderRequest: USDCOptionsModifyOrderRequest[]
replaceOrderRequest: USDCOptionsModifyOrderRequest[],
): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/option/usdc/openapi/private/v1/batch-replace-orders',
{ replaceOrderRequest }
{ replaceOrderRequest },
);
}
/** Cancel order */
cancelOrder(
params: USDCOptionsCancelOrderRequest
params: USDCOptionsCancelOrderRequest,
): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/option/usdc/openapi/private/v1/cancel-order',
params
params,
);
}
/** Batch cancel orders */
batchCancelOrders(
cancelRequest: USDCOptionsCancelOrderRequest[]
cancelRequest: USDCOptionsCancelOrderRequest[],
): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/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. */
cancelActiveOrders(
params?: USDCOptionsCancelAllOrdersRequest
params?: USDCOptionsCancelAllOrdersRequest,
): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/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 */
getActiveRealtimeOrders(
params?: USDCOptionsActiveOrdersRealtimeRequest
params?: USDCOptionsActiveOrdersRealtimeRequest,
): Promise<APIResponseV3<any>> {
return this.getPrivate(
'/option/usdc/openapi/private/v1/trade/query-active-orders',
params
params,
);
}
/** Query Unfilled/Partially Filled Orders */
getActiveOrders(
params: USDCOptionsActiveOrdersRequest
params: USDCOptionsActiveOrdersRequest,
): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/option/usdc/openapi/private/v1/query-active-orders',
params
params,
);
}
/** Query order history. The endpoint only supports up to 30 days of queried records */
getHistoricOrders(
params: USDCOptionsHistoricOrdersRequest
params: USDCOptionsHistoricOrdersRequest,
): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/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.
*/
getOrderExecutionHistory(
params: USDCOptionsOrderExecutionRequest
params: USDCOptionsOrderExecutionRequest,
): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/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. */
getTransactionLog(
params: USDCTransactionLogRequest
params: USDCTransactionLogRequest,
): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/option/usdc/openapi/private/v1/query-transaction-log',
params
params,
);
}
/** Wallet info for USDC account. */
getBalances(): Promise<APIResponseV3<any>> {
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>> {
return this.postPrivate(
'/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.
*/
setMarginMode(
newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN'
newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN',
): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/option/usdc/private/asset/account/setMarginMode',
{ setMarginMode: newMarginMode }
{ setMarginMode: newMarginMode },
);
}
/** Query margin mode for USDC account. */
getMarginMode(): Promise<APIResponseV3<any>> {
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>> {
return this.postPrivate(
'/option/usdc/openapi/private/v1/query-position',
params
params,
);
}
/** Query Delivery History */
getDeliveryHistory(
params: USDCOptionsDeliveryHistoryRequest
params: USDCOptionsDeliveryHistoryRequest,
): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/option/usdc/openapi/private/v1/query-delivery-list',
params
params,
);
}
/** Query Positions Info Upon Expiry */
getPositionsInfoUponExpiry(
params?: USDCOptionsPositionsInfoExpiryRequest
params?: USDCOptionsPositionsInfoExpiryRequest,
): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/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>> {
return this.postPrivate(
'/option/usdc/openapi/private/v1/mmp-modify',
params
params,
);
}

View File

@@ -23,6 +23,10 @@ import BaseRestClient from './util/BaseRestClient';
/**
* 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 {
getClientType() {
@@ -47,7 +51,7 @@ export class USDCPerpetualClient extends BaseRestClient {
/** Fetch trading rules (such as min/max qty). Query for all if blank. */
getContractInfo(
params?: USDCSymbolDirectionLimit
params?: USDCSymbolDirectionLimit,
): Promise<APIResponseV3<any>> {
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>> {
return this.get(
'/perpetual/usdc/openapi/public/v1/mark-price-kline',
params
params,
);
}
getIndexPrice(params: USDCKlineRequest): Promise<APIResponseV3<any>> {
return this.get(
'/perpetual/usdc/openapi/public/v1/index-price-kline',
params
params,
);
}
getIndexPremium(params: USDCKlineRequest): Promise<APIResponseV3<any>> {
return this.get(
'/perpetual/usdc/openapi/public/v1/premium-index-kline',
params
params,
);
}
getOpenInterest(
params: USDCOpenInterestRequest
params: USDCOpenInterestRequest,
): Promise<APIResponseV3<any>> {
return this.get('/perpetual/usdc/openapi/public/v1/open-interest', params);
}
getLargeOrders(
params: SymbolLimitParam<string>
params: SymbolLimitParam<string>,
): Promise<APIResponseV3<any>> {
return this.get('/perpetual/usdc/openapi/public/v1/big-deal', params);
}
getLongShortRatio(
params: SymbolPeriodLimitParam<string>
params: SymbolPeriodLimitParam<string>,
): Promise<APIResponseV3<any>> {
return this.get('/perpetual/usdc/openapi/public/v1/account-ratio', params);
}
getLast500Trades(
params: USDCLast500TradesRequest
params: USDCLast500TradesRequest,
): Promise<APIResponseV3<any>> {
return this.get(
'/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>> {
return this.postPrivate(
'/perpetual/usdc/openapi/private/v1/place-order',
params
params,
);
}
@@ -133,7 +137,7 @@ export class USDCPerpetualClient extends BaseRestClient {
modifyOrder(params: USDCPerpModifyOrderRequest): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/perpetual/usdc/openapi/private/v1/replace-order',
params
params,
);
}
@@ -141,14 +145,14 @@ export class USDCPerpetualClient extends BaseRestClient {
cancelOrder(params: USDCPerpCancelOrderRequest): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/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. */
cancelActiveOrders(
symbol: string,
orderFilter: USDCOrderFilter
orderFilter: USDCOrderFilter,
): Promise<APIResponseV3<any>> {
return this.postPrivate('/perpetual/usdc/openapi/private/v1/cancel-all', {
symbol,
@@ -158,31 +162,31 @@ export class USDCPerpetualClient extends BaseRestClient {
/** Query Unfilled/Partially Filled Orders */
getActiveOrders(
params: USDCPerpActiveOrdersRequest
params: USDCPerpActiveOrdersRequest,
): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/option/usdc/openapi/private/v1/query-active-orders',
params
params,
);
}
/** Query order history. The endpoint only supports up to 30 days of queried records */
getHistoricOrders(
params: USDCPerpHistoricOrdersRequest
params: USDCPerpHistoricOrdersRequest,
): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/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. */
getOrderExecutionHistory(
params: USDCPerpActiveOrdersRequest
params: USDCPerpActiveOrdersRequest,
): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/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. */
getTransactionLog(
params: USDCTransactionLogRequest
params: USDCTransactionLogRequest,
): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/option/usdc/openapi/private/v1/query-transaction-log',
params
params,
);
}
/** Wallet info for USDC account. */
getBalances(): Promise<APIResponseV3<any>> {
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>> {
return this.postPrivate(
'/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.
*/
setMarginMode(
newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN'
newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN',
): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/option/usdc/private/asset/account/setMarginMode',
{ setMarginMode: newMarginMode }
{ setMarginMode: newMarginMode },
);
}
/** Query margin mode for USDC account. */
getMarginMode(): Promise<APIResponseV3<any>> {
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>> {
return this.postPrivate(
'/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>> {
return this.postPrivate(
'/perpetual/usdc/openapi/private/v1/position/leverage/save',
{ symbol, leverage }
{ symbol, leverage },
);
}
/** Query Settlement History */
getSettlementHistory(
params?: USDCSymbolDirectionLimitCursor
params?: USDCSymbolDirectionLimitCursor,
): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/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',
{
symbol,
}
},
);
}
@@ -279,7 +283,7 @@ export class USDCPerpetualClient extends BaseRestClient {
setRiskLimit(symbol: string, riskId: number): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/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>> {
return this.postPrivate(
'/perpetual/usdc/openapi/private/v1/predicted-funding',
{ symbol }
{ symbol },
);
}