Skip to content

Commit

Permalink
Merge pull request #67 from JJ-Cro/RelNotes9_9_24
Browse files Browse the repository at this point in the history
v1.4.4 feat(): added new endpoints, updated types
  • Loading branch information
tiagosiebler authored Sep 9, 2024
2 parents 9f6be5c + cc63742 commit a5bdb61
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 7 deletions.
5 changes: 5 additions & 0 deletions docs/endpointFunctionList.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ This table includes all endpoints from the official Exchange API docs and corres
| `getAccountPositionRisk()` | :closed_lock_with_key: | GET | `/api/v5/account/account-position-risk` |
| `getBills()` | :closed_lock_with_key: | GET | `/api/v5/account/bills` |
| `getBillsArchive()` | :closed_lock_with_key: | GET | `/api/v5/account/bills-archive` |
| `requestBillsHistoryDownloadLink()` | :closed_lock_with_key: | POST | `/api/v5/account/bills-history-archive` |
| `getRequestedBillsHistoryLink()` | :closed_lock_with_key: | GET | `/api/v5/account/bills-history-archive` |
| `getAccountConfiguration()` | :closed_lock_with_key: | GET | `/api/v5/account/config` |
| `setPositionMode()` | :closed_lock_with_key: | POST | `/api/v5/account/set-position-mode` |
| `setLeverage()` | :closed_lock_with_key: | POST | `/api/v5/account/set-leverage` |
Expand All @@ -65,6 +67,7 @@ This table includes all endpoints from the official Exchange API docs and corres
| `getLeverageEstimatedInfo()` | :closed_lock_with_key: | GET | `/api/v5/account/adjust-leverage-info` |
| `getMaxLoan()` | :closed_lock_with_key: | GET | `/api/v5/account/max-loan` |
| `getFeeRates()` | :closed_lock_with_key: | GET | `/api/v5/account/trade-fee` |
| `getFeeRatesV2()` | :closed_lock_with_key: | GET | `/api/v5/account/trade-fee` |
| `getInterestAccrued()` | :closed_lock_with_key: | GET | `/api/v5/account/interest-accrued` |
| `getInterestRate()` | :closed_lock_with_key: | GET | `/api/v5/account/interest-rate` |
| `setGreeksDisplayType()` | :closed_lock_with_key: | POST | `/api/v5/account/set-greeks` |
Expand Down Expand Up @@ -122,6 +125,7 @@ This table includes all endpoints from the official Exchange API docs and corres
| `cancelMassOrder()` | :closed_lock_with_key: | POST | `/api/v5/trade/mass-cancel` |
| `cancelAllAfter()` | :closed_lock_with_key: | POST | `/api/v5/trade/cancel-all-after` |
| `getAccountRateLimit()` | :closed_lock_with_key: | GET | `/api/v5/trade/account-rate-limit` |
| `submitOrderPrecheck()` | :closed_lock_with_key: | POST | `/api/v5/trade/order-precheck` |
| `placeAlgoOrder()` | :closed_lock_with_key: | POST | `/api/v5/trade/order-algo` |
| `cancelAlgoOrder()` | :closed_lock_with_key: | POST | `/api/v5/trade/cancel-algos` |
| `amendAlgoOrder()` | :closed_lock_with_key: | POST | `/api/v5/trade/amend-algos` |
Expand All @@ -147,6 +151,7 @@ This table includes all endpoints from the official Exchange API docs and corres
| `getGridAIParameter()` | | GET | `/api/v5/tradingBot/grid/ai-param` |
| `computeGridMinInvestment()` | | POST | `/api/v5/tradingBot/grid/min-investment` |
| `getRSIBackTesting()` | | GET | `/api/v5/tradingBot/public/rsi-back-testing` |
| `getMaxGridQuantity()` | | GET | `/api/v5/tradingBot/grid/grid-quantity` |
| `createSignal()` | :closed_lock_with_key: | POST | `/api/v5/tradingBot/signal/create-signal` |
| `getSignals()` | :closed_lock_with_key: | GET | `/api/v5/tradingBot/signal/signals` |
| `createSignalBot()` | :closed_lock_with_key: | POST | `/api/v5/tradingBot/signal/order-algo` |
Expand Down
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.3",
"version": "1.4.4",
"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
29 changes: 28 additions & 1 deletion src/rest-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ import {
SetMmpConfigResult,
OrderPrecheckRequest,
AccountHistoryBill,
MaxGridQuantityRequest,
} from './types';
import { ASSET_BILL_TYPE } from './constants';

