-
-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathllms.txt
More file actions
16068 lines (15756 loc) · 381 KB
/
Copy pathllms.txt
File metadata and controls
16068 lines (15756 loc) · 381 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
This file is a merged representation of a subset of the codebase, containing files not matching ignore patterns, combined into a single document by Repomix.
The content has been processed where content has been compressed (code blocks are separated by ⋮---- delimiter).
================================================================
File Summary
================================================================
Purpose:
--------
This file contains a packed representation of a subset of the repository's contents that is considered the most important context.
It is designed to be easily consumable by AI systems for analysis, code review,
or other automated processes.
File Format:
------------
The content is organized as follows:
1. This summary section
2. Repository information
3. Directory structure
4. Repository files (if enabled)
5. Multiple file entries, each consisting of:
a. A separator line (================)
b. The file path (File: path/to/file)
c. Another separator line
d. The full contents of the file
e. A blank line
Usage Guidelines:
-----------------
- This file should be treated as read-only. Any changes should be made to the
original repository files, not this packed version.
- When processing this file, use the file path to distinguish
between different files in the repository.
- Be aware that this file may contain sensitive information. Handle it with
the same level of security as you would the original repository.
Notes:
------
- Some files may have been excluded based on .gitignore rules and Repomix's configuration
- Binary files are not included in this packed representation. Please refer to the Repository Structure section for a complete list of file paths, including binary files
- Files matching these patterns are excluded: .github/, examples/apidoc/, docs/images/, docs/endpointFunctionList.md, test/, src/util/, dist/, lib/
- Files matching patterns in .gitignore are excluded
- Files matching default ignore patterns are excluded
- Content has been compressed - code blocks are separated by ⋮---- delimiter
- Files are sorted by Git change count (files with more changes are at the bottom)
================================================================
Directory Structure
================================================================
examples/
auth/
fasterHmacSign.ts
rest-private-rsa.md
rest-private-rsa.ts
V2 - Classic/
Rest/
rest-private-futures.ts
rest-private-spot.ts
rest-public-futures.ts
rest-public-spot.ts
rest-trade-futures.ts
rest-trade-spot.ts
Websocket/
ws-demo-trading.ts
ws-private.ts
ws-public.ts
V3 - UTA/
Rest/
rest-private.ts
rest-public-UTA-futures.ts
rest-public-UTA-spot.ts
rest-trade-UTA-futures.ts
rest-trade-UTA-spot.ts
Websocket/
ws-private.ts
ws-public.ts
WS-API/
ws-api-client-trade.ts
ws-api-trade-raw.ts
README.md
src/
constants/
enum.ts
types/
request/
v2/
broker.ts
common.ts
copytrading.ts
earn.ts
futures.ts
margin.ts
spot.ts
v3/
account.ts
broker.ts
copytrading.ts
earn.ts
loan.ts
p2p.ts
public.ts
strategy.ts
trade.ts
shared.ts
response/
v2/
broker.ts
common.ts
copy-trading.ts
earn.ts
futures.ts
margin.ts
spot.ts
v3/
account.ts
broker.ts
copytrading.ts
earn.ts
loan.ts
p2p.ts
public.ts
strategy.ts
trade.ts
websockets/
ws-api-request.ts
ws-api-response.ts
ws-api.ts
ws-events.ts
ws-general.ts
shared.ts
index.ts
rest-client-v2.ts
rest-client-v3.ts
websocket-api-client.ts
websocket-client-v2.ts
websocket-client-v3.ts
webpack/
webpack.config.cjs
.eslintrc.cjs
.gitignore
.jshintrc
.nvmrc
.prettierrc
jest.config.ts
LICENSE.md
package.json
postBuild.sh
README.md
tsconfig.cjs.json
tsconfig.esm.json
tsconfig.json
tsconfig.linting.json
================================================================
Files
================================================================
================
File: examples/auth/rest-private-rsa.md
================
# RSA Authentication with Bitget APIs in Node.js, JavaScript & TypeScript
## Creating RSA Keys
Officially, Bitget recommends downloading and running a key generator from their repo. Guidance for this can be found on the Bitget's website when trying to add a new RSA API key.
However, openssl can be used to create the public & private key files using the following steps:
```bash
# Generate a private key with either 2048 or 4096 bit length
openssl genrsa -out rsa-private-key.pem 4096
# Generate a corresponding public key
openssl rsa -in rsa-private-key.pem -pubout -out rsa-public-key.pem
```
## Using the RSA public key to get an API key from Bitget
Once created, keep your **private key** completely secret! The **public** key needs to be provided to Bitget when creating new API credentials with the "Self-generated" option.
Your public key should look something like this:
```pem
-----BEGIN PUBLIC KEY-----
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA1uWxxOXZUaX6AeZszf4x
rBsU6axA5ipwxG7VPihVgssphDrrSOD0hZqnBmtF2bvT9ee1U0XOfMn+H+J5SH+1
jgUpfioqH0L+KXl6wmLoPsadgfJz0SiQlFnKTkDXvMmecr6cdMHi2qNEx4CMc68C
obvQ4Voz5qqpDwbohGtJh0p10PB//0Ejcoz0UwrTDq8BGeFmWa9pL/7h2vHtw+QU
UxlnGmt98M8KkKqqvVicMK+IVtng/QlDw9ofG2kQcbBkPRaTjNI+8ULtCDH0sOkZ
nT8PtGm4sEwmWH/dRWtUTWkMnUwCzuo/rWPb7WMprW2pKDTrLjUAr9M161t3Xa6W
JO03K3NOxupy7ilululLY8d/WKWYDOZMvS5bPiPRUoZqlJneC0CT/2q1W6GfWzsT
DCDTpgq/Ao7jTtnME9iadpwvFn0nMtNgJSrFDWPq8vKY9pRcEp/Na5qvIEOQIFnp
/kIDPuMf+LZwO8lGFO3jnndY+62835rm7t6ZNM3NLoNCarvUCEasobgDJHw7x7c1
fW/OxYtLrWGdMpsP0MewgGJZXcT7mvlBjQ+JWLoyIc5rYMIDw9RLWUPnrlRCxvPp
sD9kDX7eaipdoik5yLyMaRvd16Vt9Bck/9pbSHazm41m/nd4KCZeGdsvrAA2beww
zFWQQV9EX6/VLBgbnGTsMe0CAwEAAQ==
-----END PUBLIC KEY-----
```
Submit this in the "Upload public key" form, shown when creating a new API key on Bitget and choosing the "self-generated"/RSA option.
Note: the "-----BEGIN PUBLIC KEY-----" and "-----END PUBLIC KEY-----" header & footer can be included.
After using the public key to create a new API key, you will be given an API Key such as the following:
```
SIHqWcDeRoj6gkOjLjQh1dnV1CD7IgwQTfL4LVa8wu04zNTYVSmJBIHsjQjgwWqt
```
This is the first piece, used as the "apiKey" in the [rest-private-rsa.ts](./rest-private-rsa.ts) example.
## Using the RSA private key for RSA authentication with Bitget APIs in Node.js
Your private key, if generated with the above steps, should look something like this (but with much more text):
```pem
-----BEGIN RSA PRIVATE KEY-----
uayyi6wFTaNeG1/WCqhrowj2kCx8eB6NDZYl+OS9ZI9WC
q/44iFERNuP0TXvQx8tgvSZXyu4/G618QzKh0Ii1uAATt2upa8dp1uGl2U7EqBE8
p5y4pPzJuwvB3j6LQON20u2Wpbg8PQZACMfKym7lYDO+9MloK/gAQpyeYJzbw92C
YE/ymq4JVjCMCQKCAQEA4/X0I9TO8vT0D0l83o693QA3C09uSZ6j9Obx5UrtDnA9
sMkkRoe+R/vvIpVDzukMEEOmCuxbcdPoniVUKlTooK0Llo6JJ1l8CdFzQsOR97Pe
csB6pxkLLH2qHx05xPBy4PyoB
-----END RSA PRIVATE KEY-----
```
This is your secret, you should never share this with anyone, not even Bitget! Treat this like a password.
As part of this authentication process, your private key is used to generate a signature (using `RSA-SHA256`). This SDK handles this process automatically for you. RSA authentication is automatically detected if the "api_secret" parameter contains the words "PRIVATE KEY", such as the header shown in the example above.
From here, simply use the key provided by Bitget as the `api_key` parameter and your private key (with the header) as the `api_secret` parameter.
Based on the above example, the following would prepare the main REST client using the above credentials:
```typescript
// Received after creating a new API key with a self-generated RSA public key on Bitget
const API_KEY = 'bg_0866563123123123123f567e83e52fd';
// The self-generated RSA private key, this is never directly given to Bitget, but used to generate a signature
// Note: this MUST include the "BEGIN PRIVATE KEY" header so that the SDK understands this is RSA auth
const rsaPrivateKey = `
-----BEGIN PRIVATE KEY-----
MIIJQQIBADANBgkqhkiG9w0BAQEFAASCCSswggknAgEAAoICAQC4kNgO71O0xkuH
FjHnr5pimpEeiGPAtDTAeJoS55+kVrh3ThHsm0ARf36zimU
gwrCWAnKqPlbqzWzs9mH9JvZWrEaOgWy
8wMSJ21vtz1rRJhfaUUsOC1KLoWyvzqWW44zKaxoKSqCUMJqDbxIq7RjGlmc8KGJ
scFWRSdfGEEpvqLlpTLoEtWHZP0pUUamSWrH/IgieFFhKaOPvmED24DJAlqSeEFw
z7TW4dfWPRgjCRu4AAfgCtjb+3/7ONeQfx5XFvKFM7VNi/9sRh+alRqpzKrlI
79bM1p/egrC4c8KUqrNk2s5c3HIU......THISISANEXAMPLE
-----END PRIVATE KEY-----
`;
// This is set by you when registering your RSA API key in Bitget's website.
const API_PASS = 'TestingRSA';
const client = new RestClientV2({
apiKey: API_KEY,
apiSecret: rsaPrivateKey,
apiPass: API_PASS,
});
const clientV3 = new RestClientV3({
apiKey: API_KEY,
apiSecret: rsaPrivateKey,
apiPass: API_PASS,
});
```
For a complete example, refer to the [rest-private-rsa.ts](./rest-private-rsa.ts) file on GitHub.
================
File: examples/README.md
================
# Examples
These samples can be executed using `ts-node`:
```
ts-node ./examples/rest-spot-public.ts
```
Samples that require authentication can be edited directly but also support environmental variables. E.g. on mac/unix:
```
API_KEY_COM='yourkeyhere' API_SECRET_COM='yoursecrethere' API_PASS_COM='yourapipasshere' ts-node examples/rest-trade-futures.ts
```
They can also be converted to JavaScript by changing the imports to require & removing any type annotations.
## V3 / Unified Trading Account (UTA)
These newer examples are for Bitget's V3 APIs and WebSockets. They can be found in the examples/V3 folder.
Refer to the V3 / UTA API documentation for more information on the V3 APIs:
https://www.bitget.com/api-doc/uta/intro
These APIs require your account to be upgraded to the Unified Trading Account, if you plan on using the account-level REST APIs and WebSockets. Once upgraded, the V2 APIs are no longer available to you, unless you revert back to Classic Account mode.
### WebSocket API (WS API)
The V3/UTA API introduces order placement via a persisted WebSocket connection. This Bitget Node.js, JavaScript & TypeScript SDK supports Bitget's full V3 API offering, including the WebSocket API.
There are two approaches to placing orders via the Bitget WebSocket APIs
#### WebsocketAPIClient (recommended)
This integration looks & feels like a REST API client, but uses WebSockets, via the WebsocketClient's sendWSAPIRequest method. It returns promises and has end to end types.
This is the recommended approach to easily start sending orders via an automatically persisted WebSocket connection. A simple example is below, but for a more thorough example, check the example here: [./V3/ws-api-client-trade.ts](./V3/ws-api-client-trade.ts)
```typescript
import { WebsocketAPIClient } from 'bitget-api';
// or if you prefer require:
// const { WebsocketAPIClient } = require("bitget-api");
// Make an instance of the WS API Client class with your API keys
const wsClient = new WebsocketAPIClient({
apiKey: API_KEY,
apiSecret: API_SECRET,
apiPass: API_PASS,
// Whether to use the demo trading wss connection
// demoTrading: true,
});
async function start() {
// Start using it like a REST API. All actions are sent via a persisted WebSocket connection.
/**
* Place Order
* https://www.bitget.com/api-doc/uta/websocket/private/Place-Order-Channel#request-parameters
*/
try {
const res = await wsClient.submitNewOrder('spot', {
orderType: 'limit',
price: '100',
qty: '0.1',
side: 'buy',
symbol: 'BTCUSDT',
timeInForce: 'gtc',
});
console.log(new Date(), 'WS API "submitNewOrder()" result: ', res);
} catch (e) {
console.error(new Date(), 'Exception with WS API "submitNewOrder()": ', e);
}
}
start().catch((e) => console.error('Exception in example: '.e));
```
#### ws.sendWSAPIRequest(wsKey, command, category, operation)
This is the "raw" integration within the existing WebSocket client. It uses an automatically persisted & authenticated connection to send events through Bitget's WebSocket API. It automatically tracks and connects outgoing requests with incoming responses, and returns promises that resolve/reject when a matching response is received.
Refer to [V3/ws-api-trade-raw.ts](./V3/ws-api-trade-raw.ts) to see an example.
Note: The WebsocketClient is built around this. For a more user friendly experience, it is recommended to use the WebsocketClient for WS API requests. It uses this method but has the convenience of behaving similar to a REST API (while all communication automatically happens over a persisted WebSocket connection).
## V2
These examples are for Bitget's V2 APIs and WebSockets. They can be found in the examples/V2 folder.
Refer to the V2 API documentation for more information on the V2 APIs:
https://www.bitget.com/api-doc/common/intro
================
File: src/types/request/v2/copytrading.ts
================
/**
*
*
* Copy Trading | Future copy trading | Trader Api
*
*
*/
⋮----
export type CopyTradingProductTypeV2 =
| 'USDT-FUTURES'
| 'COIN-FUTURES'
| 'USDC-FUTURES';
⋮----
export interface GetFuturesTraderCurrentOrdersRequestV2 {
symbol?: string;
productType: CopyTradingProductTypeV2;
startTime?: string;
endTime?: string;
limit?: string;
idGreaterThan?: string;
idLessThan?: string;
}
⋮----
export interface GetFuturesTraderHistoryOrdersRequestV2 {
idLessThan?: string;
idGreaterThan?: string;
startTime?: string;
endTime?: string;
limit?: string;
order?: 'asc' | 'desc';
symbol?: string;
productType: CopyTradingProductTypeV2;
}
⋮----
export interface ModifyFuturesTraderOrderTPSLRequestV2 {
trackingNo: string;
productType: CopyTradingProductTypeV2;
stopSurplusPrice?: string;
stopLossPrice?: string;
}
⋮----
export interface GetFuturesTraderProfitShareDetailRequestV2 {
coin?: string;
idLessThan?: string;
idGreaterThan?: string;
startTime?: string;
endTime?: string;
limit?: string;
}
⋮----
export interface FuturesTraderSymbolSettingRequestV2 {
symbol: string;
productType: CopyTradingProductTypeV2;
settingType: 'ADD' | 'DELETE' | 'UPDATE';
stopSurplusRatio?: string;
stopLossRatio?: string;
}
⋮----
export interface GetFuturesTraderFollowersRequestV2 {
pageNo?: string;
pageSize?: string;
startTime?: string;
endTime?: string;
}
⋮----
/**
*
*
* Copy Trading | Future copy trading | Follower Api
*
*
*/
⋮----
export interface GetFollowerFuturesCurrentTrackingOrdersRequestV2 {
idLessThan?: string;
idGreaterThan?: string;
startTime?: string;
endTime?: string;
limit?: string;
symbol?: string;
productType: CopyTradingProductTypeV2;
traderId?: string;
}
⋮----
export interface GetFollowerFuturesHistoryTrackingOrdersRequestV2 {
idLessThan?: string;
idGreaterThan?: string;
startTime?: string;
endTime?: string;
limit?: string;
symbol?: string;
productType: CopyTradingProductTypeV2;
traderId?: string;
}
⋮----
export interface UpdateFuturesFollowerTPSLRequestV2 {
trackingNo: string;
symbol?: string;
productType: CopyTradingProductTypeV2;
stopSurplusPrice?: string;
stopLossPrice?: string;
}
⋮----
export type AutoCopyOption = 'on' | 'off';
export type FollowMode = 'basic' | 'advanced';
export type LeverageType = 'position' | 'specify' | 'trader';
export type TraceType = 'percent' | 'amount' | 'count';
⋮----
export interface FollowerCopyTradeSettingRequestV2 {
symbol: string;
productType: CopyTradingProductTypeV2;
marginType: 'trader' | 'specify';
marginCoin?: string;
leverType: LeverageType;
longLeverage?: string;
shortLeverage?: string;
traceType: TraceType;
traceValue: string;
maxHoldSize?: string;
stopSurplusRatio?: string;
stopLossRatio?: string;
}
⋮----
export interface UpdateFuturesFollowerSettingsRequestV2 {
traderId: string;
autoCopy?: AutoCopyOption;
mode?: FollowMode;
settings: FollowerCopyTradeSettingRequestV2[];
}
export interface CloseFuturesFollowerPositionsRequestV2 {
productType: CopyTradingProductTypeV2;
trackingNo?: string;
symbol?: string;
marginCoin?: string;
marginMode?: 'isolated' | 'cross';
holdSide?: 'long' | 'short';
}
⋮----
export interface GetFuturesFollowerTradersRequestV2 {
startTime?: string;
endTime?: string;
pageNo?: string;
pageSize?: string;
}
⋮----
/**
*
*
* Copy Trading | Spot copy trading | Trader api
*
*
*/
⋮----
export interface GetSpotTraderHistoryProfitRequestV2 {
idLessThan?: string;
idGreaterThan?: string;
startTime?: string;
endTime?: string;
limit?: string;
coin?: string;
}
⋮----
export interface GetSpotTraderHistoryOrdersRequestV2 {
idLessThan?: string;
idGreaterThan?: string;
startTime?: string;
endTime?: string;
limit?: string;
symbol?: string;
}
⋮----
export interface GetSpotTraderCurrentOrdersRequestV2 {
symbol?: string;
idLessThan?: string;
idGreaterThan?: string;
startTime?: string;
endTime?: string;
limit?: string;
}
⋮----
export interface GetSpotTraderFollowersRequestV2 {
pageNo?: string;
pageSize?: string;
startTime?: string;
endTime?: string;
}
⋮----
/**
*
*
* Copy Trading | Spot copy trading | Follower api
*
*
*/
⋮----
export interface SpotFollowerCopyTradeSettingV2 {
symbol: string;
traceType: 'percent' | 'amount' | 'count';
maxHoldSize: string;
traceValue: string;
stopLossRatio?: string;
stopSurplusRatio?: string;
}
⋮----
export interface GetSpotFollowerHistoryOrdersRequestV2 {
symbol?: string;
traderId?: string;
idLessThan?: string;
idGreaterThan?: string;
startTime?: string;
endTime?: string;
limit?: string;
}
⋮----
export interface GetSpotFollowerOpenOrdersRequestV2 {
symbol?: string;
traderId?: string;
idLessThan?: string;
idGreaterThan?: string;
startTime?: string;
endTime?: string;
limit?: string;
}
================
File: src/types/request/v2/margin.ts
================
/**
*
* * Margin | Cross/Isolated | Order Record
*
*/
⋮----
export interface GetBorrowHistoryRequestV2 {
loanId?: string;
coin?: string;
startTime: string;
endTime?: string;
limit?: string;
idLessThan?: string;
}
⋮----
export interface GetRepayHistoryRequestV2 {
repayId?: string;
coin?: string;
startTime: string;
endTime?: string;
limit?: string;
idLessThan?: string;
}
⋮----
export interface GetInterestHistoryRequestV2 {
coin?: string;
startTime: string;
endTime?: string;
limit?: string;
idLessThan?: string;
}
⋮----
export interface GetLiquidationHistoryRequestV2 {
startTime: string;
endTime?: string;
limit?: string;
idLessThan?: string;
}
⋮----
export interface GetFinancialHistoryRequestV2 {
marginType?: string;
coin?: string;
startTime: string;
endTime?: string;
limit?: string;
idLessThan?: string;
}
⋮----
/**
*
* * Margin | Cross/Isolated | Account
*
*/
⋮----
/**
*
* * Margin | Cross/Isolated | Trade
*
*/
⋮----
export type MarginOrderTypeV2 = 'limit' | 'market';
⋮----
export type MarginLoanTypeV2 =
| 'normal'
| 'autoLoan'
| 'autoRepay'
| 'autoLoanAndRepay';
⋮----
export type MarginTimeInForceV2 = 'gtc' | 'post_only' | 'fok' | 'ioc';
⋮----
export type MarginOrderSideV2 = 'buy' | 'sell';
⋮----
export type MarginSTPModeV2 =
| 'none'
| 'cancel_taker'
| 'cancel_maker'
| 'cancel_both';
⋮----
export interface MarginPlaceOrderRequestV2 {
symbol: string;
orderType: MarginOrderTypeV2;
price?: string;
loanType: MarginLoanTypeV2;
force: MarginTimeInForceV2;
baseSize?: string;
quoteSize?: string;
clientOid?: string;
side: MarginOrderSideV2;
stpMode?: MarginSTPModeV2;
}
⋮----
export interface MarginBatchOrderEntry {
orderType: MarginOrderTypeV2;
price?: string;
loanType: MarginLoanTypeV2;
force: MarginTimeInForceV2;
baseSize?: string;
quoteSize?: string;
clientOid?: string;
side: MarginOrderSideV2;
stpMode?: MarginSTPModeV2;
}
⋮----
export interface MarginBatchOrdersRequestV2 {
symbol: string;
orderList: MarginBatchOrderEntry[];
}
⋮----
export interface GetMarginCurrentOrdersRequestV2 {
symbol: string;
orderId?: string;
clientOid?: string;
startTime: string;
endTime?: string;
limit?: string;
idLessThan?: string;
}
⋮----
export interface GetHistoryOrdersRequestV2 {
symbol: string;
orderId?: string;
enterPointSource?: string;
clientOid?: string;
startTime: string;
endTime?: string;
limit?: string;
idLessThan?: string;
}
⋮----
export interface GetMarginOrderFillsRequestV2 {
symbol: string;
orderId?: string;
idLessThan?: string;
startTime: string;
endTime?: string;
limit?: string;
}
⋮----
export interface GetMarginLiquidationOrdersRequestV2 {
type?: 'swap' | 'place_order';
symbol?: string;
fromCoin?: string;
toCoin?: string;
startTime?: string;
endTime?: string;
limit?: string;
idLessThan?: string;
}
================
File: src/types/request/v2/spot.ts
================
type SpotKlineIntervalV2 =
| '1min'
| '5min'
| '15min'
| '30min'
| '1h'
| '4h'
| '6h'
| '12h'
| '1day'
| '3day'
| '1week'
| '1M'
| '6Hutc'
| '12Hutc'
| '1Dutc'
| '3Dutc'
| '1Wutc'
| '1Mutc';
⋮----
export interface SpotCandlesRequestV2 {
symbol: string;
granularity: SpotKlineIntervalV2;
startTime?: string;
endTime?: string;
limit?: string;
}
⋮----
export interface SpotHistoricCandlesRequestV2 {
symbol: string;
granularity: SpotKlineIntervalV2;
endTime?: string;
limit?: string;
}
⋮----
export interface SpotHistoricTradesRequestV2 {
symbol: string;
limit?: string;
idLessThan?: string;
startTime?: string;
endTime?: string;
}
⋮----
/**
*
* * Spot | Trade
*
*/
⋮----
export type SpotOrderSideV2 = 'buy' | 'sell';
⋮----
export type SpotOrderTypeV2 = 'limit' | 'market';
⋮----
export type SpotOrderForceV2 = 'gtc' | 'post_only' | 'fok' | 'ioc';
⋮----
export type SpotTPSLTypeV2 = 'normal' | 'tpsl';
⋮----
export type SpotSTPModeV2 =
| 'none'
| 'cancel_taker'
| 'cancel_maker'
| 'cancel_both';
⋮----
export type SpotBatchModeV2 = 'single' | 'multiple';
⋮----
export interface SpotOrderRequestV2 {
symbol: string;
side: SpotOrderSideV2;
orderType: SpotOrderTypeV2;
force: SpotOrderForceV2;
price?: string;
size: string;
clientOid?: string;
triggerPrice?: string;
tpslType?: SpotTPSLTypeV2;
requestTime?: string;
receiveWindow?: string;
stpMode?: SpotSTPModeV2;
presetTakeProfitPrice?: string;
executeTakeProfitPrice?: string;
presetStopLossPrice?: string;
executeStopLossPrice?: string;
}
⋮----
export interface SpotCancelandSubmitOrderRequestV2 {
symbol: string;
price: string;
size: string;
orderId?: string;
clientOid?: string;
newClientOid?: string;
presetTakeProfitPrice?: string;
executeTakeProfitPrice?: string;
presetStopLossPrice?: string;
executeStopLossPrice?: string;
}
⋮----
export interface SpotCancelOrderRequestV2 {
symbol: string;
tpslType?: SpotTPSLTypeV2;
orderId?: string;
clientOid?: string;
}
⋮----
export interface SpotBatchOrderRequestItemV2 {
symbol?: string;
side: SpotOrderSideV2;
orderType: SpotOrderTypeV2;
force: SpotOrderForceV2;
price?: string;
size: string;
clientOid?: string;
stpMode?: SpotSTPModeV2;
presetTakeProfitPrice?: string;
executeTakeProfitPrice?: string;
presetStopLossPrice?: string;
executeStopLossPrice?: string;
}
⋮----
export interface SpotBatchOrderRequestV2 {
symbol?: string;
batchMode?: SpotBatchModeV2;
orderList: SpotBatchOrderRequestItemV2[];
}
⋮----
export interface SpotBatchCancelOrderRequestV2 {
symbol?: string;
batchMode?: SpotBatchModeV2;
orderList: {
symbol?: string;
orderId?: string;
clientOid?: string;
}[];
}
⋮----
export interface GetSpotOrderInfoRequestV2 {
orderId?: string;
clientOid?: string;
requestTime?: string;
receiveWindow?: string;
}
⋮----
export interface GetSpotOpenOrdersRequestV2 {
symbol?: string;
startTime?: string;
endTime?: string;
idLessThan?: string;
limit?: string;
orderId?: string;
tpslType?: SpotTPSLTypeV2;
requestTime?: string;
receiveWindow?: string;
}
⋮----
export interface GetSpotHistoryOrdersRequestV2 {
symbol?: string;
startTime?: string;
endTime?: string;
idLessThan?: string;
limit?: string;
orderId?: string;
tpslType?: SpotTPSLTypeV2;
requestTime?: string;
receiveWindow?: string;
}
⋮----
export interface GetSpotFillsRequestV2 {
symbol: string;
orderId?: string;
startTime?: string;
endTime?: string;
limit?: string;
idLessThan?: string;
}
⋮----
/**
*
* * Spot | Trigger Orders
*
*/
⋮----
export type SpotPlanTypeV2 = 'amount' | 'total';
⋮----
export type SpotTriggerTypeV2 = 'fill_price' | 'mark_price';
⋮----
export interface SpotPlanOrderRequestV2 {
symbol: string;
side: SpotOrderSideV2;
triggerPrice: string;
orderType: SpotOrderTypeV2;
executePrice?: string;
planType?: SpotPlanTypeV2;
size: string;
triggerType: SpotTriggerTypeV2;
clientOid?: string;
force?: SpotOrderForceV2;
stpMode?: SpotSTPModeV2;
}
⋮----
export interface SpotModifyPlanOrderRequestV2 {
orderId?: string;
clientOid?: string;
triggerPrice: string;
orderType: SpotOrderTypeV2;
executePrice?: string;
size: string;
}
⋮----
export interface GetSpotCurrentPlanOrdersRequestV2 {
symbol: string;
limit?: string;
idLessThan?: string;
startTime?: string;
endTime?: string;
}
⋮----
export interface GetSpotHistoryPlanOrdersRequestV2 {
symbol: string;
startTime: string;
endTime: string;
limit?: string;
}
⋮----
/**
*
* * Spot | Account
*
*/
⋮----
export type SpotBillGroupTypeV2 =
| 'deposit'
| 'withdraw'
| 'transaction'
| 'transfer'
| 'other';
⋮----
export type SpotBusinessTypeV2 =
| 'deposit'
| 'withdraw'
| 'buy'
| 'sell'
| 'deduction of handling fee'
| 'transfer-in'
| 'transfer-out'
| 'rebate rewards'
| 'airdrop rewards'
| 'USDT contract rewards'
| 'mix contract rewards'
| 'system lock'
| 'user lock';
⋮----