cleaning around api response types
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import { AxiosRequestConfig } from 'axios';
|
import { AxiosRequestConfig } from 'axios';
|
||||||
import {
|
import {
|
||||||
GenericAPIResponse,
|
|
||||||
getRestBaseUrl,
|
getRestBaseUrl,
|
||||||
RestClientOptions,
|
RestClientOptions,
|
||||||
REST_CLIENT_TYPE_ENUM,
|
REST_CLIENT_TYPE_ENUM,
|
||||||
@@ -133,7 +132,7 @@ export class InverseClient extends BaseRestClient {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getApiKeyInfo(): GenericAPIResponse {
|
getApiKeyInfo(): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/account/api-key');
|
return this.getPrivate('v2/private/account/api-key');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,21 +142,27 @@ export class InverseClient extends BaseRestClient {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getWalletBalance(params?: Partial<CoinParam>): GenericAPIResponse {
|
getWalletBalance(
|
||||||
|
params?: Partial<CoinParam>
|
||||||
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/wallet/balance', params);
|
return this.getPrivate('v2/private/wallet/balance', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWalletFundRecords(params?: WalletFundRecordsReq): GenericAPIResponse {
|
getWalletFundRecords(
|
||||||
|
params?: WalletFundRecordsReq
|
||||||
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/wallet/fund/records', params);
|
return this.getPrivate('v2/private/wallet/fund/records', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWithdrawRecords(params?: WithdrawRecordsReq): GenericAPIResponse {
|
getWithdrawRecords(
|
||||||
|
params?: WithdrawRecordsReq
|
||||||
|
): 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
|
||||||
): GenericAPIResponse {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/exchange-order/list', params);
|
return this.getPrivate('v2/private/exchange-order/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +204,7 @@ export class InverseClient extends BaseRestClient {
|
|||||||
sl_trigger_by?: 'LastPrice' | 'MarkPrice' | 'IndexPrice';
|
sl_trigger_by?: 'LastPrice' | 'MarkPrice' | 'IndexPrice';
|
||||||
close_on_trigger?: boolean;
|
close_on_trigger?: boolean;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/order/create', orderRequest);
|
return this.postPrivate('v2/private/order/create', orderRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +214,7 @@ export class InverseClient extends BaseRestClient {
|
|||||||
direction?: string;
|
direction?: string;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
cursor?: string;
|
cursor?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/order/list', params);
|
return this.getPrivate('v2/private/order/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,11 +222,13 @@ export class InverseClient extends BaseRestClient {
|
|||||||
symbol: string;
|
symbol: string;
|
||||||
order_id?: string;
|
order_id?: string;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/order/cancel', params);
|
return this.postPrivate('v2/private/order/cancel', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelAllActiveOrders(params: SymbolParam): GenericAPIResponse {
|
cancelAllActiveOrders(
|
||||||
|
params: SymbolParam
|
||||||
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/order/cancelAll', params);
|
return this.postPrivate('v2/private/order/cancelAll', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,7 +242,7 @@ export class InverseClient extends BaseRestClient {
|
|||||||
stop_loss?: number;
|
stop_loss?: number;
|
||||||
tp_trigger_by?: string;
|
tp_trigger_by?: string;
|
||||||
sl_trigger_by?: string;
|
sl_trigger_by?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/order/replace', params);
|
return this.postPrivate('v2/private/order/replace', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,7 +250,7 @@ export class InverseClient extends BaseRestClient {
|
|||||||
order_id?: string;
|
order_id?: string;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
symbol: string;
|
symbol: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/order', params);
|
return this.getPrivate('v2/private/order', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,7 +270,7 @@ export class InverseClient extends BaseRestClient {
|
|||||||
trigger_by?: string;
|
trigger_by?: string;
|
||||||
close_on_trigger?: boolean;
|
close_on_trigger?: boolean;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/stop-order/create', params);
|
return this.postPrivate('v2/private/stop-order/create', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,7 +281,7 @@ export class InverseClient extends BaseRestClient {
|
|||||||
direction?: string;
|
direction?: string;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
cursor?: string;
|
cursor?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/stop-order/list', params);
|
return this.getPrivate('v2/private/stop-order/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,11 +289,13 @@ export class InverseClient extends BaseRestClient {
|
|||||||
symbol: string;
|
symbol: string;
|
||||||
stop_order_id?: string;
|
stop_order_id?: string;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/stop-order/cancel', params);
|
return this.postPrivate('v2/private/stop-order/cancel', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelAllConditionalOrders(params: SymbolParam): GenericAPIResponse {
|
cancelAllConditionalOrders(
|
||||||
|
params: SymbolParam
|
||||||
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/stop-order/cancelAll', params);
|
return this.postPrivate('v2/private/stop-order/cancelAll', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,7 +306,7 @@ export class InverseClient extends BaseRestClient {
|
|||||||
p_r_qty?: number;
|
p_r_qty?: number;
|
||||||
p_r_price?: string;
|
p_r_price?: string;
|
||||||
p_r_trigger_price?: string;
|
p_r_trigger_price?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/stop-order/replace', params);
|
return this.postPrivate('v2/private/stop-order/replace', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,7 +314,7 @@ export class InverseClient extends BaseRestClient {
|
|||||||
symbol: string;
|
symbol: string;
|
||||||
stop_order_id?: string;
|
stop_order_id?: string;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/stop-order', params);
|
return this.getPrivate('v2/private/stop-order', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,14 +322,16 @@ export class InverseClient extends BaseRestClient {
|
|||||||
* Position
|
* Position
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getPosition(params?: Partial<SymbolParam>): GenericAPIResponse {
|
getPosition(
|
||||||
|
params?: Partial<SymbolParam>
|
||||||
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/position/list', params);
|
return this.getPrivate('v2/private/position/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
changePositionMargin(params: {
|
changePositionMargin(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
margin: string;
|
margin: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('position/change-position-margin', params);
|
return this.postPrivate('position/change-position-margin', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,7 +343,7 @@ export class InverseClient extends BaseRestClient {
|
|||||||
tp_trigger_by?: string;
|
tp_trigger_by?: string;
|
||||||
sl_trigger_by?: string;
|
sl_trigger_by?: string;
|
||||||
new_trailing_active?: number;
|
new_trailing_active?: number;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/position/trading-stop', params);
|
return this.postPrivate('v2/private/position/trading-stop', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,7 +351,7 @@ export class InverseClient extends BaseRestClient {
|
|||||||
symbol: string;
|
symbol: string;
|
||||||
leverage: number;
|
leverage: number;
|
||||||
leverage_only?: boolean;
|
leverage_only?: boolean;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/position/leverage/save', params);
|
return this.postPrivate('v2/private/position/leverage/save', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,7 +362,7 @@ export class InverseClient extends BaseRestClient {
|
|||||||
page?: number;
|
page?: number;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
order?: string;
|
order?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/execution/list', params);
|
return this.getPrivate('v2/private/execution/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,14 +373,14 @@ export class InverseClient extends BaseRestClient {
|
|||||||
exec_type?: string;
|
exec_type?: string;
|
||||||
page?: number;
|
page?: number;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/trade/closed-pnl/list', params);
|
return this.getPrivate('v2/private/trade/closed-pnl/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
setSlTpPositionMode(params: {
|
setSlTpPositionMode(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
tp_sl_mode: 'Full' | 'Partial';
|
tp_sl_mode: 'Full' | 'Partial';
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/tpsl/switch-mode', params);
|
return this.postPrivate('v2/private/tpsl/switch-mode', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,7 +389,7 @@ export class InverseClient extends BaseRestClient {
|
|||||||
is_isolated: boolean;
|
is_isolated: boolean;
|
||||||
buy_leverage: number;
|
buy_leverage: number;
|
||||||
sell_leverage: number;
|
sell_leverage: number;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('v2/private/position/switch-isolated', params);
|
return this.postPrivate('v2/private/position/switch-isolated', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,14 +397,14 @@ export class InverseClient extends BaseRestClient {
|
|||||||
* Risk Limit
|
* Risk Limit
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getRiskLimitList(): GenericAPIResponse {
|
getRiskLimitList(): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('open-api/wallet/risk-limit/list');
|
return this.getPrivate('open-api/wallet/risk-limit/list');
|
||||||
}
|
}
|
||||||
|
|
||||||
setRiskLimit(params: {
|
setRiskLimit(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
risk_id: string;
|
risk_id: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('open-api/wallet/risk-limit', params);
|
return this.postPrivate('open-api/wallet/risk-limit', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,15 +412,15 @@ export class InverseClient extends BaseRestClient {
|
|||||||
* Funding
|
* Funding
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getLastFundingRate(params: SymbolParam): GenericAPIResponse {
|
getLastFundingRate(params: SymbolParam): Promise<APIResponseWithTime<any>> {
|
||||||
return this.get('v2/public/funding/prev-funding-rate', params);
|
return this.get('v2/public/funding/prev-funding-rate', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getMyLastFundingFee(params: SymbolParam): GenericAPIResponse {
|
getMyLastFundingFee(params: SymbolParam): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/funding/prev-funding', params);
|
return this.getPrivate('v2/private/funding/prev-funding', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPredictedFunding(params: SymbolParam): GenericAPIResponse {
|
getPredictedFunding(params: SymbolParam): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/funding/predicted-funding', params);
|
return this.getPrivate('v2/private/funding/predicted-funding', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,7 +428,7 @@ export class InverseClient extends BaseRestClient {
|
|||||||
* LCP Info
|
* LCP Info
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getLcpInfo(params: SymbolParam): GenericAPIResponse {
|
getLcpInfo(params: SymbolParam): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/account/lcp', params);
|
return this.getPrivate('v2/private/account/lcp', params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { AxiosRequestConfig } from 'axios';
|
import { AxiosRequestConfig } from 'axios';
|
||||||
import {
|
import {
|
||||||
GenericAPIResponse,
|
|
||||||
getRestBaseUrl,
|
getRestBaseUrl,
|
||||||
RestClientOptions,
|
RestClientOptions,
|
||||||
REST_CLIENT_TYPE_ENUM,
|
REST_CLIENT_TYPE_ENUM,
|
||||||
@@ -136,7 +135,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getApiKeyInfo(): GenericAPIResponse {
|
getApiKeyInfo(): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/account/api-key');
|
return this.getPrivate('v2/private/account/api-key');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,21 +145,27 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getWalletBalance(params?: Partial<CoinParam>): GenericAPIResponse {
|
getWalletBalance(
|
||||||
|
params?: Partial<CoinParam>
|
||||||
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/wallet/balance', params);
|
return this.getPrivate('v2/private/wallet/balance', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWalletFundRecords(params?: WalletFundRecordsReq): GenericAPIResponse {
|
getWalletFundRecords(
|
||||||
|
params?: WalletFundRecordsReq
|
||||||
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/wallet/fund/records', params);
|
return this.getPrivate('v2/private/wallet/fund/records', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWithdrawRecords(params?: WithdrawRecordsReq): GenericAPIResponse {
|
getWithdrawRecords(
|
||||||
|
params?: WithdrawRecordsReq
|
||||||
|
): 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
|
||||||
): GenericAPIResponse {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/exchange-order/list', params);
|
return this.getPrivate('v2/private/exchange-order/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +179,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
return this.get('v2/public/time');
|
return this.get('v2/public/time');
|
||||||
}
|
}
|
||||||
|
|
||||||
getApiAnnouncements(): GenericAPIResponse {
|
getApiAnnouncements(): Promise<APIResponseWithTime<any>> {
|
||||||
return this.get('v2/public/announcement');
|
return this.get('v2/public/announcement');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +205,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
reduce_only?: boolean;
|
reduce_only?: boolean;
|
||||||
close_on_trigger?: boolean;
|
close_on_trigger?: boolean;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('futures/private/order/create', orderRequest);
|
return this.postPrivate('futures/private/order/create', orderRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,7 +215,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
direction?: string;
|
direction?: string;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
cursor?: string;
|
cursor?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('futures/private/order/list', params);
|
return this.getPrivate('futures/private/order/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,11 +223,13 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
symbol: string;
|
symbol: string;
|
||||||
order_id?: string;
|
order_id?: string;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('futures/private/order/cancel', params);
|
return this.postPrivate('futures/private/order/cancel', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelAllActiveOrders(params: SymbolParam): GenericAPIResponse {
|
cancelAllActiveOrders(
|
||||||
|
params: SymbolParam
|
||||||
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('futures/private/order/cancelAll', params);
|
return this.postPrivate('futures/private/order/cancelAll', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +239,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
symbol: string;
|
symbol: string;
|
||||||
p_r_qty?: string;
|
p_r_qty?: string;
|
||||||
p_r_price?: string;
|
p_r_price?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('futures/private/order/replace', params);
|
return this.postPrivate('futures/private/order/replace', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +247,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
order_id?: string;
|
order_id?: string;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
symbol: string;
|
symbol: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('futures/private/order', params);
|
return this.getPrivate('futures/private/order', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +267,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
trigger_by?: string;
|
trigger_by?: string;
|
||||||
close_on_trigger?: boolean;
|
close_on_trigger?: boolean;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('futures/private/stop-order/create', params);
|
return this.postPrivate('futures/private/stop-order/create', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,7 +277,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
direction?: string;
|
direction?: string;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
cursor?: string;
|
cursor?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('futures/private/stop-order/list', params);
|
return this.getPrivate('futures/private/stop-order/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,11 +285,13 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
symbol: string;
|
symbol: string;
|
||||||
stop_order_id?: string;
|
stop_order_id?: string;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('futures/private/stop-order/cancel', params);
|
return this.postPrivate('futures/private/stop-order/cancel', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelAllConditionalOrders(params: SymbolParam): GenericAPIResponse {
|
cancelAllConditionalOrders(
|
||||||
|
params: SymbolParam
|
||||||
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('futures/private/stop-order/cancelAll', params);
|
return this.postPrivate('futures/private/stop-order/cancelAll', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,7 +302,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
p_r_qty?: number;
|
p_r_qty?: number;
|
||||||
p_r_price?: string;
|
p_r_price?: string;
|
||||||
p_r_trigger_price?: string;
|
p_r_trigger_price?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('futures/private/stop-order/replace', params);
|
return this.postPrivate('futures/private/stop-order/replace', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,7 +310,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
symbol: string;
|
symbol: string;
|
||||||
stop_order_id?: string;
|
stop_order_id?: string;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('futures/private/stop-order', params);
|
return this.getPrivate('futures/private/stop-order', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,14 +321,16 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
/**
|
/**
|
||||||
* Get position list
|
* Get position list
|
||||||
*/
|
*/
|
||||||
getPosition(params?: Partial<SymbolParam>): GenericAPIResponse {
|
getPosition(
|
||||||
|
params?: Partial<SymbolParam>
|
||||||
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('futures/private/position/list', params);
|
return this.getPrivate('futures/private/position/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
changePositionMargin(params: {
|
changePositionMargin(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
margin: string;
|
margin: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'futures/private/position/change-position-margin',
|
'futures/private/position/change-position-margin',
|
||||||
params
|
params
|
||||||
@@ -334,7 +345,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
tp_trigger_by?: string;
|
tp_trigger_by?: string;
|
||||||
sl_trigger_by?: string;
|
sl_trigger_by?: string;
|
||||||
new_trailing_active?: number;
|
new_trailing_active?: number;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('futures/private/position/trading-stop', params);
|
return this.postPrivate('futures/private/position/trading-stop', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,7 +353,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
symbol: string;
|
symbol: string;
|
||||||
buy_leverage: number;
|
buy_leverage: number;
|
||||||
sell_leverage: number;
|
sell_leverage: number;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('futures/private/position/leverage/save', params);
|
return this.postPrivate('futures/private/position/leverage/save', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,7 +363,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
setPositionMode(params: {
|
setPositionMode(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
mode: number;
|
mode: number;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('futures/private/position/switch-mode', params);
|
return this.postPrivate('futures/private/position/switch-mode', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,7 +375,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
is_isolated: boolean;
|
is_isolated: boolean;
|
||||||
buy_leverage: number;
|
buy_leverage: number;
|
||||||
sell_leverage: number;
|
sell_leverage: number;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('futures/private/position/switch-isolated', params);
|
return this.postPrivate('futures/private/position/switch-isolated', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,7 +386,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
page?: number;
|
page?: number;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
order?: string;
|
order?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('futures/private/execution/list', params);
|
return this.getPrivate('futures/private/execution/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,7 +397,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
exec_type?: string;
|
exec_type?: string;
|
||||||
page?: number;
|
page?: number;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('futures/private/trade/closed-pnl/list', params);
|
return this.getPrivate('futures/private/trade/closed-pnl/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,14 +408,14 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
/**
|
/**
|
||||||
* Risk Limit
|
* Risk Limit
|
||||||
*/
|
*/
|
||||||
getRiskLimitList(): GenericAPIResponse {
|
getRiskLimitList(): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('open-api/wallet/risk-limit/list');
|
return this.getPrivate('open-api/wallet/risk-limit/list');
|
||||||
}
|
}
|
||||||
|
|
||||||
setRiskLimit(params: {
|
setRiskLimit(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
risk_id: string;
|
risk_id: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('open-api/wallet/risk-limit', params);
|
return this.postPrivate('open-api/wallet/risk-limit', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,15 +423,15 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
* Funding
|
* Funding
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getLastFundingRate(params: SymbolParam): GenericAPIResponse {
|
getLastFundingRate(params: SymbolParam): Promise<APIResponseWithTime<any>> {
|
||||||
return this.get('v2/public/funding/prev-funding-rate', params);
|
return this.get('v2/public/funding/prev-funding-rate', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getMyLastFundingFee(params: SymbolParam): GenericAPIResponse {
|
getMyLastFundingFee(params: SymbolParam): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/funding/prev-funding', params);
|
return this.getPrivate('v2/private/funding/prev-funding', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPredictedFunding(params: SymbolParam): GenericAPIResponse {
|
getPredictedFunding(params: SymbolParam): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/funding/predicted-funding', params);
|
return this.getPrivate('v2/private/funding/predicted-funding', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,7 +439,7 @@ export class InverseFuturesClient extends BaseRestClient {
|
|||||||
* LCP Info
|
* LCP Info
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getLcpInfo(params: SymbolParam): GenericAPIResponse {
|
getLcpInfo(params: SymbolParam): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/account/lcp', params);
|
return this.getPrivate('v2/private/account/lcp', params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { AxiosRequestConfig } from 'axios';
|
import { AxiosRequestConfig } from 'axios';
|
||||||
import {
|
import {
|
||||||
GenericAPIResponse,
|
|
||||||
getRestBaseUrl,
|
getRestBaseUrl,
|
||||||
RestClientOptions,
|
RestClientOptions,
|
||||||
REST_CLIENT_TYPE_ENUM,
|
REST_CLIENT_TYPE_ENUM,
|
||||||
@@ -139,7 +138,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getApiKeyInfo(): GenericAPIResponse {
|
getApiKeyInfo(): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/account/api-key');
|
return this.getPrivate('v2/private/account/api-key');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,21 +148,27 @@ export class LinearClient extends BaseRestClient {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getWalletBalance(params?: Partial<CoinParam>): GenericAPIResponse {
|
getWalletBalance(
|
||||||
|
params?: Partial<CoinParam>
|
||||||
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/wallet/balance', params);
|
return this.getPrivate('v2/private/wallet/balance', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWalletFundRecords(params?: WalletFundRecordsReq): GenericAPIResponse {
|
getWalletFundRecords(
|
||||||
|
params?: WalletFundRecordsReq
|
||||||
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/wallet/fund/records', params);
|
return this.getPrivate('v2/private/wallet/fund/records', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWithdrawRecords(params?: WithdrawRecordsReq): GenericAPIResponse {
|
getWithdrawRecords(
|
||||||
|
params?: WithdrawRecordsReq
|
||||||
|
): 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
|
||||||
): GenericAPIResponse {
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('v2/private/exchange-order/list', params);
|
return this.getPrivate('v2/private/exchange-order/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +182,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
return this.get('v2/public/time');
|
return this.get('v2/public/time');
|
||||||
}
|
}
|
||||||
|
|
||||||
getApiAnnouncements(): GenericAPIResponse {
|
getApiAnnouncements(): Promise<APIResponseWithTime<any>> {
|
||||||
return this.get('v2/public/announcement');
|
return this.get('v2/public/announcement');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +207,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
close_on_trigger: boolean;
|
close_on_trigger: boolean;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
position_idx?: number;
|
position_idx?: number;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/order/create', params);
|
return this.postPrivate('private/linear/order/create', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +219,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
page?: number;
|
page?: number;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
order_status?: string;
|
order_status?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('private/linear/order/list', params);
|
return this.getPrivate('private/linear/order/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,11 +227,13 @@ export class LinearClient extends BaseRestClient {
|
|||||||
symbol: string;
|
symbol: string;
|
||||||
order_id?: string;
|
order_id?: string;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/order/cancel', params);
|
return this.postPrivate('private/linear/order/cancel', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelAllActiveOrders(params: SymbolParam): GenericAPIResponse {
|
cancelAllActiveOrders(
|
||||||
|
params: SymbolParam
|
||||||
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/order/cancel-all', params);
|
return this.postPrivate('private/linear/order/cancel-all', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +247,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
stop_loss?: number;
|
stop_loss?: number;
|
||||||
tp_trigger_by?: string;
|
tp_trigger_by?: string;
|
||||||
sl_trigger_by?: string;
|
sl_trigger_by?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/order/replace', params);
|
return this.postPrivate('private/linear/order/replace', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,7 +255,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
order_id?: string;
|
order_id?: string;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
symbol: string;
|
symbol: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('private/linear/order/search', params);
|
return this.getPrivate('private/linear/order/search', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,7 +280,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
stop_loss?: number;
|
stop_loss?: number;
|
||||||
tp_trigger_by?: string;
|
tp_trigger_by?: string;
|
||||||
sl_trigger_by?: string;
|
sl_trigger_by?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/stop-order/create', params);
|
return this.postPrivate('private/linear/stop-order/create', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,7 +292,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
order?: string;
|
order?: string;
|
||||||
page?: number;
|
page?: number;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('private/linear/stop-order/list', params);
|
return this.getPrivate('private/linear/stop-order/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,11 +300,13 @@ export class LinearClient extends BaseRestClient {
|
|||||||
symbol: string;
|
symbol: string;
|
||||||
stop_order_id?: string;
|
stop_order_id?: string;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/stop-order/cancel', params);
|
return this.postPrivate('private/linear/stop-order/cancel', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelAllConditionalOrders(params: SymbolParam): GenericAPIResponse {
|
cancelAllConditionalOrders(
|
||||||
|
params: SymbolParam
|
||||||
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/stop-order/cancel-all', params);
|
return this.postPrivate('private/linear/stop-order/cancel-all', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +321,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
stop_loss?: number;
|
stop_loss?: number;
|
||||||
tp_trigger_by?: string;
|
tp_trigger_by?: string;
|
||||||
sl_trigger_by?: string;
|
sl_trigger_by?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/stop-order/replace', params);
|
return this.postPrivate('private/linear/stop-order/replace', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,7 +329,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
symbol: string;
|
symbol: string;
|
||||||
stop_order_id?: string;
|
stop_order_id?: string;
|
||||||
order_link_id?: string;
|
order_link_id?: string;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('private/linear/stop-order/search', params);
|
return this.getPrivate('private/linear/stop-order/search', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,7 +337,9 @@ export class LinearClient extends BaseRestClient {
|
|||||||
* Position
|
* Position
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getPosition(params?: Partial<SymbolParam>): GenericAPIResponse {
|
getPosition(
|
||||||
|
params?: Partial<SymbolParam>
|
||||||
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('private/linear/position/list', params);
|
return this.getPrivate('private/linear/position/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,7 +347,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
symbol: string;
|
symbol: string;
|
||||||
side: string;
|
side: string;
|
||||||
auto_add_margin: boolean;
|
auto_add_margin: boolean;
|
||||||
}): GenericAPIResponse {
|
}): 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
|
||||||
@@ -348,7 +359,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
is_isolated: boolean;
|
is_isolated: boolean;
|
||||||
buy_leverage: number;
|
buy_leverage: number;
|
||||||
sell_leverage: number;
|
sell_leverage: number;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/position/switch-isolated', params);
|
return this.postPrivate('private/linear/position/switch-isolated', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,7 +369,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
setPositionMode(params: {
|
setPositionMode(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
mode: typeof linearPositionModeEnum[keyof typeof linearPositionModeEnum];
|
mode: typeof linearPositionModeEnum[keyof typeof linearPositionModeEnum];
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/position/switch-mode', params);
|
return this.postPrivate('private/linear/position/switch-mode', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,7 +380,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
setPositionTpSlMode(params: {
|
setPositionTpSlMode(params: {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
tp_sl_mode: typeof positionTpSlModeEnum[keyof typeof positionTpSlModeEnum];
|
tp_sl_mode: typeof positionTpSlModeEnum[keyof typeof positionTpSlModeEnum];
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/tpsl/switch-mode', params);
|
return this.postPrivate('private/linear/tpsl/switch-mode', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,7 +388,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
symbol: string;
|
symbol: string;
|
||||||
side: string;
|
side: string;
|
||||||
margin: number;
|
margin: number;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/position/add-margin', params);
|
return this.postPrivate('private/linear/position/add-margin', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,7 +396,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
symbol: string;
|
symbol: string;
|
||||||
buy_leverage: number;
|
buy_leverage: number;
|
||||||
sell_leverage: number;
|
sell_leverage: number;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/position/set-leverage', params);
|
return this.postPrivate('private/linear/position/set-leverage', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,7 +410,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
sl_trigger_by?: string;
|
sl_trigger_by?: string;
|
||||||
sl_size?: number;
|
sl_size?: number;
|
||||||
tp_size?: number;
|
tp_size?: number;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/position/trading-stop', params);
|
return this.postPrivate('private/linear/position/trading-stop', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,7 +421,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
exec_type?: string;
|
exec_type?: string;
|
||||||
page?: number;
|
page?: number;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('private/linear/trade/execution/list', params);
|
return this.getPrivate('private/linear/trade/execution/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,7 +432,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
exec_type?: string;
|
exec_type?: string;
|
||||||
page?: number;
|
page?: number;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('private/linear/trade/closed-pnl/list', params);
|
return this.getPrivate('private/linear/trade/closed-pnl/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,7 +440,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
* Risk Limit
|
* Risk Limit
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getRiskLimitList(params: SymbolParam): GenericAPIResponse {
|
getRiskLimitList(params: SymbolParam): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('public/linear/risk-limit', params);
|
return this.getPrivate('public/linear/risk-limit', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,7 +448,7 @@ export class LinearClient extends BaseRestClient {
|
|||||||
symbol: string;
|
symbol: string;
|
||||||
side: string;
|
side: string;
|
||||||
risk_id: number;
|
risk_id: number;
|
||||||
}): GenericAPIResponse {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate('private/linear/position/set-risk', params);
|
return this.postPrivate('private/linear/position/set-risk', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,11 +456,13 @@ export class LinearClient extends BaseRestClient {
|
|||||||
* Funding
|
* Funding
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getPredictedFundingFee(params: SymbolParam): GenericAPIResponse {
|
getPredictedFundingFee(
|
||||||
|
params: SymbolParam
|
||||||
|
): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('private/linear/funding/predicted-funding', params);
|
return this.getPrivate('private/linear/funding/predicted-funding', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLastFundingFee(params: SymbolParam): GenericAPIResponse {
|
getLastFundingFee(params: SymbolParam): Promise<APIResponseWithTime<any>> {
|
||||||
return this.getPrivate('private/linear/funding/prev-funding', params);
|
return this.getPrivate('private/linear/funding/prev-funding', params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,15 +120,15 @@ export class SpotClient extends BaseRestClient {
|
|||||||
* Account Data Endpoints
|
* Account Data Endpoints
|
||||||
*/
|
*/
|
||||||
|
|
||||||
submitOrder(params: NewSpotOrder) {
|
submitOrder(params: NewSpotOrder): Promise<APIResponse<any>> {
|
||||||
return this.postPrivate('/spot/v1/order', params);
|
return this.postPrivate('/spot/v1/order', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getOrder(params: SpotOrderQueryById) {
|
getOrder(params: SpotOrderQueryById): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/spot/v1/order', params);
|
return this.getPrivate('/spot/v1/order', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelOrder(params: SpotOrderQueryById) {
|
cancelOrder(params: SpotOrderQueryById): Promise<APIResponse<any>> {
|
||||||
return this.deletePrivate('/spot/v1/order', params);
|
return this.deletePrivate('/spot/v1/order', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ export class SpotClient extends BaseRestClient {
|
|||||||
symbol: string;
|
symbol: string;
|
||||||
side?: OrderSide;
|
side?: OrderSide;
|
||||||
orderTypes: OrderTypeSpot[];
|
orderTypes: OrderTypeSpot[];
|
||||||
}) {
|
}): Promise<APIResponse<any>> {
|
||||||
const orderTypes = params.orderTypes
|
const orderTypes = params.orderTypes
|
||||||
? params.orderTypes.join(',')
|
? params.orderTypes.join(',')
|
||||||
: undefined;
|
: undefined;
|
||||||
@@ -146,7 +146,11 @@ export class SpotClient extends BaseRestClient {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getOpenOrders(symbol?: string, orderId?: string, limit?: number) {
|
getOpenOrders(
|
||||||
|
symbol?: string,
|
||||||
|
orderId?: string,
|
||||||
|
limit?: number
|
||||||
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/spot/v1/open-orders', {
|
return this.getPrivate('/spot/v1/open-orders', {
|
||||||
symbol,
|
symbol,
|
||||||
orderId,
|
orderId,
|
||||||
@@ -154,7 +158,11 @@ export class SpotClient extends BaseRestClient {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getPastOrders(symbol?: string, orderId?: string, limit?: number) {
|
getPastOrders(
|
||||||
|
symbol?: string,
|
||||||
|
orderId?: string,
|
||||||
|
limit?: number
|
||||||
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/spot/v1/history-orders', {
|
return this.getPrivate('/spot/v1/history-orders', {
|
||||||
symbol,
|
symbol,
|
||||||
orderId,
|
orderId,
|
||||||
@@ -162,7 +170,12 @@ export class SpotClient extends BaseRestClient {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getMyTrades(symbol?: string, limit?: number, fromId?: number, toId?: number) {
|
getMyTrades(
|
||||||
|
symbol?: string,
|
||||||
|
limit?: number,
|
||||||
|
fromId?: number,
|
||||||
|
toId?: number
|
||||||
|
): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/spot/v1/myTrades', {
|
return this.getPrivate('/spot/v1/myTrades', {
|
||||||
symbol,
|
symbol,
|
||||||
limit,
|
limit,
|
||||||
@@ -175,7 +188,7 @@ export class SpotClient extends BaseRestClient {
|
|||||||
* Wallet Data Endpoints
|
* Wallet Data Endpoints
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getBalances() {
|
getBalances(): Promise<APIResponse<any>> {
|
||||||
return this.getPrivate('/spot/v1/account');
|
return this.getPrivate('/spot/v1/account');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,23 @@
|
|||||||
import axios, {
|
import axios, { AxiosRequestConfig, AxiosResponse, Method } from 'axios';
|
||||||
AxiosError,
|
import { APIResponse, APIResponseWithTime } from '../types/shared';
|
||||||
AxiosRequestConfig,
|
|
||||||
AxiosResponse,
|
|
||||||
Method,
|
|
||||||
} from 'axios';
|
|
||||||
|
|
||||||
import { signMessage } from './node-support';
|
import { signMessage } from './node-support';
|
||||||
import {
|
import {
|
||||||
RestClientOptions,
|
RestClientOptions,
|
||||||
GenericAPIResponse,
|
|
||||||
serializeParams,
|
serializeParams,
|
||||||
RestClientType,
|
RestClientType,
|
||||||
REST_CLIENT_TYPE_ENUM,
|
REST_CLIENT_TYPE_ENUM,
|
||||||
} from './requestUtils';
|
} from './requestUtils';
|
||||||
|
|
||||||
|
// axios.interceptors.request.use((request) => {
|
||||||
|
// console.log(new Date(), 'Starting Request', JSON.stringify(request, null, 2));
|
||||||
|
// return request;
|
||||||
|
// });
|
||||||
|
|
||||||
|
// axios.interceptors.response.use((response) => {
|
||||||
|
// console.log(new Date(), 'Response:', JSON.stringify(response, null, 2));
|
||||||
|
// return response;
|
||||||
|
// });
|
||||||
|
|
||||||
interface SignedRequestContext {
|
interface SignedRequestContext {
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
@@ -95,23 +99,23 @@ export default abstract class BaseRestClient {
|
|||||||
return this.clientType === REST_CLIENT_TYPE_ENUM.spot;
|
return this.clientType === REST_CLIENT_TYPE_ENUM.spot;
|
||||||
}
|
}
|
||||||
|
|
||||||
get(endpoint: string, params?: any): GenericAPIResponse {
|
get(endpoint: string, params?: any) {
|
||||||
return this._call('GET', endpoint, params, true);
|
return this._call('GET', endpoint, params, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
post(endpoint: string, params?: any): GenericAPIResponse {
|
post(endpoint: string, params?: any) {
|
||||||
return this._call('POST', endpoint, params, true);
|
return this._call('POST', endpoint, params, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPrivate(endpoint: string, params?: any): GenericAPIResponse {
|
getPrivate(endpoint: string, params?: any) {
|
||||||
return this._call('GET', endpoint, params, false);
|
return this._call('GET', endpoint, params, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
postPrivate(endpoint: string, params?: any): GenericAPIResponse {
|
postPrivate(endpoint: string, params?: any) {
|
||||||
return this._call('POST', endpoint, params, false);
|
return this._call('POST', endpoint, params, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
deletePrivate(endpoint: string, params?: any): GenericAPIResponse {
|
deletePrivate(endpoint: string, params?: any) {
|
||||||
return this._call('DELETE', endpoint, params, false);
|
return this._call('DELETE', endpoint, params, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +146,7 @@ export default abstract class BaseRestClient {
|
|||||||
endpoint: string,
|
endpoint: string,
|
||||||
params?: any,
|
params?: any,
|
||||||
isPublicApi?: boolean
|
isPublicApi?: boolean
|
||||||
): GenericAPIResponse {
|
): Promise<any> {
|
||||||
const options = {
|
const options = {
|
||||||
...this.globalRequestOptions,
|
...this.globalRequestOptions,
|
||||||
url: [this.baseUrl, endpoint].join(endpoint.startsWith('/') ? '' : '/'),
|
url: [this.baseUrl, endpoint].join(endpoint.startsWith('/') ? '' : '/'),
|
||||||
@@ -247,7 +251,7 @@ export default abstract class BaseRestClient {
|
|||||||
/**
|
/**
|
||||||
* Trigger time sync and store promise
|
* Trigger time sync and store promise
|
||||||
*/
|
*/
|
||||||
private syncTime(): GenericAPIResponse {
|
private syncTime(): Promise<any> {
|
||||||
if (this.options.disable_time_sync === true) {
|
if (this.options.disable_time_sync === true) {
|
||||||
return Promise.resolve(false);
|
return Promise.resolve(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ export interface RestClientOptions {
|
|||||||
parse_exceptions?: boolean;
|
parse_exceptions?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type GenericAPIResponse<T = any> = Promise<T>;
|
|
||||||
|
|
||||||
export function serializeParams(
|
export function serializeParams(
|
||||||
params: object = {},
|
params: object = {},
|
||||||
strict_validation = false
|
strict_validation = false
|
||||||
|
|||||||
Reference in New Issue
Block a user