diff --git a/package.json b/package.json index 4f3afd7..f1fdd7c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "okx-api", - "version": "1.3.0", + "version": "1.3.1", "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 da34da8..9a6d5a7 100644 --- a/src/rest-client.ts +++ b/src/rest-client.ts @@ -103,6 +103,10 @@ import { AmendAlgoOrderRequest, AmendAlgoOrderResult, AlgoOrderRequest, + EconomicCalendarData, + UnitConvertData, + EconomicCalendarRequest, + UnitConvertRequest, } from './types'; import { ASSET_BILL_TYPE } from './constants'; @@ -1238,10 +1242,16 @@ export class RestClient extends BaseRestClient { return this.get('/api/v5/public/insurance-fund', params); } - getUnitConvert(params: any): Promise { + getUnitConvert(params: UnitConvertRequest): Promise { return this.get('/api/v5/public/convert-contract-coin', params); } + getEconomicCalendar( + params: EconomicCalendarRequest + ): Promise { + return this.getPrivate('/api/v5/public/economic-calendar', params); + } + /** * * Trading data endpoints (public) @@ -1356,28 +1366,25 @@ export class RestClient extends BaseRestClient { } createSubAccount(params: { - subAcct:string, - label?:string, - clientIP?:string, - mainAcct: string, + subAcct: string; + label?: string; + clientIP?: string; + mainAcct: string; }): Promise { return this.postPrivate('/api/v5/broker/nd/create-subaccount', params); } - deleteSubAccount(params: { - subAcct:string, - }): Promise { + deleteSubAccount(params: { subAcct: string }): Promise { return this.postPrivate('/api/v5/broker/nd/delete-subaccount', params); - } + } createSubAccountAPIKey(params: { - subAcct:string, - label: string, - passphrase: string, - ip?:string, - perm?:string, + subAcct: string; + label: string; + passphrase: string; + ip?: string; + perm?: string; }): Promise { return this.postPrivate('/api/v5/broker/nd/subaccount/apikey', params); - } - + } } diff --git a/src/types/rest/request/index.ts b/src/types/rest/request/index.ts index a1e1e22..304843a 100644 --- a/src/types/rest/request/index.ts +++ b/src/types/rest/request/index.ts @@ -6,3 +6,4 @@ export * from './subaccount'; export * from './trade'; export * from './block-trading'; export * from './grid-trading'; +export * from './public'; diff --git a/src/types/rest/request/public.ts b/src/types/rest/request/public.ts new file mode 100644 index 0000000..961524c --- /dev/null +++ b/src/types/rest/request/public.ts @@ -0,0 +1,16 @@ +export interface EconomicCalendarRequest { + region?: string; + importance?: '1' | '2' | '3'; + before?: string; + after?: string; + limit?: string; +} + +export interface UnitConvertRequest { + type?: '1' | '2'; + instId: string; + sz: string; + px?: string; + unit?: 'coin' | 'usds'; + opType: 'open' | 'close'; +} diff --git a/src/types/rest/response/public-data.ts b/src/types/rest/response/public-data.ts index 8cc9aa7..e1ff702 100644 --- a/src/types/rest/response/public-data.ts +++ b/src/types/rest/response/public-data.ts @@ -110,3 +110,29 @@ export interface Instrument { maxTriggerSz: string; maxStopSz: string; } + +export interface EconomicCalendarData { + calendarId: string; + date: string; + region: string; + category: string; + event: string; + refDate: string; + actual: string; + previous: string; + forecast: string; + dateSpan: string; + importance: string; + uTime: string; + prevInitial: string; + ccy: string; + unit: string; +} + +export interface UnitConvertData { + type: '1' | '2'; + instId: string; + px: string; + sz: string; + unit: 'coin' | 'usds'; +}