Skip to content

Commit

Permalink
Merge pull request #71 from JJ-Cro/Update031024
Browse files Browse the repository at this point in the history
feat():  new endpoints, updated types, remove delisted applyTransactionDetailsArchive & getTransactionDetailsArchiveLink endpoints
  • Loading branch information
tiagosiebler authored Oct 3, 2024
2 parents 6601fe1 + d0f063f commit 8a261cf
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 34 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
82 changes: 56 additions & 26 deletions src/rest-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ import {
OrderPrecheckRequest,
AccountHistoryBill,
MaxGridQuantityRequest,
Announcement,
} from './types';
import { ASSET_BILL_TYPE } from './constants';

Expand Down Expand Up @@ -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<any[]> {
Expand Down Expand Up @@ -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<any[]> {
return this.getPrivate('/api/v5/trade/fills-archive', params);
}

/** Get easy convert currency list */
getEasyConvertCurrencies(): Promise<any> {
return this.getPrivate('/api/v5/trade/easy-convert-currency-list');
Expand Down Expand Up @@ -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;
}[]
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions src/types/rest/request/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -156,5 +156,3 @@ export interface SetMMPConfigRequest {
frozenInterval: string;
qtyLimit: string;
}


Empty file.
2 changes: 2 additions & 0 deletions src/types/rest/response/private-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ export interface AccountConfiguration {
perm: string;
mainUid: string;
discountType: '0' | '1';
enableSpotBorrow: boolean;
spotBorrowAutoRepay: boolean;
}

export interface AccountPositionModeResult {
Expand Down
5 changes: 3 additions & 2 deletions src/types/rest/response/private-trade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ export interface AlgoOrderDetailsResult {
algoClOrdId: string;
amendPxOnTriggerType: string;
cTime: string;
isTradeBorrowMode: boolean;
}

export interface AlgoOrderListItem {
Expand Down Expand Up @@ -301,6 +302,7 @@ export interface AlgoOrderListItem {
algoClOrdId: string;
triggerTime: string;
amendPxOnTriggerType: string;
isTradeBorrowMode: boolean;
}

export interface HistoricAlgoOrder {
Expand Down Expand Up @@ -351,12 +353,11 @@ export interface HistoricAlgoOrder {
triggerPxType: string;
triggerTime: string;
amendPxOnTriggerType: string;
isTradeBorrowMode: boolean;
}


export interface CancelAllAfterResponse {
triggerTime: string;
tag: string;
ts: string;
}

7 changes: 7 additions & 0 deletions src/types/rest/response/public-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,10 @@ export interface OptionTrades {
markPx: string;
ts: string;
}

export interface Announcement {
annType: string;
pTime: string;
title: string;
url: string;
}

0 comments on commit 8a261cf

Please sign in to comment.