ccxt 4.2.73 → 4.2.74
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/README.md +5 -5
- package/build.sh +1 -1
- package/dist/ccxt.browser.js +181 -100
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +1 -1
- package/dist/cjs/src/bitget.js +62 -50
- package/dist/cjs/src/bybit.js +90 -30
- package/dist/cjs/src/coinbaseinternational.js +1 -1
- package/dist/cjs/src/htx.js +16 -9
- package/dist/cjs/src/hyperliquid.js +2 -1
- package/dist/cjs/src/pro/krakenfutures.js +8 -7
- 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 +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.d.ts +2 -2
- package/js/src/base/Exchange.js +1 -1
- package/js/src/bitget.js +62 -50
- package/js/src/bybit.d.ts +3 -1
- package/js/src/bybit.js +90 -30
- package/js/src/coinbaseinternational.js +1 -1
- package/js/src/htx.js +16 -9
- package/js/src/hyperliquid.js +2 -1
- package/js/src/pro/krakenfutures.js +8 -7
- package/package.json +4 -1
- package/skip-tests.json +214 -424
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import ccxt from '../../js/ccxt.js';
|
|
4
|
+
import asTable from 'as-table';
|
|
5
|
+
import ansicolor from 'ansicolor';
|
|
6
|
+
import ololog from 'ololog';
|
|
7
|
+
|
|
8
|
+
const log = ololog.configure ({ locate: false }), verbose = process.argv.includes ('--verbose');
|
|
9
|
+
|
|
10
|
+
ansicolor.nice
|
|
11
|
+
|
|
12
|
+
//-----------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
let printSupportedExchanges = function () {
|
|
15
|
+
log ('Supported exchanges:', ccxt.exchanges.join (', ').green)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let printUsage = function () {
|
|
19
|
+
log ('Usage: node', process.argv[1], 'id'.green, '[symbol]'.yellow)
|
|
20
|
+
printSupportedExchanges ()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let printSymbols = function (exchange) {
|
|
24
|
+
log (id.green, 'has', exchange.symbols.length, 'symbols:', exchange.symbols.join (', ').yellow)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let sleep = (ms) => new Promise (resolve => setTimeout (resolve, ms))
|
|
28
|
+
|
|
29
|
+
let printTicker = async (exchange, symbol) => {
|
|
30
|
+
let ticker = await exchange.fetchTicker (symbol)
|
|
31
|
+
log (exchange.id.green, symbol.yellow, 'ticker',
|
|
32
|
+
ticker['datetime'],
|
|
33
|
+
'high: ' + ticker['high'],
|
|
34
|
+
'low: ' + ticker['low'],
|
|
35
|
+
'bid: ' + ticker['bid'],
|
|
36
|
+
'ask: ' + ticker['ask'],
|
|
37
|
+
'volume: ' + ticker['baseVolume'])
|
|
38
|
+
return ticker
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//-----------------------------------------------------------------------------
|
|
42
|
+
|
|
43
|
+
let printTickers = async (id) => {
|
|
44
|
+
|
|
45
|
+
log ('Instantiating', id.green, 'exchange exchange')
|
|
46
|
+
|
|
47
|
+
// instantiate the exchange by id
|
|
48
|
+
let exchange = new ccxt[id] ({ verbose })
|
|
49
|
+
|
|
50
|
+
// load all markets from the exchange
|
|
51
|
+
let markets = await exchange.loadMarkets ()
|
|
52
|
+
|
|
53
|
+
if (process.argv.length > 3) { // if a symbol was supplied, get that symbol only
|
|
54
|
+
|
|
55
|
+
let symbol = process.argv[3]
|
|
56
|
+
|
|
57
|
+
await printTicker (exchange, symbol)
|
|
58
|
+
|
|
59
|
+
} else { // otherwise run through all symbols one by one
|
|
60
|
+
|
|
61
|
+
for (let symbol of exchange.symbols)
|
|
62
|
+
if ((symbol.indexOf ('.d') < 0)) { // skip darkpool symbols
|
|
63
|
+
|
|
64
|
+
const market = exchange.markets[symbol];
|
|
65
|
+
|
|
66
|
+
if (!market['active']) {
|
|
67
|
+
log.red (exchange.id + ' ' + symbol + ' inactive');
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
await sleep (exchange.rateLimit)
|
|
72
|
+
await printTicker (exchange, symbol)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//-----------------------------------------------------------------------------
|
|
78
|
+
|
|
79
|
+
;(async function main () {
|
|
80
|
+
|
|
81
|
+
if (process.argv.length > 2) {
|
|
82
|
+
|
|
83
|
+
let id = process.argv[2]
|
|
84
|
+
|
|
85
|
+
// check if the exchange is supported by ccxt
|
|
86
|
+
let exchangeFound = ccxt.exchanges.indexOf (id) > -1
|
|
87
|
+
|
|
88
|
+
if (exchangeFound) {
|
|
89
|
+
|
|
90
|
+
await printTickers (id)
|
|
91
|
+
|
|
92
|
+
} else {
|
|
93
|
+
|
|
94
|
+
log ('Exchange ' + id.red + ' not found')
|
|
95
|
+
printUsage ()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
} else {
|
|
99
|
+
|
|
100
|
+
printUsage ()
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
process.exit ()
|
|
105
|
+
|
|
106
|
+
}) ()
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import ccxt from '../../js/ccxt.js';
|
|
4
|
+
import ololog from 'ololog'
|
|
5
|
+
import ansicolor from 'ansicolor';
|
|
6
|
+
|
|
7
|
+
const log = ololog.configure ({ locate: false })
|
|
8
|
+
|
|
9
|
+
ansicolor.nice
|
|
10
|
+
|
|
11
|
+
//-----------------------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* Warning: Sometimes the exchanges have gaps in their OHLCV data, so it does not mean
|
|
15
|
+
* that CCXT is broken if you see gaps in the chart.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
async function fetchData(exchange, symbol, timeframe) {
|
|
19
|
+
await exchange.loadMarkets()
|
|
20
|
+
// exchange.verbose = true;
|
|
21
|
+
const duration = exchange.parseTimeframe (timeframe) *1000; // in milliseconds
|
|
22
|
+
const ohlcv = await exchange.fetchOHLCV (symbol, timeframe, undefined, undefined, {'paginate': true, 'paginationCalls': 5})
|
|
23
|
+
validateTimeframes(ohlcv, duration, exchange, symbol)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function validateTimeframes(ohlcv, duration, exchange, symbol) {
|
|
27
|
+
for (let j = 0; j < ohlcv.length; j++) {
|
|
28
|
+
const [timestamp, open, high, low, close, volume] = ohlcv[j]
|
|
29
|
+
if (j > 0) {
|
|
30
|
+
const [prevTimestamp, prevOpen, prevHigh, prevLow, prevClose, prevVolume] = ohlcv[j - 1]
|
|
31
|
+
if (timestamp - prevTimestamp !== duration) {
|
|
32
|
+
log.red ('[' + j + ']',exchange.id, symbol, 'OHLCV data is not continuous, at', exchange.iso8601 (timestamp), 'diff:', ((timestamp - prevTimestamp) / 1000), 's expected:', duration/ 1000, 's')
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
log.green(exchange.id, symbol, `All the ${ohlcv.length} candles returned are continuous`)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function main () {
|
|
40
|
+
|
|
41
|
+
const exchanges = {
|
|
42
|
+
'binance': 'BTC/USDT',
|
|
43
|
+
'bitget': 'BTC/USDT',
|
|
44
|
+
'kucoin': 'BTC/USDT',
|
|
45
|
+
'kucoinfutures': 'BTC/USDT:USDT',
|
|
46
|
+
'okex': 'BTC/USDT',
|
|
47
|
+
'bybit': 'BTC/USDT'
|
|
48
|
+
}
|
|
49
|
+
const timeframe = '1m';
|
|
50
|
+
const keys = Object.keys (exchanges)
|
|
51
|
+
const promises = [];
|
|
52
|
+
for (let i = 0; i < keys.length; i++) {
|
|
53
|
+
const name = keys[i]
|
|
54
|
+
const symbol = exchanges[name]
|
|
55
|
+
const exchange = new ccxt[name] ({ enableRateLimit: true })
|
|
56
|
+
promises.push(fetchData(exchange, symbol, timeframe))
|
|
57
|
+
}
|
|
58
|
+
await Promise.all(promises)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
main()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import ccxt from '../../js/ccxt.js';
|
|
2
|
+
// AUTO-TRANSPILE //
|
|
3
|
+
async function example() {
|
|
4
|
+
const binance = new ccxt.pro.binance({});
|
|
5
|
+
const subscriptions = [
|
|
6
|
+
['BTC/USDT', '5m'],
|
|
7
|
+
['ETH/USDT', '5m'],
|
|
8
|
+
['BTC/USDT', '1h'],
|
|
9
|
+
];
|
|
10
|
+
while (true) {
|
|
11
|
+
const ohlcv = await binance.watchOHLCVForSymbols(subscriptions);
|
|
12
|
+
console.log(ohlcv);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
await example();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import ccxt from '../../js/ccxt.js';
|
|
2
|
+
// AUTO-TRANSPILE //
|
|
3
|
+
async function example() {
|
|
4
|
+
const binance = new ccxt.pro.binance({});
|
|
5
|
+
const symbol = 'BTC/USDT';
|
|
6
|
+
const timeframe = '1m';
|
|
7
|
+
while (true) {
|
|
8
|
+
const ohlcv = await binance.watchOHLCV(symbol, timeframe);
|
|
9
|
+
console.log(ohlcv);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
await example();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ccxt from '../../js/ccxt.js';
|
|
2
|
+
// AUTO-TRANSPILE //
|
|
3
|
+
async function example() {
|
|
4
|
+
const binance = new ccxt.pro.binance({});
|
|
5
|
+
const symbols = ['BTC/USDT', 'ETH/USDT', 'DOGE/USDT'];
|
|
6
|
+
while (true) {
|
|
7
|
+
const orderbook = await binance.watchOrderBookForSymbols(symbols);
|
|
8
|
+
console.log(orderbook['symbol'], orderbook['asks'][0], orderbook['bids'][0]);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
await example();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ccxt from '../../js/ccxt.js';
|
|
2
|
+
// AUTO-TRANSPILE //
|
|
3
|
+
async function example() {
|
|
4
|
+
const binance = new ccxt.pro.binance({});
|
|
5
|
+
const symbols = ['BTC/USDT', 'ETH/USDT', 'DOGE/USDT'];
|
|
6
|
+
while (true) {
|
|
7
|
+
const trades = await binance.watchTradesForSymbols(symbols);
|
|
8
|
+
console.log(trades);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
await example();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ccxt from '../../js/ccxt.js';
|
|
2
|
+
// AUTO-TRANSPILE //
|
|
3
|
+
async function example() {
|
|
4
|
+
const binance = new ccxt.pro.binance({});
|
|
5
|
+
const symbols = ['BTC/USDT', 'ETH/USDT', 'DOGE/USDT'];
|
|
6
|
+
while (true) {
|
|
7
|
+
const tickers = await binance.watchTickers(symbols);
|
|
8
|
+
console.log(tickers['BTC/USDT'], tickers['ETH/USDT'], tickers['DOGE/USDT']);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
await example();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import ccxt from '../../js/ccxt.js';
|
|
2
|
+
// AUTO-TRANSPILE //
|
|
3
|
+
async function example() {
|
|
4
|
+
const binance = new ccxt.pro.binance({});
|
|
5
|
+
const subscriptions = [
|
|
6
|
+
['BTC/USDT', '5m'],
|
|
7
|
+
['ETH/USDT', '5m'],
|
|
8
|
+
['BTC/USDT', '1h'],
|
|
9
|
+
];
|
|
10
|
+
while (true) {
|
|
11
|
+
const ohlcv = await binance.watchOHLCVForSymbols(subscriptions);
|
|
12
|
+
console.log(ohlcv);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
await example();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ccxt from '../../js/ccxt.js';
|
|
2
|
+
// AUTO-TRANSPILE //
|
|
3
|
+
async function example() {
|
|
4
|
+
const binance = new ccxt.pro.binance({});
|
|
5
|
+
const symbol = ['BTC/USDT', 'ETH/USDT', 'DOGE/USDT'];
|
|
6
|
+
while (true) {
|
|
7
|
+
const orderbook = await binance.watchOrderBookForSymbols(symbol);
|
|
8
|
+
console.log(orderbook['symbol'], orderbook['asks'][0], orderbook['bids'][0]);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
await example();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watchPositions-many-exchanges-continuosly.d.ts","sourceRoot":"","sources":["../ts/watchPositions-many-exchanges-continuosly.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import ccxt from '../../js/ccxt.js';
|
|
2
|
+
// AUTO-TRANSPILE //
|
|
3
|
+
// watch and handle constinuosly
|
|
4
|
+
async function watchPositionsContinuously(exchange) {
|
|
5
|
+
while (true) {
|
|
6
|
+
try {
|
|
7
|
+
const positions = await exchange.watchPositions();
|
|
8
|
+
console.log('Fetched ', exchange.id, ' - Positions: ', positions);
|
|
9
|
+
}
|
|
10
|
+
catch (e) {
|
|
11
|
+
console.log(e);
|
|
12
|
+
break;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
// start exchanges and fetch OHLCV loop
|
|
17
|
+
async function startExchange(exchangeName, config) {
|
|
18
|
+
const ex = new ccxt[exchangeName](config);
|
|
19
|
+
const promises = [];
|
|
20
|
+
promises.push(watchPositionsContinuously(ex));
|
|
21
|
+
await Promise.all(promises);
|
|
22
|
+
await ex.close();
|
|
23
|
+
}
|
|
24
|
+
// main function
|
|
25
|
+
async function example() {
|
|
26
|
+
const exchanges = {
|
|
27
|
+
'binanceusdm': {
|
|
28
|
+
'apiKey': 'YOUR_API_KEY',
|
|
29
|
+
'secret': 'YOUR_API_SECRET',
|
|
30
|
+
},
|
|
31
|
+
'okx': {
|
|
32
|
+
'apiKey': 'YOUR_API_KEY',
|
|
33
|
+
'secret': 'YOUR_API_SECRET',
|
|
34
|
+
},
|
|
35
|
+
'huobi': {
|
|
36
|
+
'apiKey': 'YOUR_API_KEY',
|
|
37
|
+
'secret': 'YOUR_API_SECRET',
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
const promises = [];
|
|
41
|
+
const exchangeIds = Object.keys(exchanges);
|
|
42
|
+
for (let i = 0; i < exchangeIds.length; i++) {
|
|
43
|
+
const exchangeName = exchangeIds[i];
|
|
44
|
+
const config = exchanges[exchangeName];
|
|
45
|
+
promises.push(startExchange(exchangeName, config));
|
|
46
|
+
}
|
|
47
|
+
await Promise.all(promises);
|
|
48
|
+
}
|
|
49
|
+
await example();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watchPositions.d.ts","sourceRoot":"","sources":["../ts/watchPositions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import ccxt from '../../js/ccxt.js';
|
|
2
|
+
// AUTO-TRANSPILE //
|
|
3
|
+
async function example() {
|
|
4
|
+
const exchange = new ccxt.pro.binanceusdm({
|
|
5
|
+
'apiKey': 'YOUR_API_KEY',
|
|
6
|
+
'secret': 'YOUR_API_SECRET'
|
|
7
|
+
});
|
|
8
|
+
while (true) {
|
|
9
|
+
const trades = await exchange.watchPositions();
|
|
10
|
+
console.log(trades);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
await example();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watchPositionsForSymbols.d.ts","sourceRoot":"","sources":["../ts/watchPositionsForSymbols.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import ccxt from '../../js/ccxt.js';
|
|
2
|
+
// AUTO-TRANSPILE //
|
|
3
|
+
async function example() {
|
|
4
|
+
const exchange = new ccxt.pro.binanceusdm({
|
|
5
|
+
'apiKey': 'YOUR_API_KEY',
|
|
6
|
+
'secret': 'Your_API_SECRET'
|
|
7
|
+
});
|
|
8
|
+
const symbols = ['BTC/USDT:USDT', 'ETH/USDT:USDT', 'DOGE/USDT:USDT'];
|
|
9
|
+
while (true) {
|
|
10
|
+
const trades = await exchange.watchPositions(symbols);
|
|
11
|
+
console.log(trades);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
await example();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ccxt from '../../js/ccxt.js';
|
|
2
|
+
// AUTO-TRANSPILE //
|
|
3
|
+
async function example() {
|
|
4
|
+
const binance = new ccxt.pro.binance({});
|
|
5
|
+
const symbols = ['BTC/USDT', 'ETH/USDT', 'DOGE/USDT'];
|
|
6
|
+
while (true) {
|
|
7
|
+
const trades = await binance.watchTradesForSymbols(symbols);
|
|
8
|
+
console.log(trades);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
await example();
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import ccxt from '../../js/ccxt.js';
|
|
2
|
+
|
|
3
|
+
console.log ('CCXT Version', ccxt.version)
|
|
4
|
+
|
|
5
|
+
async function main () {
|
|
6
|
+
|
|
7
|
+
const binance = new ccxt.binance ({
|
|
8
|
+
'apiKey': 'YOUR_API_KEY',
|
|
9
|
+
'secret': 'YOUR_SECRET',
|
|
10
|
+
'options': {
|
|
11
|
+
'fetchCurrencies': true,
|
|
12
|
+
},
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const kucoin = new ccxt.kucoin ({
|
|
16
|
+
'apiKey': 'YOUR_API_KEY',
|
|
17
|
+
'secret': 'YOUR_SECRET',
|
|
18
|
+
'password': 'YOUR_API_PASSWORD',
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
await binance.loadMarkets ()
|
|
22
|
+
await kucoin.loadMarkets ()
|
|
23
|
+
|
|
24
|
+
binance.verbose = true
|
|
25
|
+
kucoin.verbose = true
|
|
26
|
+
|
|
27
|
+
const code = 'COTI'
|
|
28
|
+
const amount = 40
|
|
29
|
+
|
|
30
|
+
// https://github.com/ccxt/ccxt/wiki/Manual#overriding-unified-api-params
|
|
31
|
+
// https://binance-docs.github.io/apidocs/spot/en/#deposit-address-supporting-network-user_data
|
|
32
|
+
const deposit = await binance.fetchDepositAddress (code, { 'network': 'ETH' })
|
|
33
|
+
|
|
34
|
+
console.log ('-----------------------------------------------------------')
|
|
35
|
+
|
|
36
|
+
console.log (depositAddress)
|
|
37
|
+
|
|
38
|
+
console.log ('-----------------------------------------------------------')
|
|
39
|
+
|
|
40
|
+
// https://github.com/ccxt/ccxt/wiki/Manual#overriding-unified-api-params
|
|
41
|
+
// https://docs.kucoin.com/#apply-withdraw-2
|
|
42
|
+
const withdrawal = await kucoin.withdraw (code, amount, deposit['address'], deposit['tag'], { 'chain': 'ERC20' })
|
|
43
|
+
|
|
44
|
+
console.log ('-----------------------------------------------------------')
|
|
45
|
+
|
|
46
|
+
console.log (withdrawal)
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
main ()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# CCXT Python Examples
|
|
2
|
+
|
|
3
|
+
To run Python examples from any folder, type in console:
|
|
4
|
+
|
|
5
|
+
```shell
|
|
6
|
+
python path/to/example.py # substitute for actual filename here
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Example files starting with `async-` require Python 3.6 with `async`/`await` and async generators support.
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
## See Also
|
|
14
|
+
|
|
15
|
+
[co3k-crypto-currency-note](https://github.com/co3k/co3k-crypto-currency-note/blob/master/Untitled.ipynb) – an example of using ccxt to fetch OHLCV candles from Kraken and charting them with matplotlib in a Jupyter Notebook, made by [co3k](https://github.com/co3k).
|