From d6718c4af52ef73ff5e99ace0ccb69a6d06cd5d9 Mon Sep 17 00:00:00 2001 From: t0chk <86585817+t0chk@users.noreply.github.com> Date: Sat, 25 Nov 2023 09:00:24 +0300 Subject: [PATCH 1/3] rest v1 spot & futures update - add plan order symbol canceling - fix candles data params (spot & futures) - fix futures filter data (data in api-doc dither from real request! --- package.json | 2 +- src/futures-client.ts | 20 +++++++++++--- src/spot-client.ts | 11 +++++--- src/types/request/v1/futuresV1.ts | 2 ++ src/types/request/v1/spotV1.ts | 44 ++++++++++++++++++++----------- src/types/response/futures.ts | 39 ++++++++++++++++----------- 6 files changed, 80 insertions(+), 38 deletions(-) diff --git a/package.json b/package.json index 8b8b2a5..4cc997b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bitget-api", - "version": "2.0.2", + "version": "2.0.3", "description": "Node.js & JavaScript SDK for Bitget REST APIs & WebSockets, with TypeScript & end-to-end tests.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/futures-client.ts b/src/futures-client.ts index d6d82b4..2426e93 100644 --- a/src/futures-client.ts +++ b/src/futures-client.ts @@ -26,6 +26,7 @@ import { FuturesKlineInterval, FuturesHistoricPositions, ModifyFuturesOrder, + FuturesCandleData, } from './types'; import { REST_CLIENT_TYPE_ENUM } from './util'; import BaseRestClient from './util/BaseRestClient'; @@ -104,14 +105,16 @@ export class FuturesClient extends BaseRestClient { symbol: string, granularity: FuturesKlineInterval, startTime: string, - endTime: string, + endTime: string, limit?: string, - ): Promise { + kLineType?: 'market' | 'mark' | 'index' + ): Promise { return this.get('/api/mix/v1/market/candles', { symbol, granularity, startTime, endTime, + kLineType, limit, }); } @@ -559,13 +562,24 @@ export class FuturesClient extends BaseRestClient { return this.postPrivate('/api/mix/v1/plan/modifyTPSLPlan', params); } - /** Cancel Plan Order TPSL */ + /** Cancel Plan Order (TPSL) */ cancelPlanOrderTPSL( params: CancelFuturesPlanTPSL, ): Promise> { return this.postPrivate('/api/mix/v1/plan/cancelPlan', params); } + /** Cancel Symbol Plan Order (TPSL) */ + cancelSymbolPlanOrders( + symbol: string, + planType: FuturesPlanType, + ): Promise> { + return this.postPrivate('/api/mix/v1/plan/cancelSymbolPlan', { + symbol, + planType, + }); + } + /** Cancel All Trigger Order (TPSL) */ cancelAllPlanOrders( productType: FuturesProductType, diff --git a/src/spot-client.ts b/src/spot-client.ts index a500a26..2fd8331 100644 --- a/src/spot-client.ts +++ b/src/spot-client.ts @@ -21,6 +21,7 @@ import { GetHistoricTradesParams, VIPFeeRate, SpotKlineInterval, + SpotCandleData, } from './types'; import { REST_CLIENT_TYPE_ENUM } from './util'; import BaseRestClient from './util/BaseRestClient'; @@ -111,12 +112,16 @@ export class SpotClient extends BaseRestClient { getCandles( symbol: string, period: SpotKlineInterval, - pagination?: Pagination, - ): Promise> { + limit?: string, + after?: string, + before?: string, + ): Promise> { return this.get('/api/spot/v1/market/candles', { symbol, period, - ...pagination, + limit, + after, + before }); } diff --git a/src/types/request/v1/futuresV1.ts b/src/types/request/v1/futuresV1.ts index e93fc0d..2d6a8aa 100644 --- a/src/types/request/v1/futuresV1.ts +++ b/src/types/request/v1/futuresV1.ts @@ -215,3 +215,5 @@ export interface HistoricPlanOrderTPSLRequest { isPre?: boolean; isPlan?: string; } + +export type FuturesCandleData = string[6]; \ No newline at end of file diff --git a/src/types/request/v1/spotV1.ts b/src/types/request/v1/spotV1.ts index 79b758b..032811c 100644 --- a/src/types/request/v1/spotV1.ts +++ b/src/types/request/v1/spotV1.ts @@ -3,22 +3,23 @@ import { OrderTimeInForce } from '../shared'; export type WalletType = 'spot' | 'mix_usdt' | 'mix_usd'; export type SpotKlineInterval = - | '1min' - | '5min' - | '15min' - | '30min' - | '1h' - | '4h' - | '6h' - | '12h' - | '1M' - | '1W' - | '1week' - | '6Hutc' - | '12Hutc' - | '1Dutc' - | '3Dutc' - | '1Wutc' + | '1min' + | '5min' + | '15min' + | '30min' + | '1h' + | '4h' + | '6h' + | '12h' + | '1day' + | '3day' + | '1week' + | '1M' + | '6Hutc' + | '12Hutc' + | '1Dutc' + | '3Dutc' + | '1Wutc' | '1Mutc'; export interface NewWalletTransfer { @@ -124,3 +125,14 @@ export interface GetHistoricPlanOrdersParams { startTime: string; endTime: string; } + +export interface SpotCandleData { + open: string + high: string + low: string + close: string + quoteVol: string + baseVol: string + usdtVol: string + ts: string +} \ No newline at end of file diff --git a/src/types/response/futures.ts b/src/types/response/futures.ts index f195bd4..cfb6504 100644 --- a/src/types/response/futures.ts +++ b/src/types/response/futures.ts @@ -32,21 +32,30 @@ export interface FuturesAccount { } export interface FuturesSymbolRule { - baseCoin: string; - buyLimitPriceRatio: string; - feeRateUpRatio: string; - makerFeeRate: string; - minTradeNum: string; - openCostUpRatio: string; - priceEndStep: string; - pricePlace: string; - quoteCoin: string; - sellLimitPriceRatio: string; - sizeMultiplier: string; - supportMarginCoins: string[]; - symbol: string; - takerFeeRate: string; - volumePlace: string; + baseCoin: string + buyLimitPriceRatio: string + feeRateUpRatio: string + limitOpenTime: string + maintainTime: string + makerFeeRate: string + maxOrderNum: string + maxPositionNum: string + minTradeNum: string + minTradeUSDT: string + offTime: string + openCostUpRatio: string + priceEndStep: string + pricePlace: string + quoteCoin: string + sellLimitPriceRatio: string + sizeMultiplier: string + supportMarginCoins: string[] + symbol: string + symbolName: string + symbolStatus: string + symbolType: string + takerFeeRate: string + volumePlace: string } export interface FuturesPosition { From 025498a5e44a9120e906df1725ccc1bb376ec7de Mon Sep 17 00:00:00 2001 From: t0chk <86585817+t0chk@users.noreply.github.com> Date: Sat, 25 Nov 2023 13:54:15 +0300 Subject: [PATCH 2/3] add semicolons --- src/types/request/v1/spotV1.ts | 16 ++++++------ src/types/response/futures.ts | 48 +++++++++++++++++----------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/types/request/v1/spotV1.ts b/src/types/request/v1/spotV1.ts index 032811c..0009c4a 100644 --- a/src/types/request/v1/spotV1.ts +++ b/src/types/request/v1/spotV1.ts @@ -127,12 +127,12 @@ export interface GetHistoricPlanOrdersParams { } export interface SpotCandleData { - open: string - high: string - low: string - close: string - quoteVol: string - baseVol: string - usdtVol: string - ts: string + open: string; + high: string; + low: string; + close: string; + quoteVol: string; + baseVol: string; + usdtVol: string; + ts: string; } \ No newline at end of file diff --git a/src/types/response/futures.ts b/src/types/response/futures.ts index cfb6504..fb3b4f3 100644 --- a/src/types/response/futures.ts +++ b/src/types/response/futures.ts @@ -32,30 +32,30 @@ export interface FuturesAccount { } export interface FuturesSymbolRule { - baseCoin: string - buyLimitPriceRatio: string - feeRateUpRatio: string - limitOpenTime: string - maintainTime: string - makerFeeRate: string - maxOrderNum: string - maxPositionNum: string - minTradeNum: string - minTradeUSDT: string - offTime: string - openCostUpRatio: string - priceEndStep: string - pricePlace: string - quoteCoin: string - sellLimitPriceRatio: string - sizeMultiplier: string - supportMarginCoins: string[] - symbol: string - symbolName: string - symbolStatus: string - symbolType: string - takerFeeRate: string - volumePlace: string + baseCoin: string; + buyLimitPriceRatio: string; + feeRateUpRatio: string; + limitOpenTime: string; + maintainTime: string; + makerFeeRate: string; + maxOrderNum: string; + maxPositionNum: string; + minTradeNum: string; + minTradeUSDT: string; + offTime: string; + openCostUpRatio: string; + priceEndStep: string; + pricePlace: string; + quoteCoin: string; + sellLimitPriceRatio: string; + sizeMultiplier: string; + supportMarginCoins: string[]; + symbol: string; + symbolName: string; + symbolStatus: string; + symbolType: string; + takerFeeRate: string; + volumePlace: string; } export interface FuturesPosition { From 3e91b99b68c6fe2a39b407e755a795ae280d1948 Mon Sep 17 00:00:00 2001 From: t0chk <86585817+t0chk@users.noreply.github.com> Date: Sat, 2 Dec 2023 10:45:56 +0300 Subject: [PATCH 3/3] revert to pagination and add js-doc to futures --- src/spot-client.ts | 8 ++------ src/types/request/v1/futuresV1.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/spot-client.ts b/src/spot-client.ts index 2fd8331..975e976 100644 --- a/src/spot-client.ts +++ b/src/spot-client.ts @@ -112,16 +112,12 @@ export class SpotClient extends BaseRestClient { getCandles( symbol: string, period: SpotKlineInterval, - limit?: string, - after?: string, - before?: string, + pagination?: Pagination, ): Promise> { return this.get('/api/spot/v1/market/candles', { symbol, period, - limit, - after, - before + ...pagination, }); } diff --git a/src/types/request/v1/futuresV1.ts b/src/types/request/v1/futuresV1.ts index 2d6a8aa..527e967 100644 --- a/src/types/request/v1/futuresV1.ts +++ b/src/types/request/v1/futuresV1.ts @@ -216,4 +216,14 @@ export interface HistoricPlanOrderTPSLRequest { isPlan?: string; } +/** + * @typedef {string[6]} FuturesCandleData + * @property {Array[0]} Timestamp in milliseconds + * @property {Array[1]} Opening price + * @property {Array[2]} Highest price + * @property {Array[3]} Lowest price + * @property {Array[4]} Closing price - Value of the latest candle stick might change + * @property {Array[5]} Base currency trading volume + * @property {Array[6]} Quote currency trading volume + */ export type FuturesCandleData = string[6]; \ No newline at end of file