feat(): add new spot market endpoints + params

This commit is contained in:
Tiago Siebler
2023-03-22 15:51:19 +00:00
parent b2bbd8097c
commit b92739de97
3 changed files with 66 additions and 3 deletions

View File

@@ -18,6 +18,9 @@ import {
GetSpotPlanOrdersParams, GetSpotPlanOrdersParams,
SpotPlanOrder, SpotPlanOrder,
GetHistoricPlanOrdersParams, GetHistoricPlanOrdersParams,
SpotMarketTrade,
GetHistoricTradesParams,
SpotVIPFeeRate,
} 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';
@@ -77,8 +80,28 @@ export class SpotClient extends BaseRestClient {
return this.get('/api/spot/v1/market/tickers'); return this.get('/api/spot/v1/market/tickers');
} }
/** Get Market Trades */ /** Get most recent trades (up to 500, 100 by default) */
getMarketTrades(symbol: string, limit?: string): Promise<APIResponse<any>> { getRecentTrades(
symbol: string,
limit?: string
): Promise<APIResponse<SpotMarketTrade[]>> {
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<APIResponse<SpotMarketTrade[]>> {
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<APIResponse<SpotMarketTrade[]>> {
return this.get('/api/spot/v1/market/fills', { symbol, limit }); 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 }); return this.get('/api/spot/v1/market/depth', { symbol, type, limit });
} }
/** Get VIP fee rates */
getVIPFeeRates(): Promise<APIResponse<SpotVIPFeeRate[]>> {
return this.get('/api/spot/v1/market/spot-vip-level');
}
/** /**
* *
* Wallet Endpoints * Wallet Endpoints
@@ -181,7 +209,8 @@ export class SpotClient extends BaseRestClient {
startTime: string, startTime: string,
endTime: string, endTime: string,
pageSize?: string, pageSize?: string,
pageNo?: string pageNo?: string,
clientOid?: string
): Promise<APIResponse<any>> { ): Promise<APIResponse<any>> {
return this.getPrivate('/api/spot/v1/wallet/withdrawal-list', { return this.getPrivate('/api/spot/v1/wallet/withdrawal-list', {
coin, coin,
@@ -189,6 +218,7 @@ export class SpotClient extends BaseRestClient {
endTime, endTime,
pageSize, pageSize,
pageNo, pageNo,
clientOid,
}); });
} }
@@ -225,6 +255,11 @@ export class SpotClient extends BaseRestClient {
return this.getPrivate('/api/spot/v1/account/assets', { coin }); return this.getPrivate('/api/spot/v1/account/assets', { coin });
} }
/** Get sub Account Spot Asset */
getSubAccountSpotAssets(): Promise<APIResponse<any>> {
return this.postPrivate('/api/spot/v1/account/sub-account-spot-assets');
}
/** Get Bills : get transaction detail flow */ /** Get Bills : get transaction detail flow */
getTransactionHistory(params?: { getTransactionHistory(params?: {
coinId?: number; coinId?: number;
@@ -244,6 +279,7 @@ export class SpotClient extends BaseRestClient {
after?: string; after?: string;
before?: string; before?: string;
limit?: number; limit?: number;
clientOid?: string;
}): Promise<APIResponse<any>> { }): Promise<APIResponse<any>> {
return this.getPrivate('/api/spot/v1/account/transferRecords', params); return this.getPrivate('/api/spot/v1/account/transferRecords', params);
} }

View File

@@ -1,5 +1,13 @@
import { OrderTimeInForce } from './shared'; 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 type WalletType = 'spot' | 'mix_usdt' | 'mix_usd';
export interface NewWalletTransfer { export interface NewWalletTransfer {

View File

@@ -21,6 +21,16 @@ export interface SymbolRules {
status: string; status: string;
} }
export interface SpotVIPFeeRate {
level: number;
dealAmount: string;
assetAmount: string;
takerFeeRate?: string;
makerFeeRate?: number;
withdrawAmount: string;
withdrawAmountUSDT: string;
}
export interface SpotOrderResult { export interface SpotOrderResult {
orderId: string; orderId: string;
clientOrderId: string; clientOrderId: string;
@@ -40,3 +50,12 @@ export interface SpotPlanOrder {
enterPointSource: string; enterPointSource: string;
cTime: number; cTime: number;
} }
export interface SpotMarketTrade {
symbol: string;
tradeId: string;
side: 'buy' | 'sell';
fillPrice: string;
fillQuantity: string;
fillTime: string;
}