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,42 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ "env": {
5
+ "node": true
6
+ },
7
+ "parserOptions": {
8
+ "ecmaVersion": 2017,
9
+ "sourceType": "script",
10
+ },
11
+ "extends": ["eslint:recommended"],
12
+ "rules": {
13
+ "semi": ["error", "never"],
14
+ "no-unused-vars": ["off"],
15
+ "quotes": ["off", "single"],
16
+ "func-call-spacing": ["error", "always"],
17
+ "one-var": "off",
18
+ "indent": ["error", 4],
19
+ "comma-style": "off",
20
+ "no-multi-spaces": "off",
21
+ "comma-dangle": "off",
22
+ "spaced-comment": "off",
23
+ "camelcase": "off",
24
+ "padded-blocks": "off",
25
+ "multiline-comment-style": "off",
26
+ "curly": "off",
27
+ "rest-spread-spacing": "off",
28
+ "no-multiple-empty-lines": "off",
29
+ "no-undef-init": "off",
30
+ "no-useless-return": "off",
31
+ "no-console": "off",
32
+ "operator-linebreak": "off",
33
+ "key-spacing": "off",
34
+ "brace-style": "off",
35
+ "padding-line-between-statements": ["off",
36
+ { "blankLine": "always", "prev":"function", "next": "*" },
37
+ { "blankLine": "always", "prev":"directive", "next": "*" },
38
+ { "blankLine": "always", "prev":"*", "next": "cjs-export" },
39
+ ],
40
+ "import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
41
+ },
42
+ }
@@ -0,0 +1,61 @@
1
+ 'use strict'
2
+
3
+ // ----------------------------------------------------------------------------
4
+
5
+ const assert = require ('assert')
6
+
7
+ // ----------------------------------------------------------------------------
8
+
9
+ module.exports = (exchange, balance, method) => {
10
+
11
+ const currencies = [
12
+ 'USD',
13
+ 'USDT',
14
+ 'CNY',
15
+ 'EUR',
16
+ 'BTC',
17
+ 'ETH',
18
+ 'JPY',
19
+ 'LTC',
20
+ 'DASH',
21
+ 'DOGE',
22
+ 'UAH',
23
+ 'RUB',
24
+ 'XRP',
25
+ ]
26
+
27
+ assert (typeof balance['total'] === 'object')
28
+ assert (typeof balance['free'] === 'object')
29
+ assert (typeof balance['used'] === 'object')
30
+
31
+ const codes = Object.keys (balance['total'])
32
+ for (let i = 0; i < codes.length; i++) {
33
+ const code = codes[i]
34
+ const total = balance['total'][code]
35
+ const free = balance['free'][code]
36
+ const used = balance['used'][code]
37
+ if ((total !== undefined) && (free !== undefined) && (used !== undefined)) {
38
+ assert (total === free + used, 'free and used do not sum to total ' + exchange.id)
39
+ }
40
+ }
41
+
42
+ let result = currencies
43
+ .filter ((currency) => (currency in balance) &&
44
+ (balance[currency]['total'] !== undefined))
45
+
46
+ if (result.length > 0) {
47
+ result = result.map ((currency) => currency + ': ' + balance[currency]['total'])
48
+ if (exchange.currencies.length > result.length) {
49
+ result = result.join (', ') + ' + more...'
50
+ } else {
51
+ result = result.join (', ')
52
+ }
53
+
54
+ } else {
55
+
56
+ result = 'zero balance'
57
+ }
58
+
59
+ console.log (result)
60
+
61
+ }
@@ -0,0 +1,32 @@
1
+ 'use strict'
2
+
3
+ // ----------------------------------------------------------------------------
4
+
5
+ const assert = require ('assert')
6
+
7
+ // ----------------------------------------------------------------------------
8
+
9
+ module.exports = (exchange, borrowRate, method, code) => {
10
+
11
+ const format = {
12
+ 'currency': 'USDT',
13
+ 'info': {}, // Or []
14
+ 'timestamp': 1638230400000,
15
+ 'datetime': '2021-11-30T00:00:00.000Z',
16
+ 'rate': 0.0006, // Interest rate
17
+ // 'period': 86400000, // Amount of time the interest rate is based on in milliseconds
18
+ }
19
+
20
+ const keys = Object.keys (format)
21
+ for (let i = 0; i < keys.length; i++) {
22
+ const key = keys[i]
23
+ assert (key in borrowRate)
24
+ }
25
+
26
+ console.log (borrowRate['datetime'], exchange.id, method, borrowRate['currency'], borrowRate['rate'])
27
+
28
+ // assert (borrowRate['period'] === 86400000 || borrowRate['period'] === 3600000) // Milliseconds in an hour or a day
29
+ assert (borrowRate['rate'] > 0)
30
+
31
+ return borrowRate
32
+ }
@@ -0,0 +1,52 @@
1
+ 'use strict'
2
+
3
+ // ----------------------------------------------------------------------------
4
+
5
+ const assert = require ('assert')
6
+
7
+ // ----------------------------------------------------------------------------
8
+
9
+ module.exports = (exchange, currency, method) => {
10
+
11
+ const format = {
12
+ 'id': 'btc', // string literal for referencing within an exchange
13
+ 'code': 'BTC', // uppercase string literal of a pair of currencies
14
+ //----------------------------------------------------------------------
15
+ // commented temporarily to bring currencies to consistency first
16
+ // 'name': 'Bitcoin', // uppercase string, base currency, 3 or more letters
17
+ // 'quote': 'USD', // uppercase string, quote currency, 3 or more letters
18
+ // 'withdraw': true, // can withdraw
19
+ // 'deposit': true, // can deposit
20
+ // 'active': true, // can both withdraw & deposit
21
+ // 'precision': 8, // number of decimal digits "after the dot"
22
+ // 'limits': { // value limits when placing orders on this market
23
+ // 'amount': {
24
+ // 'min': 0.01, // order amount should be > min
25
+ // 'max': 1000, // order amount should be < max
26
+ // },
27
+ // 'price': {
28
+ // 'min': 0.01, // order price should be > min
29
+ // 'max': 1000, // order price should be < max
30
+ // },
31
+ // 'cost': { // order cost = price * amount
32
+ // 'min': 0.01, // order cost should be > min
33
+ // 'max': 1000, // order cost should be < max
34
+ // },
35
+ // },
36
+ // 'info': {}, // the original unparsed market info from the exchange
37
+ //----------------------------------------------------------------------
38
+ }
39
+
40
+ const keys = Object.keys (format)
41
+ for (let i = 0; i < keys.length; i++) {
42
+ const key = keys[i]
43
+ assert (key in currency)
44
+ }
45
+
46
+ // expect (currency['precision']).to.not.be.undefined
47
+ // expect (currency['limits']['amount']['min']).to.not.be.undefined
48
+ // expect (currency['limits']['price']['min']).to.not.be.undefined
49
+ // expect (market['limits']['cost']['min']).to.not.be.undefined
50
+
51
+ return currency
52
+ }
@@ -0,0 +1,23 @@
1
+ 'use strict'
2
+
3
+ // ----------------------------------------------------------------------------
4
+
5
+ const testBalance = require ('./test.balance.js')
6
+
7
+ // ----------------------------------------------------------------------------
8
+
9
+ module.exports = async (exchange) => {
10
+
11
+ if (!(exchange.has.fetchBalance)) {
12
+ console.log (exchange.id, ' does not have fetchBalance')
13
+ return
14
+ }
15
+
16
+ console.log ('fetching balance...')
17
+
18
+ const response = await exchange.fetchBalance ()
19
+
20
+ testBalance (exchange, response)
21
+
22
+ return response
23
+ }
@@ -0,0 +1,59 @@
1
+ 'use strict'
2
+
3
+ // ----------------------------------------------------------------------------
4
+
5
+ const assert = require ('assert')
6
+
7
+ // ----------------------------------------------------------------------------
8
+
9
+ module.exports = async (exchange, code, symbol) => {
10
+
11
+ const method = 'fetchBorrowInterest'
12
+
13
+ if (exchange.has[method]) {
14
+
15
+ const format = {
16
+ 'account': 'BTC/USDT',
17
+ 'currency': 'USDT',
18
+ 'interest': '0.1444',
19
+ 'interestRate': 0.0006,
20
+ 'amountBorrowed': 30.0,
21
+ 'timestamp': 1638230400000,
22
+ 'datetime': '2021-11-30T00:00:00.000Z',
23
+ 'info': {},
24
+ }
25
+
26
+ const interest = await exchange.fetchBorrowInterest (code, symbol)
27
+
28
+ console.log (code, method, interest['datetime'], 'symbol: ', symbol, 'interest: ', interest['interest'], 'interestRate: ', interest['interestRate'], 'amountBorrowed: ', interest['amountBorrowed'])
29
+
30
+ if (code) {
31
+ assert (interest['currency'] === code)
32
+ }
33
+ assert (interest['account'] === symbol || interest['account'] === undefined)
34
+
35
+ const keys = Object.keys (format)
36
+ for (let i = 0; i < keys.length; i++) {
37
+ const key = keys[i]
38
+ assert (key in interest)
39
+ }
40
+
41
+ if (interest['amountBorrowed'] !== undefined) {
42
+ assert (interest['amountBorrowed'] >= 0)
43
+ }
44
+ if (interest['interestRate'] !== undefined) {
45
+ assert (interest['interestRate'] > 0)
46
+ }
47
+ if (interest['interest'] !== undefined) {
48
+ assert (interest['interest'] >= 0)
49
+ }
50
+ if (interest['timestamp'] !== undefined) {
51
+ assert (interest['timestamp'] > 1640933203000)
52
+ }
53
+
54
+ return interest
55
+
56
+ } else {
57
+ console.log (code, 'fetchBorrowInterest () not supported')
58
+ }
59
+ }
@@ -0,0 +1,32 @@
1
+ 'use strict'
2
+
3
+ // ----------------------------------------------------------------------------
4
+
5
+ const assert = require ('assert')
6
+ , testBorrowRate = require ('./test.borrowRate.js')
7
+
8
+ // ----------------------------------------------------------------------------
9
+
10
+ module.exports = async (exchange, code) => {
11
+
12
+ const method = 'fetchBorrowRate'
13
+
14
+ if (exchange.has[method]) {
15
+
16
+ const borrowRate = await exchange.fetchBorrowRate (code)
17
+
18
+ testBorrowRate (exchange, borrowRate, method, code)
19
+
20
+ console.log (code, method, borrowRate['datetime'], 'rate:', borrowRate['rate'], 'period:', borrowRate['period'])
21
+
22
+ if (code) {
23
+ assert (borrowRate['currency'] === code)
24
+ }
25
+
26
+ return borrowRate
27
+
28
+ } else {
29
+
30
+ console.log (code, 'fetchBorrowRate () not supported')
31
+ }
32
+ }
@@ -0,0 +1,28 @@
1
+ 'use strict'
2
+
3
+ // ----------------------------------------------------------------------------
4
+
5
+ const testBorrowRate = require ('./test.borrowRate.js')
6
+
7
+ // ----------------------------------------------------------------------------
8
+
9
+ module.exports = async (exchange) => {
10
+
11
+ if (exchange.has.fetchBorrowRates) {
12
+
13
+ const method = 'fetchBorrowRates'
14
+ const borrowRates = await exchange[method] ()
15
+ console.log ('fetched all', Object.keys (borrowRates).length, 'borrow rates')
16
+
17
+ const values = Object.values (borrowRates)
18
+ for (let i = 0; i < values.length; i++) {
19
+ const borrowRate = values[i]
20
+ testBorrowRate (exchange, borrowRate, method)
21
+ }
22
+ return borrowRates
23
+
24
+ } else {
25
+
26
+ console.log ('fetching all borrow rates at once not supported')
27
+ }
28
+ }
@@ -0,0 +1,32 @@
1
+ 'use strict'
2
+
3
+ // ----------------------------------------------------------------------------
4
+
5
+ const assert = require ('assert')
6
+ , testOrder = require ('./test.order.js')
7
+
8
+ // ----------------------------------------------------------------------------
9
+
10
+ module.exports = async (exchange, symbol) => {
11
+
12
+ if (exchange.has.fetchClosedOrders) {
13
+
14
+ const orders = await exchange.fetchClosedOrders (symbol)
15
+
16
+ console.log ('fetched', orders.length, 'closed orders, testing each')
17
+
18
+ assert (orders instanceof Array)
19
+
20
+ const now = Date.now ()
21
+
22
+ for (let i = 0; i < orders.length; i++) {
23
+ const order = orders[i]
24
+ testOrder (exchange, order, symbol, now)
25
+ assert (order.status === 'closed' || order.status === 'canceled')
26
+ }
27
+
28
+ } else {
29
+
30
+ console.log ('fetching closed orders not supported')
31
+ }
32
+ }
@@ -0,0 +1,35 @@
1
+ 'use strict'
2
+
3
+ // ----------------------------------------------------------------------------
4
+
5
+ const testCurrency = require ('./test.currency.js')
6
+
7
+ // ----------------------------------------------------------------------------
8
+
9
+ module.exports = async (exchange) => {
10
+
11
+ const skippedExchanges = []
12
+
13
+ if (skippedExchanges.includes (exchange.id)) {
14
+ console.log (exchange.id, 'found in ignored exchanges, skipping fetchCurrencies...')
15
+ return
16
+ }
17
+
18
+ if (exchange.has.fetchCurrencies === true || exchange.has.fetchCurrencies === 'emulated') {
19
+
20
+ const method = 'fetchCurrencies'
21
+ const currencies = await exchange[method] ()
22
+ if (currencies !== undefined) {
23
+ const values = Object.values (currencies)
24
+ for (let i = 0; i < values.length; i++) {
25
+ const currency = values[i]
26
+ testCurrency (exchange, currency, method)
27
+ }
28
+ }
29
+ return currencies
30
+
31
+ } else {
32
+
33
+ console.log ('fetching currencies not supported')
34
+ }
35
+ }
@@ -0,0 +1,31 @@
1
+ 'use strict'
2
+
3
+ // ----------------------------------------------------------------------------
4
+
5
+ const assert = require ('assert')
6
+ , testTransaction = require ('./test.transaction.js')
7
+
8
+ // ----------------------------------------------------------------------------
9
+
10
+ module.exports = async (exchange, code) => {
11
+
12
+ if (exchange.has.fetchDeposits) {
13
+
14
+ const transactions = await exchange.fetchDeposits (code)
15
+
16
+ console.log ('fetched', transactions.length, 'deposits, asserting each...')
17
+
18
+ assert (transactions instanceof Array)
19
+
20
+ const now = Date.now ()
21
+
22
+ for (let i = 0; i < transactions.length; i++) {
23
+ const transaction = transactions[i]
24
+ testTransaction (exchange, transaction, code, now)
25
+ }
26
+
27
+ } else {
28
+
29
+ console.log ('fetching deposits not supported')
30
+ }
31
+ }
@@ -0,0 +1,19 @@
1
+ 'use strict'
2
+
3
+ module.exports = async (exchange) => {
4
+ const skippedExchanges = [
5
+ 'bibox', // fetchFundingFees should be rewritten to fetchFundingFee
6
+ ]
7
+ if (skippedExchanges.includes (exchange.id)) {
8
+ console.log (exchange.id, 'found in ignored exchanges, skipping fetchFundingFees...')
9
+ return
10
+ }
11
+ if (exchange.has.fetchFundingFees) {
12
+ const method = 'fetchFundingFees'
13
+ const fees = await exchange[method] ()
14
+ console.log (fees)
15
+ return fees
16
+ } else {
17
+ console.log ('fetching funding fees not supported')
18
+ }
19
+ }
@@ -0,0 +1,40 @@
1
+ 'use strict'
2
+
3
+ // ----------------------------------------------------------------------------
4
+
5
+ const assert = require ('assert')
6
+
7
+ // ----------------------------------------------------------------------------
8
+
9
+ module.exports = async (exchange) => {
10
+
11
+ const format = {
12
+ 'currency': 'USDT',
13
+ 'info': {}, // Or []
14
+ 'timestamp': 1638230400000,
15
+ 'datetime': '2021-11-30T00:00:00.000Z',
16
+ 'rate': 0.0006,
17
+ }
18
+
19
+ if (exchange.has.fetchFundingRateHistory) {
20
+
21
+ const method = 'fetchFundingRateHistory'
22
+ const fundingRates = await exchange[method] ()
23
+ console.log ('fetched all', fundingRates.length, 'funding rates')
24
+
25
+ for (let i = 0; i < fundingRates.length; i++) {
26
+ const fundingRate = fundingRates[i]
27
+ const keys = Object.keys (format)
28
+ for (let i = 0; i < keys.length; i++) {
29
+ const key = keys[i]
30
+ assert (key in fundingRate)
31
+ }
32
+ assert (fundingRate['rate'] >= 0)
33
+ assert (fundingRate['timestamp'] >= 1199145600000) // 2008-01-01 00:00:00
34
+ }
35
+ return fundingRates
36
+
37
+ } else {
38
+ console.log ('fetchFundingRateHistory not supported')
39
+ }
40
+ }
@@ -0,0 +1,23 @@
1
+ 'use strict'
2
+
3
+ // ----------------------------------------------------------------------------
4
+
5
+ const testOrderBook = require ('./test.orderbook.js')
6
+
7
+ // ----------------------------------------------------------------------------
8
+
9
+ module.exports = async (exchange, symbol) => {
10
+
11
+ const method = 'fetchL2OrderBook'
12
+
13
+ if (exchange.has[method]) {
14
+
15
+ const orderbook = await exchange[method] (symbol)
16
+ testOrderBook (exchange, orderbook, method, symbol)
17
+ return orderbook
18
+
19
+ } else {
20
+
21
+ console.log (method + '() not supported')
22
+ }
23
+ }
@@ -0,0 +1,42 @@
1
+ 'use strict'
2
+
3
+ // ----------------------------------------------------------------------------
4
+
5
+ const assert = require ('assert')
6
+ , testLedgerItem = require ('./test.ledgerItem')
7
+
8
+ // ----------------------------------------------------------------------------
9
+
10
+ module.exports = async (exchange, code) => {
11
+
12
+ if (exchange.has.fetchLedger) {
13
+
14
+ const items = await exchange.fetchLedger (code)
15
+
16
+ assert (items instanceof Array)
17
+
18
+ console.log ('Fetched', items.length, 'ledger items')
19
+
20
+ const now = Date.now ()
21
+
22
+ for (let i = 0; i < items.length; i++) {
23
+ testLedgerItem (exchange, items[i], code, now)
24
+ if (i > 0) {
25
+ assert (items[i].timestamp >= items[i - 1].timestamp)
26
+ }
27
+ }
28
+
29
+ if (exchange.has.fetchLedgerItem) {
30
+ const { id } = items.pop ()
31
+ let item = await exchange.fetchLedgerItem (id)
32
+ if (Array.isArray (item)) {
33
+ item = item[0]
34
+ }
35
+ testLedgerItem (exchange, item, code, now)
36
+ }
37
+
38
+ } else {
39
+
40
+ console.log ('Fetching ledger items not supported')
41
+ }
42
+ }
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ const assert = require ('assert')
4
+ , testLeverageTier = require ('./test.leverageTier.js')
5
+
6
+
7
+ module.exports = async (exchange, symbol) => {
8
+ const method = 'fetchLeverageTiers';
9
+ // const format = {
10
+ // 'RAY/USDT': [
11
+ // {},
12
+ // ],
13
+ // };
14
+ if (exchange.has[method]) {
15
+ const tiers = await exchange [method] ([ symbol ]);
16
+ const tierKeys = Object.keys (tiers);
17
+ const numTierKeys = tierKeys.length;
18
+ assert (numTierKeys >= 1);
19
+ console.log (method + 'for ' + numTierKeys + ' markets');
20
+ for (let i = 0; i < numTierKeys; i++) {
21
+ const tiersForSymbol = tiers [ tierKeys[i] ];
22
+ const arrayLength = tiersForSymbol.length;
23
+ assert (arrayLength >= 1);
24
+ for (let j=0; j < tiersForSymbol.length; j++) {
25
+ const tier = tiersForSymbol[j];
26
+ testLeverageTier (exchange, method, tier);
27
+ }
28
+ }
29
+ return tiers;
30
+ } else {
31
+ console.log (method + ' not supported');
32
+ }
33
+ }
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ const assert = require ('assert')
4
+ , testLeverageTier = require ('./test.leverageTier.js')
5
+
6
+
7
+ module.exports = async (exchange, symbol) => {
8
+ const method = 'fetchMarketLeverageTiers';
9
+ if (exchange.has[method]) {
10
+ const tiers = await exchange [method] (symbol);
11
+ console.log (method + 'for ' + symbol);
12
+ const arrayLength = tiers.length;
13
+ assert (arrayLength >= 1);
14
+ for (let j=0; j < tiers.length; j++) {
15
+ const tier = tiers[j];
16
+ testLeverageTier (exchange, method, tier);
17
+ }
18
+ return tiers;
19
+ } else {
20
+ console.log (method + ' not supported');
21
+ }
22
+ }
@@ -0,0 +1,33 @@
1
+ 'use strict'
2
+
3
+ // ----------------------------------------------------------------------------
4
+
5
+ const testMarket = require ('./test.market.js')
6
+
7
+ // ----------------------------------------------------------------------------
8
+
9
+ module.exports = async (exchange) => {
10
+
11
+ const skippedExchanges = [
12
+ 'bitforex',
13
+ ]
14
+
15
+ if (skippedExchanges.includes (exchange.id)) {
16
+ console.log (exchange.id, 'found in ignored exchanges, skipping fetchMarkets...')
17
+ return
18
+ }
19
+
20
+ if (exchange.has.fetchMarkets) {
21
+
22
+ // log ('fetching markets...')
23
+
24
+ const method = 'fetchMarkets'
25
+ const markets = await exchange[method] ()
26
+ Object.values (markets).forEach ((market) => testMarket (exchange, market, method))
27
+ return markets
28
+
29
+ } else {
30
+
31
+ console.log ('fetching markets not supported')
32
+ }
33
+ }