ccxt 4.2.73 → 4.2.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +206 -10
- package/README.md +10 -9
- package/build.sh +1 -1
- package/dist/ccxt.browser.js +1042 -297
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +4 -1
- package/dist/cjs/src/abstract/tradeogre.js +9 -0
- package/dist/cjs/src/ascendex.js +3 -2
- package/dist/cjs/src/base/Exchange.js +1 -1
- package/dist/cjs/src/bitget.js +62 -50
- package/dist/cjs/src/bitmart.js +1 -0
- package/dist/cjs/src/bybit.js +90 -30
- package/dist/cjs/src/coinbaseinternational.js +1 -1
- package/dist/cjs/src/coinex.js +4 -3
- package/dist/cjs/src/gate.js +1 -0
- package/dist/cjs/src/htx.js +16 -9
- package/dist/cjs/src/hyperliquid.js +2 -1
- package/dist/cjs/src/kraken.js +3 -3
- package/dist/cjs/src/kucoin.js +1 -1
- package/dist/cjs/src/pro/krakenfutures.js +8 -7
- package/dist/cjs/src/tradeogre.js +632 -0
- package/examples/README.md +308 -0
- package/examples/ccxt.pro/html/watchTicker.html +51 -0
- package/examples/ccxt.pro/js/binance-fetch-balance-snapshot-watch-balance-updates.js +55 -0
- package/examples/ccxt.pro/js/binance-https-proxy.js +48 -0
- package/examples/ccxt.pro/js/binance-watch-ohlcv-many-symbols-continuously.js +38 -0
- package/examples/ccxt.pro/js/binance-watch-ohlcv-many-symbols.js +64 -0
- package/examples/ccxt.pro/js/binance-watch-ticker-many-symbols.js +62 -0
- package/examples/ccxt.pro/js/build-ohlcv-many-symbols.js +68 -0
- package/examples/ccxt.pro/js/calculate-ohlcvs-from-trades-warmup.js +82 -0
- package/examples/ccxt.pro/js/calculate-ohlcvs-from-trades.js +59 -0
- package/examples/ccxt.pro/js/exchange-capabitities.js +72 -0
- package/examples/ccxt.pro/js/exchange-close.js +46 -0
- package/examples/ccxt.pro/js/gateio-swap-watch-many-orderbooks.js +30 -0
- package/examples/ccxt.pro/js/gateio-watch-balance.js +23 -0
- package/examples/ccxt.pro/js/gateio-watch-order-book.js +71 -0
- package/examples/ccxt.pro/js/graceful-shutdown.js +43 -0
- package/examples/ccxt.pro/js/many-exchanges-many-streams.js +37 -0
- package/examples/ccxt.pro/js/okex-create-futures-order.js +48 -0
- package/examples/ccxt.pro/js/okex-watch-balance-and-create-order.js +54 -0
- package/examples/ccxt.pro/js/okx-watch-tickers.js +31 -0
- package/examples/ccxt.pro/js/one-exchange-many-different-streams.js +46 -0
- package/examples/ccxt.pro/js/one-exchange-many-streams-2.js +26 -0
- package/examples/ccxt.pro/js/one-exchange-many-streams.js +28 -0
- package/examples/ccxt.pro/js/socks-binance-watch-orderbook.js +30 -0
- package/examples/ccxt.pro/js/watch-fetch-many-exchanges-many-ordersbooks.js +40 -0
- package/examples/ccxt.pro/js/watch-many-exchanges-many-ordersbooks.js +38 -0
- package/examples/ccxt.pro/js/watch-many-exchanges-many-symbols.js +40 -0
- package/examples/ccxt.pro/js/watch-many-orderbooks.js +27 -0
- package/examples/ccxt.pro/js/watch-new-trades-only.js +43 -0
- package/examples/ccxt.pro/js/watch-new-trades.js +42 -0
- package/examples/ccxt.pro/js/watch-trades-many-symbols.js +29 -0
- package/examples/ccxt.pro/js/watch-vs-fetch.js +29 -0
- package/examples/cs/Examples.sln +22 -0
- package/examples/cs/c#.csproj +19 -0
- package/examples/html/basic-cors-proxy.html +46 -0
- package/examples/html/basic-inheritance.html +47 -0
- package/examples/html/basic-poller.html +52 -0
- package/examples/html/basic-rate-limiting.html +49 -0
- package/examples/html/basic.html +43 -0
- package/examples/html/binance-cors-proxy.html +28 -0
- package/examples/html/bitmex-browser-cors-proxy.js +7 -0
- package/examples/html/bitmex-cors.html +46 -0
- package/examples/html/tradingview-charts.html +61 -0
- package/examples/html/webworker/index.html +97 -0
- package/examples/html/webworker/worker.js +43 -0
- package/examples/js/README.md +15 -0
- package/examples/js/advanced-error-handling.js +39 -0
- package/examples/js/aggregate-orderbook.js +54 -0
- package/examples/js/arbitrage-pairs.js +130 -0
- package/examples/js/basic-chart.js +29 -0
- package/examples/js/basic-orderbook-polling.js +13 -0
- package/examples/js/bcc-vs-bch.js +115 -0
- package/examples/js/binance-fetch-all-deposits.js +45 -0
- package/examples/js/binance-fetch-ohlcv-many-symbols-async-await.js +34 -0
- package/examples/js/binance-fetch-ohlcv-many-symbols-promise-then-callbacks.js +33 -0
- package/examples/js/binance-fetchTicker-delivery-vs-future.js +31 -0
- package/examples/js/binance-futures-transfer-from-sub-account-to-master.js +41 -0
- package/examples/js/binance-margin-stop-order.js +39 -0
- package/examples/js/binance-server-time.js +34 -0
- package/examples/js/binance-universal-transfer.js +16 -0
- package/examples/js/bitfinex-fetch-trades.js +35 -0
- package/examples/js/bitfinex2-fetch-trades.js +35 -0
- package/examples/js/bitmex-browser-cors-proxy.js +7 -0
- package/examples/js/bitpanda-fetchMyTrades-reduce.js +36 -0
- package/examples/js/bitrue-fetch-balance.js +28 -0
- package/examples/js/bitstamp-private-api.js +115 -0
- package/examples/js/bitstamp-public-api.js +39 -0
- package/examples/js/bittrex-balance.js +50 -0
- package/examples/js/bittrex-fetch-closed-orders-history.js +69 -0
- package/examples/js/blockchaincom-withdrawal.js +59 -0
- package/examples/js/build-ohlcv-bars.js +48 -0
- package/examples/js/builtin-rate-limiting-rest-poller.js +25 -0
- package/examples/js/bybit-trailing.js +62 -0
- package/examples/js/bybit-updated.cjs +154 -0
- package/examples/js/cli.js +405 -0
- package/examples/js/coinbase-fetch-all-balances.js +36 -0
- package/examples/js/coinex-fetch-all-deposit-addresses-using-fetchDepositAddress.js +47 -0
- package/examples/js/coinex-futures.js +75 -0
- package/examples/js/coinone-fetch-tickers.js +54 -0
- package/examples/js/coinone-markets.js +16 -0
- package/examples/js/compare-two-exchanges-capabilities.js +36 -0
- package/examples/js/cors-proxy.js +5 -0
- package/examples/js/create-order-handle-errors.js +55 -0
- package/examples/js/create-order-position-with-takeprofit-stoploss.js +71 -0
- package/examples/js/create-order-with-retry.js +65 -0
- package/examples/js/create-order-ws-example.js +25 -0
- package/examples/js/create-orders-example.js +17 -0
- package/examples/js/create-trailing-amount-order.js +36 -0
- package/examples/js/create-trailing-percent-order.js +36 -0
- package/examples/js/credentials.json +5 -0
- package/examples/js/custom-proxy-agent-for-js.js +10 -0
- package/examples/js/custom-proxy-url.js +23 -0
- package/examples/js/delta-maintenance-margin-rate-max-leverage.js +60 -0
- package/examples/js/env-variables.js +26 -0
- package/examples/js/error-handling.js +89 -0
- package/examples/js/exchange-capabilities.js +135 -0
- package/examples/js/exchanges-by-volume.js +60 -0
- package/examples/js/exchanges.js +40 -0
- package/examples/js/fetch-all-balances.js +219 -0
- package/examples/js/fetch-all-tickers-to-files-2.js +53 -0
- package/examples/js/fetch-all-tickers-to-files.js +77 -0
- package/examples/js/fetch-balance.js +28 -0
- package/examples/js/fetch-create-deposit-address.js +101 -0
- package/examples/js/fetch-from-many-exchanges-simultaneously.js +21 -0
- package/examples/js/fetch-funding-rate-history.js +25 -0
- package/examples/js/fetch-futures/prettier.config.js +5 -0
- package/examples/js/fetch-futures/src/index.js +25 -0
- package/examples/js/fetch-ohlcv-from-to-mark-index-premium.js +72 -0
- package/examples/js/fetch-ohlcv-many-exchanges-continuosly.js +39 -0
- package/examples/js/fetch-ohlcv.js +16 -0
- package/examples/js/fetch-okex-futures.js +22 -0
- package/examples/js/fetch-orders.js +27 -0
- package/examples/js/fetch-ticker-from-multiple-exchanges.js +35 -0
- package/examples/js/fetch-ticker-where-available.js +75 -0
- package/examples/js/fetch-tickers/build/index.js +19 -0
- package/examples/js/fetch-tickers/prettier.config.js +5 -0
- package/examples/js/fetch-tickers/src/index.js +17 -0
- package/examples/js/gateio-create-batch-order.js +43 -0
- package/examples/js/gateio-futures.js +49 -0
- package/examples/js/gateio-open-close-contract.js +49 -0
- package/examples/js/gateio-swaps.js +74 -0
- package/examples/js/gdax-fetch-trades-pagination.js +29 -0
- package/examples/js/hitbtc2-withdraw.js +61 -0
- package/examples/js/how-to-import-one-exchange-esm.js +10 -0
- package/examples/js/huobi-futures.js +71 -0
- package/examples/js/huobi-open-close-contract.js +63 -0
- package/examples/js/huobi-swaps.js +70 -0
- package/examples/js/huobipro-market-buy-sell-fetch-trading-limits.js +98 -0
- package/examples/js/hybridCJSExample.cjs +19 -0
- package/examples/js/hybridESMExample.js +19 -0
- package/examples/js/idex-fetch-balance.js +13 -0
- package/examples/js/instantiate-all-at-once.js +46 -0
- package/examples/js/instantiate-all-from-json.js +31 -0
- package/examples/js/kraken-create-and-close-position.js +54 -0
- package/examples/js/kraken-fetch-order-trades.js +33 -0
- package/examples/js/kraken-margin-trading.js +89 -0
- package/examples/js/kucoin-rate-limit.js +38 -0
- package/examples/js/latoken-example.js +108 -0
- package/examples/js/live-orderbook.js +106 -0
- package/examples/js/live-ticker.js +80 -0
- package/examples/js/live-tickers.js +74 -0
- package/examples/js/load-all-contracts.js +41 -0
- package/examples/js/load-all-symbols-at-once.js +69 -0
- package/examples/js/load-all-tickers-at-once.js +91 -0
- package/examples/js/load-markets-to-files.js +57 -0
- package/examples/js/looping-over-all-symbols-of-specific-exchanges.js +61 -0
- package/examples/js/looping-over-specific-symbols-of-all-exchanges.js +91 -0
- package/examples/js/margin-loan-borrow-buy-sell-repay.js +70 -0
- package/examples/js/market-status-and-currency-status.js +29 -0
- package/examples/js/ohlcv-console-chart.js +29 -0
- package/examples/js/okex-fetch-closed-orders-archive.js +31 -0
- package/examples/js/okex-transfer.js +51 -0
- package/examples/js/okx-poll-fetch-my-trades.js +37 -0
- package/examples/js/okx-poll-rate-limit.js +48 -0
- package/examples/js/order-book-extra-level-depth-param.js +20 -0
- package/examples/js/phemex-create-order-position-with-takeprofit-stoploss.js +49 -0
- package/examples/js/poll-ohlcv.js +43 -0
- package/examples/js/poloniex-fetch-order-books.js +35 -0
- package/examples/js/poloniex-limits-amount-min.js +62 -0
- package/examples/js/proxy-round-robin.js +98 -0
- package/examples/js/proxy-usage.js +32 -0
- package/examples/js/sample-local-proxy-server-with-cors.js +12 -0
- package/examples/js/search-all-exchanges.js +159 -0
- package/examples/js/shared-load-markets.js +80 -0
- package/examples/js/sort-swap-markets-by-hourly-price-change.js +55 -0
- package/examples/js/symbols.js +110 -0
- package/examples/js/theocean.js +41 -0
- package/examples/js/tickers.js +106 -0
- package/examples/js/validate-paginated-data.js +61 -0
- package/examples/js/watch-OHLCV-For-Symbols.js +15 -0
- package/examples/js/watch-OHLCV.js +12 -0
- package/examples/js/watch-OrderBook-For-Symbols.js +11 -0
- package/examples/js/watch-Trades-For-Symbols.js +11 -0
- package/examples/js/watch-tickers.js +11 -0
- package/examples/js/watchOHLCVForSymbols.js +15 -0
- package/examples/js/watchOrderBookForSymbols.js +11 -0
- package/examples/js/watchPositions-many-exchanges-continuosly.d.ts +2 -0
- package/examples/js/watchPositions-many-exchanges-continuosly.d.ts.map +1 -0
- package/examples/js/watchPositions-many-exchanges-continuosly.js +49 -0
- package/examples/js/watchPositions.d.ts +2 -0
- package/examples/js/watchPositions.d.ts.map +1 -0
- package/examples/js/watchPositions.js +13 -0
- package/examples/js/watchPositionsForSymbols.d.ts +2 -0
- package/examples/js/watchPositionsForSymbols.d.ts.map +1 -0
- package/examples/js/watchPositionsForSymbols.js +14 -0
- package/examples/js/watchTradesForSymbols.js +11 -0
- package/examples/js/withdraw-from-one-exchange-to-another.js +50 -0
- package/examples/php/README.md +7 -0
- package/examples/py/README.md +15 -0
- package/examples/py/playing_with_ccxt_example.ipynb +222 -0
- package/examples/ts/.eslintrc +111 -0
- package/examples/ts/build-ohlcv-bars.ts +53 -0
- package/examples/ts/cli.ts +397 -0
- package/examples/ts/compare-two-exchanges-capabilities.ts +36 -0
- package/examples/ts/create-order-position-with-takeprofit-stoploss.ts +89 -0
- package/examples/ts/create-order-ws-example.ts +33 -0
- package/examples/ts/create-orders-example.ts +21 -0
- package/examples/ts/create-trailing-amount-order.ts +37 -0
- package/examples/ts/create-trailing-percent-order.ts +37 -0
- package/examples/ts/custom-proxy-agent-for-js.ts +14 -0
- package/examples/ts/fetch-futures/package-lock.json +116 -0
- package/examples/ts/fetch-futures/package.json +34 -0
- package/examples/ts/fetch-futures/prettier.config.js +4 -0
- package/examples/ts/fetch-futures/src/index.ts +28 -0
- package/examples/ts/fetch-futures/tsconfig.json +28 -0
- package/examples/ts/fetch-ohlcv-many-exchanges-continuosly.ts +44 -0
- package/examples/ts/fetch-ohlcv.ts +17 -0
- package/examples/ts/fetch-tickers/package-lock.json +116 -0
- package/examples/ts/fetch-tickers/package.json +34 -0
- package/examples/ts/fetch-tickers/prettier.config.js +4 -0
- package/examples/ts/fetch-tickers/src/index.ts +21 -0
- package/examples/ts/fetch-tickers/tsconfig.json +28 -0
- package/examples/ts/how-to-import-one-exchange-esm.ts +11 -0
- package/examples/ts/kraken-create-and-close-position.ts +69 -0
- package/examples/ts/margin-loan-borrow-buy-sell-repay.ts +72 -0
- package/examples/ts/nextjs-page-router/.eslintrc.json +3 -0
- package/examples/ts/nextjs-page-router/README.md +43 -0
- package/examples/ts/nextjs-page-router/next.config.js +6 -0
- package/examples/ts/nextjs-page-router/package-lock.json +7425 -0
- package/examples/ts/nextjs-page-router/package.json +28 -0
- package/examples/ts/nextjs-page-router/postcss.config.js +6 -0
- package/examples/ts/nextjs-page-router/public/favicon.ico +0 -0
- package/examples/ts/nextjs-page-router/src/pages/_app.tsx +6 -0
- package/examples/ts/nextjs-page-router/src/pages/_document.tsx +13 -0
- package/examples/ts/nextjs-page-router/src/pages/balance.tsx +46 -0
- package/examples/ts/nextjs-page-router/src/pages/index.tsx +8 -0
- package/examples/ts/nextjs-page-router/src/pages/tickers.tsx +61 -0
- package/examples/ts/nextjs-page-router/src/styles/globals.css +27 -0
- package/examples/ts/nextjs-page-router/tailwind.config.ts +20 -0
- package/examples/ts/nextjs-page-router/tsconfig.json +22 -0
- package/examples/ts/phemex-create-order-position-with-takeprofit-stoploss.ts +62 -0
- package/examples/ts/proxy-usage.ts +41 -0
- package/examples/ts/sample-local-proxy-server-with-cors.ts +15 -0
- package/examples/ts/watch-OHLCV-For-Symbols.ts +17 -0
- package/examples/ts/watch-OHLCV.ts +14 -0
- package/examples/ts/watch-OrderBook-For-Symbols.ts +13 -0
- package/examples/ts/watch-Trades-For-Symbols.ts +13 -0
- package/examples/ts/watch-tickers.ts +13 -0
- package/examples/ts/watchPositions-many-exchanges-continuosly.ts +53 -0
- package/examples/ts/watchPositions.ts +15 -0
- package/examples/ts/watchPositionsForSymbols.ts +16 -0
- package/examples/tsconfig.json +27 -0
- package/js/ccxt.d.ts +5 -2
- package/js/ccxt.js +4 -2
- package/js/src/abstract/tradeogre.d.ts +19 -0
- package/js/src/abstract/tradeogre.js +11 -0
- package/js/src/ascendex.d.ts +2 -7
- package/js/src/ascendex.js +3 -2
- package/js/src/base/Exchange.d.ts +7 -7
- package/js/src/base/Exchange.js +1 -1
- package/js/src/base/types.d.ts +7 -1
- package/js/src/binance.d.ts +1 -1
- package/js/src/bitget.js +62 -50
- package/js/src/bitmart.d.ts +1 -1
- package/js/src/bitmart.js +2 -1
- package/js/src/bybit.d.ts +3 -1
- package/js/src/bybit.js +90 -30
- package/js/src/coinbase.d.ts +4 -4
- package/js/src/coinbaseinternational.d.ts +1 -1
- package/js/src/coinbaseinternational.js +1 -1
- package/js/src/coinbasepro.d.ts +2 -2
- package/js/src/coinex.js +4 -3
- package/js/src/coinlist.d.ts +2 -2
- package/js/src/cryptocom.d.ts +2 -2
- package/js/src/currencycom.d.ts +2 -2
- package/js/src/deribit.d.ts +2 -2
- package/js/src/gate.d.ts +1 -1
- package/js/src/gate.js +1 -0
- package/js/src/htx.d.ts +2 -2
- package/js/src/htx.js +16 -9
- package/js/src/huobijp.d.ts +2 -2
- package/js/src/hyperliquid.js +2 -1
- package/js/src/kraken.d.ts +1 -1
- package/js/src/kraken.js +3 -3
- package/js/src/kucoin.d.ts +3 -3
- package/js/src/kucoin.js +1 -1
- package/js/src/luno.d.ts +2 -2
- package/js/src/mexc.d.ts +3 -3
- package/js/src/ndax.d.ts +2 -2
- package/js/src/novadax.d.ts +2 -2
- package/js/src/okx.d.ts +2 -2
- package/js/src/pro/bitfinex2.d.ts +1 -1
- package/js/src/pro/krakenfutures.js +8 -7
- package/js/src/tradeogre.d.ts +32 -0
- package/js/src/tradeogre.js +633 -0
- package/js/src/woo.d.ts +2 -2
- package/package.json +4 -1
- package/skip-tests.json +219 -424
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
{
|
|
2
|
+
"env": {
|
|
3
|
+
"es2021": true,
|
|
4
|
+
"node": true
|
|
5
|
+
},
|
|
6
|
+
"parserOptions": {
|
|
7
|
+
"ecmaVersion": 2020,
|
|
8
|
+
"sourceType": "module"
|
|
9
|
+
},
|
|
10
|
+
"parser": "@typescript-eslint/parser",
|
|
11
|
+
"plugins": ["@typescript-eslint"],
|
|
12
|
+
"extends": ["eslint:recommended", "airbnb-base", "plugin:import/typescript"],
|
|
13
|
+
"ignorePatterns": ["*/*", "cli.ts"],
|
|
14
|
+
"rules": {
|
|
15
|
+
"no-console": "off",
|
|
16
|
+
"import/no-unresolved":"off", // tmp until typescript decides to properly resolve names
|
|
17
|
+
"import/named": "off",
|
|
18
|
+
"strict": "off",
|
|
19
|
+
"semi": "error",
|
|
20
|
+
"indent": ["error", 4],
|
|
21
|
+
"init-declarations": "error",
|
|
22
|
+
"no-undef-init": "off",
|
|
23
|
+
"comma-dangle": ["error", {
|
|
24
|
+
"arrays": "always-multiline",
|
|
25
|
+
"objects": "always-multiline",
|
|
26
|
+
"imports": "always-multiline",
|
|
27
|
+
"exports": "always-multiline",
|
|
28
|
+
"functions": "never"
|
|
29
|
+
}],
|
|
30
|
+
"import/extensions": "off",
|
|
31
|
+
"brace-style": ["error", "1tbs"],
|
|
32
|
+
"multiline-comment-style": ["error", "separate-lines"],
|
|
33
|
+
"dot-notation": "off",
|
|
34
|
+
"quote-props": ["error", "always"],
|
|
35
|
+
"no-multi-spaces": ["error", { "ignoreEOLComments": true }],
|
|
36
|
+
"no-whitespace-before-property": "error",
|
|
37
|
+
"space-before-blocks": ["error", "always"],
|
|
38
|
+
"space-before-function-paren": ["error", "always"],
|
|
39
|
+
"no-spaced-func": "off",
|
|
40
|
+
"func-call-spacing": ["error", "always"],
|
|
41
|
+
"block-spacing": ["error", "always"],
|
|
42
|
+
"keyword-spacing": ["error", { "before": true, "after": true }],
|
|
43
|
+
"object-curly-spacing": ["error", "always", { "objectsInObjects": false }],
|
|
44
|
+
"object-curly-newline": ["error", { "consistent": true }],
|
|
45
|
+
"space-infix-ops": "error",
|
|
46
|
+
"space-unary-ops": "error",
|
|
47
|
+
"space-in-parens": "error",
|
|
48
|
+
"no-nested-ternary": "error",
|
|
49
|
+
"eqeqeq": "error",
|
|
50
|
+
"quotes": ["error", "single", { "avoidEscape": true }],
|
|
51
|
+
"no-unused-vars": ["warn", { "argsIgnorePattern": "^(headers|body|account|info|symbol|price|tag|side|since|limit|params|market|timeframe|api|path|code|currency|statusCode|statusText|url|method|response|requestHeaders|requestBody|bidsKey|asksKey|context|config|type|priceKey|amountKey|networkCode|marginMode|subscription|message|client)" }],
|
|
52
|
+
"new-parens": "error",
|
|
53
|
+
"new-cap": "off",
|
|
54
|
+
"no-var": "error",
|
|
55
|
+
"prefer-const": ["error", {
|
|
56
|
+
"destructuring": "any",
|
|
57
|
+
"ignoreReadBeforeAssign": false
|
|
58
|
+
}],
|
|
59
|
+
"no-warning-comments": ["warn", { "terms": ["fixme"] }],
|
|
60
|
+
"padded-blocks": ["error", "never"],
|
|
61
|
+
"lines-between-class-members": "error",
|
|
62
|
+
"no-multiple-empty-lines": ["error", { "max": 2 }],
|
|
63
|
+
"padding-line-between-statements": ["warn",
|
|
64
|
+
// { "blankLine": "never", "prev":"*", "next": "*" }, // comment this to allow blank-lines
|
|
65
|
+
{ "blankLine": "always", "prev":"directive", "next": "*" },
|
|
66
|
+
{ "blankLine": "always", "prev":"*", "next": "cjs-export" },
|
|
67
|
+
{ "blankLine": "always", "prev":"*", "next": "export" },
|
|
68
|
+
{ "blankLine": "always", "prev":"*", "next": "function" }
|
|
69
|
+
],
|
|
70
|
+
"prefer-template": "off",
|
|
71
|
+
"curly": "error",
|
|
72
|
+
"no-plusplus": "off",
|
|
73
|
+
"no-restricted-properties": "off",
|
|
74
|
+
"prefer-destructuring": "off",
|
|
75
|
+
"class-methods-use-this": "off",
|
|
76
|
+
"no-param-reassign": "off",
|
|
77
|
+
"max-len": "off",
|
|
78
|
+
"no-return-await": "off",
|
|
79
|
+
"array-bracket-spacing": ["error", "always"],
|
|
80
|
+
"radix": "off",
|
|
81
|
+
"camelcase": "off",
|
|
82
|
+
"no-lonely-if": "off",
|
|
83
|
+
"no-mixed-operators": "off",
|
|
84
|
+
"no-shadow": "off",
|
|
85
|
+
"no-useless-concat": "off",
|
|
86
|
+
"no-continue": "off",
|
|
87
|
+
"no-else-return": "off",
|
|
88
|
+
"no-unneeded-ternary": "off",
|
|
89
|
+
"operator-assignment": "off",
|
|
90
|
+
"no-underscore-dangle": "off",
|
|
91
|
+
"consistent-return": "off",
|
|
92
|
+
"no-await-in-loop": "off",
|
|
93
|
+
"prefer-exponentiation-operator": "off",
|
|
94
|
+
"no-use-before-define": ["error", {
|
|
95
|
+
"functions": false,
|
|
96
|
+
"classes": true,
|
|
97
|
+
"variables": true,
|
|
98
|
+
"allowNamedExports": false
|
|
99
|
+
}]
|
|
100
|
+
},
|
|
101
|
+
"settings": {
|
|
102
|
+
"import/resolver": {
|
|
103
|
+
"node": {
|
|
104
|
+
"extensions": [".js", ".ts"]
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"import/parsers": {
|
|
108
|
+
"@typescript-eslint/parser": [".ts", ".js"]
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import ccxt from '../../js/ccxt.js';
|
|
2
|
+
|
|
3
|
+
// AUTO-TRANSPILE //
|
|
4
|
+
|
|
5
|
+
// Bulding OHLCV array from trades (executions) data is a bit tricky. For example, if you want to build 100 ohlcv bars of 1-minute timeframe, then you have to fetch the 100 minutes of trading data. So, higher timeframe bars require more trading data (i.e. building 100 bars of 1-day timeframe OHLCV would require massive amount of trading data, which might not be desirable for user, because of data-usage rate limits)
|
|
6
|
+
|
|
7
|
+
async function example_with_fetch_trades () {
|
|
8
|
+
const exch = new ccxt.binance ({});
|
|
9
|
+
const timeframe = '1m';
|
|
10
|
+
const symbol = 'OGN/USDT';
|
|
11
|
+
const since = exch.milliseconds () - 1000 * 60 * 30; // last 30 mins
|
|
12
|
+
const limit = 1000;
|
|
13
|
+
const trades = await exch.fetchTrades (symbol, since, limit);
|
|
14
|
+
const generatedBars = exch.buildOHLCVC (trades, timeframe, since, limit);
|
|
15
|
+
// you can ignore 6th index ("count" field) from ohlcv entries, which is not part of OHLCV standard structure and is just added internally by `buildOHLCVC` method
|
|
16
|
+
console.log ('[REST] Constructed', generatedBars.length, 'bars from trades: ', generatedBars);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function example_with_watch_trades () {
|
|
20
|
+
const exch = new ccxt.pro.binance ({});
|
|
21
|
+
const timeframe = '1m';
|
|
22
|
+
const symbol = 'DOGE/USDT';
|
|
23
|
+
const limit = 1000;
|
|
24
|
+
const since = exch.milliseconds () - 10 * 60 * 1000 * 1000; // last 10 hrs
|
|
25
|
+
let collectedTrades = [];
|
|
26
|
+
const collectedBars = [];
|
|
27
|
+
while (true) {
|
|
28
|
+
const wsTrades = await exch.watchTrades (symbol, since, limit, {});
|
|
29
|
+
collectedTrades = collectedTrades.concat (wsTrades);
|
|
30
|
+
const generatedBars = exch.buildOHLCVC (collectedTrades, timeframe, since, limit);
|
|
31
|
+
// Note: first bar would be partially constructed bar and its 'open' & 'high' & 'low' prices (except 'close' price) would probably have different values compared to real bar on chart, because the first obtained trade timestamp might be somewhere in the middle of timeframe period, so the pre-period would be missing because we would not have trades data. To fix that, you can get older data with `fetchTrades` to fill up bars till start bar.
|
|
32
|
+
for (let i = 0; i < generatedBars.length; i++) {
|
|
33
|
+
const bar = generatedBars[i];
|
|
34
|
+
const barTimestamp = bar[0];
|
|
35
|
+
const collectedBarsLength = collectedBars.length;
|
|
36
|
+
const lastCollectedBarTimestamp = collectedBarsLength > 0 ? collectedBars[collectedBarsLength - 1][0] : 0;
|
|
37
|
+
if (barTimestamp === lastCollectedBarTimestamp) {
|
|
38
|
+
// if timestamps are same, just updarte the last bar
|
|
39
|
+
collectedBars[collectedBarsLength - 1] = bar;
|
|
40
|
+
} else if (barTimestamp > lastCollectedBarTimestamp) {
|
|
41
|
+
collectedBars.push (bar);
|
|
42
|
+
// remove the trades from saved array, which were till last collected bar's open timestamp
|
|
43
|
+
collectedTrades = exch.filterBySinceLimit (collectedTrades, barTimestamp);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Note: first bar would carry incomplete values, please read comment in "buildOHLCVCFromWatchTrades" method definition for further explanation
|
|
47
|
+
console.log ('[WS] Constructed', collectedBars.length, 'bars from', symbol, 'trades: ', collectedBars);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
await example_with_fetch_trades ();
|
|
53
|
+
await example_with_watch_trades ();
|
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import ansi from 'ansicolor'
|
|
4
|
+
import asTable from 'as-table'
|
|
5
|
+
import ololog from 'ololog'
|
|
6
|
+
import util from 'util'
|
|
7
|
+
import { execSync } from 'child_process'
|
|
8
|
+
import ccxt from '../../ts/ccxt.js'
|
|
9
|
+
import { Agent } from 'https'
|
|
10
|
+
|
|
11
|
+
const fsPromises = fs.promises;
|
|
12
|
+
ansi.nice
|
|
13
|
+
const log = ololog.configure ({ locate: false }).unlimited
|
|
14
|
+
const { ExchangeError , NetworkError} = ccxt
|
|
15
|
+
//-----------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
let [processPath, , exchangeId, methodName, ... params] = process.argv.filter (x => !x.startsWith ('--'))
|
|
18
|
+
, verbose = process.argv.includes ('--verbose')
|
|
19
|
+
, debug = process.argv.includes ('--debug')
|
|
20
|
+
, poll = process.argv.includes ('--poll')
|
|
21
|
+
, no_send = process.argv.includes ('--no-send')
|
|
22
|
+
, no_load_markets = process.argv.includes ('--no-load-markets')
|
|
23
|
+
, details = process.argv.includes ('--details')
|
|
24
|
+
, no_table = process.argv.includes ('--no-table')
|
|
25
|
+
, table = process.argv.includes ('--table')
|
|
26
|
+
, iso8601 = process.argv.includes ('--iso8601')
|
|
27
|
+
, cors = process.argv.includes ('--cors')
|
|
28
|
+
, cache_markets = process.argv.includes ('--cache-markets')
|
|
29
|
+
, testnet =
|
|
30
|
+
process.argv.includes ('--test') ||
|
|
31
|
+
process.argv.includes ('--testnet') ||
|
|
32
|
+
process.argv.includes ('--sandbox')
|
|
33
|
+
, signIn = process.argv.includes ('--sign-in') || process.argv.includes ('--signIn')
|
|
34
|
+
, isSpot = process.argv.includes ('--spot')
|
|
35
|
+
, isSwap = process.argv.includes ('--swap')
|
|
36
|
+
, isFuture = process.argv.includes ('--future')
|
|
37
|
+
, isOption = process.argv.includes ('--option')
|
|
38
|
+
, shouldCreateRequestReport = process.argv.includes ('--report')
|
|
39
|
+
, shouldCreateResponseReport = process.argv.includes ('--response')
|
|
40
|
+
, shouldCreateBoth = process.argv.includes ('--static')
|
|
41
|
+
|
|
42
|
+
//-----------------------------------------------------------------------------
|
|
43
|
+
|
|
44
|
+
log ((new Date ()).toISOString())
|
|
45
|
+
log ('Node.js:', process.version)
|
|
46
|
+
log ('CCXT v' + ccxt.version)
|
|
47
|
+
|
|
48
|
+
//-----------------------------------------------------------------------------
|
|
49
|
+
|
|
50
|
+
process.on ('uncaughtException', e => { log.bright.red.error (e); log.red.error (e.message); process.exit (1) })
|
|
51
|
+
process.on ('unhandledRejection', e => { log.bright.red.error (e); log.red.error ((e as any).message); process.exit (1) })
|
|
52
|
+
|
|
53
|
+
//-----------------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
// set up keys and settings, if any
|
|
56
|
+
const keysGlobal = path.resolve ('keys.json')
|
|
57
|
+
const keysLocal = path.resolve ('keys.local.json')
|
|
58
|
+
|
|
59
|
+
const keysFile = fs.existsSync (keysLocal) ? keysLocal : keysGlobal
|
|
60
|
+
const settingsFile = fs.readFileSync(keysFile);
|
|
61
|
+
// eslint-disable-next-line import/no-dynamic-require, no-path-concat
|
|
62
|
+
let settings = JSON.parse(settingsFile.toString())
|
|
63
|
+
settings = settings[exchangeId] || {}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
//-----------------------------------------------------------------------------
|
|
67
|
+
|
|
68
|
+
const timeout = 30000
|
|
69
|
+
let exchange = undefined as any
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
const httpsAgent = new Agent ({
|
|
74
|
+
ecdhCurve: 'auto',
|
|
75
|
+
keepAlive: true,
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
// check here if we have a arg like this: binance.fetchOrders()
|
|
80
|
+
const callRegex = /\s*(\w+)\s*\.\s*(\w+)\s*\(([^()]*)\)/
|
|
81
|
+
if (callRegex.test (exchangeId)) {
|
|
82
|
+
const res = callRegex.exec (exchangeId) as any;
|
|
83
|
+
exchangeId = res[1];
|
|
84
|
+
methodName = res[2];
|
|
85
|
+
params = res[3].split(",").map(x => x.trim());
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
if ((ccxt.pro as any).exchanges.includes(exchangeId)) {
|
|
90
|
+
exchange = new (ccxt.pro)[exchangeId] ({ timeout, httpsAgent, ... settings })
|
|
91
|
+
} else {
|
|
92
|
+
exchange = new (ccxt)[exchangeId] ({ timeout, httpsAgent, ... settings })
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (exchange === undefined) {
|
|
96
|
+
process.exit ()
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (isSpot) {
|
|
100
|
+
exchange.options['defaultType'] = 'spot';
|
|
101
|
+
} else if (isSwap) {
|
|
102
|
+
exchange.options['defaultType'] = 'swap';
|
|
103
|
+
} else if (isFuture) {
|
|
104
|
+
exchange.options['defaultType'] = 'future';
|
|
105
|
+
} else if (isOption) {
|
|
106
|
+
exchange.options['defaultType'] = 'option';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// check auth keys in env var
|
|
110
|
+
const requiredCredentials = exchange.requiredCredentials;
|
|
111
|
+
for (const [credential, isRequired] of Object.entries (requiredCredentials)) {
|
|
112
|
+
if (isRequired && exchange[credential] === undefined) {
|
|
113
|
+
const credentialEnvName = (exchangeId + '_' + credential).toUpperCase () // example: KRAKEN_APIKEY
|
|
114
|
+
const credentialValue = process.env[credentialEnvName]
|
|
115
|
+
if (credentialValue) {
|
|
116
|
+
exchange[credential] = credentialValue
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (testnet) {
|
|
122
|
+
exchange.setSandboxMode (true)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
} catch (e) {
|
|
126
|
+
|
|
127
|
+
log.red (e)
|
|
128
|
+
printUsage ()
|
|
129
|
+
process.exit ()
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
//-----------------------------------------------------------------------------
|
|
133
|
+
|
|
134
|
+
function createRequestTemplate(exchange, methodName, args, result) {
|
|
135
|
+
const final = {
|
|
136
|
+
'description': 'Fill this with a description of the method call',
|
|
137
|
+
'method': methodName,
|
|
138
|
+
'url': exchange.last_request_url ?? '',
|
|
139
|
+
'input': args,
|
|
140
|
+
'output': exchange.last_request_body ?? undefined
|
|
141
|
+
}
|
|
142
|
+
log('Report: (paste inside static/request/' + exchange.id + '.json ->' + methodName + ')')
|
|
143
|
+
log.green('-------------------------------------------')
|
|
144
|
+
log (JSON.stringify (final, null, 2))
|
|
145
|
+
log.green('-------------------------------------------')
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
//-----------------------------------------------------------------------------
|
|
149
|
+
|
|
150
|
+
function createResponseTemplate(exchange, methodName, args, result) {
|
|
151
|
+
const final = {
|
|
152
|
+
'description': 'Fill this with a description of the method call',
|
|
153
|
+
'method': methodName,
|
|
154
|
+
'input': args,
|
|
155
|
+
'httpResponse': exchange.last_json_response ?? exchange.last_http_response,
|
|
156
|
+
'parsedResponse': result
|
|
157
|
+
}
|
|
158
|
+
log('Report: (paste inside static/response/' + exchange.id + '.json ->' + methodName + ')')
|
|
159
|
+
log.green('-------------------------------------------')
|
|
160
|
+
log (JSON.stringify (final, function(k, v) { return v === undefined ? null : v; }, 2))
|
|
161
|
+
log.green('-------------------------------------------')
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
//-----------------------------------------------------------------------------
|
|
165
|
+
|
|
166
|
+
function printSupportedExchanges () {
|
|
167
|
+
log ('Supported exchanges:', (ccxt.exchanges.join (', ') as any).green)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
//-----------------------------------------------------------------------------
|
|
171
|
+
|
|
172
|
+
function printUsage () {
|
|
173
|
+
log ('This is an example of a basic command-line interface to all exchanges')
|
|
174
|
+
log ('Usage: node', process.argv[1], ('id' as any).green, ('method' as any).yellow, ('"param1" param2 "param3" param4 ...' as any).blue)
|
|
175
|
+
log ('Examples:')
|
|
176
|
+
log ('node', process.argv[1], 'okcoin fetchOHLCV BTC/USD 15m')
|
|
177
|
+
log ('node', process.argv[1], 'bitfinex fetchBalance')
|
|
178
|
+
log ('node', process.argv[1], 'kraken fetchOrderBook ETH/BTC')
|
|
179
|
+
printSupportedExchanges ()
|
|
180
|
+
log ('Supported options:')
|
|
181
|
+
log ('--verbose Print verbose output')
|
|
182
|
+
log ('--debug Print debugging output')
|
|
183
|
+
log ('--poll Repeat continuously in rate-limited mode')
|
|
184
|
+
log ('--no-send Print the request but do not actually send it to the exchange (sets verbose and load-markets)')
|
|
185
|
+
log ('--no-load-markets Do not pre-load markets (for debugging)')
|
|
186
|
+
log ('--details Print detailed fetch responses')
|
|
187
|
+
log ('--no-table Do not print the fetch response as a table')
|
|
188
|
+
log ('--table Print the fetch response as a table')
|
|
189
|
+
log ('--iso8601 Print timestamps as ISO8601 datetimes')
|
|
190
|
+
log ('--cors use CORS proxy for debugging')
|
|
191
|
+
log ('--sign-in Call signIn() if any')
|
|
192
|
+
log ('--sandbox Use the exchange sandbox if available, same as --testnet')
|
|
193
|
+
log ('--testnet Use the exchange testnet if available, same as --sandbox')
|
|
194
|
+
log ('--test Use the exchange testnet if available, same as --sandbox')
|
|
195
|
+
log ('--cache-markets Cache the loaded markets in the .cache folder in the current directory')
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
//-----------------------------------------------------------------------------
|
|
199
|
+
|
|
200
|
+
const printHumanReadable = (exchange, result) => {
|
|
201
|
+
if (!no_table && Array.isArray (result) || table) {
|
|
202
|
+
result = Object.values (result)
|
|
203
|
+
let arrayOfObjects = (typeof result[0] === 'object')
|
|
204
|
+
|
|
205
|
+
if (details)
|
|
206
|
+
result.forEach (object => {
|
|
207
|
+
if (arrayOfObjects)
|
|
208
|
+
log ('-------------------------------------------')
|
|
209
|
+
log (object)
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
if (arrayOfObjects || table && Array.isArray (result)) {
|
|
213
|
+
const configuredAsTable = (asTable as any).configure ({
|
|
214
|
+
delimiter: (' | ' as any).lightGray.dim,
|
|
215
|
+
right: true,
|
|
216
|
+
title: x => (String (x) as any).lightGray,
|
|
217
|
+
dash: ('-' as any).lightGray.dim,
|
|
218
|
+
print: x => {
|
|
219
|
+
if (typeof x === 'object') {
|
|
220
|
+
const j = JSON.stringify (x).trim ()
|
|
221
|
+
if (j.length < 100) return j
|
|
222
|
+
}
|
|
223
|
+
return String (x)
|
|
224
|
+
}
|
|
225
|
+
})
|
|
226
|
+
log (result.length > 0 ? configuredAsTable (result.map (element => {
|
|
227
|
+
let keys = Object.keys (element)
|
|
228
|
+
delete element['info']
|
|
229
|
+
keys.forEach (key => {
|
|
230
|
+
if (!iso8601)
|
|
231
|
+
return element[key]
|
|
232
|
+
try {
|
|
233
|
+
const iso8601 = exchange.iso8601 (element[key])
|
|
234
|
+
if (iso8601.match (/^20[0-9]{2}[-]?/))
|
|
235
|
+
element[key] = iso8601
|
|
236
|
+
else
|
|
237
|
+
throw new Error ('wrong date')
|
|
238
|
+
} catch (e) {
|
|
239
|
+
return element[key]
|
|
240
|
+
}
|
|
241
|
+
})
|
|
242
|
+
return element
|
|
243
|
+
})) : result)
|
|
244
|
+
log (result.length, 'objects');
|
|
245
|
+
} else {
|
|
246
|
+
console.dir (result, { depth: null })
|
|
247
|
+
log (result.length, 'objects');
|
|
248
|
+
}
|
|
249
|
+
} else {
|
|
250
|
+
console.dir (result, { depth: null, maxArrayLength: null })
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
//-----------------------------------------------------------------------------
|
|
255
|
+
|
|
256
|
+
async function run () {
|
|
257
|
+
|
|
258
|
+
if (!exchangeId) {
|
|
259
|
+
|
|
260
|
+
printUsage ()
|
|
261
|
+
|
|
262
|
+
} else {
|
|
263
|
+
|
|
264
|
+
let args = params
|
|
265
|
+
.map (s => s.match (/^[0-9]{4}[-][0-9]{2}[-][0-9]{2}[T\s]?[0-9]{2}[:][0-9]{2}[:][0-9]{2}/g) ? exchange.parse8601 (s) : s)
|
|
266
|
+
.map (s => (() => {
|
|
267
|
+
if (s.match ( /^\d+$/g)) return s < Number.MAX_SAFE_INTEGER ? Number (s) : s
|
|
268
|
+
try {return eval ('(() => (' + s + ')) ()') } catch (e) { return s }
|
|
269
|
+
}) ())
|
|
270
|
+
|
|
271
|
+
const www = Array.isArray (exchange.urls.www) ? exchange.urls.www[0] : exchange.urls.www
|
|
272
|
+
|
|
273
|
+
if (cors) {
|
|
274
|
+
exchange.proxy = 'https://cors-anywhere.herokuapp.com/';
|
|
275
|
+
exchange.origin = exchange.uuid ()
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
no_load_markets = no_send ? true : no_load_markets
|
|
279
|
+
|
|
280
|
+
if (debug) {
|
|
281
|
+
exchange.verbose = verbose
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const path = '.cache/' + exchangeId + '-markets.json'
|
|
285
|
+
|
|
286
|
+
if (!no_load_markets) {
|
|
287
|
+
try {
|
|
288
|
+
await fsPromises.access (path, fs.constants.R_OK)
|
|
289
|
+
exchange.markets = JSON.parse ((await fsPromises.readFile (path)).toString())
|
|
290
|
+
} catch {
|
|
291
|
+
await exchange.loadMarkets ()
|
|
292
|
+
if (cache_markets) {
|
|
293
|
+
await fsPromises.writeFile (path, JSON.stringify (exchange.markets))
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (signIn && exchange.has.signIn) {
|
|
299
|
+
await exchange.signIn ()
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
exchange.verbose = verbose
|
|
303
|
+
|
|
304
|
+
if (no_send) {
|
|
305
|
+
|
|
306
|
+
exchange.verbose = no_send
|
|
307
|
+
exchange.fetch = function fetch (url, method = 'GET', headers = undefined, body = undefined) {
|
|
308
|
+
log.dim.noLocate ('-------------------------------------------')
|
|
309
|
+
log.dim.noLocate (exchange.iso8601 (exchange.milliseconds ()))
|
|
310
|
+
log.green.unlimited ({
|
|
311
|
+
url,
|
|
312
|
+
method,
|
|
313
|
+
headers,
|
|
314
|
+
body,
|
|
315
|
+
})
|
|
316
|
+
process.exit ()
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (methodName) {
|
|
321
|
+
|
|
322
|
+
if (typeof exchange[methodName] === 'function') {
|
|
323
|
+
|
|
324
|
+
log (exchange.id + '.' + methodName, '(' + args.join (', ') + ')')
|
|
325
|
+
|
|
326
|
+
let start = exchange.milliseconds ()
|
|
327
|
+
let end = exchange.milliseconds ()
|
|
328
|
+
|
|
329
|
+
let i = 0;
|
|
330
|
+
|
|
331
|
+
let isWsMethod = false
|
|
332
|
+
if (methodName.startsWith("watch")) { // handle WS methods
|
|
333
|
+
isWsMethod = true;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
while (true) {
|
|
337
|
+
try {
|
|
338
|
+
const result = await exchange[methodName] (... args)
|
|
339
|
+
end = exchange.milliseconds ()
|
|
340
|
+
if (!isWsMethod) {
|
|
341
|
+
log (exchange.iso8601 (end), 'iteration', i++, 'passed in', end - start, 'ms\n')
|
|
342
|
+
}
|
|
343
|
+
printHumanReadable (exchange, result)
|
|
344
|
+
if (!isWsMethod) {
|
|
345
|
+
log (exchange.iso8601 (end), 'iteration', i, 'passed in', end - start, 'ms\n')
|
|
346
|
+
}
|
|
347
|
+
if (shouldCreateRequestReport || shouldCreateBoth) {
|
|
348
|
+
createRequestTemplate(exchange, methodName, args, result)
|
|
349
|
+
}
|
|
350
|
+
if (shouldCreateResponseReport || shouldCreateBoth) {
|
|
351
|
+
createResponseTemplate(exchange, methodName, args, result)
|
|
352
|
+
}
|
|
353
|
+
start = end
|
|
354
|
+
} catch (e) {
|
|
355
|
+
if (e instanceof ExchangeError) {
|
|
356
|
+
log.red (e.constructor.name, e.message)
|
|
357
|
+
} else if (e instanceof NetworkError) {
|
|
358
|
+
log.yellow (e.constructor.name, e.message)
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
log.dim ('---------------------------------------------------')
|
|
362
|
+
|
|
363
|
+
// rethrow for call-stack // other errors
|
|
364
|
+
throw e
|
|
365
|
+
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (debug) {
|
|
369
|
+
const keys = Object.keys (httpsAgent.freeSockets)
|
|
370
|
+
const firstKey = keys[0]
|
|
371
|
+
let httpAgent = httpsAgent.freeSockets[firstKey] as any;
|
|
372
|
+
log (firstKey, httpAgent.length)
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if (!poll && !isWsMethod){
|
|
376
|
+
break
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
} else if (exchange[methodName] === undefined) {
|
|
381
|
+
log.red (exchange.id + '.' + methodName + ': no such property')
|
|
382
|
+
} else {
|
|
383
|
+
printHumanReadable (exchange, exchange[methodName])
|
|
384
|
+
}
|
|
385
|
+
} else {
|
|
386
|
+
log (exchange)
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
//-----------------------------------------------------------------------------
|
|
393
|
+
|
|
394
|
+
run ()
|
|
395
|
+
|
|
396
|
+
export {
|
|
397
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import ccxt from '../../js/ccxt.js';
|
|
2
|
+
|
|
3
|
+
// AUTO-TRANSPILE //
|
|
4
|
+
|
|
5
|
+
async function example () {
|
|
6
|
+
const prefix = '-';
|
|
7
|
+
const exchange_1 = new ccxt.okx ();
|
|
8
|
+
const exchange_2 = new ccxt.htx ();
|
|
9
|
+
const keys_1 = Object.keys (exchange_1.has);
|
|
10
|
+
const keys_2 = Object.keys (exchange_2.has);
|
|
11
|
+
// check missing from exchange-1
|
|
12
|
+
console.log ('### checking missing functionalities from exchange-1:', exchange_1.id);
|
|
13
|
+
for (let i = 0; i < keys_2.length; i++) {
|
|
14
|
+
const key = keys_2[i];
|
|
15
|
+
if (exchange_2.has[key]) {
|
|
16
|
+
if (!keys_1.includes (key)) {
|
|
17
|
+
console.log (prefix, key, 'does not exist in', exchange_1.id, 'as opposed to', exchange_2.id);
|
|
18
|
+
} else if (exchange_2.has[key] !== exchange_1.has[key]) {
|
|
19
|
+
console.log (prefix, key, '> ', exchange_1.id, ':', exchange_1.has[key], ',', exchange_2.id, ':', exchange_2.has[key]);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// check missing from exchange-2
|
|
24
|
+
console.log ('### checking missing functionalities from exchange-2:', exchange_2.id);
|
|
25
|
+
for (let i = 0; i < keys_1.length; i++) {
|
|
26
|
+
const key = keys_1[i];
|
|
27
|
+
if (exchange_1.has[key]) {
|
|
28
|
+
if (!keys_2.includes (key)) {
|
|
29
|
+
console.log (prefix, key, 'does not exist in', exchange_2.id, 'as opposed to', exchange_1.id);
|
|
30
|
+
} else if (exchange_1.has[key] !== exchange_2.has[key]) {
|
|
31
|
+
console.log (prefix, key, '> ', exchange_2.id, ':', exchange_2.has[key], ',', exchange_1.id, ':', exchange_1.has[key]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
await example ();
|