From 8da191b913843a1567c6e97565f31fb5bfc64c45 Mon Sep 17 00:00:00 2001 From: Jerko J <83344666+JJ-Cro@users.noreply.github.com> Date: Thu, 3 Oct 2024 14:49:57 +0200 Subject: [PATCH 1/2] feat(): added new endpoints, updated types --- package.json | 2 +- src/rest-client.ts | 82 +++++++++++++++------- src/types/rest/request/account.ts | 4 +- src/types/rest/request/announement.ts | 0 src/types/rest/response/private-account.ts | 2 + src/types/rest/response/private-trade.ts | 5 +- src/types/rest/response/public-data.ts | 7 ++ 7 files changed, 70 insertions(+), 32 deletions(-) create mode 100644 src/types/rest/request/announement.ts diff --git a/package.json b/package.json index 533766d..2994f47 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "okx-api", - "version": "1.4.5", + "version": "1.4.6", "description": "Complete & robust Node.js SDK for OKX's REST APIs and WebSockets, with TypeScript & end-to-end tests", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/rest-client.ts b/src/rest-client.ts index b27a317..06e43e8 100644 --- a/src/rest-client.ts +++ b/src/rest-client.ts @@ -247,6 +247,7 @@ import { OrderPrecheckRequest, AccountHistoryBill, MaxGridQuantityRequest, + Announcement, } from './types'; import { ASSET_BILL_TYPE } from './constants'; @@ -621,6 +622,32 @@ export class RestClient extends BaseRestClient { ); } + convertFixedLoanToMarketLoan(params: { ordId: string }): Promise< + { + ordId: string; + }[] + > { + return this.postPrivate( + '/api/v5/account/fixed-loan/convert-to-market-loan', + params + ); + } + + reduceFixedLoanLiabilities(params: { + ordId: string; + pendingRepay: boolean; + }): Promise< + { + ordId: string; + pendingRepay: boolean; + }[] + > { + return this.postPrivate( + '/api/v5/account/fixed-loan/reduce-liabilities', + params + ); + } + getFixedLoanBorrowOrders( params: GetFixedLoanBorrowingOrdersListRequest ): Promise { @@ -774,31 +801,6 @@ export class RestClient extends BaseRestClient { return this.getPrivate('/api/v5/trade/fills-history', params); } - /** - * @deprecated - use requestBillsHistoryDownloadLink and getRequestedBillsHistoryLink - */ - applyTransactionDetailsArchive(params: { - year: string; - quarter: 'Q1' | 'Q2' | 'Q3' | 'Q4'; - }): Promise< - { - result: string; - ts: string; - }[] - > { - return this.postPrivate('/api/v5/trade/fills-archive', params); - } - - /** - * @deprecated - use requestBillsHistoryDownloadLink and getRequestedBillsHistoryLink - */ - getTransactionDetailsArchiveLink(params: { - year: string; - quarter: 'Q1' | 'Q2' | 'Q3' | 'Q4'; - }): Promise { - return this.getPrivate('/api/v5/trade/fills-archive', params); - } - /** Get easy convert currency list */ getEasyConvertCurrencies(): Promise { return this.getPrivate('/api/v5/trade/easy-convert-currency-list'); @@ -858,7 +860,11 @@ export class RestClient extends BaseRestClient { return this.getPrivate('/api/v5/trade/one-click-repay-history', params); } - cancelMassOrder(params: { instType: string; instFamily: string }): Promise< + cancelMassOrder(params: { + instType: string; + instFamily: string; + lockInterval?: string; + }): Promise< { result: boolean; }[] @@ -2788,6 +2794,30 @@ export class RestClient extends BaseRestClient { return this.get('/api/v5/system/status', { state }); } + /** + * + * Announcement endpoints + * + */ + + getAnnouncements(params?: { annType?: string; page?: string }): Promise< + { + totalPage: string; + details: Announcement[]; + }[] + > { + return this.get('/api/v5/support/announcements', params); + } + + getAnnouncementTypes(): Promise< + { + annType: string; + annTypeDesc: string; + }[] + > { + return this.get('/api/v5/support/announcement-types'); + } + /** * * Broker endpoints (private) diff --git a/src/types/rest/request/account.ts b/src/types/rest/request/account.ts index 93a9f99..d6f5b22 100644 --- a/src/types/rest/request/account.ts +++ b/src/types/rest/request/account.ts @@ -130,7 +130,7 @@ export interface UpdateFixedLoanBorrowingOrderRequest { export interface GetFixedLoanBorrowingOrdersListRequest { ordId?: string; ccy?: string; - state?: '1' | '2' | '3' | '4' | '5' | '6' | '7'; + state?: string; after?: string; before?: string; limit?: string; @@ -156,5 +156,3 @@ export interface SetMMPConfigRequest { frozenInterval: string; qtyLimit: string; } - - diff --git a/src/types/rest/request/announement.ts b/src/types/rest/request/announement.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/types/rest/response/private-account.ts b/src/types/rest/response/private-account.ts index b9aa88d..d0cee2a 100644 --- a/src/types/rest/response/private-account.ts +++ b/src/types/rest/response/private-account.ts @@ -193,6 +193,8 @@ export interface AccountConfiguration { perm: string; mainUid: string; discountType: '0' | '1'; + enableSpotBorrow: boolean; + spotBorrowAutoRepay: boolean; } export interface AccountPositionModeResult { diff --git a/src/types/rest/response/private-trade.ts b/src/types/rest/response/private-trade.ts index 6e4e979..c94e60e 100644 --- a/src/types/rest/response/private-trade.ts +++ b/src/types/rest/response/private-trade.ts @@ -251,6 +251,7 @@ export interface AlgoOrderDetailsResult { algoClOrdId: string; amendPxOnTriggerType: string; cTime: string; + isTradeBorrowMode: boolean; } export interface AlgoOrderListItem { @@ -301,6 +302,7 @@ export interface AlgoOrderListItem { algoClOrdId: string; triggerTime: string; amendPxOnTriggerType: string; + isTradeBorrowMode: boolean; } export interface HistoricAlgoOrder { @@ -351,12 +353,11 @@ export interface HistoricAlgoOrder { triggerPxType: string; triggerTime: string; amendPxOnTriggerType: string; + isTradeBorrowMode: boolean; } - export interface CancelAllAfterResponse { triggerTime: string; tag: string; ts: string; } - diff --git a/src/types/rest/response/public-data.ts b/src/types/rest/response/public-data.ts index bd1f665..fae879a 100644 --- a/src/types/rest/response/public-data.ts +++ b/src/types/rest/response/public-data.ts @@ -180,3 +180,10 @@ export interface OptionTrades { markPx: string; ts: string; } + +export interface Announcement { + annType: string; + pTime: string; + title: string; + url: string; +} From d0f063f5d94d6a8a6e7ae6ac7e37ef7733b18288 Mon Sep 17 00:00:00 2001 From: Jerko J <83344666+JJ-Cro@users.noreply.github.com> Date: Thu, 3 Oct 2024 14:50:32 +0200 Subject: [PATCH 2/2] chore(): bumped version --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index fd345d1..eda8d52 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "okx-api", - "version": "1.4.5", + "version": "1.4.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "okx-api", - "version": "1.4.5", + "version": "1.4.6", "license": "MIT", "dependencies": { "axios": "^1.6.7",