Skip to content

Commit

Permalink
Merge pull request #46 from SebastianBoehler/master
Browse files Browse the repository at this point in the history
v1.3.1: chore: economic calendar endpoint and types
  • Loading branch information
tiagosiebler authored Feb 26, 2024
2 parents 7651721 + 504452a commit b41d572
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 17 deletions.
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.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",
Expand Down
39 changes: 23 additions & 16 deletions src/rest-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ import {
AmendAlgoOrderRequest,
AmendAlgoOrderResult,
AlgoOrderRequest,
EconomicCalendarData,
UnitConvertData,
EconomicCalendarRequest,
UnitConvertRequest,
} from './types';
import { ASSET_BILL_TYPE } from './constants';

Expand Down Expand Up @@ -1238,10 +1242,16 @@ export class RestClient extends BaseRestClient {
return this.get('/api/v5/public/insurance-fund', params);
}

getUnitConvert(params: any): Promise<any[]> {
getUnitConvert(params: UnitConvertRequest): Promise<UnitConvertData[]> {
return this.get('/api/v5/public/convert-contract-coin', params);
}

getEconomicCalendar(
params: EconomicCalendarRequest
): Promise<EconomicCalendarData[]> {
return this.getPrivate('/api/v5/public/economic-calendar', params);
}

/**
*
* Trading data endpoints (public)
Expand Down Expand Up @@ -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<any[]> {
return this.postPrivate('/api/v5/broker/nd/create-subaccount', params);
}

deleteSubAccount(params: {
subAcct:string,
}): Promise<any[]> {
deleteSubAccount(params: { subAcct: string }): Promise<any[]> {
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<any[]> {
return this.postPrivate('/api/v5/broker/nd/subaccount/apikey', params);
}

}
}
1 change: 1 addition & 0 deletions src/types/rest/request/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from './subaccount';
export * from './trade';
export * from './block-trading';
export * from './grid-trading';
export * from './public';
16 changes: 16 additions & 0 deletions src/types/rest/request/public.ts
Original file line number Diff line number Diff line change
@@ -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';
}
26 changes: 26 additions & 0 deletions src/types/rest/response/public-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

0 comments on commit b41d572

Please sign in to comment.