Expand Down Expand Up @@ -423,18 +424,36 @@ export class RestClient extends BaseRestClient {
});
}

/**
* @deprecated - Use getFeeRatesV2() instead, which uses an object for all parameters.
* In future, getFeeRates() will also use an object for params (breaking change if you continue using getFeeRates() as is)
*/
getFeeRates(
instType: InstrumentType,
instId?: string,
uly?: string
uly?: string,
instFamily?: string,
ruleType?: string
): Promise<AccountFeeRate[]> {
return this.getPrivate('/api/v5/account/trade-fee', {
instType,
instId,
uly,
instFamily,
ruleType,
});
}

getFeeRatesV2(params: {
instType: InstrumentType;
instId?: string;
uly?: string;
instFamily?: string;
ruleType?: string;
}): Promise<AccountFeeRate[]> {
return this.getPrivate('/api/v5/account/trade-fee', params);
}

getInterestAccrued(params?: {
type?: '1' | '2';
ccy?: string;
Expand Down Expand Up @@ -1087,6 +1106,14 @@ export class RestClient extends BaseRestClient {
return this.get('/api/v5/tradingBot/public/rsi-back-testing', params);
}

getMaxGridQuantity(params: MaxGridQuantityRequest): Promise<
{
maxGridQty: string;
}[]
> {
return this.get('/api/v5/tradingBot/grid/grid-quantity', params);
}

/**
*
* Orderbook trading - Signal bot trading endpoints
Expand Down
10 changes: 9 additions & 1 deletion src/types/rest/request/grid-trading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export interface GridAlgoTrigger {
stopType?: '1' | '2';
}


export interface GridAlgoOrderRequest {
instId: string;
algoOrdType: GridAlgoOrderType;
Expand Down Expand Up @@ -65,3 +64,12 @@ export interface GetRSIBackTestingRequest {
triggerCond?: 'cross_up' | 'cross_down' | 'above' | 'below' | 'cross';
duration?: string;
}

export interface MaxGridQuantityRequest {
instId: string;
runType: '1' | '2';
algoOrdType: 'grid' | 'contract_grid';
maxPx: string;
minPx: string;
lever?: string;
}
8 changes: 8 additions & 0 deletions src/types/rest/response/private-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ export interface AccountBalanceDetail {
upl: string;
uplLiab: string;
stgyEq: string;
spotBal: string; // Spot balance. The unit is currency, e.g. BTC.
openAvgPx: string[]; // Spot average cost price. The unit is USD.
accAvgPx: string[]; // Spot accumulated cost price. The unit is USD.
spotUpl: string; // Spot unrealized profit and loss. The unit is USD.
spotUplRatio: string; // Spot unrealized profit and loss ratio.
totalPnl: string; // Spot accumulated profit and loss. The unit is USD.
totalPnlRatio: string; // Spot accumulated profit and loss ratio.
}

export interface AccountPosition {
Expand Down Expand Up @@ -256,6 +263,7 @@ export interface AccountFeeRate {
taker: string;
takerU: string;
ts: string;
ruleType: string;
}

export interface AccountIsolatedMode {
Expand Down
3 changes: 2 additions & 1 deletion src/types/rest/response/private-spread-trading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface UpdateSpreadOrderResponse {
sMsg: string;
}

export interface SpreadOrder {
export interface SpreadOrder {
instId: string;
ordId: string;
clOrdId: string;
Expand Down Expand Up @@ -50,6 +50,7 @@ export interface SpreadTradeLeg {
sz: string;
side: 'buy' | 'sell';
fee: string;
szCont: string;
feeCcy: string;
tradeId: string;
}
Expand Down
9 changes: 8 additions & 1 deletion src/types/rest/response/private-subaccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ export interface SubAccountBalanceDetail {
uTime: string;
upl: string;
uplLiab: string;
spotBal: string; // Spot balance. The unit is currency, e.g. BTC.
openAvgPx: string[]; // Spot average cost price. The unit is USD.
accAvgPx: string[]; // Spot accumulated cost price. The unit is USD.
spotUpl: string; // Spot unrealized profit and loss. The unit is USD.
spotUplRatio: string; // Spot unrealized profit and loss ratio.
totalPnl: string; // Spot accumulated profit and loss. The unit is USD.
totalPnlRatio: string; // Spot accumulated profit and loss ratio.
}

export interface SubAccountBalances {
Expand Down Expand Up @@ -75,4 +82,4 @@ export interface ManagedSubAccountTransfer {
subAcct: string;
subUid: string;
ts: string;
}
}

0 comments on commit a5bdb61

Please sign in to comment.