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
package/dist/cjs/ccxt.js
CHANGED
|
@@ -180,7 +180,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
180
180
|
|
|
181
181
|
//-----------------------------------------------------------------------------
|
|
182
182
|
// this is updated by vss.js when building
|
|
183
|
-
const version = '4.2.
|
|
183
|
+
const version = '4.2.74';
|
|
184
184
|
Exchange["default"].ccxtVersion = version;
|
|
185
185
|
const exchanges = {
|
|
186
186
|
'ace': ace,
|
|
@@ -98,7 +98,7 @@ class Exchange {
|
|
|
98
98
|
this.last_request_body = undefined;
|
|
99
99
|
this.last_request_url = undefined;
|
|
100
100
|
this.last_request_path = undefined;
|
|
101
|
-
this.id =
|
|
101
|
+
this.id = 'Exchange';
|
|
102
102
|
this.markets = undefined;
|
|
103
103
|
this.status = undefined;
|
|
104
104
|
this.rateLimit = undefined; // milliseconds
|
package/dist/cjs/src/bitget.js
CHANGED
|
@@ -1340,10 +1340,10 @@ class bitget extends bitget$1 {
|
|
|
1340
1340
|
},
|
|
1341
1341
|
'fetchOHLCV': {
|
|
1342
1342
|
'spot': {
|
|
1343
|
-
'method': 'publicSpotGetV2SpotMarketCandles', // or publicSpotGetV2SpotMarketHistoryCandles
|
|
1343
|
+
'method': 'publicSpotGetV2SpotMarketCandles', // publicSpotGetV2SpotMarketCandles or publicSpotGetV2SpotMarketHistoryCandles
|
|
1344
1344
|
},
|
|
1345
1345
|
'swap': {
|
|
1346
|
-
'method': 'publicMixGetV2MixMarketCandles', // or publicMixGetV2MixMarketHistoryCandles or publicMixGetV2MixMarketHistoryIndexCandles or publicMixGetV2MixMarketHistoryMarkCandles
|
|
1346
|
+
'method': 'publicMixGetV2MixMarketCandles', // publicMixGetV2MixMarketCandles or publicMixGetV2MixMarketHistoryCandles or publicMixGetV2MixMarketHistoryIndexCandles or publicMixGetV2MixMarketHistoryMarkCandles
|
|
1347
1347
|
},
|
|
1348
1348
|
'maxDaysPerTimeframe': {
|
|
1349
1349
|
'1m': 30,
|
|
@@ -3313,11 +3313,13 @@ class bitget extends bitget$1 {
|
|
|
3313
3313
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
3314
3314
|
*/
|
|
3315
3315
|
await this.loadMarkets();
|
|
3316
|
-
const
|
|
3316
|
+
const defaultLimit = 100; // default 100, max 1000
|
|
3317
|
+
const maxLimitForRecentEndpoint = 1000;
|
|
3318
|
+
const maxLimitForHistoryEndpoint = 200; // note, max 1000 bars are supported for "recent-candles" endpoint, but "historical-candles" support only max 200
|
|
3317
3319
|
let paginate = false;
|
|
3318
3320
|
[paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
|
|
3319
3321
|
if (paginate) {
|
|
3320
|
-
return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params,
|
|
3322
|
+
return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, maxLimitForHistoryEndpoint);
|
|
3321
3323
|
}
|
|
3322
3324
|
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
3323
3325
|
let market = undefined;
|
|
@@ -3330,32 +3332,17 @@ class bitget extends bitget$1 {
|
|
|
3330
3332
|
}
|
|
3331
3333
|
const marketType = market['spot'] ? 'spot' : 'swap';
|
|
3332
3334
|
const timeframes = this.options['timeframes'][marketType];
|
|
3333
|
-
const
|
|
3335
|
+
const msInDay = 86400000;
|
|
3334
3336
|
const duration = this.parseTimeframe(timeframe) * 1000;
|
|
3335
3337
|
const request = {
|
|
3336
3338
|
'symbol': market['id'],
|
|
3337
|
-
'granularity':
|
|
3339
|
+
'granularity': this.safeString(timeframes, timeframe, timeframe),
|
|
3338
3340
|
};
|
|
3339
|
-
const defaultLimit = 100; // by default, exchange returns 100 items
|
|
3340
|
-
const msInDay = 1000 * 60 * 60 * 24;
|
|
3341
|
-
if (limit !== undefined) {
|
|
3342
|
-
limit = Math.min(limit, maxLimit);
|
|
3343
|
-
request['limit'] = limit;
|
|
3344
|
-
}
|
|
3345
3341
|
const until = this.safeInteger2(params, 'until', 'till');
|
|
3342
|
+
const limitDefined = limit !== undefined;
|
|
3343
|
+
const sinceDefined = since !== undefined;
|
|
3344
|
+
const untilDefined = until !== undefined;
|
|
3346
3345
|
params = this.omit(params, ['until', 'till']);
|
|
3347
|
-
if (until !== undefined) {
|
|
3348
|
-
request['endTime'] = until;
|
|
3349
|
-
}
|
|
3350
|
-
if (since !== undefined) {
|
|
3351
|
-
request['startTime'] = since;
|
|
3352
|
-
if (market['spot'] && (until === undefined)) {
|
|
3353
|
-
// for spot we need to send "entTime" too
|
|
3354
|
-
const limitForEnd = (limit !== undefined) ? limit : defaultLimit;
|
|
3355
|
-
const calculatedEnd = this.sum(since, duration * limitForEnd);
|
|
3356
|
-
request['endTime'] = calculatedEnd;
|
|
3357
|
-
}
|
|
3358
|
-
}
|
|
3359
3346
|
let response = undefined;
|
|
3360
3347
|
const now = this.milliseconds();
|
|
3361
3348
|
// retrievable periods listed here:
|
|
@@ -3363,21 +3350,47 @@ class bitget extends bitget$1 {
|
|
|
3363
3350
|
// - https://www.bitget.com/api-doc/contract/market/Get-Candle-Data#description
|
|
3364
3351
|
const ohlcOptions = this.safeDict(this.options, 'fetchOHLCV', {});
|
|
3365
3352
|
const retrievableDaysMap = this.safeDict(ohlcOptions, 'maxDaysPerTimeframe', {});
|
|
3366
|
-
const
|
|
3367
|
-
const endpointTsBoundary = now -
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
if (since !== undefined && since < endpointTsBoundary) {
|
|
3372
|
-
// if since it earlier than the allowed diapason
|
|
3373
|
-
needsHistoryEndpoint = true;
|
|
3374
|
-
}
|
|
3375
|
-
else if (until !== undefined && until - displaceByLimit < endpointTsBoundary) {
|
|
3376
|
-
// if until is earlier than the allowed diapason
|
|
3377
|
-
needsHistoryEndpoint = true;
|
|
3353
|
+
const maxRetrievableDaysForRecent = this.safeInteger(retrievableDaysMap, timeframe, 30); // default to safe minimum
|
|
3354
|
+
const endpointTsBoundary = now - maxRetrievableDaysForRecent * msInDay;
|
|
3355
|
+
if (limitDefined) {
|
|
3356
|
+
limit = Math.min(limit, maxLimitForRecentEndpoint);
|
|
3357
|
+
request['limit'] = limit;
|
|
3378
3358
|
}
|
|
3359
|
+
else {
|
|
3360
|
+
limit = defaultLimit;
|
|
3361
|
+
}
|
|
3362
|
+
const limitMultipliedDuration = limit * duration;
|
|
3363
|
+
// exchange aligns from endTime, so it's important, not startTime
|
|
3364
|
+
// startTime is supported only on "recent" endpoint, not on "historical" endpoint
|
|
3365
|
+
let calculatedStartTime = undefined;
|
|
3366
|
+
let calculatedEndTime = undefined;
|
|
3367
|
+
if (sinceDefined) {
|
|
3368
|
+
calculatedStartTime = since;
|
|
3369
|
+
request['startTime'] = since;
|
|
3370
|
+
if (!untilDefined) {
|
|
3371
|
+
calculatedEndTime = this.sum(calculatedStartTime, limitMultipliedDuration);
|
|
3372
|
+
request['endTime'] = calculatedEndTime;
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
if (untilDefined) {
|
|
3376
|
+
calculatedEndTime = until;
|
|
3377
|
+
request['endTime'] = calculatedEndTime;
|
|
3378
|
+
if (!sinceDefined) {
|
|
3379
|
+
calculatedStartTime = calculatedEndTime - limitMultipliedDuration;
|
|
3380
|
+
// we do not need to set "startTime" here
|
|
3381
|
+
}
|
|
3382
|
+
}
|
|
3383
|
+
const historicalEndpointNeeded = (calculatedStartTime !== undefined) && (calculatedStartTime <= endpointTsBoundary);
|
|
3384
|
+
if (historicalEndpointNeeded) {
|
|
3385
|
+
// only for "historical-candles" - ensure we use correct max limit
|
|
3386
|
+
if (limitDefined) {
|
|
3387
|
+
request['limit'] = Math.min(limit, maxLimitForHistoryEndpoint);
|
|
3388
|
+
}
|
|
3389
|
+
}
|
|
3390
|
+
// make request
|
|
3379
3391
|
if (market['spot']) {
|
|
3380
|
-
if
|
|
3392
|
+
// checks if we need history endpoint
|
|
3393
|
+
if (historicalEndpointNeeded) {
|
|
3381
3394
|
response = await this.publicSpotGetV2SpotMarketHistoryCandles(this.extend(request, params));
|
|
3382
3395
|
}
|
|
3383
3396
|
else {
|
|
@@ -3385,19 +3398,18 @@ class bitget extends bitget$1 {
|
|
|
3385
3398
|
}
|
|
3386
3399
|
}
|
|
3387
3400
|
else {
|
|
3388
|
-
const maxDistanceDaysForContracts = 90; // maximum 90 days allowed between start-end times
|
|
3389
|
-
|
|
3390
|
-
if (
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
throw new errors.BadRequest(this.id + ' fetchOHLCV() between start and end must be less than ' + maxDistanceDaysForContracts.toString() + ' days');
|
|
3401
|
+
const maxDistanceDaysForContracts = 90; // for contract, maximum 90 days allowed between start-end times
|
|
3402
|
+
// only correct the request to fix 90 days if until was auto-calculated
|
|
3403
|
+
if (sinceDefined) {
|
|
3404
|
+
if (!untilDefined) {
|
|
3405
|
+
request['endTime'] = Math.min(calculatedEndTime, this.sum(since, maxDistanceDaysForContracts * msInDay));
|
|
3406
|
+
}
|
|
3407
|
+
else if (calculatedEndTime - calculatedStartTime > maxDistanceDaysForContracts * msInDay) {
|
|
3408
|
+
throw new errors.BadRequest(this.id + ' fetchOHLCV() between start and end must be less than ' + maxDistanceDaysForContracts.toString() + ' days');
|
|
3409
|
+
}
|
|
3398
3410
|
}
|
|
3399
|
-
|
|
3400
|
-
params = this.
|
|
3411
|
+
let priceType = undefined;
|
|
3412
|
+
[priceType, params] = this.handleParamString(params, 'price');
|
|
3401
3413
|
let productType = undefined;
|
|
3402
3414
|
[productType, params] = this.handleProductTypeAndParams(market, params);
|
|
3403
3415
|
request['productType'] = productType;
|
|
@@ -3410,7 +3422,7 @@ class bitget extends bitget$1 {
|
|
|
3410
3422
|
response = await this.publicMixGetV2MixMarketHistoryIndexCandles(extended);
|
|
3411
3423
|
}
|
|
3412
3424
|
else {
|
|
3413
|
-
if (
|
|
3425
|
+
if (historicalEndpointNeeded) {
|
|
3414
3426
|
response = await this.publicMixGetV2MixMarketHistoryCandles(extended);
|
|
3415
3427
|
}
|
|
3416
3428
|
else {
|
package/dist/cjs/src/bybit.js
CHANGED
|
@@ -79,6 +79,7 @@ class bybit extends bybit$1 {
|
|
|
79
79
|
'fetchIsolatedBorrowRates': false,
|
|
80
80
|
'fetchLedger': true,
|
|
81
81
|
'fetchLeverage': true,
|
|
82
|
+
'fetchLeverageTiers': true,
|
|
82
83
|
'fetchMarketLeverageTiers': true,
|
|
83
84
|
'fetchMarkets': true,
|
|
84
85
|
'fetchMarkOHLCV': true,
|
|
@@ -7265,36 +7266,6 @@ class bybit extends bybit$1 {
|
|
|
7265
7266
|
market['id'];
|
|
7266
7267
|
return await this.fetchDerivativesMarketLeverageTiers(symbol, params);
|
|
7267
7268
|
}
|
|
7268
|
-
parseMarketLeverageTiers(info, market = undefined) {
|
|
7269
|
-
//
|
|
7270
|
-
// {
|
|
7271
|
-
// "id": 1,
|
|
7272
|
-
// "symbol": "BTCUSD",
|
|
7273
|
-
// "riskLimitValue": "150",
|
|
7274
|
-
// "maintenanceMargin": "0.5",
|
|
7275
|
-
// "initialMargin": "1",
|
|
7276
|
-
// "isLowestRisk": 1,
|
|
7277
|
-
// "maxLeverage": "100.00"
|
|
7278
|
-
// }
|
|
7279
|
-
//
|
|
7280
|
-
let minNotional = 0;
|
|
7281
|
-
const tiers = [];
|
|
7282
|
-
for (let i = 0; i < info.length; i++) {
|
|
7283
|
-
const item = info[i];
|
|
7284
|
-
const maxNotional = this.safeNumber(item, 'riskLimitValue');
|
|
7285
|
-
tiers.push({
|
|
7286
|
-
'tier': this.sum(i, 1),
|
|
7287
|
-
'currency': market['base'],
|
|
7288
|
-
'minNotional': minNotional,
|
|
7289
|
-
'maxNotional': maxNotional,
|
|
7290
|
-
'maintenanceMarginRate': this.safeNumber(item, 'maintenanceMargin'),
|
|
7291
|
-
'maxLeverage': this.safeNumber(item, 'maxLeverage'),
|
|
7292
|
-
'info': item,
|
|
7293
|
-
});
|
|
7294
|
-
minNotional = maxNotional;
|
|
7295
|
-
}
|
|
7296
|
-
return tiers;
|
|
7297
|
-
}
|
|
7298
7269
|
parseTradingFee(fee, market = undefined) {
|
|
7299
7270
|
//
|
|
7300
7271
|
// {
|
|
@@ -7999,6 +7970,95 @@ class bybit extends bybit$1 {
|
|
|
7999
7970
|
'datetime': this.iso8601(timestamp),
|
|
8000
7971
|
});
|
|
8001
7972
|
}
|
|
7973
|
+
async fetchLeverageTiers(symbols = undefined, params = {}) {
|
|
7974
|
+
/**
|
|
7975
|
+
* @method
|
|
7976
|
+
* @name bybit#fetchLeverageTiers
|
|
7977
|
+
* @see https://bybit-exchange.github.io/docs/v5/market/risk-limit
|
|
7978
|
+
* @description retrieve information on the maximum leverage, for different trade sizes
|
|
7979
|
+
* @param {string[]} [symbols] a list of unified market symbols
|
|
7980
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
7981
|
+
* @param {string} [params.subType] market subType, ['linear', 'inverse'], default is 'linear'
|
|
7982
|
+
* @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
|
|
7983
|
+
*/
|
|
7984
|
+
await this.loadMarkets();
|
|
7985
|
+
let market = undefined;
|
|
7986
|
+
if (symbols !== undefined) {
|
|
7987
|
+
market = this.market(symbols[0]);
|
|
7988
|
+
if (market['spot']) {
|
|
7989
|
+
throw new errors.NotSupported(this.id + ' fetchLeverageTiers() is not supported for spot market');
|
|
7990
|
+
}
|
|
7991
|
+
}
|
|
7992
|
+
let subType = undefined;
|
|
7993
|
+
[subType, params] = this.handleSubTypeAndParams('fetchTickers', market, params, 'linear');
|
|
7994
|
+
const request = {
|
|
7995
|
+
'category': subType,
|
|
7996
|
+
};
|
|
7997
|
+
const response = await this.publicGetV5MarketRiskLimit(this.extend(request, params));
|
|
7998
|
+
const result = this.safeDict(response, 'result', {});
|
|
7999
|
+
const data = this.safeList(result, 'list', []);
|
|
8000
|
+
symbols = this.marketSymbols(symbols);
|
|
8001
|
+
return this.parseLeverageTiers(data, symbols, 'symbol');
|
|
8002
|
+
}
|
|
8003
|
+
parseLeverageTiers(response, symbols = undefined, marketIdKey = undefined) {
|
|
8004
|
+
//
|
|
8005
|
+
// [
|
|
8006
|
+
// {
|
|
8007
|
+
// "id": 1,
|
|
8008
|
+
// "symbol": "BTCUSD",
|
|
8009
|
+
// "riskLimitValue": "150",
|
|
8010
|
+
// "maintenanceMargin": "0.5",
|
|
8011
|
+
// "initialMargin": "1",
|
|
8012
|
+
// "isLowestRisk": 1,
|
|
8013
|
+
// "maxLeverage": "100.00"
|
|
8014
|
+
// }
|
|
8015
|
+
// ]
|
|
8016
|
+
//
|
|
8017
|
+
const tiers = {};
|
|
8018
|
+
const marketIds = this.marketIds(symbols);
|
|
8019
|
+
const filteredResults = this.filterByArray(response, marketIdKey, marketIds, false);
|
|
8020
|
+
const grouped = this.groupBy(filteredResults, marketIdKey);
|
|
8021
|
+
const keys = Object.keys(grouped);
|
|
8022
|
+
for (let i = 0; i < keys.length; i++) {
|
|
8023
|
+
const marketId = keys[i];
|
|
8024
|
+
const entry = grouped[marketId];
|
|
8025
|
+
const market = this.safeMarket(marketId, undefined, undefined, 'contract');
|
|
8026
|
+
const symbol = market['symbol'];
|
|
8027
|
+
tiers[symbol] = this.parseMarketLeverageTiers(entry, market);
|
|
8028
|
+
}
|
|
8029
|
+
return tiers;
|
|
8030
|
+
}
|
|
8031
|
+
parseMarketLeverageTiers(info, market = undefined) {
|
|
8032
|
+
//
|
|
8033
|
+
// [
|
|
8034
|
+
// {
|
|
8035
|
+
// "id": 1,
|
|
8036
|
+
// "symbol": "BTCUSD",
|
|
8037
|
+
// "riskLimitValue": "150",
|
|
8038
|
+
// "maintenanceMargin": "0.5",
|
|
8039
|
+
// "initialMargin": "1",
|
|
8040
|
+
// "isLowestRisk": 1,
|
|
8041
|
+
// "maxLeverage": "100.00"
|
|
8042
|
+
// }
|
|
8043
|
+
// ]
|
|
8044
|
+
//
|
|
8045
|
+
const tiers = [];
|
|
8046
|
+
for (let i = 0; i < info.length; i++) {
|
|
8047
|
+
const tier = info[i];
|
|
8048
|
+
const marketId = this.safeString(info, 'symbol');
|
|
8049
|
+
market = this.safeMarket(marketId);
|
|
8050
|
+
tiers.push({
|
|
8051
|
+
'tier': this.safeInteger(tier, 'id'),
|
|
8052
|
+
'currency': market['settle'],
|
|
8053
|
+
'minNotional': undefined,
|
|
8054
|
+
'maxNotional': undefined,
|
|
8055
|
+
'maintenanceMarginRate': this.safeNumber(tier, 'maintenanceMargin'),
|
|
8056
|
+
'maxLeverage': this.safeNumber(tier, 'maxLeverage'),
|
|
8057
|
+
'info': tier,
|
|
8058
|
+
});
|
|
8059
|
+
}
|
|
8060
|
+
return tiers;
|
|
8061
|
+
}
|
|
8002
8062
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
8003
8063
|
let url = this.implodeHostname(this.urls['api'][api]) + '/' + path;
|
|
8004
8064
|
if (api === 'public') {
|
|
@@ -115,7 +115,7 @@ class coinbaseinternational extends coinbaseinternational$1 {
|
|
|
115
115
|
'test': {
|
|
116
116
|
'rest': 'https://api-n5e1.coinbase.com/api',
|
|
117
117
|
},
|
|
118
|
-
'www': 'https://
|
|
118
|
+
'www': 'https://international.coinbase.com',
|
|
119
119
|
'doc': [
|
|
120
120
|
'https://docs.cloud.coinbaseinternational.com/intx/docs',
|
|
121
121
|
],
|
package/dist/cjs/src/htx.js
CHANGED
|
@@ -949,6 +949,9 @@ class htx extends htx$1 {
|
|
|
949
949
|
},
|
|
950
950
|
},
|
|
951
951
|
},
|
|
952
|
+
'fetchOHLCV': {
|
|
953
|
+
'useHistoricalEndpointForSpot': true,
|
|
954
|
+
},
|
|
952
955
|
'withdraw': {
|
|
953
956
|
'includeFee': false,
|
|
954
957
|
},
|
|
@@ -2956,6 +2959,7 @@ class htx extends htx$1 {
|
|
|
2956
2959
|
* @param {int} [limit] the maximum amount of candles to fetch
|
|
2957
2960
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2958
2961
|
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
2962
|
+
* @param {string} [params.useHistoricalEndpointForSpot] true/false - whether use the historical candles endpoint for spot markets or default klines endpoint
|
|
2959
2963
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
2960
2964
|
*/
|
|
2961
2965
|
await this.loadMarkets();
|
|
@@ -3062,19 +3066,22 @@ class htx extends htx$1 {
|
|
|
3062
3066
|
}
|
|
3063
3067
|
}
|
|
3064
3068
|
else {
|
|
3065
|
-
if (since !== undefined) {
|
|
3066
|
-
request['from'] = this.parseToInt(since / 1000);
|
|
3067
|
-
}
|
|
3068
|
-
if (limit !== undefined) {
|
|
3069
|
-
request['size'] = limit; // max 2000
|
|
3070
|
-
}
|
|
3071
3069
|
request['symbol'] = market['id'];
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3070
|
+
let useHistorical = undefined;
|
|
3071
|
+
[useHistorical, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'useHistoricalEndpointForSpot', true);
|
|
3072
|
+
if (!useHistorical) {
|
|
3073
|
+
// `limit` only available for the this endpoint
|
|
3074
|
+
if (limit !== undefined) {
|
|
3075
|
+
request['size'] = limit; // max 2000
|
|
3076
|
+
}
|
|
3075
3077
|
response = await this.spotPublicGetMarketHistoryKline(this.extend(request, params));
|
|
3076
3078
|
}
|
|
3077
3079
|
else {
|
|
3080
|
+
// `since` only available for the this endpoint
|
|
3081
|
+
if (since !== undefined) {
|
|
3082
|
+
// default 150 bars
|
|
3083
|
+
request['from'] = this.parseToInt(since / 1000);
|
|
3084
|
+
}
|
|
3078
3085
|
response = await this.spotPublicGetMarketHistoryCandles(this.extend(request, params));
|
|
3079
3086
|
}
|
|
3080
3087
|
}
|
|
@@ -365,7 +365,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
365
365
|
'optionType': undefined,
|
|
366
366
|
'precision': {
|
|
367
367
|
'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'szDecimals'))),
|
|
368
|
-
'price':
|
|
368
|
+
'price': 5, // significant digits
|
|
369
369
|
},
|
|
370
370
|
'limits': {
|
|
371
371
|
'leverage': {
|
|
@@ -847,6 +847,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
847
847
|
throw new errors.ArgumentsRequired(this.id + ' market orders require price to calculate the max slippage price. Default slippage can be set in options (default is 5%).');
|
|
848
848
|
}
|
|
849
849
|
px = (isBuy) ? Precise["default"].stringMul(price, Precise["default"].stringAdd('1', slippage)) : Precise["default"].stringMul(price, Precise["default"].stringSub('1', slippage));
|
|
850
|
+
px = this.priceToPrecision(symbol, px); // round after adding slippage
|
|
850
851
|
}
|
|
851
852
|
else {
|
|
852
853
|
px = this.priceToPrecision(symbol, price);
|
|
@@ -467,16 +467,17 @@ class krakenfutures extends krakenfutures$1 {
|
|
|
467
467
|
const market = this.market(marketId);
|
|
468
468
|
const symbol = market['symbol'];
|
|
469
469
|
const messageHash = 'trade:' + symbol;
|
|
470
|
-
|
|
471
|
-
if (tradesArray === undefined) {
|
|
470
|
+
if (this.safeList(this.trades, symbol) === undefined) {
|
|
472
471
|
const tradesLimit = this.safeInteger(this.options, 'tradesLimit', 1000);
|
|
473
|
-
|
|
474
|
-
this.trades[symbol] = tradesArray;
|
|
472
|
+
this.trades[symbol] = new Cache.ArrayCache(tradesLimit);
|
|
475
473
|
}
|
|
474
|
+
const tradesArray = this.trades[symbol];
|
|
476
475
|
if (channel === 'trade_snapshot') {
|
|
477
|
-
const trades = this.
|
|
478
|
-
|
|
479
|
-
|
|
476
|
+
const trades = this.safeList(message, 'trades', []);
|
|
477
|
+
const length = trades.length;
|
|
478
|
+
for (let i = 0; i < length; i++) {
|
|
479
|
+
const index = length - 1 - i; // need reverse to correct chronology
|
|
480
|
+
const item = trades[index];
|
|
480
481
|
const trade = this.parseWsTrade(item);
|
|
481
482
|
tradesArray.append(trade);
|
|
482
483
|
}
|