From b92739de979490fa0339cb69c8d8fca2acd0d120 Mon Sep 17 00:00:00 2001 From: Tiago Siebler Date: Wed, 22 Mar 2023 15:51:19 +0000 Subject: [PATCH] feat(): add new spot market endpoints + params --- src/spot-client.ts | 42 +++++++++++++++++++++++++++++++++++--- src/types/request/spot.ts | 8 ++++++++ src/types/response/spot.ts | 19 +++++++++++++++++ 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/src/spot-client.ts b/src/spot-client.ts index a2b7417..a3079ec 100644 --- a/src/spot-client.ts +++ b/src/spot-client.ts @@ -18,6 +18,9 @@ import { GetSpotPlanOrdersParams, SpotPlanOrder, GetHistoricPlanOrdersParams, + SpotMarketTrade, + GetHistoricTradesParams, + SpotVIPFeeRate, } from './types'; import { REST_CLIENT_TYPE_ENUM } from './util'; import BaseRestClient from './util/BaseRestClient'; @@ -77,8 +80,28 @@ export class SpotClient extends BaseRestClient { return this.get('/api/spot/v1/market/tickers'); } - /** Get Market Trades */ - getMarketTrades(symbol: string, limit?: string): Promise> { + /** Get most recent trades (up to 500, 100 by default) */ + getRecentTrades( + symbol: string, + limit?: string + ): Promise> { + return this.get('/api/spot/v1/market/fills', { symbol, limit }); + } + + /** Get historic trades, up to 30 days at a time. Same-parameter responses are cached for 10 minutes. */ + getHistoricTrades( + params: GetHistoricTradesParams + ): Promise> { + return this.get('/api/spot/v1/market/fills-history', params); + } + + /** + * @deprecated use getRecentTrades() instead. This method will be removed soon. + */ + getMarketTrades( + symbol: string, + limit?: string + ): Promise> { return this.get('/api/spot/v1/market/fills', { symbol, limit }); } @@ -104,6 +127,11 @@ export class SpotClient extends BaseRestClient { return this.get('/api/spot/v1/market/depth', { symbol, type, limit }); } + /** Get VIP fee rates */ + getVIPFeeRates(): Promise> { + return this.get('/api/spot/v1/market/spot-vip-level'); + } + /** * * Wallet Endpoints @@ -181,7 +209,8 @@ export class SpotClient extends BaseRestClient { startTime: string, endTime: string, pageSize?: string, - pageNo?: string + pageNo?: string, + clientOid?: string ): Promise> { return this.getPrivate('/api/spot/v1/wallet/withdrawal-list', { coin, @@ -189,6 +218,7 @@ export class SpotClient extends BaseRestClient { endTime, pageSize, pageNo, + clientOid, }); } @@ -225,6 +255,11 @@ export class SpotClient extends BaseRestClient { return this.getPrivate('/api/spot/v1/account/assets', { coin }); } + /** Get sub Account Spot Asset */ + getSubAccountSpotAssets(): Promise> { + return this.postPrivate('/api/spot/v1/account/sub-account-spot-assets'); + } + /** Get Bills : get transaction detail flow */ getTransactionHistory(params?: { coinId?: number; @@ -244,6 +279,7 @@ export class SpotClient extends BaseRestClient { after?: string; before?: string; limit?: number; + clientOid?: string; }): Promise> { return this.getPrivate('/api/spot/v1/account/transferRecords', params); } diff --git a/src/types/request/spot.ts b/src/types/request/spot.ts index 071f2ee..3bea3ed 100644 --- a/src/types/request/spot.ts +++ b/src/types/request/spot.ts @@ -1,5 +1,13 @@ import { OrderTimeInForce } from './shared'; +export interface GetHistoricTradesParams { + symbol: string; + limit?: string; + tradeId?: string; + startTime?: string; + endTime?: string; +} + export type WalletType = 'spot' | 'mix_usdt' | 'mix_usd'; export interface NewWalletTransfer { diff --git a/src/types/response/spot.ts b/src/types/response/spot.ts index 460fbcb..dee7775 100644 --- a/src/types/response/spot.ts +++ b/src/types/response/spot.ts @@ -21,6 +21,16 @@ export interface SymbolRules { status: string; } +export interface SpotVIPFeeRate { + level: number; + dealAmount: string; + assetAmount: string; + takerFeeRate?: string; + makerFeeRate?: number; + withdrawAmount: string; + withdrawAmountUSDT: string; +} + export interface SpotOrderResult { orderId: string; clientOrderId: string; @@ -40,3 +50,12 @@ export interface SpotPlanOrder { enterPointSource: string; cTime: number; } + +export interface SpotMarketTrade { + symbol: string; + tradeId: string; + side: 'buy' | 'sell'; + fillPrice: string; + fillQuantity: string; + fillTime: string; +}