ccxt-look 1.81.50

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.
Files changed (264) hide show
  1. package/.cache/eslintcache +1 -0
  2. package/.dockerignore +6 -0
  3. package/.eslintignore +1 -0
  4. package/.gitattributes +5 -0
  5. package/.readthedocs.yaml +16 -0
  6. package/CONTRIBUTING.md +1049 -0
  7. package/LICENSE.txt +21 -0
  8. package/README.md +537 -0
  9. package/SECURITY.md +5 -0
  10. package/build/cleanup-old-tags.js +94 -0
  11. package/build/countries.js +256 -0
  12. package/build/export-exchanges.js +520 -0
  13. package/build/fs.js +51 -0
  14. package/build/transpile.js +1772 -0
  15. package/build/vss.js +78 -0
  16. package/ccxt.browser.js +7 -0
  17. package/ccxt.d.ts +692 -0
  18. package/ccxt.js +171 -0
  19. package/cleanup.sh +2 -0
  20. package/composer-install.sh +20 -0
  21. package/dist/ccxt.browser.js +208383 -0
  22. package/gource.sh +3 -0
  23. package/index.html +7 -0
  24. package/js/.eslintrc +87 -0
  25. package/js/aax.js +2686 -0
  26. package/js/ascendex.js +2584 -0
  27. package/js/base/.eslintrc.js +43 -0
  28. package/js/base/Exchange.js +2371 -0
  29. package/js/base/Precise.js +283 -0
  30. package/js/base/errorHierarchy.js +47 -0
  31. package/js/base/errors.js +55 -0
  32. package/js/base/functions/crypto.js +158 -0
  33. package/js/base/functions/encode.js +118 -0
  34. package/js/base/functions/generic.js +270 -0
  35. package/js/base/functions/misc.js +138 -0
  36. package/js/base/functions/number.js +329 -0
  37. package/js/base/functions/platform.js +38 -0
  38. package/js/base/functions/string.js +21 -0
  39. package/js/base/functions/throttle.js +79 -0
  40. package/js/base/functions/time.js +210 -0
  41. package/js/base/functions/type.js +66 -0
  42. package/js/base/functions.js +28 -0
  43. package/js/bequant.js +32 -0
  44. package/js/bibox.js +1407 -0
  45. package/js/bigone.js +1366 -0
  46. package/js/binance.js +5652 -0
  47. package/js/binancecoinm.js +46 -0
  48. package/js/binanceus.js +46 -0
  49. package/js/binanceusdm.js +49 -0
  50. package/js/bit2c.js +535 -0
  51. package/js/bitbank.js +842 -0
  52. package/js/bitbay.js +16 -0
  53. package/js/bitbns.js +1073 -0
  54. package/js/bitcoincom.js +15 -0
  55. package/js/bitfinex.js +1433 -0
  56. package/js/bitfinex2.js +2025 -0
  57. package/js/bitflyer.js +840 -0
  58. package/js/bitforex.js +614 -0
  59. package/js/bitget.js +2397 -0
  60. package/js/bithumb.js +980 -0
  61. package/js/bitmart.js +2516 -0
  62. package/js/bitmex.js +1809 -0
  63. package/js/bitopro.js +1443 -0
  64. package/js/bitpanda.js +1782 -0
  65. package/js/bitrue.js +1747 -0
  66. package/js/bitso.js +1062 -0
  67. package/js/bitstamp.js +1757 -0
  68. package/js/bitstamp1.js +343 -0
  69. package/js/bittrex.js +1876 -0
  70. package/js/bitvavo.js +1579 -0
  71. package/js/bkex.js +1233 -0
  72. package/js/bl3p.js +346 -0
  73. package/js/blockchaincom.js +969 -0
  74. package/js/btcalpha.js +680 -0
  75. package/js/btcbox.js +477 -0
  76. package/js/btcmarkets.js +1022 -0
  77. package/js/btctradeua.js +466 -0
  78. package/js/btcturk.js +734 -0
  79. package/js/buda.js +946 -0
  80. package/js/bw.js +1265 -0
  81. package/js/bybit.js +3372 -0
  82. package/js/bytetrade.js +1336 -0
  83. package/js/cdax.js +1646 -0
  84. package/js/cex.js +1410 -0
  85. package/js/coinbase.js +1342 -0
  86. package/js/coinbaseprime.js +31 -0
  87. package/js/coinbasepro.js +1466 -0
  88. package/js/coincheck.js +755 -0
  89. package/js/coinex.js +3400 -0
  90. package/js/coinfalcon.js +880 -0
  91. package/js/coinmate.js +794 -0
  92. package/js/coinone.js +816 -0
  93. package/js/coinspot.js +345 -0
  94. package/js/crex24.js +1636 -0
  95. package/js/cryptocom.js +1832 -0
  96. package/js/currencycom.js +1748 -0
  97. package/js/delta.js +1547 -0
  98. package/js/deribit.js +2148 -0
  99. package/js/digifinex.js +1585 -0
  100. package/js/eqonex.js +1660 -0
  101. package/js/exmo.js +1670 -0
  102. package/js/fairdesk.js +1231 -0
  103. package/js/flowbtc.js +35 -0
  104. package/js/fmfwio.js +34 -0
  105. package/js/ftx.js +2751 -0
  106. package/js/ftxus.js +38 -0
  107. package/js/gateio.js +4174 -0
  108. package/js/gemini.js +1397 -0
  109. package/js/hitbtc.js +1343 -0
  110. package/js/hitbtc3.js +2329 -0
  111. package/js/hollaex.js +1486 -0
  112. package/js/huobi.js +5706 -0
  113. package/js/huobijp.js +1710 -0
  114. package/js/huobipro.js +18 -0
  115. package/js/idex.js +1439 -0
  116. package/js/independentreserve.js +649 -0
  117. package/js/indodax.js +742 -0
  118. package/js/itbit.js +722 -0
  119. package/js/kraken.js +2179 -0
  120. package/js/kucoin.js +2571 -0
  121. package/js/kucoinfutures.js +1771 -0
  122. package/js/kuna.js +809 -0
  123. package/js/latoken.js +1445 -0
  124. package/js/lbank.js +760 -0
  125. package/js/liquid.js +1432 -0
  126. package/js/luno.js +873 -0
  127. package/js/lykke.js +1147 -0
  128. package/js/mercado.js +771 -0
  129. package/js/mexc.js +3151 -0
  130. package/js/ndax.js +2233 -0
  131. package/js/novadax.js +1318 -0
  132. package/js/oceanex.js +816 -0
  133. package/js/okcoin.js +3841 -0
  134. package/js/okex.js +16 -0
  135. package/js/okex5.js +16 -0
  136. package/js/okx.js +4795 -0
  137. package/js/paymium.js +498 -0
  138. package/js/phemex.js +2957 -0
  139. package/js/poloniex.js +1674 -0
  140. package/js/probit.js +1346 -0
  141. package/js/qtrade.js +1588 -0
  142. package/js/ripio.js +1061 -0
  143. package/js/static_dependencies/BN/bn.js +3526 -0
  144. package/js/static_dependencies/README.md +1 -0
  145. package/js/static_dependencies/crypto-js/crypto-js.js +5988 -0
  146. package/js/static_dependencies/elliptic/lib/elliptic/curve/base.js +375 -0
  147. package/js/static_dependencies/elliptic/lib/elliptic/curve/edwards.js +433 -0
  148. package/js/static_dependencies/elliptic/lib/elliptic/curve/index.js +8 -0
  149. package/js/static_dependencies/elliptic/lib/elliptic/curve/mont.js +180 -0
  150. package/js/static_dependencies/elliptic/lib/elliptic/curve/short.js +938 -0
  151. package/js/static_dependencies/elliptic/lib/elliptic/curves.js +204 -0
  152. package/js/static_dependencies/elliptic/lib/elliptic/ec/index.js +240 -0
  153. package/js/static_dependencies/elliptic/lib/elliptic/ec/key.js +119 -0
  154. package/js/static_dependencies/elliptic/lib/elliptic/ec/signature.js +24 -0
  155. package/js/static_dependencies/elliptic/lib/elliptic/eddsa/index.js +145 -0
  156. package/js/static_dependencies/elliptic/lib/elliptic/eddsa/key.js +100 -0
  157. package/js/static_dependencies/elliptic/lib/elliptic/eddsa/signature.js +65 -0
  158. package/js/static_dependencies/elliptic/lib/elliptic/precomputed/secp256k1.js +780 -0
  159. package/js/static_dependencies/elliptic/lib/elliptic/utils.js +214 -0
  160. package/js/static_dependencies/elliptic/lib/elliptic.js +22 -0
  161. package/js/static_dependencies/elliptic/lib/hmac-drbg/hmac-drbg.js +114 -0
  162. package/js/static_dependencies/fetch-ponyfill/fetch-node.js +39 -0
  163. package/js/static_dependencies/node-fetch/index.js +1564 -0
  164. package/js/static_dependencies/node-rsa/NodeRSA.js +223 -0
  165. package/js/static_dependencies/node-rsa/asn1/ber/errors.js +13 -0
  166. package/js/static_dependencies/node-rsa/asn1/ber/index.js +21 -0
  167. package/js/static_dependencies/node-rsa/asn1/ber/reader.js +262 -0
  168. package/js/static_dependencies/node-rsa/asn1/ber/types.js +36 -0
  169. package/js/static_dependencies/node-rsa/asn1/index.js +17 -0
  170. package/js/static_dependencies/node-rsa/encryptEngines/js.js +34 -0
  171. package/js/static_dependencies/node-rsa/formats/components.js +71 -0
  172. package/js/static_dependencies/node-rsa/formats/formats.js +31 -0
  173. package/js/static_dependencies/node-rsa/formats/pkcs1.js +148 -0
  174. package/js/static_dependencies/node-rsa/formats/pkcs8.js +187 -0
  175. package/js/static_dependencies/node-rsa/libs/jsbn.js +1252 -0
  176. package/js/static_dependencies/node-rsa/libs/rsa.js +147 -0
  177. package/js/static_dependencies/node-rsa/schemes/pkcs1.js +176 -0
  178. package/js/static_dependencies/node-rsa/schemes/schemes.js +21 -0
  179. package/js/static_dependencies/node-rsa/utils.js +98 -0
  180. package/js/static_dependencies/qs/formats.js +18 -0
  181. package/js/static_dependencies/qs/index.js +11 -0
  182. package/js/static_dependencies/qs/parse.js +242 -0
  183. package/js/static_dependencies/qs/stringify.js +269 -0
  184. package/js/static_dependencies/qs/utils.js +230 -0
  185. package/js/stex.js +1925 -0
  186. package/js/test/.eslintrc.js +42 -0
  187. package/js/test/Exchange/test.balance.js +61 -0
  188. package/js/test/Exchange/test.borrowRate.js +32 -0
  189. package/js/test/Exchange/test.currency.js +52 -0
  190. package/js/test/Exchange/test.fetchBalance.js +23 -0
  191. package/js/test/Exchange/test.fetchBorrowInterest.js +59 -0
  192. package/js/test/Exchange/test.fetchBorrowRate.js +32 -0
  193. package/js/test/Exchange/test.fetchBorrowRates.js +28 -0
  194. package/js/test/Exchange/test.fetchClosedOrders.js +32 -0
  195. package/js/test/Exchange/test.fetchCurrencies.js +35 -0
  196. package/js/test/Exchange/test.fetchDeposits.js +31 -0
  197. package/js/test/Exchange/test.fetchFundingFees.js +19 -0
  198. package/js/test/Exchange/test.fetchFundingRateHistory.js +40 -0
  199. package/js/test/Exchange/test.fetchL2OrderBook.js +23 -0
  200. package/js/test/Exchange/test.fetchLedger.js +42 -0
  201. package/js/test/Exchange/test.fetchLeverageTiers.js +33 -0
  202. package/js/test/Exchange/test.fetchMarketLeverageTiers.js +22 -0
  203. package/js/test/Exchange/test.fetchMarkets.js +33 -0
  204. package/js/test/Exchange/test.fetchMyTrades.js +42 -0
  205. package/js/test/Exchange/test.fetchOHLCV.js +46 -0
  206. package/js/test/Exchange/test.fetchOpenOrders.js +36 -0
  207. package/js/test/Exchange/test.fetchOrderBook.js +25 -0
  208. package/js/test/Exchange/test.fetchOrderBooks.js +35 -0
  209. package/js/test/Exchange/test.fetchOrders.js +41 -0
  210. package/js/test/Exchange/test.fetchPositions.js +47 -0
  211. package/js/test/Exchange/test.fetchStatus.js +35 -0
  212. package/js/test/Exchange/test.fetchTicker.js +38 -0
  213. package/js/test/Exchange/test.fetchTickers.js +49 -0
  214. package/js/test/Exchange/test.fetchTrades.js +39 -0
  215. package/js/test/Exchange/test.fetchTradingFee.js +18 -0
  216. package/js/test/Exchange/test.fetchTradingFees.js +22 -0
  217. package/js/test/Exchange/test.fetchTransactions.js +31 -0
  218. package/js/test/Exchange/test.fetchWithdrawals.js +31 -0
  219. package/js/test/Exchange/test.ledgerItem.js +46 -0
  220. package/js/test/Exchange/test.leverageTier.js +33 -0
  221. package/js/test/Exchange/test.loadMarkets.js +35 -0
  222. package/js/test/Exchange/test.market.js +129 -0
  223. package/js/test/Exchange/test.ohlcv.js +33 -0
  224. package/js/test/Exchange/test.order.js +62 -0
  225. package/js/test/Exchange/test.orderbook.js +61 -0
  226. package/js/test/Exchange/test.position.js +21 -0
  227. package/js/test/Exchange/test.throttle.js +94 -0
  228. package/js/test/Exchange/test.ticker.js +95 -0
  229. package/js/test/Exchange/test.trade.js +68 -0
  230. package/js/test/Exchange/test.tradingFee.js +34 -0
  231. package/js/test/Exchange/test.transaction.js +35 -0
  232. package/js/test/base/.eslintrc +38 -0
  233. package/js/test/base/functions/test.crypto.js +110 -0
  234. package/js/test/base/functions/test.datetime.js +62 -0
  235. package/js/test/base/functions/test.generic.js +152 -0
  236. package/js/test/base/functions/test.number.js +362 -0
  237. package/js/test/base/functions/test.time.js +56 -0
  238. package/js/test/base/functions/test.type.js +53 -0
  239. package/js/test/base/test.base.js +193 -0
  240. package/js/test/errors/test.InsufficientFunds.js +86 -0
  241. package/js/test/errors/test.InvalidNonce.js +64 -0
  242. package/js/test/errors/test.InvalidOrder.js +35 -0
  243. package/js/test/errors/test.OrderNotFound.js +39 -0
  244. package/js/test/test.js +426 -0
  245. package/js/test/test.timeout_hang.js +12 -0
  246. package/js/therock.js +1431 -0
  247. package/js/tidebit.js +632 -0
  248. package/js/tidex.js +939 -0
  249. package/js/timex.js +1283 -0
  250. package/js/upbit.js +1622 -0
  251. package/js/vcc.js +1353 -0
  252. package/js/wavesexchange.js +2185 -0
  253. package/js/wazirx.js +732 -0
  254. package/js/whitebit.js +1352 -0
  255. package/js/woo.js +1577 -0
  256. package/js/xena.js +1948 -0
  257. package/js/yobit.js +1129 -0
  258. package/js/zaif.js +647 -0
  259. package/js/zb.js +4088 -0
  260. package/js/zipmex.js +40 -0
  261. package/js/zonda.js +1497 -0
  262. package/multilang.sh +159 -0
  263. package/package.json +591 -0
  264. package/postinstall.js +103 -0
