okx-api 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -168
- package/lib/index.d.ts +2 -1
- package/lib/index.js +17 -13
- package/lib/index.js.map +1 -1
- package/lib/rest-client.d.ts +315 -0
- package/lib/rest-client.js +635 -0
- package/lib/rest-client.js.map +1 -0
- package/lib/types/rest/index.d.ts +3 -0
- package/lib/types/rest/index.js +20 -0
- package/lib/types/rest/index.js.map +1 -0
- package/lib/types/rest/request/index.d.ts +4 -0
- package/lib/types/rest/request/index.js +21 -0
- package/lib/types/rest/request/index.js.map +1 -0
- package/lib/types/rest/request/private-account.d.ts +16 -0
- package/lib/types/rest/request/private-account.js +3 -0
- package/lib/types/rest/request/private-account.js.map +1 -0
- package/lib/types/rest/request/private-block-trading.d.ts +60 -0
- package/lib/types/rest/request/private-block-trading.js +3 -0
- package/lib/types/rest/request/private-block-trading.js.map +1 -0
- package/lib/types/rest/request/private-trade.d.ts +111 -0
- package/lib/types/rest/request/private-trade.js +3 -0
- package/lib/types/rest/request/private-trade.js.map +1 -0
- package/lib/types/rest/request/shared.d.ts +7 -0
- package/lib/types/rest/request/shared.js +3 -0
- package/lib/types/rest/request/shared.js.map +1 -0
- package/lib/types/rest/response/index.d.ts +6 -0
- package/lib/types/rest/response/index.js +23 -0
- package/lib/types/rest/response/index.js.map +1 -0
- package/lib/types/rest/response/private-account.d.ts +213 -0
- package/lib/types/rest/response/private-account.js +3 -0
- package/lib/types/rest/response/private-account.js.map +1 -0
- package/lib/types/rest/response/private-block-trading.d.ts +89 -0
- package/lib/types/rest/response/private-block-trading.js +3 -0
- package/lib/types/rest/response/private-block-trading.js.map +1 -0
- package/lib/types/rest/response/private-funding.d.ts +67 -0
- package/lib/types/rest/response/private-funding.js +3 -0
- package/lib/types/rest/response/private-funding.js.map +1 -0
- package/lib/types/rest/response/private-subaccount.d.ts +56 -0
- package/lib/types/rest/response/private-subaccount.js +3 -0
- package/lib/types/rest/response/private-subaccount.js.map +1 -0
- package/lib/types/rest/response/private-trade.d.ts +235 -0
- package/lib/types/rest/response/private-trade.js +3 -0
- package/lib/types/rest/response/private-trade.js.map +1 -0
- package/lib/types/rest/response/public-data.d.ts +70 -0
- package/lib/types/rest/response/public-data.js +3 -0
- package/lib/types/rest/response/public-data.js.map +1 -0
- package/lib/types/rest/shared.d.ts +36 -0
- package/lib/types/rest/shared.js +3 -0
- package/lib/types/rest/shared.js.map +1 -0
- package/lib/util/BaseRestClient.d.ts +35 -0
- package/lib/util/BaseRestClient.js +204 -0
- package/lib/util/BaseRestClient.js.map +1 -0
- package/lib/util/browser-support.d.ts +1 -0
- package/lib/util/browser-support.js +24 -0
- package/lib/util/browser-support.js.map +1 -0
- package/lib/util/node-support.d.ts +1 -0
- package/lib/util/node-support.js +9 -0
- package/lib/util/node-support.js.map +1 -0
- package/lib/util/requestUtils.d.ts +17 -0
- package/lib/util/requestUtils.js +52 -0
- package/lib/util/requestUtils.js.map +1 -0
- package/lib/util/typeGuards.d.ts +2 -0
- package/lib/util/typeGuards.js +14 -0
- package/lib/util/typeGuards.js.map +1 -0
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
[1]: https://www.npmjs.com/package/okx-api
|
|
8
8
|
|
|
9
|
-
WARNING: This package is still early beta
|
|
9
|
+
**WARNING: This package is still early beta! Expect breaking changes until this sees a major release.**
|
|
10
|
+
|
|
11
|
+
If you want to stay informed when this may be ready for testing, please get in touch via telegram.
|
|
10
12
|
|
|
11
13
|
Node.js connector for the okx APIs and WebSockets, with TypeScript & browser support.
|
|
12
14
|
|
|
@@ -17,6 +19,17 @@ Node.js connector for the okx APIs and WebSockets, with TypeScript & browser sup
|
|
|
17
19
|
- Issues? Check the [issues tab](https://github.com/tiagosiebler/okx-api/issues).
|
|
18
20
|
- Discuss & collaborate with other node devs? Join our [Node.js Algo Traders](https://t.me/nodetraders) engineering community on telegram.
|
|
19
21
|
|
|
22
|
+
## Related projects
|
|
23
|
+
- Try my connectors:
|
|
24
|
+
- [ftx-api](https://www.npmjs.com/package/ftx-api)
|
|
25
|
+
- [bybit-api](https://www.npmjs.com/package/bybit-api)
|
|
26
|
+
- [okx-api](https://www.npmjs.com/package/okx-api)
|
|
27
|
+
- [binance](https://www.npmjs.com/package/binance)
|
|
28
|
+
- Try my misc utilities:
|
|
29
|
+
- [orderbooks](https://www.npmjs.com/package/orderbooks)
|
|
30
|
+
- Check out my examples:
|
|
31
|
+
- [awesome-crypto-examples](https://github.com/tiagosiebler/awesome-crypto-examples)
|
|
32
|
+
|
|
20
33
|
## Documentation
|
|
21
34
|
Most methods accept JS objects. These can be populated using parameters specified by okx's API documentation.
|
|
22
35
|
- [OKX API Documentation](https://www.okx.com/docs-v5/en/#rest-api).
|
|
@@ -24,8 +37,8 @@ Most methods accept JS objects. These can be populated using parameters specifie
|
|
|
24
37
|
## Structure
|
|
25
38
|
This project uses typescript. Resources are stored in 3 key structures:
|
|
26
39
|
- [src](./src) - the whole connector written in typescript
|
|
27
|
-
- [lib](./lib) - the javascript version of the project (compiled from typescript). This should not be edited directly, as it will be overwritten with each release.
|
|
28
|
-
- [dist](./dist) - the packed bundle of the project for use in browser environments.
|
|
40
|
+
- [lib](./lib) - the javascript version of the project (compiled from typescript). This should not be edited directly, as it will be overwritten with each release. This is also the version published to npm.
|
|
41
|
+
- [dist](./dist) - the packed bundle of the project for use in browser environments (manual, using webpack).
|
|
29
42
|
- [examples](./examples) - some implementation examples & demonstrations. Contributions are welcome!
|
|
30
43
|
|
|
31
44
|
---
|
|
@@ -34,171 +47,14 @@ This project uses typescript. Resources are stored in 3 key structures:
|
|
|
34
47
|
Create API credentials at okx
|
|
35
48
|
- [OKX my-api](https://www.okx.com/account/my-api)
|
|
36
49
|
|
|
37
|
-
|
|
38
|
-
### REST Inverse
|
|
39
|
-
To use the inverse REST APIs, import the `InverseClient`:
|
|
40
|
-
|
|
41
|
-
```javascript
|
|
42
|
-
const { InverseClient } = require('okx-api');
|
|
43
|
-
|
|
44
|
-
const restClientOptions = {
|
|
45
|
-
// override the max size of the request window (in ms)
|
|
46
|
-
recv_window?: number;
|
|
47
|
-
|
|
48
|
-
// how often to sync time drift with okx servers
|
|
49
|
-
sync_interval_ms?: number | string;
|
|
50
|
-
|
|
51
|
-
// Default: false. Disable above sync mechanism if true.
|
|
52
|
-
disable_time_sync?: boolean;
|
|
53
|
-
|
|
54
|
-
// Default: false. If true, we'll throw errors if any params are undefined
|
|
55
|
-
strict_param_validation?: boolean;
|
|
56
|
-
|
|
57
|
-
// Optionally override API protocol + domain
|
|
58
|
-
// e.g 'https://api.bytick.com'
|
|
59
|
-
baseUrl?: string;
|
|
60
|
-
|
|
61
|
-
// Default: true. whether to try and post-process request exceptions.
|
|
62
|
-
parse_exceptions?: boolean;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const API_KEY = 'xxx';
|
|
66
|
-
const PRIVATE_KEY = 'yyy';
|
|
67
|
-
const useLivenet = false;
|
|
68
|
-
|
|
69
|
-
const client = new InverseClient(
|
|
70
|
-
API_KEY,
|
|
71
|
-
PRIVATE_KEY,
|
|
72
|
-
|
|
73
|
-
// optional, uses testnet by default. Set to 'true' to use livenet.
|
|
74
|
-
useLivenet,
|
|
75
|
-
|
|
76
|
-
// restClientOptions,
|
|
77
|
-
// requestLibraryOptions
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
client.getApiKeyInfo()
|
|
81
|
-
.then(result => {
|
|
82
|
-
console.log("apiKey result: ", result);
|
|
83
|
-
})
|
|
84
|
-
.catch(err => {
|
|
85
|
-
console.error("apiKey error: ", err);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
client.getOrderBook({ symbol: 'BTCUSD' })
|
|
89
|
-
.then(result => {
|
|
90
|
-
console.log("getOrderBook inverse result: ", result);
|
|
91
|
-
})
|
|
92
|
-
.catch(err => {
|
|
93
|
-
console.error("getOrderBook inverse error: ", err);
|
|
94
|
-
});
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
See [inverse-client.ts](./src/inverse-client.ts) for further information. -->
|
|
99
|
-
|
|
100
|
-
## WebSockets
|
|
101
|
-
Inverse, linear & spot WebSockets can be used via a shared `WebsocketClient`. However, make sure to make one instance of WebsocketClient per market type (spot vs inverse vs linear vs linearfutures):
|
|
102
|
-
|
|
103
|
-
```javascript
|
|
104
|
-
const { WebsocketClient } = require('okx-api');
|
|
105
|
-
|
|
106
|
-
const API_KEY = 'xxx';
|
|
107
|
-
const PRIVATE_KEY = 'yyy';
|
|
108
|
-
|
|
109
|
-
const wsConfig = {
|
|
110
|
-
key: API_KEY,
|
|
111
|
-
secret: PRIVATE_KEY,
|
|
112
|
-
|
|
113
|
-
/*
|
|
114
|
-
The following parameters are optional:
|
|
115
|
-
*/
|
|
116
|
-
|
|
117
|
-
// defaults to false == testnet. Set to true for livenet.
|
|
118
|
-
// livenet: true
|
|
119
|
-
|
|
120
|
-
// NOTE: to listen to multiple markets (spot vs inverse vs linear vs linearfutures) at once, make one WebsocketClient instance per market
|
|
121
|
-
|
|
122
|
-
// defaults to inverse:
|
|
123
|
-
// market: 'inverse'
|
|
124
|
-
// market: 'linear'
|
|
125
|
-
// market: 'spot'
|
|
126
|
-
|
|
127
|
-
// how long to wait (in ms) before deciding the connection should be terminated & reconnected
|
|
128
|
-
// pongTimeout: 1000,
|
|
129
|
-
|
|
130
|
-
// how often to check (in ms) that WS connection is still alive
|
|
131
|
-
// pingInterval: 10000,
|
|
132
|
-
|
|
133
|
-
// how long to wait before attempting to reconnect (in ms) after connection is closed
|
|
134
|
-
// reconnectTimeout: 500,
|
|
135
|
-
|
|
136
|
-
// config options sent to RestClient (used for time sync). See RestClient docs.
|
|
137
|
-
// restOptions: { },
|
|
138
|
-
|
|
139
|
-
// config for axios used for HTTP requests. E.g for proxy support
|
|
140
|
-
// requestOptions: { }
|
|
141
|
-
|
|
142
|
-
// override which URL to use for websocket connections
|
|
143
|
-
// wsUrl: 'wss://stream.bytick.com/realtime'
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
const ws = new WebsocketClient(wsConfig);
|
|
147
|
-
|
|
148
|
-
// subscribe to multiple topics at once
|
|
149
|
-
ws.subscribe(['position', 'execution', 'trade']);
|
|
150
|
-
|
|
151
|
-
// and/or subscribe to individual topics on demand
|
|
152
|
-
ws.subscribe('kline.BTCUSD.1m');
|
|
153
|
-
|
|
154
|
-
// Listen to events coming from websockets. This is the primary data source
|
|
155
|
-
ws.on('update', data => {
|
|
156
|
-
console.log('update', data);
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
// Optional: Listen to websocket connection open event (automatic after subscribing to one or more topics)
|
|
160
|
-
ws.on('open', ({ wsKey, event }) => {
|
|
161
|
-
console.log('connection open for websocket with ID: ' + wsKey);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
// Optional: Listen to responses to websocket queries (e.g. the response after subscribing to a topic)
|
|
165
|
-
ws.on('response', response => {
|
|
166
|
-
console.log('response', response);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
// Optional: Listen to connection close event. Unexpected connection closes are automatically reconnected.
|
|
170
|
-
ws.on('close', () => {
|
|
171
|
-
console.log('connection closed');
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
// Optional: Listen to raw error events.
|
|
175
|
-
// Note: responses to invalid topics are currently only sent in the "response" event.
|
|
176
|
-
ws.on('error', err => {
|
|
177
|
-
console.error('ERR', err);
|
|
178
|
-
});
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
See [websocket-client.ts](./src/websocket-client.ts) for further information.
|
|
183
|
-
|
|
184
|
-
Note: for linear websockets, pass `linear: true` in the constructor options when instancing the `WebsocketClient`. To connect to both linear and inverse websockets, make two instances of the WebsocketClient.
|
|
185
|
-
|
|
186
|
-
---
|
|
187
|
-
|
|
188
|
-
## Customise Logging
|
|
189
|
-
Pass a custom logger which supports the log methods `silly`, `debug`, `notice`, `info`, `warning` and `error`, or override methods from the default logger as desired.
|
|
190
|
-
|
|
191
|
-
```javascript
|
|
192
|
-
const { WebsocketClient, DefaultLogger } = require('okx-api');
|
|
193
|
-
|
|
194
|
-
// Disable all logging on the silly level
|
|
195
|
-
DefaultLogger.silly = () => {};
|
|
50
|
+
## REST Client
|
|
196
51
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
52
|
+
### Requests & Responses
|
|
53
|
+
- If your IDE doesn't have IntelliSense, check the [rest-client.ts](./src/rest-client.ts) for a list of methods, params & return types.
|
|
54
|
+
- Requests follow the same ordering and format as the categories in the [API docs](https://www.okx.com/docs-v5/en/#rest-api).
|
|
55
|
+
- Responses are parsed automatically for less nesting. Error responses are thrown in full:
|
|
56
|
+
- If the response looks successful (HTTP 200 and "code" in the response body === "0"), only the `data` property is directly (without the `code`, `data` & `msg` properties).
|
|
57
|
+
- If the response looks like an error (HTTP error OR the "code" property in the response does not equal "0"), the full response is thrown (including `code` and `msg` properties). See the interface for [APIResponse<T>](./src/types/rest/shared.ts).
|
|
202
58
|
|
|
203
59
|
## Browser Usage
|
|
204
60
|
Build a bundle using webpack:
|
|
@@ -214,8 +70,10 @@ The bundle can be found in `dist/`. Altough usage should be largely consistent,
|
|
|
214
70
|
### Donations
|
|
215
71
|
#### tiagosiebler
|
|
216
72
|
Support my efforts to make algo trading accessible to all - register with my referral links:
|
|
217
|
-
- [
|
|
73
|
+
- [Bybit](https://www.bybit.com/en-US/register?affiliate_id=9410&language=en-US&group_id=0&group_type=1)
|
|
218
74
|
- [Binance](https://www.binance.com/en/register?ref=20983262)
|
|
75
|
+
- [OKX](https://www.okx.com/join/18504944)
|
|
76
|
+
- [FTX](https://ftx.com/referrals#a=ftxapigithub)
|
|
219
77
|
|
|
220
78
|
Or buy me a coffee using any of these:
|
|
221
79
|
- BTC: `1C6GWZL1XW3jrjpPTS863XtZiXL1aTK7Jk`
|
package/lib/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './rest-client';
|
|
2
|
+
export * from './util/typeGuards';
|
package/lib/index.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
__exportStar(require("./rest-client"), exports);
|
|
18
|
+
__exportStar(require("./util/typeGuards"), exports);
|
|
19
|
+
// export * from './util/WsStore';
|
|
16
20
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,oDAAkC;AAClC,kCAAkC"}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { OKXEnvironment, RestClientOptions } from './util/requestUtils';
|
|
3
|
+
import BaseRestClient, { APICredentials } from './util/BaseRestClient';
|
|
4
|
+
import { ContractGridDirection, GridAlgoOrderType, GridAlgoSubOrderType, InstrumentType, MarginMode, numberInString, Ticker, AlgoOrderRequest, AmendOrderRequest, CancelAlgoOrderRequest, OrderIdRequest, ClosePositionRequest, OrderRequest, OrderHistoryRequest, FillsHistoryRequest, AlgoRecentHistoryRequest, AlgoLongHistoryRequest, PaginatedSymbolRequest, OrderResult, CancelledOrderResult, AmendedOrder, ClosedPositions, OrderDetails, OrderListItem, HistoricOrder, OrderFill, AlgoOrderResult, AlgoOrderListItem, HistoricAlgoOrder, BlockCounterParty, CreateBlockRFQRequest, CreateRFQResult, CancelBlockRFQRequest, CancelBlockQuoteResult, CancelMultipleBlockRFQRequest, TimestampObject, ExecuteBlockQuoteResult, ExecuteBlockQuoteRequest, CreateBlockQuoteRequest, CreateBlockQuoteResult, CancelBlockRFQResult, CancelBlockQuoteRequest, CancelMultipleBlockQuoteRequest, BlockRFQResult, GetBlockRFQSParams, GetBlockQuoteParams, GetBlockQuoteResult, FundingCurrency, FundingBalance, AccountAssetValuation, FundTransferResult, FundTransferState, AssetBillDetails, AccountBalance, GetPositionsParams, AccountPosition, GetHistoricPositionParams, HistoricAccountPosition, AccountPositionRisk, AccountBill, AccountConfiguration, AccountPositionModeResult, AccountLeverageResult, AccountMaxOrderAmount, AccountMaxTradableAmount, AccountChangeMarginResult, AccountLeverage, AccountMaxLoan, AccountFeeRate, AccountIsolatedMode, SubAccount, SubAccountAPIReset, SubAccountBalances, SubAccountTransferResult, IndexTicker, OrderBook, Candle, CandleNoVolume, Trade } from './types/rest';
|
|
5
|
+
export declare class RestClient extends BaseRestClient {
|
|
6
|
+
/**
|
|
7
|
+
* @public Creates an instance of the REST API client.
|
|
8
|
+
*/
|
|
9
|
+
constructor(credentials?: APICredentials | null, environment?: OKXEnvironment, restClientOptions?: RestClientOptions, requestOptions?: AxiosRequestConfig);
|
|
10
|
+
getServerTime(): Promise<number>;
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* Trade endpoints (private)
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
placeOrder(params: OrderRequest): Promise<OrderResult[]>;
|
|
17
|
+
placeMultipleOrders(params: OrderRequest[]): Promise<OrderResult[]>;
|
|
18
|
+
cancelOrder(params: OrderIdRequest): Promise<CancelledOrderResult[]>;
|
|
19
|
+
cancelMultipleOrders(params: OrderIdRequest[]): Promise<CancelledOrderResult[]>;
|
|
20
|
+
amendOrder(params: AmendOrderRequest): Promise<AmendedOrder[]>;
|
|
21
|
+
amendMultipleOrders(params: AmendOrderRequest[]): Promise<AmendedOrder[]>;
|
|
22
|
+
closePositions(params: ClosePositionRequest): Promise<ClosedPositions[]>;
|
|
23
|
+
getOrderDetails(params: OrderIdRequest): Promise<OrderDetails[]>;
|
|
24
|
+
getOrderList(params?: OrderHistoryRequest): Promise<OrderListItem[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Get history for last 7 days
|
|
27
|
+
*/
|
|
28
|
+
getOrderHistory(params: OrderHistoryRequest): Promise<HistoricOrder[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Get history for last 3 months
|
|
31
|
+
*/
|
|
32
|
+
getOrderHistoryArchive(params: OrderHistoryRequest): Promise<HistoricOrder[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Get history for last 7 days
|
|
35
|
+
*/
|
|
36
|
+
getFills(params?: FillsHistoryRequest): Promise<OrderFill[]>;
|
|
37
|
+
/**
|
|
38
|
+
* Get history for last 3 months
|
|
39
|
+
*/
|
|
40
|
+
getFillsHistory(params: FillsHistoryRequest): Promise<OrderFill[]>;
|
|
41
|
+
placeAlgoOrder(params: AlgoOrderRequest): Promise<AlgoOrderResult[]>;
|
|
42
|
+
cancelAlgoOrder(params: CancelAlgoOrderRequest[]): Promise<AlgoOrderResult[]>;
|
|
43
|
+
cancelAdvanceAlgoOrder(params: CancelAlgoOrderRequest[]): Promise<AlgoOrderResult[]>;
|
|
44
|
+
getAlgoOrderList(params: AlgoRecentHistoryRequest): Promise<AlgoOrderListItem[]>;
|
|
45
|
+
getAlgoOrderHistory(params: AlgoLongHistoryRequest): Promise<HistoricAlgoOrder[]>;
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* Block trading endpoints (private)
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
getBlockCounterParties(): Promise<BlockCounterParty[]>;
|
|
52
|
+
createBlockRFQ(params: CreateBlockRFQRequest): Promise<CreateRFQResult[]>;
|
|
53
|
+
cancelBlockRFQ(params?: CancelBlockRFQRequest): Promise<CancelBlockRFQResult[]>;
|
|
54
|
+
cancelMultipleBlockRFQs(params: CancelMultipleBlockRFQRequest): Promise<CancelBlockRFQResult[]>;
|
|
55
|
+
cancelAllRFQs(): Promise<TimestampObject[]>;
|
|
56
|
+
executeBlockQuote(params: ExecuteBlockQuoteRequest): Promise<ExecuteBlockQuoteResult[]>;
|
|
57
|
+
createBlockQuote(params: CreateBlockQuoteRequest): Promise<CreateBlockQuoteResult[]>;
|
|
58
|
+
cancelBlockQuote(params: CancelBlockQuoteRequest): Promise<CancelBlockQuoteResult[]>;
|
|
59
|
+
cancelMultipleBlockQuotes(params: CancelMultipleBlockQuoteRequest): Promise<CancelBlockQuoteResult[]>;
|
|
60
|
+
cancelAllBlockQuotes(): Promise<TimestampObject[]>;
|
|
61
|
+
getBlockRFQs(params?: GetBlockRFQSParams): Promise<BlockRFQResult[]>;
|
|
62
|
+
getBlockQuotes(params?: GetBlockQuoteParams): Promise<GetBlockQuoteResult[]>;
|
|
63
|
+
getBlockTrades(params: unknown): Promise<unknown[]>;
|
|
64
|
+
getPublicRFQBlockTrades(params: unknown): Promise<unknown[]>;
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
* Funding endpoints (private)
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
getCurrencies(ccy?: string): Promise<FundingCurrency[]>;
|
|
71
|
+
getBalances(ccy?: string): Promise<FundingBalance[]>;
|
|
72
|
+
getAccountAssetValuation(ccy?: string): Promise<AccountAssetValuation[]>;
|
|
73
|
+
fundsTransfer(params: unknown): Promise<FundTransferResult[]>;
|
|
74
|
+
getFundsTransferState(params: {
|
|
75
|
+
transId?: string;
|
|
76
|
+
clientId?: string;
|
|
77
|
+
type?: '0' | '1' | '2';
|
|
78
|
+
}): Promise<FundTransferState[]>;
|
|
79
|
+
getAssetBillsDetails(params?: {
|
|
80
|
+
ccy?: string;
|
|
81
|
+
type?: numberInString;
|
|
82
|
+
clientId?: string;
|
|
83
|
+
after?: numberInString;
|
|
84
|
+
before?: numberInString;
|
|
85
|
+
limit?: numberInString;
|
|
86
|
+
}): Promise<AssetBillDetails[]>;
|
|
87
|
+
getLightningDeposits(ccy: string, amt: numberInString, to?: '6' | '18'): Promise<unknown[]>;
|
|
88
|
+
getDepositAddress(ccy: string): Promise<unknown[]>;
|
|
89
|
+
getDepositHistory(params: unknown): Promise<unknown[]>;
|
|
90
|
+
withdraw(params: unknown): Promise<unknown[]>;
|
|
91
|
+
withdrawLightning(ccy: string, invoice: string, memo?: string): Promise<unknown[]>;
|
|
92
|
+
cancelWithdrawal(wdId: string): Promise<unknown[]>;
|
|
93
|
+
getWithdrawalHistory(params?: unknown): Promise<unknown[]>;
|
|
94
|
+
smallAssetsConvert(ccy: string[]): Promise<unknown[]>;
|
|
95
|
+
getSavingBalance(ccy?: string): Promise<unknown[]>;
|
|
96
|
+
savingsPurchaseRedemption(ccy: string, amt: numberInString, side: 'purchase' | 'redempt', rate: numberInString): Promise<unknown[]>;
|
|
97
|
+
setLendingRate(ccy: string, rate: numberInString): Promise<unknown[]>;
|
|
98
|
+
getLendingHistory(params?: PaginatedSymbolRequest): Promise<unknown[]>;
|
|
99
|
+
getPublicBorrowInfo(ccy?: string): Promise<unknown[]>;
|
|
100
|
+
getPublicBorrowHistory(params?: PaginatedSymbolRequest): Promise<unknown[]>;
|
|
101
|
+
/**
|
|
102
|
+
*
|
|
103
|
+
* Convert endpoints (private)
|
|
104
|
+
*
|
|
105
|
+
*/
|
|
106
|
+
getConvertCurrencies(): Promise<unknown[]>;
|
|
107
|
+
getConvertCurrencyPair(fromCcy: string, toCcy: string): Promise<unknown[]>;
|
|
108
|
+
estimateConvertQuote(params: unknown): Promise<unknown[]>;
|
|
109
|
+
convertTrade(params: unknown): Promise<unknown[]>;
|
|
110
|
+
getConvertHistory(params?: unknown): Promise<unknown[]>;
|
|
111
|
+
/**
|
|
112
|
+
*
|
|
113
|
+
* Account endpoints (private)
|
|
114
|
+
*
|
|
115
|
+
*/
|
|
116
|
+
getBalance(ccy?: string): Promise<AccountBalance[]>;
|
|
117
|
+
getPositions(params?: GetPositionsParams): Promise<AccountPosition[]>;
|
|
118
|
+
getPositionsHistory(params?: GetHistoricPositionParams): Promise<HistoricAccountPosition[]>;
|
|
119
|
+
getAccountPositionRisk(instType?: Omit<'SPOT', InstrumentType>): Promise<AccountPositionRisk[]>;
|
|
120
|
+
/** Up to last 7 days */
|
|
121
|
+
getBills(params?: unknown): Promise<AccountBill[]>;
|
|
122
|
+
/** Last 3 months */
|
|
123
|
+
getBillsArchive(params?: unknown): Promise<AccountBill[]>;
|
|
124
|
+
getAccountConfiguration(): Promise<AccountConfiguration[]>;
|
|
125
|
+
setPositionMode(posMode: 'long_short_mode' | 'net'): Promise<AccountPositionModeResult[]>;
|
|
126
|
+
setLeverage(params: unknown): Promise<AccountLeverageResult[]>;
|
|
127
|
+
/** Max buy/sell amount or open amount */
|
|
128
|
+
getMaxOrderAmount(params: unknown): Promise<AccountMaxOrderAmount[]>;
|
|
129
|
+
getMaxAvailableTradableAmount(params: unknown): Promise<AccountMaxTradableAmount[]>;
|
|
130
|
+
changePositionMargin(params: unknown): Promise<AccountChangeMarginResult[]>;
|
|
131
|
+
getLeverage(instId: string, mgnMode: MarginMode): Promise<AccountLeverage[]>;
|
|
132
|
+
getMaxLoan(instId: string, mgnMode: MarginMode, mgnCcy?: string): Promise<AccountMaxLoan[]>;
|
|
133
|
+
getFeeRates(instType: InstrumentType, instId?: string, uly?: string): Promise<AccountFeeRate[]>;
|
|
134
|
+
getInterestAccrued(params?: unknown): Promise<unknown[]>;
|
|
135
|
+
getInterestRate(ccy?: string): Promise<unknown[]>;
|
|
136
|
+
setGreeksDisplayType(greeksType: 'PA' | 'BS'): Promise<unknown[]>;
|
|
137
|
+
setIsolatedMode(isoMode: 'automatic' | 'autonomy', type: 'MARGIN' | 'CONTRACTS'): Promise<AccountIsolatedMode[]>;
|
|
138
|
+
getMaxWithdrawals(ccy?: string): Promise<unknown[]>;
|
|
139
|
+
getAccountRiskState(): Promise<unknown[]>;
|
|
140
|
+
VIPLoanBorrowRepay(ccy: string, side: 'borrow' | 'repay', amt: numberInString): Promise<unknown[]>;
|
|
141
|
+
getVIPLoanBorrowRepayHistory(params?: unknown): Promise<unknown[]>;
|
|
142
|
+
getBorrowInterestLimits(params?: {
|
|
143
|
+
type?: '1' | '2';
|
|
144
|
+
ccy?: string;
|
|
145
|
+
}): Promise<unknown[]>;
|
|
146
|
+
positionBuilder(params?: unknown): Promise<unknown[]>;
|
|
147
|
+
getGreeks(ccy?: string): Promise<unknown[]>;
|
|
148
|
+
getPMLimitation(instType: 'SWAP' | 'FUTURES' | 'OPTION', uly: string): Promise<unknown[]>;
|
|
149
|
+
/**
|
|
150
|
+
*
|
|
151
|
+
* SubAccount endpoints (private)
|
|
152
|
+
*
|
|
153
|
+
*/
|
|
154
|
+
getSubAccountList(params?: unknown): Promise<SubAccount[]>;
|
|
155
|
+
resetSubAccountAPIKey(subAcct: string, apiKey: string, options?: {
|
|
156
|
+
label?: string;
|
|
157
|
+
perm?: string;
|
|
158
|
+
ip?: string;
|
|
159
|
+
}): Promise<SubAccountAPIReset[]>;
|
|
160
|
+
getSubAccountBalances(subAcct: string): Promise<SubAccountBalances[]>;
|
|
161
|
+
getSubAccountFundingBalances(subAcct: string, ccy?: string): Promise<FundingBalance[]>;
|
|
162
|
+
getSubAccountTransferHistory(params?: unknown): Promise<unknown[]>;
|
|
163
|
+
transferSubAccountBalance(params: unknown): Promise<SubAccountTransferResult[]>;
|
|
164
|
+
setSubAccountTransferOutPermission(subAcct: string, canTransOut?: boolean): Promise<unknown[]>;
|
|
165
|
+
getSubAccountListCustodyTrading(subAcct?: string): Promise<unknown[]>;
|
|
166
|
+
/**
|
|
167
|
+
*
|
|
168
|
+
* Grid trading endpoints (private)
|
|
169
|
+
*
|
|
170
|
+
*/
|
|
171
|
+
placeGridAlgoOrder(params: unknown): Promise<unknown[]>;
|
|
172
|
+
amendGridAlgoOrder(algoId: string, instId: string, triggerPx: {
|
|
173
|
+
slTriggerPx?: numberInString;
|
|
174
|
+
tpTriggerPx?: numberInString;
|
|
175
|
+
}): Promise<unknown[]>;
|
|
176
|
+
stopGridAlgoOrder(algoId: string, instId: string, algoOrdType: GridAlgoOrderType, stopType: '1' | '2'): Promise<unknown[]>;
|
|
177
|
+
getGridAlgoOrderList(params: unknown): Promise<unknown[]>;
|
|
178
|
+
getGridAlgoOrderHistory(params: unknown): Promise<unknown[]>;
|
|
179
|
+
getGridAlgoOrderDetails(algoOrdType: GridAlgoOrderType, algoId: string): Promise<unknown[]>;
|
|
180
|
+
getGridAlgoSubOrders(algoOrdType: GridAlgoOrderType, algoId: string, type: GridAlgoSubOrderType, groupId?: string, pagination?: {
|
|
181
|
+
after?: numberInString;
|
|
182
|
+
before?: numberInString;
|
|
183
|
+
limit?: number;
|
|
184
|
+
}): Promise<unknown[]>;
|
|
185
|
+
/** Only contract grid supports this method */
|
|
186
|
+
getGridAlgoOrderPositions(algoOrdType: 'contract_grid', algoId: string): Promise<unknown[]>;
|
|
187
|
+
spotGridWithdrawIncome(algoId: string): Promise<unknown[]>;
|
|
188
|
+
computeGridMarginBalance(algoId: string, type: 'add' | 'reduce', amt?: numberInString): Promise<unknown[]>;
|
|
189
|
+
adjustGridMarginBalance(algoId: string, type: 'add' | 'reduce', change: {
|
|
190
|
+
amt?: numberInString;
|
|
191
|
+
percent?: numberInString;
|
|
192
|
+
}): Promise<unknown[]>;
|
|
193
|
+
getGridAIParameter(algoOrdType: GridAlgoOrderType, instId: string, direction?: ContractGridDirection, duration?: '7D' | '30D' | '180D'): Promise<unknown[]>;
|
|
194
|
+
/**
|
|
195
|
+
*
|
|
196
|
+
* Market data endpoints (public)
|
|
197
|
+
*
|
|
198
|
+
*/
|
|
199
|
+
getTickers(instrumentType: InstrumentType, uly?: string): Promise<Ticker[]>;
|
|
200
|
+
getTicker(instId: string): Promise<Ticker[]>;
|
|
201
|
+
getIndexTickers(params: {
|
|
202
|
+
quoteCcy?: string;
|
|
203
|
+
instId?: string;
|
|
204
|
+
}): Promise<IndexTicker[]>;
|
|
205
|
+
getOrderBook(instId: string, sz?: numberInString): Promise<OrderBook[]>;
|
|
206
|
+
getCandles(instId: string, bar?: string, pagination?: {
|
|
207
|
+
after?: numberInString;
|
|
208
|
+
before?: numberInString;
|
|
209
|
+
limit?: numberInString;
|
|
210
|
+
}): Promise<Candle[]>;
|
|
211
|
+
getHistoricCandles(instId: string, bar?: string, pagination?: {
|
|
212
|
+
after?: numberInString;
|
|
213
|
+
before?: numberInString;
|
|
214
|
+
limit?: numberInString;
|
|
215
|
+
}): Promise<Candle[]>;
|
|
216
|
+
getIndexCandles(instId: string, bar?: string, pagination?: {
|
|
217
|
+
after?: numberInString;
|
|
218
|
+
before?: numberInString;
|
|
219
|
+
limit?: numberInString;
|
|
220
|
+
}): Promise<CandleNoVolume[]>;
|
|
221
|
+
getMarkPriceCandles(instId: string, bar?: string, pagination?: {
|
|
222
|
+
after?: numberInString;
|
|
223
|
+
before?: numberInString;
|
|
224
|
+
limit?: numberInString;
|
|
225
|
+
}): Promise<CandleNoVolume[]>;
|
|
226
|
+
getTrades(instId: string, limit?: number): Promise<Trade[]>;
|
|
227
|
+
getHistoricTrades(instId: string, pagination?: {
|
|
228
|
+
after?: numberInString;
|
|
229
|
+
before?: numberInString;
|
|
230
|
+
limit?: numberInString;
|
|
231
|
+
type?: '1' | '2';
|
|
232
|
+
}): Promise<Trade[]>;
|
|
233
|
+
get24hrTotalVolume(): Promise<unknown[]>;
|
|
234
|
+
getOracle(): Promise<unknown[]>;
|
|
235
|
+
getExchangeRate(): Promise<unknown[]>;
|
|
236
|
+
getIndexComponents(index: string): Promise<unknown[]>;
|
|
237
|
+
getBlockTickers(instType: InstrumentType, uly?: string): Promise<unknown[]>;
|
|
238
|
+
getBlockTicker(instId: string): Promise<unknown[]>;
|
|
239
|
+
getPublicBlockTrades(instId: string): Promise<unknown[]>;
|
|
240
|
+
/**
|
|
241
|
+
*
|
|
242
|
+
* Public data endpoints (public)
|
|
243
|
+
*
|
|
244
|
+
*/
|
|
245
|
+
getInstruments(params: unknown): Promise<unknown[]>;
|
|
246
|
+
getDeliveryExerciseHistory(params: unknown): Promise<unknown[]>;
|
|
247
|
+
getOpenInterest(params: unknown): Promise<unknown[]>;
|
|
248
|
+
getFundingRate(params: unknown): Promise<unknown[]>;
|
|
249
|
+
getFundingRateHistory(params: unknown): Promise<unknown[]>;
|
|
250
|
+
getMinMaxLimitPrice(params: unknown): Promise<unknown[]>;
|
|
251
|
+
getOptionMarketData(params: unknown): Promise<unknown[]>;
|
|
252
|
+
getEstimatedDeliveryExercisePrice(params: unknown): Promise<unknown[]>;
|
|
253
|
+
getDiscountRateAndInterestFreeQuota(params: unknown): Promise<unknown[]>;
|
|
254
|
+
getSystemTime(params: unknown): Promise<unknown[]>;
|
|
255
|
+
getLiquidationOrders(params: unknown): Promise<unknown[]>;
|
|
256
|
+
getMarkPrice(params: unknown): Promise<unknown[]>;
|
|
257
|
+
getPositionTiers(params: unknown): Promise<unknown[]>;
|
|
258
|
+
getInterestRateAndLoanQuota(params: unknown): Promise<unknown[]>;
|
|
259
|
+
getVIPInterestRateAndLoanQuota(params: unknown): Promise<unknown[]>;
|
|
260
|
+
getUnderlying(params: unknown): Promise<unknown[]>;
|
|
261
|
+
getInsuranceFund(params: unknown): Promise<unknown[]>;
|
|
262
|
+
getUnitConvert(params: unknown): Promise<unknown[]>;
|
|
263
|
+
/**
|
|
264
|
+
*
|
|
265
|
+
* Trading data endpoints (public)
|
|
266
|
+
*
|
|
267
|
+
*/
|
|
268
|
+
getSupportCoin(): Promise<unknown[]>;
|
|
269
|
+
getTakerVolume(): Promise<unknown[]>;
|
|
270
|
+
getMarginLendingRatio(params: {
|
|
271
|
+
ccy: string;
|
|
272
|
+
begin?: numberInString;
|
|
273
|
+
end?: numberInString;
|
|
274
|
+
period: '5m' | '1H' | '1D';
|
|
275
|
+
}): Promise<unknown[]>;
|
|
276
|
+
getLongShortRatio(params: {
|
|
277
|
+
ccy: string;
|
|
278
|
+
begin?: numberInString;
|
|
279
|
+
end?: numberInString;
|
|
280
|
+
period: '5m' | '1H' | '1D';
|
|
281
|
+
}): Promise<unknown[]>;
|
|
282
|
+
getContractsOpenInterestAndVolume(params: {
|
|
283
|
+
ccy: string;
|
|
284
|
+
begin?: numberInString;
|
|
285
|
+
end?: numberInString;
|
|
286
|
+
period: '5m' | '1H' | '1D';
|
|
287
|
+
}): Promise<unknown[]>;
|
|
288
|
+
getOptionsOpenInterestAndVolume(params: {
|
|
289
|
+
ccy: string;
|
|
290
|
+
period: '8H' | '1D';
|
|
291
|
+
}): Promise<unknown[]>;
|
|
292
|
+
getPutCallRatio(params: {
|
|
293
|
+
ccy: string;
|
|
294
|
+
period: '8H' | '1D';
|
|
295
|
+
}): Promise<unknown[]>;
|
|
296
|
+
getOpenInterestAndVolumeExpiry(params: {
|
|
297
|
+
ccy: string;
|
|
298
|
+
period: '8H' | '1D';
|
|
299
|
+
}): Promise<unknown[]>;
|
|
300
|
+
getOpenInterestAndVolumeStrike(params: {
|
|
301
|
+
ccy: string;
|
|
302
|
+
expTime: string;
|
|
303
|
+
period: '8H' | '1D';
|
|
304
|
+
}): Promise<unknown[]>;
|
|
305
|
+
getTakerFlow(params: {
|
|
306
|
+
ccy: string;
|
|
307
|
+
period: '8H' | '1D';
|
|
308
|
+
}): Promise<unknown[]>;
|
|
309
|
+
/**
|
|
310
|
+
*
|
|
311
|
+
* Status endpoints (public)
|
|
312
|
+
*
|
|
313
|
+
*/
|
|
314
|
+
getSystemStatus(state?: 'scheduled' | 'ongoing' | 'pre_open' | 'completed' | 'canceled'): Promise<unknown[]>;
|
|
315
|
+
}
|