forked from tiagosiebler/bitmart-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathllms.txt
More file actions
5598 lines (5363 loc) · 157 KB
/
llms.txt
File metadata and controls
5598 lines (5363 loc) · 157 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/
Futures/
futures-get-balances.ts
futures-get-klines.ts
futures-get-tickers.ts
futures-submit-order.ts
Spot/
spot-get-balances.ts
spot-get-klines.ts
spot-get-symbols.ts
spot-submit-order.ts
Websocket/
ws-custom-logger.ts
ws-futures-private.ts
ws-futures-public.ts
ws-spot-private.ts
ws-spot-public.ts
README.md
tsconfig.examples.json
src/
lib/
websocket/
websocket-util.ts
WsStore.ts
WsStore.types.ts
BaseRestClient.ts
BaseWSClient.ts
logger.ts
misc-util.ts
requestUtils.ts
webCryptoAPI.ts
types/
request/
futures.types.ts
spot.types.ts
response/
futures.types.ts
shared.types.ts
spot.types.ts
websockets/
client.ts
events.ts
requests.ts
FuturesClientV2.ts
index.ts
RestClient.ts
WebsocketClient.ts
webpack/
webpack.config.cjs
.eslintrc.cjs
.gitignore
.nvmrc
.prettierrc
jest.config.ts
LICENSE.md
package.json
postBuild.sh
README.md
tea.yaml
tsconfig.cjs.json
tsconfig.esm.json
tsconfig.json
tsconfig.linting.json
================================================================
Files
================================================================
================
File: examples/README.md
================
# Bitmart API Examples Node.js
Some examples written in Node.js/typescript showing how to use some of Bitmart's common API functionality, such as fetching prices, submitting orders, etc.
## Usage
Most of these examples can just be executed (e.g. using `ts-node` or `tsx`).
Any "private" examples that perform actions on an account (such as checking balance or submitting orders) will require an api key, secret and memo (provided by bitmart when you create an API key).
These can either be hardcoded or you can pass them as env vars to test the functionality.
For example on macOS or unix, using `ts-node` to execute a typescript file directly:
```bash
API_KEY="apiKeyHere" API_SECRET="secretHere" API_MEMO="memoHere" ts-node examples/futures-get-balances.ts
```
================
File: examples/tsconfig.examples.json
================
{
"extends": "../tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "dist/cjs",
"target": "esnext",
"rootDir": "../"
},
"include": ["../src/**/*.*", "../examples/**/*.*"]
}
================
File: src/lib/misc-util.ts
================
export function neverGuard(x: never, msg: string): Error
================
File: src/types/response/shared.types.ts
================
export interface APIResponse<TData = {}, TCode = number> {
message: string;
code: TCode;
trace: string;
data: TData;
}
⋮----
export type OrderSide = 'buy' | 'sell';
⋮----
/**
* Spot & Futures uses this
*/
export interface AccountCurrencyBalanceV1 {
currency: string;
name: string;
available: string;
available_usd_valuation: string;
frozen: string;
}
================
File: src/types/websockets/events.ts
================
export interface WsDataEvent<TData = any, TWSKey = string> {
data: TData;
table: string;
wsKey: TWSKey;
}
================
File: src/types/websockets/requests.ts
================
export type WsOperation =
| 'subscribe'
| 'unsubscribe'
| 'login'
| 'access'
| 'request';
⋮----
export interface WsSpotOperation<TWSTopic extends string = string> {
op: WsOperation;
args: TWSTopic[];
}
⋮----
export interface WsFuturesOperation<TWSTopic extends string> {
action: WsOperation;
args: TWSTopic[];
}
⋮----
export type WsRequestOperation<TWSTopic extends string> =
| WsSpotOperation<TWSTopic>
| WsFuturesOperation<TWSTopic>;
================
File: src/index.ts
================
================
File: .prettierrc
================
{
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "all"
}
================
File: postBuild.sh
================
#!/bin/bash
#
# Add package.json files to cjs/mjs subtrees
#
cat >dist/cjs/package.json <<!EOF
{
"type": "commonjs"
}
!EOF
cat >dist/mjs/package.json <<!EOF
{
"type": "module"
}
!EOF
find src -name '*.d.ts' -exec cp {} dist/mjs \;
find src -name '*.d.ts' -exec cp {} dist/cjs \;
================
File: tea.yaml
================
---
version: 1.0.0
codeOwners:
- '0xeb1a7BF44a801e33a339705A266Afc0Cba3D6D54'
quorum: 1
================
File: tsconfig.cjs.json
================
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "dist/cjs",
"target": "esnext"
},
"include": ["src/**/*.*"]
}
================
File: tsconfig.esm.json
================
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "esnext",
"outDir": "dist/mjs",
"target": "esnext"
},
"include": ["src/**/*.*"]
}
================
File: examples/Auth/fasterHmacSign.ts
================
import { createHmac } from 'crypto';
⋮----
import { RestClient } from '../../src/index.js';
// import from npm, after installing via npm `npm install bitmart-api`
// import { RestClient } from 'bitmart-api';
⋮----
/**
* Overkill in almost every case, but if you need any optimisation available,
* you can inject a faster sign mechanism such as node's native createHmac:
*/
⋮----
async function getSpotBalances()
================
File: examples/Rest/Futures/futures-get-balances.ts
================
import { FuturesClientV2 } from '../../../src/index.js';
// // import from npm, after installing via npm `npm install bitmart-api`
// import { FuturesClientV2 } from 'bitmart-api';
⋮----
async function getFuturesAssets()
================
File: examples/Rest/Futures/futures-get-klines.ts
================
import { FuturesClientV2 } from '../../../src/index.js';
// // import from npm, after installing via npm `npm install bitmart-api`
// import { FuturesClientV2 } from 'bitmart-api';
⋮----
async function getFuturesKlines()
================
File: examples/Rest/Futures/futures-get-tickers.ts
================
import { FuturesClientV2 } from '../../../src/index.js';
// // import from npm, after installing via npm `npm install bitmart-api`
// import { FuturesClientV2 } from 'bitmart-api';
⋮----
async function getFuturesTickers()
================
File: examples/Rest/Futures/futures-submit-order.ts
================
import { FuturesClientV2 } from '../../../src/index.js';
// // import from npm, after installing via npm `npm install bitmart-api`
// import { FuturesClientV2 } from 'bitmart-api';
⋮----
async function SumbitFuturesOrder()
⋮----
side: 1, // Order side - 1=buy_open_long -2=buy_close_short -3=sell_close_long -4=sell_open_short
================
File: examples/Rest/Spot/spot-get-balances.ts
================
import { RestClient } from '../../../src/index.js';
// import from npm, after installing via npm `npm install bitmart-api`
// import { RestClient } from 'bitmart-api';
⋮----
async function getSpotBalances()
================
File: examples/Rest/Spot/spot-get-klines.ts
================
import { RestClient } from '../../../src/index.js';
// import from npm, after installing via npm `npm install bitmart-api`
// import { RestClient } from 'bitmart-api';
⋮----
async function getKlines()
================
File: examples/Rest/Spot/spot-get-symbols.ts
================
import { RestClient } from '../../../src/index.js';
// import from npm, after installing via npm `npm install bitmart-api`
// import { RestClient } from 'bitmart-api';
⋮----
async function getTickers()
================
File: examples/Rest/Spot/spot-submit-order.ts
================
import { RestClient } from '../../../src/index.js';
// import from npm, after installing via npm `npm install bitmart-api`
// import { RestClient } from 'bitmart-api';
⋮----
async function start()
⋮----
// const usdValue = 6;
// const price = 52000;
// const qty = usdValue / price;
⋮----
// const limitBuyOrder = {
// symbol: 'BTC_USDT',
// side: 'buy',
// type: 'limit',
// size: String(qty),
// price: String(price),
// };
⋮----
// const res = await client.submitSpotOrder({
// symbol: 'BTC_USDT',
// side: 'buy',
// type: 'market',
// size: String(qty),
// });
================
File: examples/Websocket/ws-custom-logger.ts
================
import { DefaultLogger, LogParams, WebsocketClient } from '../../src/index.js';
// import from npm, after installing via npm `npm install bitmart-api`
// import { DefaultLogger, LogParams, WebsocketClient } from 'bitmart-api';
⋮----
/** Optional, implement a custom logger */
⋮----
async function start()
⋮----
// Data received
⋮----
// Something happened, attempting to reconenct
⋮----
// Reconnect successful
⋮----
// Connection closed. If unexpected, expect reconnect -> reconnected.
⋮----
// Reply to a request, e.g. "subscribe"/"unsubscribe"/"authenticate"
⋮----
//
================
File: examples/Websocket/ws-futures-public.ts
================
import { WebsocketClient } from '../../src/index.js';
// import from npm, after installing via npm `npm install bitmart-api`
// import { WebsocketClient } from 'bitmart-api';
⋮----
async function start()
⋮----
// Data received
⋮----
// Something happened, attempting to reconenct
⋮----
// Reconnect successful
⋮----
// Connection closed. If unexpected, expect reconnect -> reconnected.
⋮----
// Reply to a request, e.g. "subscribe"/"unsubscribe"/"authenticate"
⋮----
// Ticker Channel
// client.subscribe('futures/ticker', 'futures');
⋮----
// Depth Channel
// client.subscribe('futures/depth20:BTCUSDT', 'futures');
⋮----
// Trade Channel
// client.subscribe('futures/trade:BTCUSDT', 'futures');
⋮----
// KlineBin Channel
// client.subscribe('futures/klineBin1m:BTCUSDT', 'futures');
⋮----
// Or have multiple topics in one array:
================
File: examples/Websocket/ws-spot-public.ts
================
import { WebsocketClient } from '../../src/index.js';
⋮----
// import from npm, after installing via npm `npm install bitmart-api`
// import { WebsocketClient } from 'bitmart-api';
⋮----
async function start()
⋮----
// Some topics allow requests, here's an example for sending a request
// const wsKey = 'spotPublicV1';
// if (data?.wsKey === wsKey) {
// const depthIncreaseDataRequest: WsSpotOperation = {
// op: 'request',
// args: ['spot/depth/increase100:BTC_USDT'],
// };
⋮----
// client.tryWsSend(
// 'spotPublicV1',
// JSON.stringify(depthIncreaseDataRequest),
// );
// }
⋮----
// Data received
⋮----
// Something happened, attempting to reconenct
⋮----
// Reconnect successful
⋮----
// Connection closed. If unexpected, expect reconnect -> reconnected.
⋮----
// Reply to a request, e.g. "subscribe"/"unsubscribe"/"authenticate"
⋮----
/**
* Use the client subscribe(topic, market) pattern to subscribe to any websocket topic.
*
* You can subscribe to topics one at a time:
*/
⋮----
// Ticker Channel
// client.subscribe('spot/ticker:BTC_USDT', 'spot');
⋮----
// KLine/Candles Channel
// client.subscribe('spot/kline1m:BTC_USDT', 'spot');
⋮----
// Depth-All Channel
// client.subscribe('spot/depth5:BTC_USDT', 'spot');
⋮----
// Depth-Increase Channel
// client.subscribe('spot/depth/increase100:BTC_USDT', 'spot');
⋮----
// Trade Channel
// client.subscribe('spot/trade:BTC_USDT', 'spot');
⋮----
/**
* Or have multiple topics in one array, in a single request:
*/
================
File: src/lib/logger.ts
================
export type LogParams = null | any;
⋮----
export type DefaultLogger = typeof DefaultLogger;
⋮----
// eslint-disable-next-line @typescript-eslint/no-unused-vars
⋮----
// console.log(_params);
================
File: src/types/request/spot.types.ts
================
export interface SpotKlineV3Request {
symbol: string;
before?: number;
after?: number;
step?: number;
limit?: number;
}
⋮----
export interface SpotKlinesV1Request {
symbol: string;
from: number;
to: number;
step?: number;
}
⋮----
export interface SpotOrderBookDepthV1Request {
symbol: string;
precision?: string;
size?: number;
}
⋮----
export interface SubmitWithdrawalV1Request {
currency: string;
amount: string;
destination: 'To Digital Address';
address: string;
address_memo?: string;
}
⋮----
export interface DepositWithdrawHistoryV2Request {
currency?: string;
operation_type: 'deposit' | 'withdraw';
start_time?: number;
end_time?: number;
N: number;
}
⋮----
export interface SubmitMarginTransferV1Request {
symbol: string;
currency: string;
amount: string;
side: 'in' | 'out';
}
⋮----
export interface SubmitSpotOrderV2Request {
symbol: string;
side: 'buy' | 'sell';
type: 'limit' | 'market' | 'limit_maker' | 'ioc';
stpmode?: 'none' | 'cancel_maker' | 'cancel_taker' | 'cancel_both';
client_order_id?: string;
size?: string;
price?: string;
notional?: string;
}
⋮----
export type CancelOrdersV3Request = {
symbol: string;
order_id?: string;
client_order_id?: string;
} & ({ order_id: string } | { client_order_id: string });
⋮----
export interface SubmitSpotBatchOrdersV4Request {
symbol: string;
orderParams: {
clientOrderId?: string;
size?: string;
price?: string;
side: 'buy' | 'sell';
type: 'limit' | 'market' | 'limit_maker' | 'ioc';
stpmode?: 'none' | 'cancel_maker' | 'cancel_taker' | 'cancel_both';
notional?: string;
}[];
recvWindow?: number;
}
⋮----
export interface CancelSpotBatchOrdersV4Request {
symbol: string;
orderIds?: string[];
clientOrderIds?: string[];
recvWindow?: number;
}
⋮----
export interface SpotOrderByIdV4Request {
orderId: string;
queryState?: 'open' | 'history';
recvwindow?: number;
}
⋮----
export interface SpotOrderByClientOrderIdV4Request {
clientOrderId: string;
queryState?: 'open' | 'history';
recvwindow?: number;
}
⋮----
export interface SpotOpenOrdersV4Request {
orderMode?: 'spot' | 'iso_margin'; // Order mode: 'spot' for spot trade, 'iso_margin' for isolated margin trade
startTime?: number; // Start time in milliseconds, e.g., 1681701557927
endTime?: number; // End time in milliseconds, e.g., 1681701557927
limit?: number; // Number of queries, allowed range [1,200], default is 200
recvWindow?: number; // Trade time limit, allowed range (0,60000], default: 5000 milliseconds
}
⋮----
orderMode?: 'spot' | 'iso_margin'; // Order mode: 'spot' for spot trade, 'iso_margin' for isolated margin trade
startTime?: number; // Start time in milliseconds, e.g., 1681701557927
endTime?: number; // End time in milliseconds, e.g., 1681701557927
limit?: number; // Number of queries, allowed range [1,200], default is 200
recvWindow?: number; // Trade time limit, allowed range (0,60000], default: 5000 milliseconds
⋮----
export interface SpotOrderTradeHistoryV4Request {
orderMode?: 'spot' | 'iso_margin'; // Order mode: 'spot' for spot trade, 'iso_margin' for isolated margin trade
startTime?: number; // Start time in milliseconds, e.g., 1681701557927
endTime?: number; // End time in milliseconds, e.g., 1681701557927
limit?: number; // Number of queries, allowed range [1,200], default is 200
recvWindow?: number; // Trade time limit, allowed range (0,60000], default: 5000 milliseconds
symbol?: string; // Trading pair, e.g., BTC_USDT
}
⋮----
orderMode?: 'spot' | 'iso_margin'; // Order mode: 'spot' for spot trade, 'iso_margin' for isolated margin trade
startTime?: number; // Start time in milliseconds, e.g., 1681701557927
endTime?: number; // End time in milliseconds, e.g., 1681701557927
limit?: number; // Number of queries, allowed range [1,200], default is 200
recvWindow?: number; // Trade time limit, allowed range (0,60000], default: 5000 milliseconds
symbol?: string; // Trading pair, e.g., BTC_USDT
⋮----
export interface MarginBorrowRepayV1Request {
symbol: string;
currency: string;
amount: string;
}
⋮----
export interface MarginBorrowRecordsV1Request {
symbol: string;
start_time?: number;
end_time?: number;
N?: number;
borrow_id?: string;
}
⋮----
export interface MarginRepayRecordsV1Request {
symbol: string;
start_time?: number;
end_time?: number;
N?: number;
repay_id?: string;
currency?: string;
}
⋮----
export interface SubmitSubTransferSubToMainV1Request {
requestNo: string;
amount: string;
currency: string;
}
⋮----
export interface SubmitSubTransferV1Request {
requestNo: string;
amount: string;
currency: string;
subAccount: string;
}
⋮----
export interface SubmitMainTransferSubToSubV1Request {
requestNo: string;
amount: string;
currency: string;
fromAccount: string;
toAccount: string;
}
⋮----
export interface SubTransfersV1Request {
moveType: 'spot to spot';
N: number;
accountName?: string;
}
⋮----
export interface AccountSubTransfersV1Request {
moveType: 'spot to spot';
N: number;
}
⋮----
export interface SubSpotWalletBalancesV1Request {
subAccount: string;
currency?: string;
}
⋮----
export interface SpotBrokerRebateRequest {
start_time?: number;
end_time?: number;
}
================
File: webpack/webpack.config.cjs
================
function generateConfig(name)
⋮----
// Add '.ts' and '.tsx' as resolvable extensions.
⋮----
// Node.js core modules not available in browsers
// The REST client's https.Agent (for keepAlive) is Node.js-only and won't work in browsers
⋮----
// Code is already transpiled from TypeScript, no additional loaders needed
================
File: .nvmrc
================
v22.17.1
================
File: jest.config.ts
================
/**
* For a detailed explanation regarding each configuration property, visit:
* https://jestjs.io/docs/configuration
*/
⋮----
import type { Config } from 'jest';
⋮----
// All imported modules in your tests should be mocked automatically
// automock: false,
⋮----
// Stop running tests after `n` failures
// bail: 0,
bail: false, // enable to stop test when an error occur,
⋮----
// The directory where Jest should store its cached dependency information
// cacheDirectory: "/private/var/folders/kf/2k3sz4px6c9cbyzj1h_b192h0000gn/T/jest_dx",
⋮----
// Automatically clear mock calls, instances, contexts and results before every test
⋮----
// Indicates whether the coverage information should be collected while executing the test
⋮----
// An array of glob patterns indicating a set of files for which coverage information should be collected
⋮----
// The directory where Jest should output its coverage files
⋮----
// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "/node_modules/"
// ],
⋮----
// Indicates which provider should be used to instrument code for coverage
⋮----
// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
// "json",
// "text",
// "lcov",
// "clover"
// ],
⋮----
// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: undefined,
⋮----
// A path to a custom dependency extractor
// dependencyExtractor: undefined,
⋮----
// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,
⋮----
// The default configuration for fake timers
// fakeTimers: {
// "enableGlobally": false
// },
⋮----
// Force coverage collection from ignored files using an array of glob patterns
// forceCoverageMatch: [],
⋮----
// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: undefined,
⋮----
// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: undefined,
⋮----
// A set of global variables that need to be available in all test environments
// globals: {},
⋮----
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
// maxWorkers: "50%",
⋮----
// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// "node_modules"
// ],
⋮----
// An array of file extensions your modules use
// moduleFileExtensions: [
// "js",
// "mjs",
// "cjs",
// "jsx",
// "ts",
// "tsx",
// "json",
// "node"
// ],
⋮----
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
⋮----
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],
⋮----
// Activates notifications for test results
// notify: false,
⋮----
// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",
⋮----
// A preset that is used as a base for Jest's configuration
// preset: undefined,
⋮----
// Run tests from one or more projects
// projects: undefined,
⋮----
// Use this configuration option to add custom reporters to Jest
// reporters: undefined,
⋮----
// Automatically reset mock state before every test
// resetMocks: false,
⋮----
// Reset the module registry before running each individual test
// resetModules: false,
⋮----
// A path to a custom resolver
// resolver: undefined,
⋮----
// Automatically restore mock state and implementation before every test
// restoreMocks: false,
⋮----
// The root directory that Jest should scan for tests and modules within
// rootDir: undefined,
⋮----
// A list of paths to directories that Jest should use to search for files in
// roots: [
// "<rootDir>"
// ],
⋮----
// Allows you to use a custom runner instead of Jest's default test runner
// runner: "jest-runner",
⋮----
// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],
⋮----
// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],
⋮----
// The number of seconds after which a test is considered as slow and reported as such in the results.
// slowTestThreshold: 5,
⋮----
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],
⋮----
// The test environment that will be used for testing
// testEnvironment: "jest-environment-node",
⋮----
// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},
⋮----
// Adds a location field to test results
// testLocationInResults: false,
⋮----
// The glob patterns Jest uses to detect test files
⋮----
// "**/__tests__/**/*.[jt]s?(x)",
⋮----
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "/node_modules/"
// ],
⋮----
// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],
⋮----
// This option allows the use of a custom results processor
// testResultsProcessor: undefined,
⋮----
// This option allows use of a custom test runner
// testRunner: "jest-circus/runner",
⋮----
// A map from regular expressions to paths to transformers
// transform: undefined,
⋮----
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/",
// "\\.pnp\\.[^\\/]+$"
// ],
⋮----
// Prevents import esm module error from v1 axios release, issue #5026
⋮----
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,
⋮----
// Indicates whether each individual test should be reported during the run
// verbose: undefined,
verbose: true, // report individual test
⋮----
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],
⋮----
// Whether to use watchman for file crawling
// watchman: true,
================
File: LICENSE.md
================
Copyright 2025 Tiago Siebler
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
================
File: tsconfig.linting.json
================
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "dist/cjs",
"target": "esnext",
"rootDir": "../"
},
"include": ["src/**/*.*", "test/**/*.*", "examples/**/*.*", ".eslintrc.cjs", "jest.config.ts"]
}
================
File: examples/Websocket/ws-futures-private.ts
================
import { LogParams, WebsocketClient } from '../../src/index.js';
⋮----
// import from npm, after installing via npm `npm install bitmart-api`
// import { LogParams, WebsocketClient } from 'bitmart-api';
⋮----
// eslint-disable-next-line @typescript-eslint/no-unused-vars
⋮----
async function start()
⋮----
customLogger, // optional: inject a custom logger with all levels enabled (trace is disabled by default)
⋮----
// Data received
⋮----
// Something happened, attempting to reconenct
⋮----
// Reconnect successful
⋮----
// Connection closed. If unexpected, expect reconnect -> reconnected.
⋮----
// Reply to a request, e.g. "subscribe"/"unsubscribe"/"authenticate"
⋮----
// Assets Channel
⋮----
// Position Channel
// client.subscribe('futures/position', 'futures');
⋮----
// Order Channel
// client.subscribe('futures/order', 'futures');
================
File: examples/Websocket/ws-spot-private.ts
================
import { LogParams, WebsocketClient } from '../../src/index.js';
// import from npm, after installing via npm `npm install bitmart-api`
// import { LogParams, WebsocketClient } from 'bitmart-api';
⋮----
// eslint-disable-next-line @typescript-eslint/no-unused-vars
⋮----
async function start()
⋮----
customLogger, // optional: inject a custom logger with all levels enabled (trace is disabled by default)
⋮----
// Data received
⋮----