gateio-api 1.2.6 → 1.2.8
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 +7 -0
- package/dist/cjs/lib/BaseRestClient.js +4 -0
- package/dist/cjs/lib/BaseRestClient.js.map +1 -1
- package/dist/cjs/lib/BaseWSClient.js +7 -0
- package/dist/cjs/lib/BaseWSClient.js.map +1 -1
- package/dist/cjs/lib/webCryptoAPI.d.ts +1 -0
- package/dist/cjs/lib/webCryptoAPI.js +8 -0
- package/dist/cjs/lib/webCryptoAPI.js.map +1 -1
- package/dist/mjs/lib/BaseRestClient.js +5 -1
- package/dist/mjs/lib/BaseRestClient.js.map +1 -1
- package/dist/mjs/lib/BaseWSClient.js +7 -0
- package/dist/mjs/lib/BaseWSClient.js.map +1 -1
- package/dist/mjs/lib/webCryptoAPI.d.ts +1 -0
- package/dist/mjs/lib/webCryptoAPI.js +7 -0
- package/dist/mjs/lib/webCryptoAPI.js.map +1 -1
- package/llms.txt +882 -867
- package/package.json +3 -3
package/llms.txt
CHANGED
|
@@ -588,6 +588,8 @@ export async function signMessage(
|
|
|
588
588
|
method: SignEncodeMethod,
|
|
589
589
|
algorithm: SignAlgorithm,
|
|
590
590
|
): Promise<string>
|
|
591
|
+
⋮----
|
|
592
|
+
export function checkWebCryptoAPISupported()
|
|
591
593
|
|
|
592
594
|
================
|
|
593
595
|
File: src/types/request/account.ts
|
|
@@ -3281,174 +3283,6 @@ export interface StpGroupUser {
|
|
|
3281
3283
|
create_time: number;
|
|
3282
3284
|
}
|
|
3283
3285
|
|
|
3284
|
-
================
|
|
3285
|
-
File: src/types/response/delivery.ts
|
|
3286
|
-
================
|
|
3287
|
-
/**==========================================================================================================================
|
|
3288
|
-
* DELIVERY
|
|
3289
|
-
* ==========================================================================================================================
|
|
3290
|
-
*/
|
|
3291
|
-
⋮----
|
|
3292
|
-
export interface DeliveryOrderBook {
|
|
3293
|
-
id?: number;
|
|
3294
|
-
current: number;
|
|
3295
|
-
update: number;
|
|
3296
|
-
asks: { p: string; s: number }[];
|
|
3297
|
-
bids: { p: string; s: number }[];
|
|
3298
|
-
}
|
|
3299
|
-
⋮----
|
|
3300
|
-
export interface DeliveryTrade {
|
|
3301
|
-
id: number;
|
|
3302
|
-
create_time: number;
|
|
3303
|
-
create_time_ms: number;
|
|
3304
|
-
contract: string;
|
|
3305
|
-
size: number;
|
|
3306
|
-
price: string;
|
|
3307
|
-
is_internal?: boolean;
|
|
3308
|
-
}
|
|
3309
|
-
⋮----
|
|
3310
|
-
export interface DeliveryCandle {
|
|
3311
|
-
t: number;
|
|
3312
|
-
v?: number;
|
|
3313
|
-
c: string;
|
|
3314
|
-
h: string;
|
|
3315
|
-
l: string;
|
|
3316
|
-
o: string;
|
|
3317
|
-
}
|
|
3318
|
-
⋮----
|
|
3319
|
-
export interface DeliveryTicker {
|
|
3320
|
-
contract: string;
|
|
3321
|
-
last: string;
|
|
3322
|
-
change_percentage: string;
|
|
3323
|
-
total_size: string;
|
|
3324
|
-
low_24h: string;
|
|
3325
|
-
high_24h: string;
|
|
3326
|
-
volume_24h: string;
|
|
3327
|
-
volume_24h_btc?: string;
|
|
3328
|
-
volume_24h_usd?: string;
|
|
3329
|
-
volume_24h_base: string;
|
|
3330
|
-
volume_24h_quote: string;
|
|
3331
|
-
volume_24h_settle: string;
|
|
3332
|
-
mark_price: string;
|
|
3333
|
-
funding_rate: string;
|
|
3334
|
-
funding_rate_indicative: string;
|
|
3335
|
-
index_price: string;
|
|
3336
|
-
quanto_base_rate?: string;
|
|
3337
|
-
basis_rate: string;
|
|
3338
|
-
basis_value: string;
|
|
3339
|
-
lowest_ask: string;
|
|
3340
|
-
highest_bid: string;
|
|
3341
|
-
}
|
|
3342
|
-
⋮----
|
|
3343
|
-
export interface DeliveryAccount {
|
|
3344
|
-
total: string;
|
|
3345
|
-
unrealised_pnl: string;
|
|
3346
|
-
position_margin: string;
|
|
3347
|
-
order_margin: string;
|
|
3348
|
-
available: string;
|
|
3349
|
-
point: string;
|
|
3350
|
-
currency: string;
|
|
3351
|
-
in_dual_mode: boolean;
|
|
3352
|
-
enable_credit: boolean;
|
|
3353
|
-
position_initial_margin: string;
|
|
3354
|
-
maintenance_margin: string;
|
|
3355
|
-
bonus: string;
|
|
3356
|
-
enable_evolved_classic: boolean;
|
|
3357
|
-
cross_order_margin: string;
|
|
3358
|
-
cross_initial_margin: string;
|
|
3359
|
-
cross_maintenance_margin: string;
|
|
3360
|
-
cross_unrealised_pnl: string;
|
|
3361
|
-
cross_available: string;
|
|
3362
|
-
isolated_position_margin: string;
|
|
3363
|
-
history: {
|
|
3364
|
-
dnw: string;
|
|
3365
|
-
pnl: string;
|
|
3366
|
-
fee: string;
|
|
3367
|
-
refr: string;
|
|
3368
|
-
fund: string;
|
|
3369
|
-
point_dnw: string;
|
|
3370
|
-
point_fee: string;
|
|
3371
|
-
point_refr: string;
|
|
3372
|
-
bonus_dnw: string;
|
|
3373
|
-
bonus_offset: string;
|
|
3374
|
-
};
|
|
3375
|
-
enable_tiered_mm: boolean;
|
|
3376
|
-
}
|
|
3377
|
-
⋮----
|
|
3378
|
-
export interface DeliveryBook {
|
|
3379
|
-
time: number;
|
|
3380
|
-
change: string;
|
|
3381
|
-
balance: string;
|
|
3382
|
-
type:
|
|
3383
|
-
| 'dnw'
|
|
3384
|
-
| 'pnl'
|
|
3385
|
-
| 'fee'
|
|
3386
|
-
| 'refr'
|
|
3387
|
-
| 'fund'
|
|
3388
|
-
| 'point_dnw'
|
|
3389
|
-
| 'point_fee'
|
|
3390
|
-
| 'point_refr'
|
|
3391
|
-
| 'bonus_offset';
|
|
3392
|
-
text: string;
|
|
3393
|
-
contract?: string;
|
|
3394
|
-
trade_id?: string;
|
|
3395
|
-
}
|
|
3396
|
-
⋮----
|
|
3397
|
-
export interface DeliveryTradingHistoryRecord {
|
|
3398
|
-
id: number;
|
|
3399
|
-
create_time: number;
|
|
3400
|
-
contract: string;
|
|
3401
|
-
order_id: string;
|
|
3402
|
-
size: number;
|
|
3403
|
-
price: string;
|
|
3404
|
-
role: 'taker' | 'maker';
|
|
3405
|
-
text: string;
|
|
3406
|
-
fee: string;
|
|
3407
|
-
point_fee: string;
|
|
3408
|
-
}
|
|
3409
|
-
⋮----
|
|
3410
|
-
export interface DeliveryClosedPosition {
|
|
3411
|
-
time: number;
|
|
3412
|
-
contract: string;
|
|
3413
|
-
side: 'long' | 'short';
|
|
3414
|
-
pnl: string;
|
|
3415
|
-
pnl_pnl: string;
|
|
3416
|
-
pnl_fund: string;
|
|
3417
|
-
pnl_fee: string;
|
|
3418
|
-
text: string;
|
|
3419
|
-
max_size: string;
|
|
3420
|
-
first_open_time: number;
|
|
3421
|
-
long_price: string;
|
|
3422
|
-
short_price: string;
|
|
3423
|
-
}
|
|
3424
|
-
⋮----
|
|
3425
|
-
export interface DeliveryLiquidationHistoryRecord {
|
|
3426
|
-
time: number;
|
|
3427
|
-
contract: string;
|
|
3428
|
-
leverage?: string;
|
|
3429
|
-
size: number;
|
|
3430
|
-
margin?: string;
|
|
3431
|
-
entry_price?: string;
|
|
3432
|
-
liq_price?: string;
|
|
3433
|
-
mark_price?: string;
|
|
3434
|
-
order_id?: number;
|
|
3435
|
-
order_price: string;
|
|
3436
|
-
fill_price: string;
|
|
3437
|
-
left: number;
|
|
3438
|
-
}
|
|
3439
|
-
⋮----
|
|
3440
|
-
export interface DeliverySettlementHistoryRecord {
|
|
3441
|
-
time: number;
|
|
3442
|
-
contract: string;
|
|
3443
|
-
leverage: string;
|
|
3444
|
-
size: number;
|
|
3445
|
-
margin: string;
|
|
3446
|
-
entry_price: string;
|
|
3447
|
-
settle_price: string;
|
|
3448
|
-
profit: string;
|
|
3449
|
-
fee: string;
|
|
3450
|
-
}
|
|
3451
|
-
|
|
3452
3286
|
================
|
|
3453
3287
|
File: src/types/response/earn.ts
|
|
3454
3288
|
================
|
|
@@ -4248,65 +4082,278 @@ export function safeTerminateWs(
|
|
|
4248
4082
|
): boolean
|
|
4249
4083
|
|
|
4250
4084
|
================
|
|
4251
|
-
File: src/types/
|
|
4085
|
+
File: src/types/response/delivery.ts
|
|
4252
4086
|
================
|
|
4253
4087
|
/**==========================================================================================================================
|
|
4254
|
-
*
|
|
4088
|
+
* DELIVERY
|
|
4255
4089
|
* ==========================================================================================================================
|
|
4256
4090
|
*/
|
|
4257
4091
|
⋮----
|
|
4258
|
-
export interface
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
}
|
|
4265
|
-
⋮----
|
|
4266
|
-
export interface GetFuturesTradesReq {
|
|
4267
|
-
settle: 'btc' | 'usdt' | 'usd';
|
|
4268
|
-
contract: string;
|
|
4269
|
-
limit?: number;
|
|
4270
|
-
offset?: number;
|
|
4271
|
-
last_id?: string;
|
|
4272
|
-
from?: number;
|
|
4273
|
-
to?: number;
|
|
4092
|
+
export interface DeliveryOrderBook {
|
|
4093
|
+
id?: number;
|
|
4094
|
+
current: number;
|
|
4095
|
+
update: number;
|
|
4096
|
+
asks: { p: string; s: number }[];
|
|
4097
|
+
bids: { p: string; s: number }[];
|
|
4274
4098
|
}
|
|
4275
4099
|
⋮----
|
|
4276
|
-
export interface
|
|
4277
|
-
|
|
4100
|
+
export interface DeliveryTrade {
|
|
4101
|
+
id: number;
|
|
4102
|
+
create_time: number;
|
|
4103
|
+
create_time_ms: number;
|
|
4278
4104
|
contract: string;
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
interval?: string;
|
|
4105
|
+
size: number;
|
|
4106
|
+
price: string;
|
|
4107
|
+
is_internal?: boolean;
|
|
4283
4108
|
}
|
|
4284
4109
|
⋮----
|
|
4285
|
-
export interface
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4110
|
+
export interface DeliveryCandle {
|
|
4111
|
+
t: number;
|
|
4112
|
+
v?: number;
|
|
4113
|
+
c: string;
|
|
4114
|
+
h: string;
|
|
4115
|
+
l: string;
|
|
4116
|
+
o: string;
|
|
4291
4117
|
}
|
|
4292
4118
|
⋮----
|
|
4293
|
-
export interface
|
|
4294
|
-
settle: 'btc' | 'usdt' | 'usd';
|
|
4119
|
+
export interface DeliveryTicker {
|
|
4295
4120
|
contract: string;
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4121
|
+
last: string;
|
|
4122
|
+
change_percentage: string;
|
|
4123
|
+
total_size: string;
|
|
4124
|
+
low_24h: string;
|
|
4125
|
+
high_24h: string;
|
|
4126
|
+
volume_24h: string;
|
|
4127
|
+
volume_24h_btc?: string;
|
|
4128
|
+
volume_24h_usd?: string;
|
|
4129
|
+
volume_24h_base: string;
|
|
4130
|
+
volume_24h_quote: string;
|
|
4131
|
+
volume_24h_settle: string;
|
|
4132
|
+
mark_price: string;
|
|
4133
|
+
funding_rate: string;
|
|
4134
|
+
funding_rate_indicative: string;
|
|
4135
|
+
index_price: string;
|
|
4136
|
+
quanto_base_rate?: string;
|
|
4137
|
+
basis_rate: string;
|
|
4138
|
+
basis_value: string;
|
|
4139
|
+
lowest_ask: string;
|
|
4140
|
+
highest_bid: string;
|
|
4307
4141
|
}
|
|
4308
4142
|
⋮----
|
|
4309
|
-
export interface
|
|
4143
|
+
export interface DeliveryAccount {
|
|
4144
|
+
total: string;
|
|
4145
|
+
unrealised_pnl: string;
|
|
4146
|
+
position_margin: string;
|
|
4147
|
+
order_margin: string;
|
|
4148
|
+
available: string;
|
|
4149
|
+
point: string;
|
|
4150
|
+
currency: string;
|
|
4151
|
+
in_dual_mode: boolean;
|
|
4152
|
+
enable_credit: boolean;
|
|
4153
|
+
position_initial_margin: string;
|
|
4154
|
+
maintenance_margin: string;
|
|
4155
|
+
bonus: string;
|
|
4156
|
+
enable_evolved_classic: boolean;
|
|
4157
|
+
cross_order_margin: string;
|
|
4158
|
+
cross_initial_margin: string;
|
|
4159
|
+
cross_maintenance_margin: string;
|
|
4160
|
+
cross_unrealised_pnl: string;
|
|
4161
|
+
cross_available: string;
|
|
4162
|
+
isolated_position_margin: string;
|
|
4163
|
+
history: {
|
|
4164
|
+
dnw: string;
|
|
4165
|
+
pnl: string;
|
|
4166
|
+
fee: string;
|
|
4167
|
+
refr: string;
|
|
4168
|
+
fund: string;
|
|
4169
|
+
point_dnw: string;
|
|
4170
|
+
point_fee: string;
|
|
4171
|
+
point_refr: string;
|
|
4172
|
+
bonus_dnw: string;
|
|
4173
|
+
bonus_offset: string;
|
|
4174
|
+
};
|
|
4175
|
+
enable_tiered_mm: boolean;
|
|
4176
|
+
}
|
|
4177
|
+
⋮----
|
|
4178
|
+
export interface DeliveryBook {
|
|
4179
|
+
time: number;
|
|
4180
|
+
change: string;
|
|
4181
|
+
balance: string;
|
|
4182
|
+
type:
|
|
4183
|
+
| 'dnw'
|
|
4184
|
+
| 'pnl'
|
|
4185
|
+
| 'fee'
|
|
4186
|
+
| 'refr'
|
|
4187
|
+
| 'fund'
|
|
4188
|
+
| 'point_dnw'
|
|
4189
|
+
| 'point_fee'
|
|
4190
|
+
| 'point_refr'
|
|
4191
|
+
| 'bonus_offset';
|
|
4192
|
+
text: string;
|
|
4193
|
+
contract?: string;
|
|
4194
|
+
trade_id?: string;
|
|
4195
|
+
}
|
|
4196
|
+
⋮----
|
|
4197
|
+
export interface DeliveryTradingHistoryRecord {
|
|
4198
|
+
id: number;
|
|
4199
|
+
create_time: number;
|
|
4200
|
+
contract: string;
|
|
4201
|
+
order_id: string;
|
|
4202
|
+
size: number;
|
|
4203
|
+
price: string;
|
|
4204
|
+
role: 'taker' | 'maker';
|
|
4205
|
+
text: string;
|
|
4206
|
+
fee: string;
|
|
4207
|
+
point_fee: string;
|
|
4208
|
+
}
|
|
4209
|
+
⋮----
|
|
4210
|
+
export interface DeliveryClosedPosition {
|
|
4211
|
+
time: number;
|
|
4212
|
+
contract: string;
|
|
4213
|
+
side: 'long' | 'short';
|
|
4214
|
+
pnl: string;
|
|
4215
|
+
pnl_pnl: string;
|
|
4216
|
+
pnl_fund: string;
|
|
4217
|
+
pnl_fee: string;
|
|
4218
|
+
text: string;
|
|
4219
|
+
max_size: string;
|
|
4220
|
+
first_open_time: number;
|
|
4221
|
+
long_price: string;
|
|
4222
|
+
short_price: string;
|
|
4223
|
+
}
|
|
4224
|
+
⋮----
|
|
4225
|
+
export interface DeliveryLiquidationHistoryRecord {
|
|
4226
|
+
time: number;
|
|
4227
|
+
contract: string;
|
|
4228
|
+
leverage?: string;
|
|
4229
|
+
size: number;
|
|
4230
|
+
margin?: string;
|
|
4231
|
+
entry_price?: string;
|
|
4232
|
+
liq_price?: string;
|
|
4233
|
+
mark_price?: string;
|
|
4234
|
+
order_id?: number;
|
|
4235
|
+
order_price: string;
|
|
4236
|
+
fill_price: string;
|
|
4237
|
+
left: number;
|
|
4238
|
+
}
|
|
4239
|
+
⋮----
|
|
4240
|
+
export interface DeliverySettlementHistoryRecord {
|
|
4241
|
+
time: number;
|
|
4242
|
+
contract: string;
|
|
4243
|
+
leverage: string;
|
|
4244
|
+
size: number;
|
|
4245
|
+
margin: string;
|
|
4246
|
+
entry_price: string;
|
|
4247
|
+
settle_price: string;
|
|
4248
|
+
profit: string;
|
|
4249
|
+
fee: string;
|
|
4250
|
+
}
|
|
4251
|
+
|
|
4252
|
+
================
|
|
4253
|
+
File: .eslintrc.cjs
|
|
4254
|
+
================
|
|
4255
|
+
// 'no-unused-vars': ['warn'],
|
|
4256
|
+
|
|
4257
|
+
================
|
|
4258
|
+
File: .gitignore
|
|
4259
|
+
================
|
|
4260
|
+
!.gitkeep
|
|
4261
|
+
.DS_STORE
|
|
4262
|
+
*.log
|
|
4263
|
+
npm-debug.log*
|
|
4264
|
+
yarn-debug.log*
|
|
4265
|
+
yarn-error.log*
|
|
4266
|
+
lerna-debug.log*
|
|
4267
|
+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
4268
|
+
pids
|
|
4269
|
+
*.pid
|
|
4270
|
+
*.seed
|
|
4271
|
+
*.pid.lock
|
|
4272
|
+
node_modules/
|
|
4273
|
+
.npm
|
|
4274
|
+
.eslintcache
|
|
4275
|
+
.node_repl_history
|
|
4276
|
+
*.tgz
|
|
4277
|
+
.yarn-integrity
|
|
4278
|
+
.env
|
|
4279
|
+
.env.test
|
|
4280
|
+
.cache
|
|
4281
|
+
bundleReport.html
|
|
4282
|
+
.history/
|
|
4283
|
+
dist
|
|
4284
|
+
coverage
|
|
4285
|
+
localtest.sh
|
|
4286
|
+
repomix.sh
|
|
4287
|
+
|
|
4288
|
+
ws-private-spot-wsapi-performance.ts
|
|
4289
|
+
ws-private-perp-futures-wsapi-readonly.ts
|
|
4290
|
+
privatetest.ts
|
|
4291
|
+
|
|
4292
|
+
privaterepotracker
|
|
4293
|
+
restClientRegex.ts
|
|
4294
|
+
|
|
4295
|
+
testfile.ts
|
|
4296
|
+
|
|
4297
|
+
================
|
|
4298
|
+
File: src/types/request/futures.ts
|
|
4299
|
+
================
|
|
4300
|
+
/**==========================================================================================================================
|
|
4301
|
+
* FUTURES
|
|
4302
|
+
* ==========================================================================================================================
|
|
4303
|
+
*/
|
|
4304
|
+
⋮----
|
|
4305
|
+
export interface GetFuturesOrderBookReq {
|
|
4306
|
+
settle: 'btc' | 'usdt' | 'usd';
|
|
4307
|
+
contract: string;
|
|
4308
|
+
interval?: string;
|
|
4309
|
+
limit?: number;
|
|
4310
|
+
with_id?: boolean;
|
|
4311
|
+
}
|
|
4312
|
+
⋮----
|
|
4313
|
+
export interface GetFuturesTradesReq {
|
|
4314
|
+
settle: 'btc' | 'usdt' | 'usd';
|
|
4315
|
+
contract: string;
|
|
4316
|
+
limit?: number;
|
|
4317
|
+
offset?: number;
|
|
4318
|
+
last_id?: string;
|
|
4319
|
+
from?: number;
|
|
4320
|
+
to?: number;
|
|
4321
|
+
}
|
|
4322
|
+
⋮----
|
|
4323
|
+
export interface GetFuturesCandlesReq {
|
|
4324
|
+
settle: 'btc' | 'usdt' | 'usd';
|
|
4325
|
+
contract: string;
|
|
4326
|
+
from?: number;
|
|
4327
|
+
to?: number;
|
|
4328
|
+
limit?: number;
|
|
4329
|
+
interval?: string;
|
|
4330
|
+
}
|
|
4331
|
+
⋮----
|
|
4332
|
+
export interface GetFuturesStatsReq {
|
|
4333
|
+
settle: 'btc' | 'usdt' | 'usd';
|
|
4334
|
+
contract: string;
|
|
4335
|
+
from?: number;
|
|
4336
|
+
interval?: string;
|
|
4337
|
+
limit?: number;
|
|
4338
|
+
}
|
|
4339
|
+
⋮----
|
|
4340
|
+
export interface GetFundingRatesReq {
|
|
4341
|
+
settle: 'btc' | 'usdt' | 'usd';
|
|
4342
|
+
contract: string;
|
|
4343
|
+
limit?: number;
|
|
4344
|
+
from?: number;
|
|
4345
|
+
to?: number;
|
|
4346
|
+
}
|
|
4347
|
+
⋮----
|
|
4348
|
+
export interface GetLiquidationHistoryReq {
|
|
4349
|
+
settle: 'btc' | 'usdt' | 'usd';
|
|
4350
|
+
contract?: string;
|
|
4351
|
+
from?: number;
|
|
4352
|
+
to?: number;
|
|
4353
|
+
limit?: number;
|
|
4354
|
+
}
|
|
4355
|
+
⋮----
|
|
4356
|
+
export interface GetRiskLimitTiersReq {
|
|
4310
4357
|
settle: 'btc' | 'usdt' | 'usd';
|
|
4311
4358
|
contract: string;
|
|
4312
4359
|
limit?: number;
|
|
@@ -4498,52 +4545,7 @@ price?: string; // New order price
|
|
|
4498
4545
|
amend_text?: string; // Custom info during amending order
|
|
4499
4546
|
|
|
4500
4547
|
================
|
|
4501
|
-
File: .
|
|
4502
|
-
================
|
|
4503
|
-
// 'no-unused-vars': ['warn'],
|
|
4504
|
-
|
|
4505
|
-
================
|
|
4506
|
-
File: .gitignore
|
|
4507
|
-
================
|
|
4508
|
-
!.gitkeep
|
|
4509
|
-
.DS_STORE
|
|
4510
|
-
*.log
|
|
4511
|
-
npm-debug.log*
|
|
4512
|
-
yarn-debug.log*
|
|
4513
|
-
yarn-error.log*
|
|
4514
|
-
lerna-debug.log*
|
|
4515
|
-
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
4516
|
-
pids
|
|
4517
|
-
*.pid
|
|
4518
|
-
*.seed
|
|
4519
|
-
*.pid.lock
|
|
4520
|
-
node_modules/
|
|
4521
|
-
.npm
|
|
4522
|
-
.eslintcache
|
|
4523
|
-
.node_repl_history
|
|
4524
|
-
*.tgz
|
|
4525
|
-
.yarn-integrity
|
|
4526
|
-
.env
|
|
4527
|
-
.env.test
|
|
4528
|
-
.cache
|
|
4529
|
-
bundleReport.html
|
|
4530
|
-
.history/
|
|
4531
|
-
dist
|
|
4532
|
-
coverage
|
|
4533
|
-
localtest.sh
|
|
4534
|
-
repomix.sh
|
|
4535
|
-
|
|
4536
|
-
ws-private-spot-wsapi-performance.ts
|
|
4537
|
-
ws-private-perp-futures-wsapi-readonly.ts
|
|
4538
|
-
privatetest.ts
|
|
4539
|
-
|
|
4540
|
-
privaterepotracker
|
|
4541
|
-
restClientRegex.ts
|
|
4542
|
-
|
|
4543
|
-
testfile.ts
|
|
4544
|
-
|
|
4545
|
-
================
|
|
4546
|
-
File: src/types/response/unified.ts
|
|
4548
|
+
File: src/types/response/unified.ts
|
|
4547
4549
|
================
|
|
4548
4550
|
export interface UnifiedAccountInfo {
|
|
4549
4551
|
user_id: number;
|
|
@@ -4767,6 +4769,7 @@ import {
|
|
|
4767
4769
|
serializeParams,
|
|
4768
4770
|
} from './requestUtils.js';
|
|
4769
4771
|
import {
|
|
4772
|
+
checkWebCryptoAPISupported,
|
|
4770
4773
|
hashMessage,
|
|
4771
4774
|
SignAlgorithm,
|
|
4772
4775
|
SignEncodeMethod,
|
|
@@ -4855,6 +4858,8 @@ constructor(
|
|
|
4855
4858
|
// For more advanced configuration, raise an issue on GitHub or use the "networkOptions"
|
|
4856
4859
|
// parameter to define a custom httpsAgent with the desired properties
|
|
4857
4860
|
⋮----
|
|
4861
|
+
// Check Web Crypto API support when credentials are provided and no custom sign function is used
|
|
4862
|
+
⋮----
|
|
4858
4863
|
// Throw if one of the 3 values is missing, but at least one of them is set
|
|
4859
4864
|
⋮----
|
|
4860
4865
|
/**
|
|
@@ -5878,590 +5883,92 @@ export interface SpotHistoricTradeRecord {
|
|
|
5878
5883
|
}
|
|
5879
5884
|
|
|
5880
5885
|
================
|
|
5881
|
-
File: src/
|
|
5886
|
+
File: src/lib/BaseWSClient.ts
|
|
5882
5887
|
================
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
* ==========================================================================================================================
|
|
5886
|
-
*/
|
|
5888
|
+
import EventEmitter from 'events';
|
|
5889
|
+
import WebSocket from 'isomorphic-ws';
|
|
5887
5890
|
⋮----
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
}
|
|
5891
|
+
import {
|
|
5892
|
+
WebsocketClientOptions,
|
|
5893
|
+
WSClientConfigurableOptions,
|
|
5894
|
+
} from '../types/websockets/client.js';
|
|
5895
|
+
import { WsOperation } from '../types/websockets/requests.js';
|
|
5896
|
+
import { WS_LOGGER_CATEGORY } from '../WebsocketClient.js';
|
|
5897
|
+
import { DefaultLogger } from './logger.js';
|
|
5898
|
+
import { isMessageEvent, MessageEventLike } from './requestUtils.js';
|
|
5899
|
+
import { checkWebCryptoAPISupported } from './webCryptoAPI.js';
|
|
5900
|
+
import {
|
|
5901
|
+
safeTerminateWs,
|
|
5902
|
+
WsTopicRequest,
|
|
5903
|
+
WsTopicRequestOrStringTopic,
|
|
5904
|
+
} from './websocket/websocket-util.js';
|
|
5905
|
+
import { WsStore } from './websocket/WsStore.js';
|
|
5906
|
+
import {
|
|
5907
|
+
WSConnectedResult,
|
|
5908
|
+
WsConnectionStateEnum,
|
|
5909
|
+
} from './websocket/WsStore.types.js';
|
|
5895
5910
|
⋮----
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5911
|
+
interface WSClientEventMap<WsKey extends string> {
|
|
5912
|
+
/** Connection opened. If this connection was previously opened and reconnected, expect the reconnected event instead */
|
|
5913
|
+
open: (evt: {
|
|
5914
|
+
wsKey: WsKey;
|
|
5915
|
+
event: any;
|
|
5916
|
+
wsUrl: string;
|
|
5917
|
+
ws: WebSocket;
|
|
5918
|
+
}) => void /** Reconnecting a dropped connection */;
|
|
5919
|
+
reconnect: (evt: { wsKey: WsKey; event: any }) => void;
|
|
5920
|
+
/** Successfully reconnected a connection that dropped */
|
|
5921
|
+
reconnected: (evt: {
|
|
5922
|
+
wsKey: WsKey;
|
|
5923
|
+
event: any;
|
|
5924
|
+
wsUrl: string;
|
|
5925
|
+
ws: WebSocket;
|
|
5926
|
+
}) => void;
|
|
5927
|
+
/** Connection closed */
|
|
5928
|
+
close: (evt: { wsKey: WsKey; event: any }) => void;
|
|
5929
|
+
/** Received reply to websocket command (e.g. after subscribing to topics) */
|
|
5930
|
+
response: (response: any & { wsKey: WsKey }) => void;
|
|
5931
|
+
/** Received data for topic */
|
|
5932
|
+
update: (response: any & { wsKey: WsKey }) => void;
|
|
5933
|
+
/** Exception from ws client OR custom listeners (e.g. if you throw inside your event handler) */
|
|
5934
|
+
exception: (response: any & { wsKey: WsKey }) => void;
|
|
5935
|
+
error: (response: any & { wsKey: WsKey }) => void;
|
|
5936
|
+
/** Confirmation that a connection successfully authenticated */
|
|
5937
|
+
authenticated: (event: { wsKey: WsKey; event: any }) => void;
|
|
5904
5938
|
}
|
|
5905
5939
|
⋮----
|
|
5906
|
-
|
|
5907
|
-
t: number;
|
|
5908
|
-
v?: number;
|
|
5909
|
-
c: string;
|
|
5910
|
-
h: string;
|
|
5911
|
-
l: string;
|
|
5912
|
-
o: string;
|
|
5913
|
-
sum: string;
|
|
5914
|
-
}
|
|
5940
|
+
/** Connection opened. If this connection was previously opened and reconnected, expect the reconnected event instead */
|
|
5915
5941
|
⋮----
|
|
5916
|
-
|
|
5917
|
-
t: number;
|
|
5918
|
-
c: string;
|
|
5919
|
-
h: string;
|
|
5920
|
-
l: string;
|
|
5921
|
-
o: string;
|
|
5922
|
-
}
|
|
5942
|
+
}) => void /** Reconnecting a dropped connection */;
|
|
5923
5943
|
⋮----
|
|
5924
|
-
|
|
5925
|
-
contract: string;
|
|
5926
|
-
last: string;
|
|
5927
|
-
change_percentage: string;
|
|
5928
|
-
total_size: string;
|
|
5929
|
-
low_24h: string;
|
|
5930
|
-
high_24h: string;
|
|
5931
|
-
volume_24h: string;
|
|
5932
|
-
volume_24h_btc?: string;
|
|
5933
|
-
volume_24h_usd?: string;
|
|
5934
|
-
volume_24h_base: string;
|
|
5935
|
-
volume_24h_quote: string;
|
|
5936
|
-
volume_24h_settle: string;
|
|
5937
|
-
mark_price: string;
|
|
5938
|
-
funding_rate: string;
|
|
5939
|
-
funding_rate_indicative: string;
|
|
5940
|
-
index_price: string;
|
|
5941
|
-
quanto_base_rate?: string;
|
|
5942
|
-
basis_rate: string;
|
|
5943
|
-
basis_value: string;
|
|
5944
|
-
lowest_ask: string;
|
|
5945
|
-
highest_bid: string;
|
|
5946
|
-
lowest_size: string;
|
|
5947
|
-
highest_size: string;
|
|
5948
|
-
}
|
|
5944
|
+
/** Successfully reconnected a connection that dropped */
|
|
5949
5945
|
⋮----
|
|
5950
|
-
|
|
5951
|
-
time: number;
|
|
5952
|
-
lsr_taker: number;
|
|
5953
|
-
lsr_account: number;
|
|
5954
|
-
long_liq_size: number;
|
|
5955
|
-
long_liq_amount: number;
|
|
5956
|
-
long_liq_usd: number;
|
|
5957
|
-
short_liq_size: number;
|
|
5958
|
-
short_liq_amount: number;
|
|
5959
|
-
short_liq_usd: number;
|
|
5960
|
-
open_interest: number;
|
|
5961
|
-
open_interest_usd: number;
|
|
5962
|
-
top_lsr_account: number;
|
|
5963
|
-
top_lsr_size: number;
|
|
5964
|
-
}
|
|
5946
|
+
/** Connection closed */
|
|
5965
5947
|
⋮----
|
|
5966
|
-
|
|
5967
|
-
index: string;
|
|
5968
|
-
constituents: {
|
|
5969
|
-
exchange: string;
|
|
5970
|
-
symbols: string[];
|
|
5971
|
-
}[];
|
|
5972
|
-
}
|
|
5948
|
+
/** Received reply to websocket command (e.g. after subscribing to topics) */
|
|
5973
5949
|
⋮----
|
|
5974
|
-
|
|
5975
|
-
time: number;
|
|
5976
|
-
contract: string;
|
|
5977
|
-
size: number;
|
|
5978
|
-
order_size: number;
|
|
5979
|
-
order_price: string;
|
|
5980
|
-
fill_price: string;
|
|
5981
|
-
left: number;
|
|
5982
|
-
}
|
|
5950
|
+
/** Received data for topic */
|
|
5983
5951
|
⋮----
|
|
5984
|
-
|
|
5985
|
-
tier: number;
|
|
5986
|
-
risk_limit: string;
|
|
5987
|
-
initial_rate: string;
|
|
5988
|
-
maintenance_rate: string;
|
|
5989
|
-
leverage_max: string;
|
|
5990
|
-
contract: string;
|
|
5991
|
-
}
|
|
5952
|
+
/** Exception from ws client OR custom listeners (e.g. if you throw inside your event handler) */
|
|
5992
5953
|
⋮----
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
available: string;
|
|
5999
|
-
point: string;
|
|
6000
|
-
currency: string;
|
|
6001
|
-
in_dual_mode: boolean;
|
|
6002
|
-
enable_credit: boolean;
|
|
6003
|
-
position_initial_margin: string;
|
|
6004
|
-
maintenance_margin: string;
|
|
6005
|
-
bonus: string;
|
|
6006
|
-
enable_evolved_classic: boolean;
|
|
6007
|
-
cross_order_margin: string;
|
|
6008
|
-
cross_initial_margin: string;
|
|
6009
|
-
cross_maintenance_margin: string;
|
|
6010
|
-
cross_unrealised_pnl: string;
|
|
6011
|
-
cross_available: string;
|
|
6012
|
-
cross_margin_balance: string;
|
|
6013
|
-
cross_mmr: string;
|
|
6014
|
-
cross_imr: string;
|
|
6015
|
-
isolated_position_margin: string;
|
|
6016
|
-
enable_new_dual_mode: boolean;
|
|
6017
|
-
margin_mode: number;
|
|
6018
|
-
history: {
|
|
6019
|
-
dnw: string;
|
|
6020
|
-
pnl: string;
|
|
6021
|
-
fee: string;
|
|
6022
|
-
refr: string;
|
|
6023
|
-
fund: string;
|
|
6024
|
-
point_dnw: string;
|
|
6025
|
-
point_fee: string;
|
|
6026
|
-
point_refr: string;
|
|
6027
|
-
bonus_dnw: string;
|
|
6028
|
-
bonus_offset: string;
|
|
6029
|
-
};
|
|
6030
|
-
enable_tiered_mm: boolean;
|
|
5954
|
+
/** Confirmation that a connection successfully authenticated */
|
|
5955
|
+
⋮----
|
|
5956
|
+
export interface EmittableEvent<TEvent = any> {
|
|
5957
|
+
eventType: 'response' | 'update' | 'exception' | 'authenticated';
|
|
5958
|
+
event: TEvent;
|
|
6031
5959
|
}
|
|
6032
5960
|
⋮----
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
export interface FuturesOrder {
|
|
6045
|
-
id?: number;
|
|
6046
|
-
user?: number;
|
|
6047
|
-
create_time?: number;
|
|
6048
|
-
finish_time?: number;
|
|
6049
|
-
finish_as?:
|
|
6050
|
-
| 'filled'
|
|
6051
|
-
| 'cancelled'
|
|
6052
|
-
| 'liquidated'
|
|
6053
|
-
| 'ioc'
|
|
6054
|
-
| 'auto_deleveraged'
|
|
6055
|
-
| 'reduce_only'
|
|
6056
|
-
| 'position_closed'
|
|
6057
|
-
| 'stp';
|
|
6058
|
-
status?: 'open' | 'finished';
|
|
6059
|
-
contract: string;
|
|
6060
|
-
size: number;
|
|
6061
|
-
iceberg?: number;
|
|
6062
|
-
price?: string;
|
|
6063
|
-
close?: boolean;
|
|
6064
|
-
is_close?: boolean;
|
|
6065
|
-
reduce_only?: boolean;
|
|
6066
|
-
is_reduce_only?: boolean;
|
|
6067
|
-
is_liq?: boolean;
|
|
6068
|
-
tif?: 'gtc' | 'ioc' | 'poc' | 'fok';
|
|
6069
|
-
left?: number;
|
|
6070
|
-
fill_price?: string;
|
|
6071
|
-
text?: string;
|
|
6072
|
-
tkfr?: string;
|
|
6073
|
-
mkfr?: string;
|
|
6074
|
-
refu?: number;
|
|
6075
|
-
auto_size?: 'close_long' | 'close_short';
|
|
6076
|
-
stp_id?: number;
|
|
6077
|
-
stp_act?: 'cn' | 'co' | 'cb' | '-';
|
|
6078
|
-
amend_text?: string;
|
|
6079
|
-
biz_info?: string;
|
|
6080
|
-
}
|
|
6081
|
-
⋮----
|
|
6082
|
-
export interface FuturesPosition {
|
|
6083
|
-
user?: number;
|
|
6084
|
-
contract?: string;
|
|
6085
|
-
size?: number;
|
|
6086
|
-
leverage?: string;
|
|
6087
|
-
risk_limit?: string;
|
|
6088
|
-
leverage_max?: string;
|
|
6089
|
-
maintenance_rate?: string;
|
|
6090
|
-
value?: string;
|
|
6091
|
-
margin?: string;
|
|
6092
|
-
entry_price?: string;
|
|
6093
|
-
liq_price?: string;
|
|
6094
|
-
mark_price?: string;
|
|
6095
|
-
initial_margin?: string;
|
|
6096
|
-
maintenance_margin?: string;
|
|
6097
|
-
unrealised_pnl?: string;
|
|
6098
|
-
realised_pnl?: string;
|
|
6099
|
-
pnl_pnl?: string;
|
|
6100
|
-
pnl_fund?: string;
|
|
6101
|
-
pnl_fee?: string;
|
|
6102
|
-
history_pnl?: string;
|
|
6103
|
-
last_close_pnl?: string;
|
|
6104
|
-
realised_point?: string;
|
|
6105
|
-
history_point?: string;
|
|
6106
|
-
adl_ranking?: number;
|
|
6107
|
-
pending_orders?: number;
|
|
6108
|
-
close_order?: {
|
|
6109
|
-
id?: number;
|
|
6110
|
-
price?: string;
|
|
6111
|
-
is_liq?: boolean;
|
|
6112
|
-
} | null;
|
|
6113
|
-
mode?: 'single' | 'dual_long' | 'dual_short';
|
|
6114
|
-
cross_leverage_limit?: string;
|
|
6115
|
-
update_time?: number;
|
|
6116
|
-
update_id?: number;
|
|
6117
|
-
open_time?: number;
|
|
6118
|
-
}
|
|
6119
|
-
⋮----
|
|
6120
|
-
export interface FuturesTradingHistoryRecord {
|
|
6121
|
-
id: number;
|
|
6122
|
-
create_time: number;
|
|
6123
|
-
contract: string;
|
|
6124
|
-
order_id: string;
|
|
6125
|
-
size: number;
|
|
6126
|
-
price: string;
|
|
6127
|
-
role: 'taker' | 'maker';
|
|
6128
|
-
text: string;
|
|
6129
|
-
fee: string;
|
|
6130
|
-
point_fee: string;
|
|
6131
|
-
close_size: number;
|
|
6132
|
-
}
|
|
6133
|
-
⋮----
|
|
6134
|
-
export interface FuturesPositionHistoryRecord {
|
|
6135
|
-
time: number;
|
|
6136
|
-
contract: string;
|
|
6137
|
-
side: 'long' | 'short';
|
|
6138
|
-
pnl: string;
|
|
6139
|
-
pnl_pnl: string;
|
|
6140
|
-
pnl_fund: string;
|
|
6141
|
-
pnl_fee: string;
|
|
6142
|
-
text: string;
|
|
6143
|
-
max_size: string;
|
|
6144
|
-
first_open_time: number;
|
|
6145
|
-
long_price: string;
|
|
6146
|
-
short_price: string;
|
|
6147
|
-
accum_size: string;
|
|
6148
|
-
}
|
|
6149
|
-
⋮----
|
|
6150
|
-
export interface FuturesLiquidationHistoryRecord {
|
|
6151
|
-
time: number;
|
|
6152
|
-
contract: string;
|
|
6153
|
-
leverage: string;
|
|
6154
|
-
size: number;
|
|
6155
|
-
margin: string;
|
|
6156
|
-
entry_price: string;
|
|
6157
|
-
liq_price: string;
|
|
6158
|
-
mark_price: string;
|
|
6159
|
-
order_id: number;
|
|
6160
|
-
order_price: string;
|
|
6161
|
-
fill_price: string;
|
|
6162
|
-
left: number;
|
|
6163
|
-
}
|
|
6164
|
-
export interface FuturesAutoDeleveragingHistoryRecord {
|
|
6165
|
-
time: number;
|
|
6166
|
-
user: number;
|
|
6167
|
-
order_id: number;
|
|
6168
|
-
contract: string;
|
|
6169
|
-
leverage: string;
|
|
6170
|
-
cross_leverage_limit: string;
|
|
6171
|
-
entry_price: string;
|
|
6172
|
-
fill_price: string;
|
|
6173
|
-
trade_size: number;
|
|
6174
|
-
position_size: number;
|
|
6175
|
-
}
|
|
6176
|
-
⋮----
|
|
6177
|
-
export interface DeleteFuturesBatchOrdersResp {
|
|
6178
|
-
user_id: number;
|
|
6179
|
-
id: string;
|
|
6180
|
-
succeeded: boolean;
|
|
6181
|
-
message: string;
|
|
6182
|
-
}
|
|
6183
|
-
⋮----
|
|
6184
|
-
export interface FuturesContract {
|
|
6185
|
-
name?: string;
|
|
6186
|
-
type?: 'inverse' | 'direct';
|
|
6187
|
-
quanto_multiplier?: string;
|
|
6188
|
-
leverage_min?: string;
|
|
6189
|
-
leverage_max?: string;
|
|
6190
|
-
maintenance_rate?: string;
|
|
6191
|
-
mark_type?: 'internal' | 'index';
|
|
6192
|
-
mark_price?: string;
|
|
6193
|
-
index_price?: string;
|
|
6194
|
-
last_price?: string;
|
|
6195
|
-
maker_fee_rate?: string;
|
|
6196
|
-
taker_fee_rate?: string;
|
|
6197
|
-
order_price_round?: string;
|
|
6198
|
-
mark_price_round?: string;
|
|
6199
|
-
funding_rate?: string;
|
|
6200
|
-
funding_interval?: number;
|
|
6201
|
-
funding_next_apply?: number;
|
|
6202
|
-
risk_limit_base?: string;
|
|
6203
|
-
risk_limit_step?: string;
|
|
6204
|
-
risk_limit_max?: string;
|
|
6205
|
-
order_size_min?: number;
|
|
6206
|
-
order_size_max?: number;
|
|
6207
|
-
order_price_deviate?: string;
|
|
6208
|
-
ref_discount_rate?: string;
|
|
6209
|
-
ref_rebate_rate?: string;
|
|
6210
|
-
orderbook_id?: number;
|
|
6211
|
-
trade_id?: number;
|
|
6212
|
-
trade_size?: number;
|
|
6213
|
-
position_size?: number;
|
|
6214
|
-
config_change_time?: number;
|
|
6215
|
-
in_delisting?: boolean;
|
|
6216
|
-
orders_limit?: number;
|
|
6217
|
-
enable_bonus?: boolean;
|
|
6218
|
-
enable_credit?: boolean;
|
|
6219
|
-
create_time?: number;
|
|
6220
|
-
funding_cap_ratio?: string;
|
|
6221
|
-
}
|
|
6222
|
-
⋮----
|
|
6223
|
-
export interface FuturesPriceTriggeredOrder {
|
|
6224
|
-
initial: {
|
|
6225
|
-
contract: string;
|
|
6226
|
-
size?: number;
|
|
6227
|
-
price?: string;
|
|
6228
|
-
close?: boolean;
|
|
6229
|
-
tif?: 'gtc' | 'ioc';
|
|
6230
|
-
text?: string;
|
|
6231
|
-
reduce_only?: boolean;
|
|
6232
|
-
auto_size?: string;
|
|
6233
|
-
is_reduce_only?: boolean;
|
|
6234
|
-
is_close?: boolean;
|
|
6235
|
-
};
|
|
6236
|
-
trigger: {
|
|
6237
|
-
strategy_type?: 0 | 1;
|
|
6238
|
-
price_type?: 0 | 1 | 2;
|
|
6239
|
-
price?: string;
|
|
6240
|
-
rule?: 1 | 2;
|
|
6241
|
-
expiration?: number;
|
|
6242
|
-
};
|
|
6243
|
-
id?: number;
|
|
6244
|
-
user?: number;
|
|
6245
|
-
create_time?: number;
|
|
6246
|
-
finish_time?: number;
|
|
6247
|
-
trade_id?: number;
|
|
6248
|
-
status?: 'open' | 'finished' | 'inactive' | 'invalid';
|
|
6249
|
-
finish_as?: 'cancelled' | 'succeeded' | 'failed' | 'expired';
|
|
6250
|
-
reason?: string;
|
|
6251
|
-
order_type?:
|
|
6252
|
-
| 'close-long-order'
|
|
6253
|
-
| 'close-short-order'
|
|
6254
|
-
| 'close-long-position'
|
|
6255
|
-
| 'close-short-position'
|
|
6256
|
-
| 'plan-close-long-position'
|
|
6257
|
-
| 'plan-close-short-position';
|
|
6258
|
-
me_order_id?: number;
|
|
6259
|
-
}
|
|
6260
|
-
⋮----
|
|
6261
|
-
export interface FuturesDeliveryContract {
|
|
6262
|
-
name?: string;
|
|
6263
|
-
underlying?: string;
|
|
6264
|
-
cycle?: 'WEEKLY' | 'BI-WEEKLY' | 'QUARTERLY' | 'BI-QUARTERLY';
|
|
6265
|
-
type?: 'inverse' | 'direct';
|
|
6266
|
-
quanto_multiplier?: string;
|
|
6267
|
-
leverage_min?: string;
|
|
6268
|
-
leverage_max?: string;
|
|
6269
|
-
maintenance_rate?: string;
|
|
6270
|
-
mark_type?: 'internal' | 'index';
|
|
6271
|
-
mark_price?: string;
|
|
6272
|
-
index_price?: string;
|
|
6273
|
-
last_price?: string;
|
|
6274
|
-
maker_fee_rate?: string;
|
|
6275
|
-
taker_fee_rate?: string;
|
|
6276
|
-
order_price_round?: string;
|
|
6277
|
-
mark_price_round?: string;
|
|
6278
|
-
basis_rate?: string;
|
|
6279
|
-
basis_value?: string;
|
|
6280
|
-
basis_impact_value?: string;
|
|
6281
|
-
settle_price?: string;
|
|
6282
|
-
settle_price_interval?: number;
|
|
6283
|
-
settle_price_duration?: number;
|
|
6284
|
-
expire_time?: number;
|
|
6285
|
-
risk_limit_base?: string;
|
|
6286
|
-
risk_limit_step?: string;
|
|
6287
|
-
risk_limit_max?: string;
|
|
6288
|
-
order_size_min?: number;
|
|
6289
|
-
order_size_max?: number;
|
|
6290
|
-
order_price_deviate?: string;
|
|
6291
|
-
ref_discount_rate?: string;
|
|
6292
|
-
ref_rebate_rate?: string;
|
|
6293
|
-
orderbook_id?: number;
|
|
6294
|
-
trade_id?: number;
|
|
6295
|
-
trade_size?: number;
|
|
6296
|
-
position_size?: number;
|
|
6297
|
-
config_change_time?: number;
|
|
6298
|
-
in_delisting?: boolean;
|
|
6299
|
-
orders_limit?: number;
|
|
6300
|
-
}
|
|
6301
|
-
⋮----
|
|
6302
|
-
export interface BatchAmendOrderResp {
|
|
6303
|
-
succeeded: boolean;
|
|
6304
|
-
label?: string;
|
|
6305
|
-
detail?: string;
|
|
6306
|
-
id: number;
|
|
6307
|
-
user: number;
|
|
6308
|
-
create_time: number;
|
|
6309
|
-
finish_time?: number;
|
|
6310
|
-
finish_as?:
|
|
6311
|
-
| 'filled'
|
|
6312
|
-
| 'cancelled'
|
|
6313
|
-
| 'liquidated'
|
|
6314
|
-
| 'ioc'
|
|
6315
|
-
| 'auto_deleveraged'
|
|
6316
|
-
| 'reduce_only'
|
|
6317
|
-
| 'position_closed'
|
|
6318
|
-
| 'reduce_out'
|
|
6319
|
-
| 'stp';
|
|
6320
|
-
status: 'open' | 'finished';
|
|
6321
|
-
contract: string;
|
|
6322
|
-
size: number;
|
|
6323
|
-
iceberg: number;
|
|
6324
|
-
price: string;
|
|
6325
|
-
is_close: boolean;
|
|
6326
|
-
is_reduce_only: boolean;
|
|
6327
|
-
is_liq: boolean;
|
|
6328
|
-
tif: 'gtc' | 'ioc' | 'poc' | 'fok';
|
|
6329
|
-
left: number;
|
|
6330
|
-
fill_price: string;
|
|
6331
|
-
text: string;
|
|
6332
|
-
tkfr: string;
|
|
6333
|
-
mkfr: string;
|
|
6334
|
-
refu: number;
|
|
6335
|
-
stp_act: 'co' | 'cn' | 'cb' | '-';
|
|
6336
|
-
stp_id: number;
|
|
6337
|
-
}
|
|
6338
|
-
⋮----
|
|
6339
|
-
/**
|
|
6340
|
-
* @deprecated - Use FuturesAccount instead
|
|
6341
|
-
*/
|
|
6342
|
-
export interface UpdateFuturesDualModeResp {
|
|
6343
|
-
total: string;
|
|
6344
|
-
unrealised_pnl: string;
|
|
6345
|
-
position_margin: string;
|
|
6346
|
-
order_margin: string;
|
|
6347
|
-
available: string;
|
|
6348
|
-
point: string;
|
|
6349
|
-
currency: string;
|
|
6350
|
-
in_dual_mode: boolean;
|
|
6351
|
-
enable_credit: boolean;
|
|
6352
|
-
position_initial_margin: string;
|
|
6353
|
-
maintenance_margin: string;
|
|
6354
|
-
bonus: string;
|
|
6355
|
-
enable_evolved_classic: boolean;
|
|
6356
|
-
history: {
|
|
6357
|
-
dnw: string;
|
|
6358
|
-
pnl: string;
|
|
6359
|
-
fee: string;
|
|
6360
|
-
refr: string;
|
|
6361
|
-
fund: string;
|
|
6362
|
-
point_dnw: string;
|
|
6363
|
-
point_fee: string;
|
|
6364
|
-
point_refr: string;
|
|
6365
|
-
bonus_dnw: string;
|
|
6366
|
-
bonus_offset: string;
|
|
6367
|
-
};
|
|
6368
|
-
}
|
|
6369
|
-
⋮----
|
|
6370
|
-
export interface RiskLimitTableTier {
|
|
6371
|
-
tier: number;
|
|
6372
|
-
risk_limit: string;
|
|
6373
|
-
initial_rate: string;
|
|
6374
|
-
maintenance_rate: string;
|
|
6375
|
-
leverage_max: string;
|
|
6376
|
-
deduction: string;
|
|
6377
|
-
}
|
|
6378
|
-
|
|
6379
|
-
================
|
|
6380
|
-
File: src/lib/BaseWSClient.ts
|
|
6381
|
-
================
|
|
6382
|
-
import EventEmitter from 'events';
|
|
6383
|
-
import WebSocket from 'isomorphic-ws';
|
|
6384
|
-
⋮----
|
|
6385
|
-
import {
|
|
6386
|
-
WebsocketClientOptions,
|
|
6387
|
-
WSClientConfigurableOptions,
|
|
6388
|
-
} from '../types/websockets/client.js';
|
|
6389
|
-
import { WsOperation } from '../types/websockets/requests.js';
|
|
6390
|
-
import { WS_LOGGER_CATEGORY } from '../WebsocketClient.js';
|
|
6391
|
-
import { DefaultLogger } from './logger.js';
|
|
6392
|
-
import { isMessageEvent, MessageEventLike } from './requestUtils.js';
|
|
6393
|
-
import {
|
|
6394
|
-
safeTerminateWs,
|
|
6395
|
-
WsTopicRequest,
|
|
6396
|
-
WsTopicRequestOrStringTopic,
|
|
6397
|
-
} from './websocket/websocket-util.js';
|
|
6398
|
-
import { WsStore } from './websocket/WsStore.js';
|
|
6399
|
-
import {
|
|
6400
|
-
WSConnectedResult,
|
|
6401
|
-
WsConnectionStateEnum,
|
|
6402
|
-
} from './websocket/WsStore.types.js';
|
|
6403
|
-
⋮----
|
|
6404
|
-
interface WSClientEventMap<WsKey extends string> {
|
|
6405
|
-
/** Connection opened. If this connection was previously opened and reconnected, expect the reconnected event instead */
|
|
6406
|
-
open: (evt: {
|
|
6407
|
-
wsKey: WsKey;
|
|
6408
|
-
event: any;
|
|
6409
|
-
wsUrl: string;
|
|
6410
|
-
ws: WebSocket;
|
|
6411
|
-
}) => void /** Reconnecting a dropped connection */;
|
|
6412
|
-
reconnect: (evt: { wsKey: WsKey; event: any }) => void;
|
|
6413
|
-
/** Successfully reconnected a connection that dropped */
|
|
6414
|
-
reconnected: (evt: {
|
|
6415
|
-
wsKey: WsKey;
|
|
6416
|
-
event: any;
|
|
6417
|
-
wsUrl: string;
|
|
6418
|
-
ws: WebSocket;
|
|
6419
|
-
}) => void;
|
|
6420
|
-
/** Connection closed */
|
|
6421
|
-
close: (evt: { wsKey: WsKey; event: any }) => void;
|
|
6422
|
-
/** Received reply to websocket command (e.g. after subscribing to topics) */
|
|
6423
|
-
response: (response: any & { wsKey: WsKey }) => void;
|
|
6424
|
-
/** Received data for topic */
|
|
6425
|
-
update: (response: any & { wsKey: WsKey }) => void;
|
|
6426
|
-
/** Exception from ws client OR custom listeners (e.g. if you throw inside your event handler) */
|
|
6427
|
-
exception: (response: any & { wsKey: WsKey }) => void;
|
|
6428
|
-
error: (response: any & { wsKey: WsKey }) => void;
|
|
6429
|
-
/** Confirmation that a connection successfully authenticated */
|
|
6430
|
-
authenticated: (event: { wsKey: WsKey; event: any }) => void;
|
|
6431
|
-
}
|
|
6432
|
-
⋮----
|
|
6433
|
-
/** Connection opened. If this connection was previously opened and reconnected, expect the reconnected event instead */
|
|
6434
|
-
⋮----
|
|
6435
|
-
}) => void /** Reconnecting a dropped connection */;
|
|
6436
|
-
⋮----
|
|
6437
|
-
/** Successfully reconnected a connection that dropped */
|
|
6438
|
-
⋮----
|
|
6439
|
-
/** Connection closed */
|
|
6440
|
-
⋮----
|
|
6441
|
-
/** Received reply to websocket command (e.g. after subscribing to topics) */
|
|
6442
|
-
⋮----
|
|
6443
|
-
/** Received data for topic */
|
|
6444
|
-
⋮----
|
|
6445
|
-
/** Exception from ws client OR custom listeners (e.g. if you throw inside your event handler) */
|
|
6446
|
-
⋮----
|
|
6447
|
-
/** Confirmation that a connection successfully authenticated */
|
|
6448
|
-
⋮----
|
|
6449
|
-
export interface EmittableEvent<TEvent = any> {
|
|
6450
|
-
eventType: 'response' | 'update' | 'exception' | 'authenticated';
|
|
6451
|
-
event: TEvent;
|
|
6452
|
-
}
|
|
6453
|
-
⋮----
|
|
6454
|
-
// Type safety for on and emit handlers: https://stackoverflow.com/a/61609010/880837
|
|
6455
|
-
export interface BaseWebsocketClient<TWSKey extends string> {
|
|
6456
|
-
on<U extends keyof WSClientEventMap<TWSKey>>(
|
|
6457
|
-
event: U,
|
|
6458
|
-
listener: WSClientEventMap<TWSKey>[U],
|
|
6459
|
-
): this;
|
|
6460
|
-
|
|
6461
|
-
emit<U extends keyof WSClientEventMap<TWSKey>>(
|
|
6462
|
-
event: U,
|
|
6463
|
-
...args: Parameters<WSClientEventMap<TWSKey>[U]>
|
|
6464
|
-
): boolean;
|
|
5961
|
+
// Type safety for on and emit handlers: https://stackoverflow.com/a/61609010/880837
|
|
5962
|
+
export interface BaseWebsocketClient<TWSKey extends string> {
|
|
5963
|
+
on<U extends keyof WSClientEventMap<TWSKey>>(
|
|
5964
|
+
event: U,
|
|
5965
|
+
listener: WSClientEventMap<TWSKey>[U],
|
|
5966
|
+
): this;
|
|
5967
|
+
|
|
5968
|
+
emit<U extends keyof WSClientEventMap<TWSKey>>(
|
|
5969
|
+
event: U,
|
|
5970
|
+
...args: Parameters<WSClientEventMap<TWSKey>[U]>
|
|
5971
|
+
): boolean;
|
|
6465
5972
|
}
|
|
6466
5973
|
⋮----
|
|
6467
5974
|
on<U extends keyof WSClientEventMap<TWSKey>>(
|
|
@@ -6514,6 +6021,8 @@ constructor(
|
|
|
6514
6021
|
⋮----
|
|
6515
6022
|
// Automatically re-auth WS API, if we were auth'd before and get reconnected
|
|
6516
6023
|
⋮----
|
|
6024
|
+
// Check Web Crypto API support when credentials are provided and no custom sign function is used
|
|
6025
|
+
⋮----
|
|
6517
6026
|
protected abstract isAuthOnConnectWsKey(wsKey: TWSKey): boolean;
|
|
6518
6027
|
⋮----
|
|
6519
6028
|
protected abstract sendPingEvent(wsKey: TWSKey, ws: WebSocket): void;
|
|
@@ -6747,66 +6256,565 @@ private async onWsOpen(
|
|
|
6747
6256
|
⋮----
|
|
6748
6257
|
// Request sub to private topics, if auth on connect isn't needed
|
|
6749
6258
|
⋮----
|
|
6750
|
-
// If enabled, automatically reauth WS API if reconnected
|
|
6259
|
+
// If enabled, automatically reauth WS API if reconnected
|
|
6260
|
+
⋮----
|
|
6261
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
6262
|
+
⋮----
|
|
6263
|
+
/**
|
|
6264
|
+
* Handle subscription to private topics _after_ authentication successfully completes asynchronously.
|
|
6265
|
+
*
|
|
6266
|
+
* Only used for exchanges that require auth before sending private topic subscription requests
|
|
6267
|
+
*/
|
|
6268
|
+
private onWsAuthenticated(
|
|
6269
|
+
wsKey: TWSKey,
|
|
6270
|
+
event: { isWSAPI?: boolean; WSAPIAuthChannel?: string },
|
|
6271
|
+
)
|
|
6272
|
+
⋮----
|
|
6273
|
+
// Resolve & cleanup deferred "auth attempt in progress" promise
|
|
6274
|
+
⋮----
|
|
6275
|
+
// Remove before continuing, in case there's more requests queued
|
|
6276
|
+
⋮----
|
|
6277
|
+
private onWsMessage(event: unknown, wsKey: TWSKey, ws: WebSocket)
|
|
6278
|
+
⋮----
|
|
6279
|
+
// any message can clear the pong timer - wouldn't get a message if the ws wasn't working
|
|
6280
|
+
⋮----
|
|
6281
|
+
// console.log(`raw event: `, { data, dataType, emittableEvents });
|
|
6282
|
+
⋮----
|
|
6283
|
+
private onWsClose(event: unknown, wsKey: TWSKey)
|
|
6284
|
+
⋮----
|
|
6285
|
+
// unintentional close, attempt recovery
|
|
6286
|
+
⋮----
|
|
6287
|
+
// clean up any pending promises for this connection
|
|
6288
|
+
⋮----
|
|
6289
|
+
// intentional close - clean up
|
|
6290
|
+
// clean up any pending promises for this connection
|
|
6291
|
+
⋮----
|
|
6292
|
+
// clean up any pending promises for this connection
|
|
6293
|
+
⋮----
|
|
6294
|
+
// This was an intentional close, delete all state for this connection, as if it never existed:
|
|
6295
|
+
⋮----
|
|
6296
|
+
private getWs(wsKey: TWSKey)
|
|
6297
|
+
⋮----
|
|
6298
|
+
private setWsState(wsKey: TWSKey, state: WsConnectionStateEnum)
|
|
6299
|
+
⋮----
|
|
6300
|
+
/**
|
|
6301
|
+
* Promise-driven method to assert that a ws has successfully connected (will await until connection is open)
|
|
6302
|
+
*/
|
|
6303
|
+
protected async assertIsConnected(wsKey: TWSKey): Promise<unknown>
|
|
6304
|
+
⋮----
|
|
6305
|
+
// Already in progress? Await shared promise and retry
|
|
6306
|
+
⋮----
|
|
6307
|
+
// Start connection, it should automatically store/return a promise.
|
|
6308
|
+
⋮----
|
|
6309
|
+
/**
|
|
6310
|
+
* Promise-driven method to assert that a ws has been successfully authenticated (will await until auth is confirmed)
|
|
6311
|
+
*/
|
|
6312
|
+
public async assertIsAuthenticated(wsKey: TWSKey): Promise<unknown>
|
|
6313
|
+
⋮----
|
|
6314
|
+
// Already in progress? Await shared promise and retry
|
|
6315
|
+
⋮----
|
|
6316
|
+
// this.logger.trace('assertIsAuthenticated(): ok');
|
|
6317
|
+
⋮----
|
|
6318
|
+
// Start authentication, it should automatically store/return a promise.
|
|
6319
|
+
|
|
6320
|
+
================
|
|
6321
|
+
File: src/types/response/futures.ts
|
|
6322
|
+
================
|
|
6323
|
+
/**==========================================================================================================================
|
|
6324
|
+
* FUTURES
|
|
6325
|
+
* ==========================================================================================================================
|
|
6326
|
+
*/
|
|
6327
|
+
⋮----
|
|
6328
|
+
export interface FuturesOrderBook {
|
|
6329
|
+
id?: number;
|
|
6330
|
+
current: number;
|
|
6331
|
+
update: number;
|
|
6332
|
+
asks: { p: string; s: number }[];
|
|
6333
|
+
bids: { p: string; s: number }[];
|
|
6334
|
+
}
|
|
6751
6335
|
⋮----
|
|
6752
|
-
|
|
6336
|
+
export interface FuturesTrade {
|
|
6337
|
+
id: number;
|
|
6338
|
+
create_time: number;
|
|
6339
|
+
create_time_ms: number;
|
|
6340
|
+
contract: string;
|
|
6341
|
+
size: number;
|
|
6342
|
+
price: string;
|
|
6343
|
+
is_internal?: boolean;
|
|
6344
|
+
}
|
|
6753
6345
|
⋮----
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6346
|
+
export interface FuturesCandle {
|
|
6347
|
+
t: number;
|
|
6348
|
+
v?: number;
|
|
6349
|
+
c: string;
|
|
6350
|
+
h: string;
|
|
6351
|
+
l: string;
|
|
6352
|
+
o: string;
|
|
6353
|
+
sum: string;
|
|
6354
|
+
}
|
|
6763
6355
|
⋮----
|
|
6764
|
-
|
|
6356
|
+
export interface PremiumIndexKLine {
|
|
6357
|
+
t: number;
|
|
6358
|
+
c: string;
|
|
6359
|
+
h: string;
|
|
6360
|
+
l: string;
|
|
6361
|
+
o: string;
|
|
6362
|
+
}
|
|
6765
6363
|
⋮----
|
|
6766
|
-
|
|
6364
|
+
export interface FuturesTicker {
|
|
6365
|
+
contract: string;
|
|
6366
|
+
last: string;
|
|
6367
|
+
change_percentage: string;
|
|
6368
|
+
total_size: string;
|
|
6369
|
+
low_24h: string;
|
|
6370
|
+
high_24h: string;
|
|
6371
|
+
volume_24h: string;
|
|
6372
|
+
volume_24h_btc?: string;
|
|
6373
|
+
volume_24h_usd?: string;
|
|
6374
|
+
volume_24h_base: string;
|
|
6375
|
+
volume_24h_quote: string;
|
|
6376
|
+
volume_24h_settle: string;
|
|
6377
|
+
mark_price: string;
|
|
6378
|
+
funding_rate: string;
|
|
6379
|
+
funding_rate_indicative: string;
|
|
6380
|
+
index_price: string;
|
|
6381
|
+
quanto_base_rate?: string;
|
|
6382
|
+
basis_rate: string;
|
|
6383
|
+
basis_value: string;
|
|
6384
|
+
lowest_ask: string;
|
|
6385
|
+
highest_bid: string;
|
|
6386
|
+
lowest_size: string;
|
|
6387
|
+
highest_size: string;
|
|
6388
|
+
}
|
|
6767
6389
|
⋮----
|
|
6768
|
-
|
|
6390
|
+
export interface FuturesStats {
|
|
6391
|
+
time: number;
|
|
6392
|
+
lsr_taker: number;
|
|
6393
|
+
lsr_account: number;
|
|
6394
|
+
long_liq_size: number;
|
|
6395
|
+
long_liq_amount: number;
|
|
6396
|
+
long_liq_usd: number;
|
|
6397
|
+
short_liq_size: number;
|
|
6398
|
+
short_liq_amount: number;
|
|
6399
|
+
short_liq_usd: number;
|
|
6400
|
+
open_interest: number;
|
|
6401
|
+
open_interest_usd: number;
|
|
6402
|
+
top_lsr_account: number;
|
|
6403
|
+
top_lsr_size: number;
|
|
6404
|
+
}
|
|
6769
6405
|
⋮----
|
|
6770
|
-
|
|
6406
|
+
export interface IndexConstituents {
|
|
6407
|
+
index: string;
|
|
6408
|
+
constituents: {
|
|
6409
|
+
exchange: string;
|
|
6410
|
+
symbols: string[];
|
|
6411
|
+
}[];
|
|
6412
|
+
}
|
|
6771
6413
|
⋮----
|
|
6772
|
-
|
|
6414
|
+
export interface LiquidationHistoryRecord {
|
|
6415
|
+
time: number;
|
|
6416
|
+
contract: string;
|
|
6417
|
+
size: number;
|
|
6418
|
+
order_size: number;
|
|
6419
|
+
order_price: string;
|
|
6420
|
+
fill_price: string;
|
|
6421
|
+
left: number;
|
|
6422
|
+
}
|
|
6773
6423
|
⋮----
|
|
6774
|
-
|
|
6424
|
+
export interface RiskLimitTier {
|
|
6425
|
+
tier: number;
|
|
6426
|
+
risk_limit: string;
|
|
6427
|
+
initial_rate: string;
|
|
6428
|
+
maintenance_rate: string;
|
|
6429
|
+
leverage_max: string;
|
|
6430
|
+
contract: string;
|
|
6431
|
+
}
|
|
6775
6432
|
⋮----
|
|
6776
|
-
|
|
6433
|
+
export interface FuturesAccount {
|
|
6434
|
+
total: string;
|
|
6435
|
+
unrealised_pnl: string;
|
|
6436
|
+
position_margin: string;
|
|
6437
|
+
order_margin: string;
|
|
6438
|
+
available: string;
|
|
6439
|
+
point: string;
|
|
6440
|
+
currency: string;
|
|
6441
|
+
in_dual_mode: boolean;
|
|
6442
|
+
enable_credit: boolean;
|
|
6443
|
+
position_initial_margin: string;
|
|
6444
|
+
maintenance_margin: string;
|
|
6445
|
+
bonus: string;
|
|
6446
|
+
enable_evolved_classic: boolean;
|
|
6447
|
+
cross_order_margin: string;
|
|
6448
|
+
cross_initial_margin: string;
|
|
6449
|
+
cross_maintenance_margin: string;
|
|
6450
|
+
cross_unrealised_pnl: string;
|
|
6451
|
+
cross_available: string;
|
|
6452
|
+
cross_margin_balance: string;
|
|
6453
|
+
cross_mmr: string;
|
|
6454
|
+
cross_imr: string;
|
|
6455
|
+
isolated_position_margin: string;
|
|
6456
|
+
enable_new_dual_mode: boolean;
|
|
6457
|
+
margin_mode: number;
|
|
6458
|
+
history: {
|
|
6459
|
+
dnw: string;
|
|
6460
|
+
pnl: string;
|
|
6461
|
+
fee: string;
|
|
6462
|
+
refr: string;
|
|
6463
|
+
fund: string;
|
|
6464
|
+
point_dnw: string;
|
|
6465
|
+
point_fee: string;
|
|
6466
|
+
point_refr: string;
|
|
6467
|
+
bonus_dnw: string;
|
|
6468
|
+
bonus_offset: string;
|
|
6469
|
+
};
|
|
6470
|
+
enable_tiered_mm: boolean;
|
|
6471
|
+
}
|
|
6777
6472
|
⋮----
|
|
6778
|
-
|
|
6473
|
+
export interface FuturesAccountBookRecord {
|
|
6474
|
+
time: number;
|
|
6475
|
+
change: string;
|
|
6476
|
+
balance: string;
|
|
6477
|
+
type: string;
|
|
6478
|
+
text: string;
|
|
6479
|
+
contract?: string;
|
|
6480
|
+
trade_id: string;
|
|
6481
|
+
id: string;
|
|
6482
|
+
}
|
|
6779
6483
|
⋮----
|
|
6780
|
-
|
|
6781
|
-
|
|
6484
|
+
export interface FuturesOrder {
|
|
6485
|
+
id?: number;
|
|
6486
|
+
user?: number;
|
|
6487
|
+
create_time?: number;
|
|
6488
|
+
finish_time?: number;
|
|
6489
|
+
finish_as?:
|
|
6490
|
+
| 'filled'
|
|
6491
|
+
| 'cancelled'
|
|
6492
|
+
| 'liquidated'
|
|
6493
|
+
| 'ioc'
|
|
6494
|
+
| 'auto_deleveraged'
|
|
6495
|
+
| 'reduce_only'
|
|
6496
|
+
| 'position_closed'
|
|
6497
|
+
| 'stp';
|
|
6498
|
+
status?: 'open' | 'finished';
|
|
6499
|
+
contract: string;
|
|
6500
|
+
size: number;
|
|
6501
|
+
iceberg?: number;
|
|
6502
|
+
price?: string;
|
|
6503
|
+
close?: boolean;
|
|
6504
|
+
is_close?: boolean;
|
|
6505
|
+
reduce_only?: boolean;
|
|
6506
|
+
is_reduce_only?: boolean;
|
|
6507
|
+
is_liq?: boolean;
|
|
6508
|
+
tif?: 'gtc' | 'ioc' | 'poc' | 'fok';
|
|
6509
|
+
left?: number;
|
|
6510
|
+
fill_price?: string;
|
|
6511
|
+
text?: string;
|
|
6512
|
+
tkfr?: string;
|
|
6513
|
+
mkfr?: string;
|
|
6514
|
+
refu?: number;
|
|
6515
|
+
auto_size?: 'close_long' | 'close_short';
|
|
6516
|
+
stp_id?: number;
|
|
6517
|
+
stp_act?: 'cn' | 'co' | 'cb' | '-';
|
|
6518
|
+
amend_text?: string;
|
|
6519
|
+
biz_info?: string;
|
|
6520
|
+
}
|
|
6782
6521
|
⋮----
|
|
6783
|
-
|
|
6522
|
+
export interface FuturesPosition {
|
|
6523
|
+
user?: number;
|
|
6524
|
+
contract?: string;
|
|
6525
|
+
size?: number;
|
|
6526
|
+
leverage?: string;
|
|
6527
|
+
risk_limit?: string;
|
|
6528
|
+
leverage_max?: string;
|
|
6529
|
+
maintenance_rate?: string;
|
|
6530
|
+
value?: string;
|
|
6531
|
+
margin?: string;
|
|
6532
|
+
entry_price?: string;
|
|
6533
|
+
liq_price?: string;
|
|
6534
|
+
mark_price?: string;
|
|
6535
|
+
initial_margin?: string;
|
|
6536
|
+
maintenance_margin?: string;
|
|
6537
|
+
unrealised_pnl?: string;
|
|
6538
|
+
realised_pnl?: string;
|
|
6539
|
+
pnl_pnl?: string;
|
|
6540
|
+
pnl_fund?: string;
|
|
6541
|
+
pnl_fee?: string;
|
|
6542
|
+
history_pnl?: string;
|
|
6543
|
+
last_close_pnl?: string;
|
|
6544
|
+
realised_point?: string;
|
|
6545
|
+
history_point?: string;
|
|
6546
|
+
adl_ranking?: number;
|
|
6547
|
+
pending_orders?: number;
|
|
6548
|
+
close_order?: {
|
|
6549
|
+
id?: number;
|
|
6550
|
+
price?: string;
|
|
6551
|
+
is_liq?: boolean;
|
|
6552
|
+
} | null;
|
|
6553
|
+
mode?: 'single' | 'dual_long' | 'dual_short';
|
|
6554
|
+
cross_leverage_limit?: string;
|
|
6555
|
+
update_time?: number;
|
|
6556
|
+
update_id?: number;
|
|
6557
|
+
open_time?: number;
|
|
6558
|
+
}
|
|
6784
6559
|
⋮----
|
|
6785
|
-
|
|
6560
|
+
export interface FuturesTradingHistoryRecord {
|
|
6561
|
+
id: number;
|
|
6562
|
+
create_time: number;
|
|
6563
|
+
contract: string;
|
|
6564
|
+
order_id: string;
|
|
6565
|
+
size: number;
|
|
6566
|
+
price: string;
|
|
6567
|
+
role: 'taker' | 'maker';
|
|
6568
|
+
text: string;
|
|
6569
|
+
fee: string;
|
|
6570
|
+
point_fee: string;
|
|
6571
|
+
close_size: number;
|
|
6572
|
+
}
|
|
6786
6573
|
⋮----
|
|
6787
|
-
|
|
6574
|
+
export interface FuturesPositionHistoryRecord {
|
|
6575
|
+
time: number;
|
|
6576
|
+
contract: string;
|
|
6577
|
+
side: 'long' | 'short';
|
|
6578
|
+
pnl: string;
|
|
6579
|
+
pnl_pnl: string;
|
|
6580
|
+
pnl_fund: string;
|
|
6581
|
+
pnl_fee: string;
|
|
6582
|
+
text: string;
|
|
6583
|
+
max_size: string;
|
|
6584
|
+
first_open_time: number;
|
|
6585
|
+
long_price: string;
|
|
6586
|
+
short_price: string;
|
|
6587
|
+
accum_size: string;
|
|
6588
|
+
}
|
|
6788
6589
|
⋮----
|
|
6789
|
-
|
|
6590
|
+
export interface FuturesLiquidationHistoryRecord {
|
|
6591
|
+
time: number;
|
|
6592
|
+
contract: string;
|
|
6593
|
+
leverage: string;
|
|
6594
|
+
size: number;
|
|
6595
|
+
margin: string;
|
|
6596
|
+
entry_price: string;
|
|
6597
|
+
liq_price: string;
|
|
6598
|
+
mark_price: string;
|
|
6599
|
+
order_id: number;
|
|
6600
|
+
order_price: string;
|
|
6601
|
+
fill_price: string;
|
|
6602
|
+
left: number;
|
|
6603
|
+
}
|
|
6604
|
+
export interface FuturesAutoDeleveragingHistoryRecord {
|
|
6605
|
+
time: number;
|
|
6606
|
+
user: number;
|
|
6607
|
+
order_id: number;
|
|
6608
|
+
contract: string;
|
|
6609
|
+
leverage: string;
|
|
6610
|
+
cross_leverage_limit: string;
|
|
6611
|
+
entry_price: string;
|
|
6612
|
+
fill_price: string;
|
|
6613
|
+
trade_size: number;
|
|
6614
|
+
position_size: number;
|
|
6615
|
+
}
|
|
6790
6616
|
⋮----
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6617
|
+
export interface DeleteFuturesBatchOrdersResp {
|
|
6618
|
+
user_id: number;
|
|
6619
|
+
id: string;
|
|
6620
|
+
succeeded: boolean;
|
|
6621
|
+
message: string;
|
|
6622
|
+
}
|
|
6795
6623
|
⋮----
|
|
6796
|
-
|
|
6624
|
+
export interface FuturesContract {
|
|
6625
|
+
name?: string;
|
|
6626
|
+
type?: 'inverse' | 'direct';
|
|
6627
|
+
quanto_multiplier?: string;
|
|
6628
|
+
leverage_min?: string;
|
|
6629
|
+
leverage_max?: string;
|
|
6630
|
+
maintenance_rate?: string;
|
|
6631
|
+
mark_type?: 'internal' | 'index';
|
|
6632
|
+
mark_price?: string;
|
|
6633
|
+
index_price?: string;
|
|
6634
|
+
last_price?: string;
|
|
6635
|
+
maker_fee_rate?: string;
|
|
6636
|
+
taker_fee_rate?: string;
|
|
6637
|
+
order_price_round?: string;
|
|
6638
|
+
mark_price_round?: string;
|
|
6639
|
+
funding_rate?: string;
|
|
6640
|
+
funding_interval?: number;
|
|
6641
|
+
funding_next_apply?: number;
|
|
6642
|
+
risk_limit_base?: string;
|
|
6643
|
+
risk_limit_step?: string;
|
|
6644
|
+
risk_limit_max?: string;
|
|
6645
|
+
order_size_min?: number;
|
|
6646
|
+
order_size_max?: number;
|
|
6647
|
+
order_price_deviate?: string;
|
|
6648
|
+
ref_discount_rate?: string;
|
|
6649
|
+
ref_rebate_rate?: string;
|
|
6650
|
+
orderbook_id?: number;
|
|
6651
|
+
trade_id?: number;
|
|
6652
|
+
trade_size?: number;
|
|
6653
|
+
position_size?: number;
|
|
6654
|
+
config_change_time?: number;
|
|
6655
|
+
in_delisting?: boolean;
|
|
6656
|
+
orders_limit?: number;
|
|
6657
|
+
enable_bonus?: boolean;
|
|
6658
|
+
enable_credit?: boolean;
|
|
6659
|
+
create_time?: number;
|
|
6660
|
+
funding_cap_ratio?: string;
|
|
6661
|
+
}
|
|
6797
6662
|
⋮----
|
|
6798
|
-
|
|
6663
|
+
export interface FuturesPriceTriggeredOrder {
|
|
6664
|
+
initial: {
|
|
6665
|
+
contract: string;
|
|
6666
|
+
size?: number;
|
|
6667
|
+
price?: string;
|
|
6668
|
+
close?: boolean;
|
|
6669
|
+
tif?: 'gtc' | 'ioc';
|
|
6670
|
+
text?: string;
|
|
6671
|
+
reduce_only?: boolean;
|
|
6672
|
+
auto_size?: string;
|
|
6673
|
+
is_reduce_only?: boolean;
|
|
6674
|
+
is_close?: boolean;
|
|
6675
|
+
};
|
|
6676
|
+
trigger: {
|
|
6677
|
+
strategy_type?: 0 | 1;
|
|
6678
|
+
price_type?: 0 | 1 | 2;
|
|
6679
|
+
price?: string;
|
|
6680
|
+
rule?: 1 | 2;
|
|
6681
|
+
expiration?: number;
|
|
6682
|
+
};
|
|
6683
|
+
id?: number;
|
|
6684
|
+
user?: number;
|
|
6685
|
+
create_time?: number;
|
|
6686
|
+
finish_time?: number;
|
|
6687
|
+
trade_id?: number;
|
|
6688
|
+
status?: 'open' | 'finished' | 'inactive' | 'invalid';
|
|
6689
|
+
finish_as?: 'cancelled' | 'succeeded' | 'failed' | 'expired';
|
|
6690
|
+
reason?: string;
|
|
6691
|
+
order_type?:
|
|
6692
|
+
| 'close-long-order'
|
|
6693
|
+
| 'close-short-order'
|
|
6694
|
+
| 'close-long-position'
|
|
6695
|
+
| 'close-short-position'
|
|
6696
|
+
| 'plan-close-long-position'
|
|
6697
|
+
| 'plan-close-short-position';
|
|
6698
|
+
me_order_id?: number;
|
|
6699
|
+
}
|
|
6799
6700
|
⋮----
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6701
|
+
export interface FuturesDeliveryContract {
|
|
6702
|
+
name?: string;
|
|
6703
|
+
underlying?: string;
|
|
6704
|
+
cycle?: 'WEEKLY' | 'BI-WEEKLY' | 'QUARTERLY' | 'BI-QUARTERLY';
|
|
6705
|
+
type?: 'inverse' | 'direct';
|
|
6706
|
+
quanto_multiplier?: string;
|
|
6707
|
+
leverage_min?: string;
|
|
6708
|
+
leverage_max?: string;
|
|
6709
|
+
maintenance_rate?: string;
|
|
6710
|
+
mark_type?: 'internal' | 'index';
|
|
6711
|
+
mark_price?: string;
|
|
6712
|
+
index_price?: string;
|
|
6713
|
+
last_price?: string;
|
|
6714
|
+
maker_fee_rate?: string;
|
|
6715
|
+
taker_fee_rate?: string;
|
|
6716
|
+
order_price_round?: string;
|
|
6717
|
+
mark_price_round?: string;
|
|
6718
|
+
basis_rate?: string;
|
|
6719
|
+
basis_value?: string;
|
|
6720
|
+
basis_impact_value?: string;
|
|
6721
|
+
settle_price?: string;
|
|
6722
|
+
settle_price_interval?: number;
|
|
6723
|
+
settle_price_duration?: number;
|
|
6724
|
+
expire_time?: number;
|
|
6725
|
+
risk_limit_base?: string;
|
|
6726
|
+
risk_limit_step?: string;
|
|
6727
|
+
risk_limit_max?: string;
|
|
6728
|
+
order_size_min?: number;
|
|
6729
|
+
order_size_max?: number;
|
|
6730
|
+
order_price_deviate?: string;
|
|
6731
|
+
ref_discount_rate?: string;
|
|
6732
|
+
ref_rebate_rate?: string;
|
|
6733
|
+
orderbook_id?: number;
|
|
6734
|
+
trade_id?: number;
|
|
6735
|
+
trade_size?: number;
|
|
6736
|
+
position_size?: number;
|
|
6737
|
+
config_change_time?: number;
|
|
6738
|
+
in_delisting?: boolean;
|
|
6739
|
+
orders_limit?: number;
|
|
6740
|
+
}
|
|
6804
6741
|
⋮----
|
|
6805
|
-
|
|
6742
|
+
export interface BatchAmendOrderResp {
|
|
6743
|
+
succeeded: boolean;
|
|
6744
|
+
label?: string;
|
|
6745
|
+
detail?: string;
|
|
6746
|
+
id: number;
|
|
6747
|
+
user: number;
|
|
6748
|
+
create_time: number;
|
|
6749
|
+
finish_time?: number;
|
|
6750
|
+
finish_as?:
|
|
6751
|
+
| 'filled'
|
|
6752
|
+
| 'cancelled'
|
|
6753
|
+
| 'liquidated'
|
|
6754
|
+
| 'ioc'
|
|
6755
|
+
| 'auto_deleveraged'
|
|
6756
|
+
| 'reduce_only'
|
|
6757
|
+
| 'position_closed'
|
|
6758
|
+
| 'reduce_out'
|
|
6759
|
+
| 'stp';
|
|
6760
|
+
status: 'open' | 'finished';
|
|
6761
|
+
contract: string;
|
|
6762
|
+
size: number;
|
|
6763
|
+
iceberg: number;
|
|
6764
|
+
price: string;
|
|
6765
|
+
is_close: boolean;
|
|
6766
|
+
is_reduce_only: boolean;
|
|
6767
|
+
is_liq: boolean;
|
|
6768
|
+
tif: 'gtc' | 'ioc' | 'poc' | 'fok';
|
|
6769
|
+
left: number;
|
|
6770
|
+
fill_price: string;
|
|
6771
|
+
text: string;
|
|
6772
|
+
tkfr: string;
|
|
6773
|
+
mkfr: string;
|
|
6774
|
+
refu: number;
|
|
6775
|
+
stp_act: 'co' | 'cn' | 'cb' | '-';
|
|
6776
|
+
stp_id: number;
|
|
6777
|
+
}
|
|
6806
6778
|
⋮----
|
|
6807
|
-
|
|
6779
|
+
/**
|
|
6780
|
+
* @deprecated - Use FuturesAccount instead
|
|
6781
|
+
*/
|
|
6782
|
+
export interface UpdateFuturesDualModeResp {
|
|
6783
|
+
total: string;
|
|
6784
|
+
unrealised_pnl: string;
|
|
6785
|
+
position_margin: string;
|
|
6786
|
+
order_margin: string;
|
|
6787
|
+
available: string;
|
|
6788
|
+
point: string;
|
|
6789
|
+
currency: string;
|
|
6790
|
+
in_dual_mode: boolean;
|
|
6791
|
+
enable_credit: boolean;
|
|
6792
|
+
position_initial_margin: string;
|
|
6793
|
+
maintenance_margin: string;
|
|
6794
|
+
bonus: string;
|
|
6795
|
+
enable_evolved_classic: boolean;
|
|
6796
|
+
history: {
|
|
6797
|
+
dnw: string;
|
|
6798
|
+
pnl: string;
|
|
6799
|
+
fee: string;
|
|
6800
|
+
refr: string;
|
|
6801
|
+
fund: string;
|
|
6802
|
+
point_dnw: string;
|
|
6803
|
+
point_fee: string;
|
|
6804
|
+
point_refr: string;
|
|
6805
|
+
bonus_dnw: string;
|
|
6806
|
+
bonus_offset: string;
|
|
6807
|
+
};
|
|
6808
|
+
}
|
|
6808
6809
|
⋮----
|
|
6809
|
-
|
|
6810
|
+
export interface RiskLimitTableTier {
|
|
6811
|
+
tier: number;
|
|
6812
|
+
risk_limit: string;
|
|
6813
|
+
initial_rate: string;
|
|
6814
|
+
maintenance_rate: string;
|
|
6815
|
+
leverage_max: string;
|
|
6816
|
+
deduction: string;
|
|
6817
|
+
}
|
|
6810
6818
|
|
|
6811
6819
|
================
|
|
6812
6820
|
File: src/WebsocketAPIClient.ts
|
|
@@ -7133,6 +7141,7 @@ Updated & performant JavaScript & Node.js SDK for the Gate.com (gate.io) REST AP
|
|
|
7133
7141
|
- [REST-like API](#rest-like-api)
|
|
7134
7142
|
- [Customise Logging](#customise-logging)
|
|
7135
7143
|
- [LLMs & AI](#use-with-llms--ai)
|
|
7144
|
+
- [Used By](#used-by)
|
|
7136
7145
|
- [Contributions & Thanks](#contributions--thanks)
|
|
7137
7146
|
|
|
7138
7147
|
## Installation
|
|
@@ -7508,6 +7517,12 @@ This file contains AI optimised structure of all the functions in this package,
|
|
|
7508
7517
|
|
|
7509
7518
|
---
|
|
7510
7519
|
|
|
7520
|
+
## Used By
|
|
7521
|
+
|
|
7522
|
+
[](https://github.com/tiagosiebler/gateio-api/network/dependents)
|
|
7523
|
+
|
|
7524
|
+
---
|
|
7525
|
+
|
|
7511
7526
|
<!-- template_contributions -->
|
|
7512
7527
|
|
|
7513
7528
|
### Contributions & Thanks
|
|
@@ -11516,7 +11531,7 @@ File: package.json
|
|
|
11516
11531
|
================
|
|
11517
11532
|
{
|
|
11518
11533
|
"name": "gateio-api",
|
|
11519
|
-
"version": "1.2.
|
|
11534
|
+
"version": "1.2.7",
|
|
11520
11535
|
"description": "Complete & Robust Node.js SDK for Gate.com's REST APIs, WebSockets & WebSocket APIs, with TypeScript declarations.",
|
|
11521
11536
|
"scripts": {
|
|
11522
11537
|
"clean": "rm -rf dist/*",
|