@@ -0,0 +1,38 @@
1
+ {
2
+ "env": {
3
+ "node": true
4
+ },
5
+ "parserOptions": {
6
+ "ecmaVersion": 2017,
7
+ "sourceType": "script",
8
+ },
9
+ "rules": {
10
+ "semi": ["error", "never"],
11
+ "no-unused-vars": ["off"],
12
+ "quotes": ["off", "single"],
13
+ "func-call-spacing": ["error", "always"],
14
+ "one-var": "off",
15
+ "indent": ["warn", 4, { "ignoredNodes": ["ObjectPattern"] }],
16
+ "comma-style": "off",
17
+ "no-multi-spaces": "off",
18
+ "comma-dangle": "off",
19
+ "spaced-comment": "off",
20
+ "camelcase": "off",
21
+ "padded-blocks": "off",
22
+ "multiline-comment-style": "off",
23
+ "curly": "off",
24
+ "rest-spread-spacing": "off",
25
+ "no-multiple-empty-lines": "off",
26
+ "no-undef-init": "off",
27
+ "no-useless-return": "off",
28
+ "no-console": "off",
29
+ "operator-linebreak": "off",
30
+ "key-spacing": "off",
31
+ "brace-style": "off",
32
+ "padding-line-between-statements": ["off",
33
+ {"blankLine": "always", "prev":"function", "next": "*" },
34
+ {"blankLine": "always", "prev":"directive", "next": "*" },
35
+ {"blankLine": "always", "prev":"*", "next": "cjs-export" },
36
+ ],
37
+ },
38
+ }
@@ -0,0 +1,110 @@
1
+ const { hash, ecdsa, jwt } = require ('../../../base/functions/crypto')
2
+ const { encode } = require ('../../../base/functions/encode')
3
+ const Exchange = require ('../../../base/Exchange');
4
+ const assert = require ('assert')
5
+
6
+ function equals (a, b) {
7
+ // does not check if b has more properties than a
8
+ for (const prop of Object.keys (a)) {
9
+ if (a[prop] !== b[prop]) {
10
+ return false
11
+ }
12
+ }
13
+ return true
14
+ }
15
+
16
+ const exchange = new Exchange ();
17
+
18
+ // ---------------------------------------------------------------------------------------------------------------------
19
+
20
+ assert (hash (encode (''), 'sha256', 'hex') === 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855');
21
+ assert (hash (encode ('cheese'), 'sha256', 'hex') === '873ac9ffea4dd04fa719e8920cd6938f0c23cd678af330939cff53c3d2855f34');
22
+
23
+ assert (hash (encode (''), 'md5', 'hex') === 'd41d8cd98f00b204e9800998ecf8427e');
24
+ assert (hash (encode ('sexyfish'), 'md5', 'hex') === 'c8a35464aa9d5683585786f44d5889f8');
25
+
26
+ assert (hash (encode (''), 'sha1', 'hex') === 'da39a3ee5e6b4b0d3255bfef95601890afd80709');
27
+ assert (hash (encode ('nutella'), 'sha1', 'hex') === 'b3d60a34b744159793c483b067c56d8affc5111a');
28
+
29
+ // ---------------------------------------------------------------------------------------------------------------------
30
+
31
+ const privateKey = '1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a';
32
+
33
+ assert (equals (ecdsa ('1a', privateKey, 'p256', 'sha256'), {
34
+ 'r': '3f4537ef9e72240cdefaea19d68fd483b5e10227e89747c58a3b543bfaf9cc46',
35
+ 's': '278d65adebd8d52dac34820c02cee0a0e3348f9aee91a21b8e9bfa0a23b40001',
36
+ 'v': 1
37
+ }));
38
+
39
+
40
+ assert (equals (ecdsa (privateKey, privateKey, 'p256', undefined), {
41
+ 'r': '9aadbfe7feca28a8b665731abd8fdd19f8b1be5fcdd1264d111b291a01c8dea2',
42
+ 's': '5084765e08e169fbba470ed1f573c9fed8d68a9d883049054b601f66a6648912',
43
+ 'v': 0,
44
+ }));
45
+
46
+ assert (equals (ecdsa ('1a', privateKey, 'secp256k1', 'sha256'), {
47
+ 'r': '23dcb2a2a3728a35eb1a35cc01743c4609550d9cceaf2083550f13a9eb135f9f',
48
+ 's': '317963fcac18e4ec9f7921b97d7ea0c82a873dd6299cbfb6af016e08ef5ed667',
49
+ 'v': 0,
50
+ }));
51
+
52
+
53
+ assert (equals (ecdsa (privateKey, privateKey, 'secp256k1', undefined), {
54
+ 'r': 'b84a36a6fbabd5277ede578448b93d48e70b38efb5b15b1d4e2a298accf938b1',
55
+ 's': '66ebfb8221cda925526e699a59cd221bb4cc84bdc563024b1802c4d9e1d8bbe9',
56
+ 'v': 1,
57
+ }));
58
+
59
+ // ---------------------------------------------------------------------------------------------------------------------
60
+
61
+ assert (exchange.hashMessage (privateKey) === '0x59ea5d98c3500c3729f95cf98aa91663f498518cc401360df2912742c232207f');
62
+
63
+ assert (equals (exchange.signHash ('0x59ea5d98c3500c3729f95cf98aa91663f498518cc401360df2912742c232207f', privateKey), {
64
+ 'r': '0x6f684aa41c02da83dac3039d8805ddbe79a03b1297e247c7742cab8dfc19d341',
65
+ 's': '0x62473881674550563cb028ff40a7846fd53620ddf40a20cc1003b8484a109a4a',
66
+ 'v': 27
67
+ }));
68
+
69
+ assert (equals (exchange.signMessage (privateKey, privateKey), {
70
+ 'r': '0x6f684aa41c02da83dac3039d8805ddbe79a03b1297e247c7742cab8dfc19d341',
71
+ 's': '0x62473881674550563cb028ff40a7846fd53620ddf40a20cc1003b8484a109a4a',
72
+ 'v': 27
73
+ }));
74
+
75
+ // ---------------------------------------------------------------------------------------------------------------------
76
+
77
+ const pemKeyArray = [
78
+ '-----BEGIN RSA PRIVATE KEY-----',
79
+ 'MIIEpAIBAAKCAQEAqUtXQXv2uSm9zPvdJTRpu5/65rBjAoHmIiowAs+u7fY0QP9O',
80
+ '+T8CZRQjvZrfPomBiccjCxDo8mm7GkmL67rs9s7VOMQFvpTTtMBeglNSEbXJ3wTt',
81
+ '7WM5gD3ZAbhfGtwWdGpcOMX0hV5/d/fiw1zQk0+AooayTryZ7HV+DQcD1sGTYYir',
82
+ 'LePUGkKV2NCvKtGOQfRAtuo0ccigMxMvEhWuExCc9Fhd077OpXMc0n7OiFqA2JWN',
83
+ 'jlocM9S71Srvw/lDos8a7lGaFUV8gP1CsQY/4qTju6hhsRd4lFujVr5J9FqmDbnv',
84
+ 'wQ79SSu6+lT0+ToFdDHiYOorBK2ESFR7EzlyLwIDAQABAoIBAEobQMbZjNbg/sSM',
85
+ 'O/HdT6tiDGKPM8gVNLgf34RbhSeFbrpFCDzy6Al3F24YLUEi0CGPmjdt34q93blU',
86
+ 'GHvIB5LCV3PR2vHiFAo7ayOBdZtrCEMn1T7lAHaynBu0qW0IiovLQzNW9AKtqv7I',
87
+ '8+qw5lyVoKmEbOkqhfaMN/Fb8MJAo3yEVyhyp4EjtFhqDQ9DuHEjp1jGthnMgm+4',
88
+ 'qFyELf0DXZSAN+R9IGDqWPyo78lOcPW4pgeLuoLQ6Nn/2JAEGHFt1a7zMEw5yYbR',
89
+ 'XB89Bh0dheSmopBN6Heay4YuhnNKua37OlL1/nhKpLGUNE3z/UOXeiUiMeE1C2i+',
90
+ 'GjK+xgECgYEA4XH63rJ3VYDHHWUGlWffFWkEpgR4BDEkZ8MyVYQoUjQA2TpCvQ2+',
91
+ 'bR7aAIGXhBnRTrIBNu9m4+am0aUfi1hVmVHqt1b2vFgEb9uKuO4U62tCFpeji+Rz',
92
+ '8C8QJyu5v5OUWdQZ4EA0d7ljeoTl50g8tpcGsDhnImLt+/jvJuFt8dECgYEAwD0n',
93
+ 'rhlkEjKVHxu1xwKeczxYCqqcUV9Quq8HnPh4VJQ77ljfZ57V7sAKrFDi5XfVD9jS',
94
+ 'oJPwxjw6za134VobhdvCM6WNs6AJmbR8E/b5kDMbGaZn27vt+/8JfnGaWBqpDi6W',
95
+ 'a5xoJOqmcMBQBK1YleZDoY4PLbk+onVKLMfGI/8CgYEAkyUIv8euGdGWpHnm5SdJ',
96
+ 'tLi5vv4Vs267uzntJWG/y3+DukTLgIdy7dgAI+pxkVgkg/+syUVSW5eU9CqZPyLl',
97
+ 'o8+Sqh2Jp36vTq71iSRj5RA5r3ND3K+8eFzPZzGj6AWUA1lrljFxzV7kLfiF8gH1',
98
+ 'FpvWUrhNoGT/vcFJno/uabECgYAecRC5hxfLserfVDoC261PvjyK492BHUDhbxob',
99
+ 'h1U2v4qGAdjOxd5Gwm5uPxjPEZzRt5oTB5pXKe5953xWWTiGh/hGyW6ZBTy/9E65',
100
+ 'sqBub0lZVHqZ1zamcwqD1WWFkiM3NbVoMQpk3iuhKzMAqpqekiofiSlqKi16+GvY',
101
+ 'j4IW7QKBgQCrIUckPZ6IY3ERIN1IL4TIcK2gOJcznp7fLWpC+sv35ya3OhtDXKFt',
102
+ 'GjIHmwLuiUNc0iPzA9Rw89W0zIkKWmWcxM88/ithdxh3MEeNDUGSnd4hQ9SECwxB',
103
+ 'Wem3eBT7I4VtFYoaTE3/bX1SKfgBdTzIRqWKSDpgBNZg/P2Tc+s11g==',
104
+ '-----END RSA PRIVATE KEY-----',
105
+ ];
106
+
107
+ const pemKey = pemKeyArray.join ("\n");
108
+
109
+ assert (jwt ({'chicken': 'salad'}, encode (pemKey), 'RS256') === 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJjaGlja2VuIjoic2FsYWQifQ.FSKD5Y6RNzkHTuHdvG3753U7QNZ-u-GUSPfP1FMjEaK0Rr_iyQTSSmHhkdYSFFnmBvrrN_l-UwKwir52WlsgmQm9HYm0kidxbj7fWwrK2E1oe0P7OjupFjv1BZxc5W69WeaHtOPWe28tiHiON1LCnax6HgfI5lcIBsESGIIBZMVeaioQn9gDVwea7JxJvAlrhDIWZowIHTIdCQocXip7g5jREWHeEIuJNug67mwnfAFxCjvTRiTd0Bw6oBwjM3FLya-RyEyWrejQOWSuC8CNWVUHISaSmEyZ7uM6wTi2m_58TaE9mQwlef32OPErPvvBpgL5pZIyQ4ymwrCIFQLBQQ');
110
+ assert (jwt ({'lil': 'xan'}, encode ('betrayed'), 'HS256') === 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsaWwiOiJ4YW4ifQ.md-oFvZagA-NXmZoRNyJOQ7zwK-PWUMmMQ_LI9ZOKaM');
@@ -0,0 +1,62 @@
1
+ 'use strict'
2
+
3
+ const ccxt = require ('../../../../ccxt');
4
+ const assert = require ('assert');
5
+ const { ROUND_UP, ROUND_DOWN } = require ('../../../base/functions/misc');
6
+
7
+ const exchange = new ccxt.Exchange ({
8
+ 'id': 'regirock',
9
+ });
10
+
11
+ // ----------------------------------------------------------------------------
12
+
13
+ assert (exchange.iso8601 (514862627000) === '1986-04-26T01:23:47.000Z');
14
+ assert (exchange.iso8601 (514862627559) === '1986-04-26T01:23:47.559Z');
15
+ assert (exchange.iso8601 (514862627062) === '1986-04-26T01:23:47.062Z');
16
+
17
+ assert (exchange.iso8601 (0) === '1970-01-01T00:00:00.000Z');
18
+
19
+ assert (exchange.iso8601 (-1) === undefined);
20
+ assert (exchange.iso8601 () === undefined);
21
+ assert (exchange.iso8601 (undefined) === undefined);
22
+ assert (exchange.iso8601 ('') === undefined);
23
+ assert (exchange.iso8601 ('a') === undefined);
24
+ assert (exchange.iso8601 ({}) === undefined);
25
+
26
+ // ----------------------------------------------------------------------------
27
+
28
+ assert (exchange.parse8601 ('1986-04-26T01:23:47.000Z') === 514862627000);
29
+ assert (exchange.parse8601 ('1986-04-26T01:23:47.559Z') === 514862627559);
30
+ assert (exchange.parse8601 ('1986-04-26T01:23:47.062Z') === 514862627062);
31
+
32
+ assert (exchange.parse8601 ('1986-04-26T01:23:47.06Z') === 514862627060);
33
+ assert (exchange.parse8601 ('1986-04-26T01:23:47.6Z') === 514862627600);
34
+
35
+ assert (exchange.parse8601 ('1977-13-13T00:00:00.000Z') === undefined);
36
+ assert (exchange.parse8601 ('1986-04-26T25:71:47.000Z') === undefined);
37
+
38
+ assert (exchange.parse8601 ('3333') === undefined);
39
+ assert (exchange.parse8601 ('Sr90') === undefined);
40
+ assert (exchange.parse8601 ('') === undefined);
41
+ assert (exchange.parse8601 () === undefined);
42
+ assert (exchange.parse8601 (undefined) === undefined);
43
+ assert (exchange.parse8601 ({}) === undefined);
44
+ assert (exchange.parse8601 (33) === undefined);
45
+
46
+ // ----------------------------------------------------------------------------
47
+
48
+ assert (exchange.parseDate ('1986-04-26 00:00:00') === 514857600000);
49
+ assert (exchange.parseDate ('1986-04-26T01:23:47.000Z') === 514862627000);
50
+ assert (exchange.parseDate ('1986-13-13 00:00:00') === undefined);
51
+
52
+
53
+ assert (exchange.roundTimeframe('5m', exchange.parse8601('2019-08-12 13:22:08'), ROUND_DOWN) === exchange.parse8601('2019-08-12 13:20:00'));
54
+ assert (exchange.roundTimeframe('10m', exchange.parse8601('2019-08-12 13:22:08'), ROUND_DOWN) === exchange.parse8601('2019-08-12 13:20:00'));
55
+ assert (exchange.roundTimeframe('30m', exchange.parse8601('2019-08-12 13:22:08'), ROUND_DOWN) === exchange.parse8601('2019-08-12 13:00:00'));
56
+ assert (exchange.roundTimeframe('1d', exchange.parse8601('2019-08-12 13:22:08'), ROUND_DOWN) === exchange.parse8601('2019-08-12 00:00:00'));
57
+
58
+ assert (exchange.roundTimeframe('5m', exchange.parse8601('2019-08-12 13:22:08'), ROUND_UP) === exchange.parse8601('2019-08-12 13:25:00'));
59
+ assert (exchange.roundTimeframe('10m', exchange.parse8601('2019-08-12 13:22:08'), ROUND_UP) === exchange.parse8601('2019-08-12 13:30:00'));
60
+ assert (exchange.roundTimeframe('30m', exchange.parse8601('2019-08-12 13:22:08'), ROUND_UP) === exchange.parse8601('2019-08-12 13:30:00'));
61
+ assert (exchange.roundTimeframe('1h', exchange.parse8601('2019-08-12 13:22:08'), ROUND_UP) === exchange.parse8601('2019-08-12 14:00:00'));
62
+ assert (exchange.roundTimeframe('1d', exchange.parse8601('2019-08-12 13:22:08'), ROUND_UP) === exchange.parse8601('2019-08-13 00:00:00'));
@@ -0,0 +1,152 @@
1
+ 'use strict'
2
+
3
+ const { deepExtend, groupBy, filterBy, omit, sum, sortBy } = require ('../../../base/functions/generic')
4
+ const { strictEqual: equal, deepEqual } = require ('assert')
5
+
6
+ function testDeepExtend() {
7
+
8
+ let count = 0
9
+
10
+ const values = [{
11
+ a: 1,
12
+ b: 2,
13
+ d: {
14
+ a: 1,
15
+ b: [],
16
+ c: { test1: 123, test2: 321 }},
17
+ f: 5,
18
+ g: 123,
19
+ i: 321,
20
+ j: [1, 2],
21
+ },
22
+ {
23
+ b: 3,
24
+ c: 5,
25
+ d: {
26
+ b: { first: 'one', second: 'two' },
27
+ c: { test2: 222 }},
28
+ e: { one: 1, two: 2 },
29
+ f: [{ 'foo': 'bar' }],
30
+ g: (void 0),
31
+ h: /abc/g,
32
+ i: null,
33
+ j: [3, 4]
34
+ }]
35
+
36
+ const extended = deepExtend (...values)
37
+ deepEqual (extended, {
38
+ a: 1,
39
+ b: 3,
40
+ d: {
41
+ a: 1,
42
+ b: { first: 'one', second: 'two' },
43
+ c: { test1: 123, test2: 222 }
44
+ },
45
+ f: [{ 'foo': 'bar' }],
46
+ g: undefined,
47
+ c: 5,
48
+ e: { one: 1, two: 2 },
49
+ h: /abc/g,
50
+ i: null,
51
+ j: [3, 4]
52
+ })
53
+
54
+ deepEqual (deepExtend (undefined, undefined, {'foo': 'bar' }), { 'foo': 'bar' })
55
+ }
56
+
57
+ function testGroupBy() {
58
+
59
+ const array = [
60
+ { 'foo': 'a' },
61
+ { 'foo': 'b' },
62
+ { 'foo': 'c' },
63
+ { 'foo': 'b' },
64
+ { 'foo': 'c' },
65
+ { 'foo': 'c' },
66
+ ]
67
+
68
+ deepEqual (groupBy (array, 'foo'), {
69
+ 'a': [ { 'foo': 'a' } ],
70
+ 'b': [ { 'foo': 'b' }, { 'foo': 'b' } ],
71
+ 'c': [ { 'foo': 'c' }, { 'foo': 'c' }, { 'foo': 'c' } ],
72
+ })
73
+ }
74
+
75
+ function testFilterBy() {
76
+
77
+ const array = [
78
+ { 'foo': 'a' },
79
+ { 'foo': undefined },
80
+ { 'foo': 'b' },
81
+ { },
82
+ { 'foo': 'a', 'bar': 'b' },
83
+ { 'foo': 'c' },
84
+ { 'foo': 'd' },
85
+ { 'foo': 'b' },
86
+ { 'foo': 'c' },
87
+ { 'foo': 'c' },
88
+ ]
89
+
90
+ deepEqual (filterBy (array, 'foo', 'a'), [
91
+ { 'foo': 'a' },
92
+ { 'foo': 'a', 'bar': 'b' },
93
+ ])
94
+ }
95
+
96
+ function testOmit() {
97
+
98
+ deepEqual (omit ({ }, 'foo'), {})
99
+ deepEqual (omit ({ foo: 2 }, 'foo'), { })
100
+ deepEqual (omit ({ foo: 2, bar: 3 }, 'foo'), { bar: 3 })
101
+ deepEqual (omit ({ foo: 2, bar: 3 }, ['foo']), { bar: 3 })
102
+ deepEqual (omit ({ foo: 2, bar: 3 }), { foo: 2, bar: 3 })
103
+ deepEqual (omit ({ foo: 2, bar: 3 }, 'foo', 'bar'), {})
104
+ deepEqual (omit ({ foo: 2, bar: 3 }, ['foo'], 'bar'), {})
105
+ deepEqual (omit ({ 5: 2, bar: 3 }, [ 5 ]), { bar: 3 })
106
+ deepEqual (omit ({ 5: 2, bar: 3 }, 5), { bar: 3 })
107
+ }
108
+
109
+ function testSum() {
110
+
111
+ equal (undefined, sum ())
112
+ equal (2, sum (2))
113
+ equal (432, sum (2, 30, 400))
114
+ equal (432, sum (2, undefined, [ 88 ], 30, '7', 400, null))
115
+ }
116
+
117
+ function testSortBy() {
118
+
119
+ const arr = [{ 'x': 5 }, { 'x': 2 }, { 'x': 4 }, { 'x': 0 }, { 'x': 1 }, { 'x': 3 }]
120
+ sortBy (arr, 'x')
121
+
122
+ deepEqual (arr, [
123
+ { 'x': 0 },
124
+ { 'x': 1 },
125
+ { 'x': 2 },
126
+ { 'x': 3 },
127
+ { 'x': 4 },
128
+ { 'x': 5 },
129
+ ])
130
+
131
+ deepEqual (sortBy (arr, 'x', true), [
132
+ { 'x': 5 },
133
+ { 'x': 4 },
134
+ { 'x': 3 },
135
+ { 'x': 2 },
136
+ { 'x': 1 },
137
+ { 'x': 0 },
138
+ ])
139
+
140
+ deepEqual (sortBy ([], 'x'), [])
141
+ }
142
+
143
+ function testGeneric() {
144
+ testDeepExtend()
145
+ testGroupBy()
146
+ testFilterBy()
147
+ testOmit()
148
+ testSum()
149
+ testSortBy()
150
+ }
151
+
152
+ testGeneric()