chore(): run linter fixes
This commit is contained in:
@@ -8,12 +8,12 @@ module.exports = {
|
|||||||
plugins: [
|
plugins: [
|
||||||
'@typescript-eslint/eslint-plugin',
|
'@typescript-eslint/eslint-plugin',
|
||||||
'simple-import-sort',
|
'simple-import-sort',
|
||||||
'require-extensions',
|
// 'require-extensions', // only once moved to ESM
|
||||||
],
|
],
|
||||||
extends: [
|
extends: [
|
||||||
'plugin:@typescript-eslint/recommended',
|
'plugin:@typescript-eslint/recommended',
|
||||||
'plugin:prettier/recommended',
|
'plugin:prettier/recommended',
|
||||||
'plugin:require-extensions/recommended',
|
// 'plugin:require-extensions/recommended', // only once moved to ESM
|
||||||
],
|
],
|
||||||
root: true,
|
root: true,
|
||||||
env: {
|
env: {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import {
|
import {
|
||||||
APIResponse,
|
APIResponse,
|
||||||
BrokerProductType,
|
BrokerProductType,
|
||||||
BrokerSubWithdrawalRequest,
|
|
||||||
BrokerSubAPIKeyModifyRequest,
|
BrokerSubAPIKeyModifyRequest,
|
||||||
BrokerSubListRequest,
|
BrokerSubListRequest,
|
||||||
|
BrokerSubWithdrawalRequest,
|
||||||
} from './types';
|
} from './types';
|
||||||
import { REST_CLIENT_TYPE_ENUM } from './util';
|
import { REST_CLIENT_TYPE_ENUM } from './util';
|
||||||
import BaseRestClient from './util/BaseRestClient';
|
import BaseRestClient from './util/BaseRestClient';
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
import {
|
import {
|
||||||
APIResponse,
|
APIResponse,
|
||||||
FuturesProductType,
|
CancelFuturesPlanTPSL,
|
||||||
|
FuturesAccount,
|
||||||
FuturesAccountBillRequest,
|
FuturesAccountBillRequest,
|
||||||
FuturesBusinessBillRequest,
|
FuturesBusinessBillRequest,
|
||||||
NewFuturesOrder,
|
FuturesCandleData,
|
||||||
NewBatchFuturesOrder,
|
FuturesHistoricPositions,
|
||||||
|
FuturesKlineInterval,
|
||||||
|
FuturesMarginMode,
|
||||||
|
FuturesMarketTrade,
|
||||||
FuturesPagination,
|
FuturesPagination,
|
||||||
NewFuturesPlanOrder,
|
FuturesPlanType,
|
||||||
|
FuturesPosition,
|
||||||
|
FuturesProductType,
|
||||||
|
FuturesSymbolRule,
|
||||||
|
GetHistoricTradesParams,
|
||||||
|
HistoricPlanOrderTPSLRequest,
|
||||||
|
ModifyFuturesOrder,
|
||||||
ModifyFuturesPlanOrder,
|
ModifyFuturesPlanOrder,
|
||||||
ModifyFuturesPlanOrderTPSL,
|
ModifyFuturesPlanOrderTPSL,
|
||||||
NewFuturesPlanPositionTPSL,
|
|
||||||
ModifyFuturesPlanStopOrder,
|
ModifyFuturesPlanStopOrder,
|
||||||
CancelFuturesPlanTPSL,
|
NewBatchFuturesOrder,
|
||||||
HistoricPlanOrderTPSLRequest,
|
NewFuturesOrder,
|
||||||
|
NewFuturesPlanOrder,
|
||||||
|
NewFuturesPlanPositionTPSL,
|
||||||
NewFuturesPlanStopOrder,
|
NewFuturesPlanStopOrder,
|
||||||
FuturesAccount,
|
|
||||||
FuturesSymbolRule,
|
|
||||||
FuturesMarginMode,
|
|
||||||
FuturesPosition,
|
|
||||||
NewFuturesPlanTrailingStopOrder,
|
NewFuturesPlanTrailingStopOrder,
|
||||||
VIPFeeRate,
|
VIPFeeRate,
|
||||||
GetHistoricTradesParams,
|
|
||||||
FuturesMarketTrade,
|
|
||||||
FuturesPlanType,
|
|
||||||
FuturesKlineInterval,
|
|
||||||
FuturesHistoricPositions,
|
|
||||||
ModifyFuturesOrder,
|
|
||||||
FuturesCandleData,
|
|
||||||
} from './types';
|
} from './types';
|
||||||
import { REST_CLIENT_TYPE_ENUM } from './util';
|
import { REST_CLIENT_TYPE_ENUM } from './util';
|
||||||
import BaseRestClient from './util/BaseRestClient';
|
import BaseRestClient from './util/BaseRestClient';
|
||||||
@@ -107,7 +107,7 @@ export class FuturesClient extends BaseRestClient {
|
|||||||
startTime: string,
|
startTime: string,
|
||||||
endTime: string,
|
endTime: string,
|
||||||
limit?: string,
|
limit?: string,
|
||||||
kLineType?: 'market' | 'mark' | 'index'
|
kLineType?: 'market' | 'mark' | 'index',
|
||||||
): Promise<APIResponse<FuturesCandleData[]>> {
|
): Promise<APIResponse<FuturesCandleData[]>> {
|
||||||
return this.get('/api/mix/v1/market/candles', {
|
return this.get('/api/mix/v1/market/candles', {
|
||||||
symbol,
|
symbol,
|
||||||
|
|||||||
10
src/index.ts
10
src/index.ts
@@ -1,10 +1,10 @@
|
|||||||
export * from './rest-client-v2';
|
|
||||||
export * from './broker-client';
|
export * from './broker-client';
|
||||||
|
export * from './constants/enum';
|
||||||
export * from './futures-client';
|
export * from './futures-client';
|
||||||
|
export * from './rest-client-v2';
|
||||||
export * from './spot-client';
|
export * from './spot-client';
|
||||||
|
export * from './types';
|
||||||
|
export * from './util';
|
||||||
|
export * from './util/logger';
|
||||||
export * from './websocket-client';
|
export * from './websocket-client';
|
||||||
export * from './websocket-client-v2';
|
export * from './websocket-client-v2';
|
||||||
export * from './util/logger';
|
|
||||||
export * from './util';
|
|
||||||
export * from './types';
|
|
||||||
export * from './constants/enum';
|
|
||||||
|
|||||||
@@ -1,111 +1,111 @@
|
|||||||
import {
|
import {
|
||||||
APIResponse,
|
APIResponse,
|
||||||
MarginType,
|
BorrowLoanRequestV2,
|
||||||
|
CloseFuturesFollowerPositionsRequestV2,
|
||||||
|
CopyTradingProductTypeV2,
|
||||||
FuturesAccountBillRequestV2,
|
FuturesAccountBillRequestV2,
|
||||||
|
FuturesBatchCancelOrderRequestV2,
|
||||||
|
FuturesBatchOrderRequestV2,
|
||||||
|
FuturesCancelAllOrdersRequestV2,
|
||||||
|
FuturesCancelOrderRequestV2,
|
||||||
|
FuturesCancelPlanOrderRequestV2,
|
||||||
FuturesCandlesRequestV2,
|
FuturesCandlesRequestV2,
|
||||||
SpotCandlesRequestV2,
|
FuturesFlashClosePositionsRequestV2,
|
||||||
SpotAccountBill,
|
FuturesGetHistoricalFillsRequestV2,
|
||||||
SpotHistoricCandlesRequestV2,
|
FuturesGetHistoryOrdersRequestV2,
|
||||||
SpotHistoricTradesRequestV2,
|
FuturesGetHistoryPlanOrdersRequestV2,
|
||||||
SpotOrderRequestV2,
|
FuturesGetOpenOrdersRequestV2,
|
||||||
SpotCancelandSubmitOrderRequestV2,
|
FuturesGetOrderFillsRequestV2,
|
||||||
SpotCancelOrderRequestV2,
|
FuturesGetOrderRequestV2,
|
||||||
SpotBatchOrderRequestV2,
|
FuturesGetPlanOrdersRequestV2,
|
||||||
SpotBatchCancelOrderRequestV2,
|
FuturesHistoricalPositionsRequestV2,
|
||||||
GetSpotOrderInfoRequestV2,
|
FuturesHistoricTradesRequestV2,
|
||||||
GetSpotOpenOrdersRequestV2,
|
FuturesInterestHistoryRequestV2,
|
||||||
GetSpotHistoryOrdersRequestV2,
|
|
||||||
GetSpotFillsRequestV2,
|
|
||||||
SpotPlanOrderRequestV2,
|
|
||||||
SpotModifyPlanOrderRequestV2,
|
|
||||||
GetSpotCurrentPlanOrdersRequestV2,
|
|
||||||
GetSpotHistoryPlanOrdersRequestV2,
|
|
||||||
GetSpotAccountBillsRequestV2,
|
|
||||||
SpotTransferRequestV2,
|
|
||||||
SpotAccountTypeV2,
|
|
||||||
SpotSubAccountTransferRequestV2,
|
|
||||||
SpotWithdrawalRequestV2,
|
|
||||||
SpotMainSubTransferRecordRequestV2,
|
|
||||||
GetSpotTransferRecordRequestV2,
|
|
||||||
GetSpotSubAccountDepositRecordRequestV2,
|
|
||||||
GetSpotWithdrawalRecordRequestV2,
|
|
||||||
GetSpotDepositRecordRequestV2,
|
|
||||||
FuturesMergeDepthRequestV2,
|
FuturesMergeDepthRequestV2,
|
||||||
|
FuturesModifyOrderRequestV2,
|
||||||
|
FuturesModifyPlanOrderRequestV2,
|
||||||
|
FuturesModifyTPSLOrderRequestV2,
|
||||||
|
FuturesOpenCountRequestV2,
|
||||||
|
FuturesPlaceOrderRequestV2,
|
||||||
|
FuturesPlanOrderRequestV2,
|
||||||
FuturesProductTypeV2,
|
FuturesProductTypeV2,
|
||||||
FuturesRecentTradesRequestV2,
|
FuturesRecentTradesRequestV2,
|
||||||
FuturesHistoricTradesRequestV2,
|
FuturesReversalOrderRequestV2,
|
||||||
FuturesSingleAccountRequestV2,
|
|
||||||
FuturesInterestHistoryRequestV2,
|
|
||||||
FuturesOpenCountRequestV2,
|
|
||||||
FuturesSetAutoMarginRequestV2,
|
FuturesSetAutoMarginRequestV2,
|
||||||
FuturesSetLeverageRequestV2,
|
FuturesSetLeverageRequestV2,
|
||||||
FuturesSetPositionMarginRequestV2,
|
|
||||||
FuturesSetMarginModeRequestV2,
|
FuturesSetMarginModeRequestV2,
|
||||||
FuturesHistoricalPositionsRequestV2,
|
FuturesSetPositionMarginRequestV2,
|
||||||
FuturesPlaceOrderRequestV2,
|
FuturesSingleAccountRequestV2,
|
||||||
FuturesReversalOrderRequestV2,
|
|
||||||
FuturesBatchOrderRequestV2,
|
|
||||||
FuturesModifyOrderRequestV2,
|
|
||||||
FuturesCancelOrderRequestV2,
|
|
||||||
FuturesBatchCancelOrderRequestV2,
|
|
||||||
FuturesFlashClosePositionsRequestV2,
|
|
||||||
FuturesGetOrderRequestV2,
|
|
||||||
FuturesGetOrderFillsRequestV2,
|
|
||||||
FuturesGetHistoricalFillsRequestV2,
|
|
||||||
FuturesGetOpenOrdersRequestV2,
|
|
||||||
FuturesGetHistoryOrdersRequestV2,
|
|
||||||
FuturesCancelAllOrdersRequestV2,
|
|
||||||
FuturesTPSLOrderRequestV2,
|
FuturesTPSLOrderRequestV2,
|
||||||
FuturesPlanOrderRequestV2,
|
|
||||||
FuturesModifyTPSLOrderRequestV2,
|
|
||||||
FuturesModifyPlanOrderRequestV2,
|
|
||||||
FuturesGetPlanOrdersRequestV2,
|
|
||||||
FuturesCancelPlanOrderRequestV2,
|
|
||||||
FuturesGetHistoryPlanOrdersRequestV2,
|
|
||||||
GetBorrowHistoryRequestV2,
|
|
||||||
GetRepayHistoryRequestV2,
|
|
||||||
GetInterestHistoryRequestV2,
|
|
||||||
GetLiquidationHistoryRequestV2,
|
|
||||||
GetFinancialHistoryRequestV2,
|
|
||||||
MarginPlaceOrderRequestV2,
|
|
||||||
MarginBatchOrdersRequestV2,
|
|
||||||
GetMarginCurrentOrdersRequestV2,
|
|
||||||
GetHistoryOrdersRequestV2,
|
|
||||||
GetMarginOrderFillsRequestV2,
|
|
||||||
GetMarginLiquidationOrdersRequestV2,
|
|
||||||
GetFuturesTraderCurrentOrdersRequestV2,
|
|
||||||
GetFuturesTraderHistoryOrdersRequestV2,
|
|
||||||
ModifyFuturesTraderOrderTPSLRequestV2,
|
|
||||||
GetFuturesTraderProfitShareDetailRequestV2,
|
|
||||||
CopyTradingProductTypeV2,
|
|
||||||
FuturesTraderSymbolSettingRequestV2,
|
FuturesTraderSymbolSettingRequestV2,
|
||||||
GetFuturesTraderFollowersRequestV2,
|
GetBorrowHistoryRequestV2,
|
||||||
GetFollowerFuturesCurrentTrackingOrdersRequestV2,
|
|
||||||
GetFollowerFuturesHistoryTrackingOrdersRequestV2,
|
|
||||||
UpdateFuturesFollowerTPSLRequestV2,
|
|
||||||
UpdateFuturesFollowerSettingsRequestV2,
|
|
||||||
GetFuturesFollowerTradersRequestV2,
|
|
||||||
CloseFuturesFollowerPositionsRequestV2,
|
|
||||||
GetSpotTraderHistoryProfitRequestV2,
|
|
||||||
GetSpotTraderHistoryOrdersRequestV2,
|
|
||||||
GetSpotTraderCurrentOrdersRequestV2,
|
|
||||||
GetSpotTraderFollowersRequestV2,
|
|
||||||
SpotFollowerCopyTradeSettingV2,
|
|
||||||
GetSpotFollowerHistoryOrdersRequestV2,
|
|
||||||
GetSpotFollowerOpenOrdersRequestV2,
|
|
||||||
GetEarnSavingsAssetsRequestV2,
|
GetEarnSavingsAssetsRequestV2,
|
||||||
GetEarnSavingsRecordsRequestV2,
|
GetEarnSavingsRecordsRequestV2,
|
||||||
RedeemSavingsRequestV2,
|
GetFinancialHistoryRequestV2,
|
||||||
|
GetFollowerFuturesCurrentTrackingOrdersRequestV2,
|
||||||
|
GetFollowerFuturesHistoryTrackingOrdersRequestV2,
|
||||||
|
GetFuturesFollowerTradersRequestV2,
|
||||||
|
GetFuturesTraderCurrentOrdersRequestV2,
|
||||||
|
GetFuturesTraderFollowersRequestV2,
|
||||||
|
GetFuturesTraderHistoryOrdersRequestV2,
|
||||||
|
GetFuturesTraderProfitShareDetailRequestV2,
|
||||||
|
GetHistoryOrdersRequestV2,
|
||||||
|
GetInterestHistoryRequestV2,
|
||||||
|
GetLiquidationHistoryRequestV2,
|
||||||
|
GetLiquidationRecordsRequestV2,
|
||||||
|
GetLoanEstInterestAndBorrowableRequestV2,
|
||||||
|
GetLoanHistoryRequestV2,
|
||||||
|
GetLoanPledgeRateHistoryRequestV2,
|
||||||
|
GetLoanRepayHistoryRequestV2,
|
||||||
|
GetMarginCurrentOrdersRequestV2,
|
||||||
|
GetMarginLiquidationOrdersRequestV2,
|
||||||
|
GetMarginOrderFillsRequestV2,
|
||||||
|
GetRepayHistoryRequestV2,
|
||||||
GetSharkfinAssetsRequestV2,
|
GetSharkfinAssetsRequestV2,
|
||||||
GetSharkfinRecordsRequestV2,
|
GetSharkfinRecordsRequestV2,
|
||||||
GetLoanEstInterestAndBorrowableRequestV2,
|
GetSpotAccountBillsRequestV2,
|
||||||
BorrowLoanRequestV2,
|
GetSpotCurrentPlanOrdersRequestV2,
|
||||||
RepayLoanRequestV2,
|
GetSpotDepositRecordRequestV2,
|
||||||
GetLoanRepayHistoryRequestV2,
|
GetSpotFillsRequestV2,
|
||||||
|
GetSpotFollowerHistoryOrdersRequestV2,
|
||||||
|
GetSpotFollowerOpenOrdersRequestV2,
|
||||||
|
GetSpotHistoryOrdersRequestV2,
|
||||||
|
GetSpotHistoryPlanOrdersRequestV2,
|
||||||
|
GetSpotOpenOrdersRequestV2,
|
||||||
|
GetSpotOrderInfoRequestV2,
|
||||||
|
GetSpotSubAccountDepositRecordRequestV2,
|
||||||
|
GetSpotTraderCurrentOrdersRequestV2,
|
||||||
|
GetSpotTraderFollowersRequestV2,
|
||||||
|
GetSpotTraderHistoryOrdersRequestV2,
|
||||||
|
GetSpotTraderHistoryProfitRequestV2,
|
||||||
|
GetSpotTransferRecordRequestV2,
|
||||||
|
GetSpotWithdrawalRecordRequestV2,
|
||||||
|
MarginBatchOrdersRequestV2,
|
||||||
|
MarginPlaceOrderRequestV2,
|
||||||
|
MarginType,
|
||||||
|
ModifyFuturesTraderOrderTPSLRequestV2,
|
||||||
ModifyLoanPledgeRateRequestV2,
|
ModifyLoanPledgeRateRequestV2,
|
||||||
GetLoanPledgeRateHistoryRequestV2,
|
RedeemSavingsRequestV2,
|
||||||
GetLoanHistoryRequestV2,
|
RepayLoanRequestV2,
|
||||||
GetLiquidationRecordsRequestV2,
|
SpotAccountBill,
|
||||||
|
SpotAccountTypeV2,
|
||||||
|
SpotBatchCancelOrderRequestV2,
|
||||||
|
SpotBatchOrderRequestV2,
|
||||||
|
SpotCancelandSubmitOrderRequestV2,
|
||||||
|
SpotCancelOrderRequestV2,
|
||||||
|
SpotCandlesRequestV2,
|
||||||
|
SpotFollowerCopyTradeSettingV2,
|
||||||
|
SpotHistoricCandlesRequestV2,
|
||||||
|
SpotHistoricTradesRequestV2,
|
||||||
|
SpotMainSubTransferRecordRequestV2,
|
||||||
|
SpotModifyPlanOrderRequestV2,
|
||||||
|
SpotOrderRequestV2,
|
||||||
|
SpotPlanOrderRequestV2,
|
||||||
|
SpotSubAccountTransferRequestV2,
|
||||||
|
SpotTransferRequestV2,
|
||||||
|
SpotWithdrawalRequestV2,
|
||||||
|
UpdateFuturesFollowerSettingsRequestV2,
|
||||||
|
UpdateFuturesFollowerTPSLRequestV2,
|
||||||
} from './types';
|
} from './types';
|
||||||
import {
|
import {
|
||||||
CreateSubAccountApiKeyRequestV2,
|
CreateSubAccountApiKeyRequestV2,
|
||||||
@@ -122,6 +122,7 @@ import {
|
|||||||
CreateVirtualSubApiKeyRequestV2,
|
CreateVirtualSubApiKeyRequestV2,
|
||||||
CreateVirtualSubRequestV2,
|
CreateVirtualSubRequestV2,
|
||||||
GetAnnouncementsRequestV2,
|
GetAnnouncementsRequestV2,
|
||||||
|
GetConvertBGBHistoryRequestV2,
|
||||||
GetConvertHistoryRequestV2,
|
GetConvertHistoryRequestV2,
|
||||||
GetFuturesTransactionsRequestV2,
|
GetFuturesTransactionsRequestV2,
|
||||||
GetMarginTransactionsRequestV2,
|
GetMarginTransactionsRequestV2,
|
||||||
@@ -131,11 +132,10 @@ import {
|
|||||||
GetP2PTransactionsRequestV2,
|
GetP2PTransactionsRequestV2,
|
||||||
GetSpotTransactionsRequestV2,
|
GetSpotTransactionsRequestV2,
|
||||||
GetTradeRateRequestV2,
|
GetTradeRateRequestV2,
|
||||||
ModifyVirtualSubRequestV2,
|
|
||||||
ModifyVirtualSubApiKeyRequestV2,
|
ModifyVirtualSubApiKeyRequestV2,
|
||||||
GetConvertBGBHistoryRequestV2,
|
ModifyVirtualSubRequestV2,
|
||||||
} from './types/request/v2/common';
|
} from './types/request/v2/common';
|
||||||
import { REST_CLIENT_TYPE_ENUM, assertMarginType } from './util';
|
import { assertMarginType, REST_CLIENT_TYPE_ENUM } from './util';
|
||||||
import BaseRestClient from './util/BaseRestClient';
|
import BaseRestClient from './util/BaseRestClient';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,27 +1,27 @@
|
|||||||
import {
|
import {
|
||||||
|
APIResponse,
|
||||||
|
BatchCancelSpotOrderV2,
|
||||||
|
CancelSpotOrderV2,
|
||||||
|
CancelSpotPlanOrderParams,
|
||||||
|
CoinBalance,
|
||||||
|
GetHistoricPlanOrdersParams,
|
||||||
|
GetHistoricTradesParams,
|
||||||
|
GetSpotPlanOrdersParams,
|
||||||
|
ModifySpotPlanOrder,
|
||||||
NewBatchSpotOrder,
|
NewBatchSpotOrder,
|
||||||
NewSpotOrder,
|
NewSpotOrder,
|
||||||
NewWalletTransfer,
|
NewSpotPlanOrder,
|
||||||
Pagination,
|
|
||||||
APIResponse,
|
|
||||||
CoinBalance,
|
|
||||||
SymbolRules,
|
|
||||||
NewSpotSubTransfer,
|
NewSpotSubTransfer,
|
||||||
NewSpotWithdraw,
|
NewSpotWithdraw,
|
||||||
CancelSpotOrderV2,
|
NewWalletTransfer,
|
||||||
BatchCancelSpotOrderV2,
|
Pagination,
|
||||||
SpotOrderResult,
|
|
||||||
NewSpotPlanOrder,
|
|
||||||
ModifySpotPlanOrder,
|
|
||||||
CancelSpotPlanOrderParams,
|
|
||||||
GetSpotPlanOrdersParams,
|
|
||||||
SpotPlanOrder,
|
|
||||||
GetHistoricPlanOrdersParams,
|
|
||||||
SpotMarketTrade,
|
|
||||||
GetHistoricTradesParams,
|
|
||||||
VIPFeeRate,
|
|
||||||
SpotKlineInterval,
|
|
||||||
SpotCandleData,
|
SpotCandleData,
|
||||||
|
SpotKlineInterval,
|
||||||
|
SpotMarketTrade,
|
||||||
|
SpotOrderResult,
|
||||||
|
SpotPlanOrder,
|
||||||
|
SymbolRules,
|
||||||
|
VIPFeeRate,
|
||||||
} from './types';
|
} from './types';
|
||||||
import { REST_CLIENT_TYPE_ENUM } from './util';
|
import { REST_CLIENT_TYPE_ENUM } from './util';
|
||||||
import BaseRestClient from './util/BaseRestClient';
|
import BaseRestClient from './util/BaseRestClient';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export * from './response';
|
|
||||||
export * from './request';
|
export * from './request';
|
||||||
|
export * from './response';
|
||||||
export * from './shared';
|
export * from './shared';
|
||||||
export * from './websockets';
|
export * from './websockets';
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
|
export * from './shared';
|
||||||
export * from './v1/brokerV1';
|
export * from './v1/brokerV1';
|
||||||
export * from './v1/futuresV1';
|
export * from './v1/futuresV1';
|
||||||
export * from './v1/spotV1';
|
export * from './v1/spotV1';
|
||||||
export * from './v2/futures';
|
|
||||||
export * from './v2/spot';
|
|
||||||
export * from './v2/broker';
|
export * from './v2/broker';
|
||||||
export * from './v2/margin';
|
export * from './v2/common';
|
||||||
export * from './v2/copytrading';
|
export * from './v2/copytrading';
|
||||||
export * from './v2/earn';
|
export * from './v2/earn';
|
||||||
export * from './shared';
|
export * from './v2/futures';
|
||||||
export * from './v2/common';
|
export * from './v2/margin';
|
||||||
|
export * from './v2/spot';
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
|
export * from './futures';
|
||||||
export * from './shared';
|
export * from './shared';
|
||||||
export * from './spot';
|
export * from './spot';
|
||||||
export * from './futures';
|
|
||||||
|
|||||||
@@ -27,4 +27,4 @@ export type KlineInterval =
|
|||||||
| '1Mutc';
|
| '1Mutc';
|
||||||
|
|
||||||
export type RestClientType =
|
export type RestClientType =
|
||||||
typeof REST_CLIENT_TYPE_ENUM[keyof typeof REST_CLIENT_TYPE_ENUM];
|
(typeof REST_CLIENT_TYPE_ENUM)[keyof typeof REST_CLIENT_TYPE_ENUM];
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
import axios, { AxiosRequestConfig, AxiosResponse, Method } from 'axios';
|
import axios, { AxiosRequestConfig, AxiosResponse, Method } from 'axios';
|
||||||
import { RestClientType } from '../types';
|
|
||||||
|
|
||||||
|
import { RestClientType } from '../types';
|
||||||
import { signMessage } from './node-support';
|
import { signMessage } from './node-support';
|
||||||
import {
|
import {
|
||||||
|
getRestBaseUrl,
|
||||||
RestClientOptions,
|
RestClientOptions,
|
||||||
serializeParams,
|
serializeParams,
|
||||||
getRestBaseUrl,
|
|
||||||
} from './requestUtils';
|
} from './requestUtils';
|
||||||
import { neverGuard } from './websocket-util';
|
import { neverGuard } from './websocket-util';
|
||||||
|
|
||||||
interface SignedRequest<T extends object | undefined = {}> {
|
interface SignedRequest<T extends object | undefined = object> {
|
||||||
originalParams: T;
|
originalParams: T;
|
||||||
paramsWithSign?: T & { sign: string };
|
paramsWithSign?: T & { sign: string };
|
||||||
serializedParams: string;
|
serializedParams: string;
|
||||||
@@ -19,7 +19,7 @@ interface SignedRequest<T extends object | undefined = {}> {
|
|||||||
recvWindow: number;
|
recvWindow: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UnsignedRequest<T extends object | undefined = {}> {
|
interface UnsignedRequest<T extends object | undefined = object> {
|
||||||
originalParams: T;
|
originalParams: T;
|
||||||
paramsWithSign: T;
|
paramsWithSign: T;
|
||||||
}
|
}
|
||||||
@@ -229,7 +229,7 @@ export default abstract class BaseRestClient {
|
|||||||
/**
|
/**
|
||||||
* @private sign request and set recv window
|
* @private sign request and set recv window
|
||||||
*/
|
*/
|
||||||
private async signRequest<T extends object | undefined = {}>(
|
private async signRequest<T extends object | undefined = object>(
|
||||||
data: T,
|
data: T,
|
||||||
endpoint: string,
|
endpoint: string,
|
||||||
method: Method,
|
method: Method,
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ import WebSocket from 'isomorphic-ws';
|
|||||||
import {
|
import {
|
||||||
WebsocketClientOptions,
|
WebsocketClientOptions,
|
||||||
WSClientConfigurableOptions,
|
WSClientConfigurableOptions,
|
||||||
} from '../types/index.js';
|
} from '../types/index';
|
||||||
import { DefaultLogger } from './logger.js';
|
import { DefaultLogger } from './logger';
|
||||||
import { isWsPong } from './requestUtils.js';
|
import { isWsPong } from './requestUtils';
|
||||||
import { getWsAuthSignature } from './websocket-util.js';
|
import { getWsAuthSignature } from './websocket-util';
|
||||||
import WsStore from './WsStore.js';
|
import WsStore from './WsStore';
|
||||||
import { WsConnectionStateEnum } from './WsStore.types.js';
|
import { WsConnectionStateEnum } from './WsStore.types';
|
||||||
|
|
||||||
interface WSClientEventMap<WsKey extends string> {
|
interface WSClientEventMap<WsKey extends string> {
|
||||||
/** Connection opened. If this connection was previously opened and reconnected, expect the reconnected event instead */
|
/** Connection opened. If this connection was previously opened and reconnected, expect the reconnected event instead */
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import WebSocket from 'isomorphic-ws';
|
import WebSocket from 'isomorphic-ws';
|
||||||
|
|
||||||
import { DefaultLogger } from './logger';
|
import { DefaultLogger } from './logger';
|
||||||
import { WsConnectionStateEnum, WsStoredState } from './WsStore.types';
|
import { WsConnectionStateEnum, WsStoredState } from './WsStore.types';
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ export async function signMessage(
|
|||||||
return _arrayBufferToBase64(signature);
|
return _arrayBufferToBase64(signature);
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
((x: never) => {})(method);
|
((x: never) => {})(method);
|
||||||
throw new Error(`Unhandled sign method: ${method}`);
|
throw new Error(`Unhandled sign method: ${method}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
export * from './BaseRestClient';
|
export * from './BaseRestClient';
|
||||||
export * from './requestUtils';
|
|
||||||
export * from './WsStore';
|
|
||||||
export * from './logger';
|
export * from './logger';
|
||||||
|
export * from './requestUtils';
|
||||||
export * from './type-guards';
|
export * from './type-guards';
|
||||||
export * from './websocket-util';
|
export * from './websocket-util';
|
||||||
|
export * from './WsStore';
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
export type LogParams = null | any;
|
export type LogParams = null | any;
|
||||||
|
|
||||||
export const DefaultLogger = {
|
export const DefaultLogger = {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
silly: (...params: LogParams): void => {
|
silly: (...params: LogParams): void => {
|
||||||
// console.log(params);
|
// console.log(params);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export async function signMessage(
|
|||||||
return hmac.digest().toString('base64');
|
return hmac.digest().toString('base64');
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
((x: never) => {})(method);
|
((x: never) => {})(method);
|
||||||
throw new Error(`Unhandled sign method: ${method}`);
|
throw new Error(`Unhandled sign method: ${method}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export interface RestClientOptions {
|
|||||||
parseExceptions?: boolean;
|
parseExceptions?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function serializeParams<T extends object | undefined = {}>(
|
export function serializeParams<T extends object | undefined = object>(
|
||||||
params: T,
|
params: T,
|
||||||
strict_validation = false,
|
strict_validation = false,
|
||||||
encodeValues: boolean = true,
|
encodeValues: boolean = true,
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ export function isPrivateChannel<TChannel extends string>(
|
|||||||
|
|
||||||
export function getWsKeyForTopic(
|
export function getWsKeyForTopic(
|
||||||
subscribeEvent: WsTopicSubscribeEventArgs,
|
subscribeEvent: WsTopicSubscribeEventArgs,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
isPrivate?: boolean,
|
isPrivate?: boolean,
|
||||||
): WsKey {
|
): WsKey {
|
||||||
const instType = subscribeEvent.instType.toUpperCase() as BitgetInstType;
|
const instType = subscribeEvent.instType.toUpperCase() as BitgetInstType;
|
||||||
|
|||||||
@@ -12,17 +12,15 @@ import {
|
|||||||
WsTopicSubscribePrivateInstIdArgsV2,
|
WsTopicSubscribePrivateInstIdArgsV2,
|
||||||
WsTopicV2,
|
WsTopicV2,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
WS_AUTH_ON_CONNECT_KEYS,
|
|
||||||
WS_KEY_MAP,
|
|
||||||
DefaultLogger,
|
DefaultLogger,
|
||||||
WS_BASE_URL_MAP,
|
|
||||||
neverGuard,
|
|
||||||
getMaxTopicsPerSubscribeEvent,
|
getMaxTopicsPerSubscribeEvent,
|
||||||
isPrivateChannel,
|
isPrivateChannel,
|
||||||
|
neverGuard,
|
||||||
|
WS_AUTH_ON_CONNECT_KEYS,
|
||||||
|
WS_BASE_URL_MAP,
|
||||||
|
WS_KEY_MAP,
|
||||||
} from './util';
|
} from './util';
|
||||||
|
|
||||||
import { BaseWebsocketClient } from './util/BaseWSClient';
|
import { BaseWebsocketClient } from './util/BaseWSClient';
|
||||||
|
|
||||||
const LOGGER_CATEGORY = { category: 'bitget-ws' };
|
const LOGGER_CATEGORY = { category: 'bitget-ws' };
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import WebSocket from 'isomorphic-ws';
|
import WebSocket from 'isomorphic-ws';
|
||||||
|
|
||||||
import WsStore from './util/WsStore';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BitgetInstType,
|
BitgetInstType,
|
||||||
WebsocketClientOptions,
|
WebsocketClientOptions,
|
||||||
@@ -11,19 +10,19 @@ import {
|
|||||||
WsTopic,
|
WsTopic,
|
||||||
WsTopicSubscribeEventArgs,
|
WsTopicSubscribeEventArgs,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
isWsPong,
|
|
||||||
WS_AUTH_ON_CONNECT_KEYS,
|
|
||||||
WS_KEY_MAP,
|
|
||||||
DefaultLogger,
|
DefaultLogger,
|
||||||
WS_BASE_URL_MAP,
|
|
||||||
getWsKeyForTopic,
|
|
||||||
neverGuard,
|
|
||||||
getMaxTopicsPerSubscribeEvent,
|
getMaxTopicsPerSubscribeEvent,
|
||||||
isPrivateChannel,
|
|
||||||
getWsAuthSignature,
|
getWsAuthSignature,
|
||||||
|
getWsKeyForTopic,
|
||||||
|
isPrivateChannel,
|
||||||
|
isWsPong,
|
||||||
|
neverGuard,
|
||||||
|
WS_AUTH_ON_CONNECT_KEYS,
|
||||||
|
WS_BASE_URL_MAP,
|
||||||
|
WS_KEY_MAP,
|
||||||
} from './util';
|
} from './util';
|
||||||
|
import WsStore from './util/WsStore';
|
||||||
import { WsConnectionStateEnum } from './util/WsStore.types';
|
import { WsConnectionStateEnum } from './util/WsStore.types';
|
||||||
|
|
||||||
const LOGGER_CATEGORY = { category: 'bitget-ws' };
|
const LOGGER_CATEGORY = { category: 'bitget-ws' };
|
||||||
@@ -387,7 +386,7 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
this.logger.silly(
|
this.logger.silly(
|
||||||
`Subscribing to topics in batches of ${maxTopicsPerEvent}`,
|
`Subscribing to topics in batches of ${maxTopicsPerEvent}`,
|
||||||
);
|
);
|
||||||
for (var i = 0; i < topics.length; i += maxTopicsPerEvent) {
|
for (let i = 0; i < topics.length; i += maxTopicsPerEvent) {
|
||||||
const batch = topics.slice(i, i + maxTopicsPerEvent);
|
const batch = topics.slice(i, i + maxTopicsPerEvent);
|
||||||
this.logger.silly(`Subscribing to batch of ${batch.length}`);
|
this.logger.silly(`Subscribing to batch of ${batch.length}`);
|
||||||
this.requestSubscribeTopics(wsKey, batch);
|
this.requestSubscribeTopics(wsKey, batch);
|
||||||
@@ -422,7 +421,7 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
this.logger.silly(
|
this.logger.silly(
|
||||||
`Unsubscribing to topics in batches of ${maxTopicsPerEvent}`,
|
`Unsubscribing to topics in batches of ${maxTopicsPerEvent}`,
|
||||||
);
|
);
|
||||||
for (var i = 0; i < topics.length; i += maxTopicsPerEvent) {
|
for (let i = 0; i < topics.length; i += maxTopicsPerEvent) {
|
||||||
const batch = topics.slice(i, i + maxTopicsPerEvent);
|
const batch = topics.slice(i, i + maxTopicsPerEvent);
|
||||||
this.logger.silly(`Unsubscribing to batch of ${batch.length}`);
|
this.logger.silly(`Unsubscribing to batch of ${batch.length}`);
|
||||||
this.requestUnsubscribeTopics(wsKey, batch);
|
this.requestUnsubscribeTopics(wsKey, batch);
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ describe('Private Broker REST API GET Endpoints', () => {
|
|||||||
|
|
||||||
const coin = 'BTC';
|
const coin = 'BTC';
|
||||||
const subUid = '123456';
|
const subUid = '123456';
|
||||||
const timestampOneHourAgo = new Date().getTime() - 1000 * 60 * 60;
|
// const timestampOneHourAgo = new Date().getTime() - 1000 * 60 * 60;
|
||||||
const from = timestampOneHourAgo.toFixed(0);
|
// const from = timestampOneHourAgo.toFixed(0);
|
||||||
const to = String(Number(from) + 1000 * 60 * 30); // 30 minutes
|
// const to = String(Number(from) + 1000 * 60 * 30); // 30 minutes
|
||||||
|
|
||||||
it('getBrokerInfo()', async () => {
|
it('getBrokerInfo()', async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ describe('Private Broker REST API POST Endpoints', () => {
|
|||||||
apiPass: API_PASS,
|
apiPass: API_PASS,
|
||||||
});
|
});
|
||||||
|
|
||||||
const coin = 'BTC';
|
// const coin = 'BTC';
|
||||||
const subUid = '123456';
|
const subUid = '123456';
|
||||||
const timestampOneHourAgo = new Date().getTime() - 1000 * 60 * 60;
|
// const timestampOneHourAgo = new Date().getTime() - 1000 * 60 * 60;
|
||||||
const from = timestampOneHourAgo.toFixed(0);
|
// const from = timestampOneHourAgo.toFixed(0);
|
||||||
const to = String(Number(from) + 1000 * 60 * 30); // 30 minutes
|
// const to = String(Number(from) + 1000 * 60 * 30); // 30 minutes
|
||||||
|
|
||||||
it('createSubAccount()', async () => {
|
it('createSubAccount()', async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ describe('Private Futures REST API POST Endpoints', () => {
|
|||||||
|
|
||||||
const symbol = 'BTCUSDT_UMCBL';
|
const symbol = 'BTCUSDT_UMCBL';
|
||||||
const marginCoin = 'USDT';
|
const marginCoin = 'USDT';
|
||||||
const timestampOneHourAgo = new Date().getTime() - 1000 * 60 * 60;
|
// const timestampOneHourAgo = new Date().getTime() - 1000 * 60 * 60;
|
||||||
const from = timestampOneHourAgo.toFixed(0);
|
// const from = timestampOneHourAgo.toFixed(0);
|
||||||
const to = String(Number(from) + 1000 * 60 * 30); // 30 minutes
|
// const to = String(Number(from) + 1000 * 60 * 30); // 30 minutes
|
||||||
|
|
||||||
it('setLeverage()', async () => {
|
it('setLeverage()', async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
import { API_ERROR_CODE, FuturesClient } from '../../src';
|
import { FuturesClient } from '../../src';
|
||||||
import {
|
import { sucessEmptyResponseObject } from '../response.util';
|
||||||
notAuthenticatedError,
|
|
||||||
successResponseString,
|
|
||||||
sucessEmptyResponseObject,
|
|
||||||
} from '../response.util';
|
|
||||||
|
|
||||||
describe('Public Spot REST API Endpoints', () => {
|
describe('Public Spot REST API Endpoints', () => {
|
||||||
const api = new FuturesClient();
|
const api = new FuturesClient();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { API_ERROR_CODE, SpotClient } from '../../src';
|
import { SpotClient } from '../../src';
|
||||||
import { sucessEmptyResponseObject } from '../response.util';
|
import { sucessEmptyResponseObject } from '../response.util';
|
||||||
|
|
||||||
describe('Private Spot REST API GET Endpoints', () => {
|
describe('Private Spot REST API GET Endpoints', () => {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { API_ERROR_CODE, SpotClient } from '../../src';
|
import { SpotClient } from '../../src';
|
||||||
import {
|
import {
|
||||||
notAuthenticatedError,
|
|
||||||
successResponseString,
|
successResponseString,
|
||||||
sucessEmptyResponseObject,
|
sucessEmptyResponseObject,
|
||||||
} from '../response.util';
|
} from '../response.util';
|
||||||
@@ -9,8 +8,6 @@ describe('Public Spot REST API Endpoints', () => {
|
|||||||
const api = new SpotClient();
|
const api = new SpotClient();
|
||||||
|
|
||||||
const symbol = 'BTCUSDT_SPBL';
|
const symbol = 'BTCUSDT_SPBL';
|
||||||
const timestampOneHourAgo = new Date().getTime() / 1000 - 1000 * 60 * 60;
|
|
||||||
const from = Number(timestampOneHourAgo.toFixed(0));
|
|
||||||
|
|
||||||
// it('should throw for unauthenticated private calls', async () => {
|
// it('should throw for unauthenticated private calls', async () => {
|
||||||
// expect(() => api.getOpenOrders()).rejects.toMatchObject(
|
// expect(() => api.getOpenOrders()).rejects.toMatchObject(
|
||||||
|
|||||||
@@ -1,15 +1,10 @@
|
|||||||
import {
|
import {
|
||||||
WebsocketClient,
|
WebsocketClient,
|
||||||
WSClientConfigurableOptions,
|
|
||||||
WS_ERROR_ENUM,
|
WS_ERROR_ENUM,
|
||||||
WS_KEY_MAP,
|
WS_KEY_MAP,
|
||||||
|
WSClientConfigurableOptions,
|
||||||
} from '../src';
|
} from '../src';
|
||||||
import {
|
import { getSilentLogger, logAllEvents, waitForSocketEvent } from './ws.util';
|
||||||
getSilentLogger,
|
|
||||||
listenToSocketEvents,
|
|
||||||
logAllEvents,
|
|
||||||
waitForSocketEvent,
|
|
||||||
} from './ws.util';
|
|
||||||
|
|
||||||
describe.skip('Private Spot Websocket Client', () => {
|
describe.skip('Private Spot Websocket Client', () => {
|
||||||
const API_KEY = process.env.API_KEY_COM;
|
const API_KEY = process.env.API_KEY_COM;
|
||||||
@@ -50,7 +45,7 @@ describe.skip('Private Spot Websocket Client', () => {
|
|||||||
try {
|
try {
|
||||||
await Promise.all([wsResponsePromise]);
|
await Promise.all([wsResponsePromise]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// console.error()
|
console.error(e);
|
||||||
}
|
}
|
||||||
badClient.closeAll();
|
badClient.closeAll();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import {
|
import {
|
||||||
WebsocketClient,
|
WebsocketClient,
|
||||||
WSClientConfigurableOptions,
|
|
||||||
WS_KEY_MAP,
|
WS_KEY_MAP,
|
||||||
|
WSClientConfigurableOptions,
|
||||||
} from '../src';
|
} from '../src';
|
||||||
import { logAllEvents, getSilentLogger, waitForSocketEvent } from './ws.util';
|
import { getSilentLogger, logAllEvents, waitForSocketEvent } from './ws.util';
|
||||||
|
|
||||||
describe('Public Spot Websocket Client', () => {
|
describe('Public Spot Websocket Client', () => {
|
||||||
let wsClient: WebsocketClient;
|
let wsClient: WebsocketClient;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
import { WebsocketClient } from '../src';
|
import { WebsocketClient } from '../src';
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export function getSilentLogger(logHint?: string) {
|
export function getSilentLogger(logHint?: string) {
|
||||||
return {
|
return {
|
||||||
silly: () => {},
|
silly: () => {},
|
||||||
|
|||||||
Reference in New Issue
Block a user