ccxt 4.2.61 → 4.2.63
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 +100 -100
- package/dist/ccxt.browser.js +76 -25
- package/dist/ccxt.browser.min.js +5 -5
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/bitget.js +74 -23
- package/dist/cjs/src/hyperliquid.js +1 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/bitget.js +74 -23
- package/js/src/hyperliquid.js +1 -1
- package/package.json +1 -1
package/dist/ccxt.browser.js
CHANGED
|
@@ -46186,6 +46186,23 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
46186
46186
|
'swap': {
|
|
46187
46187
|
'method': 'publicMixGetV2MixMarketCandles', // or publicMixGetV2MixMarketHistoryCandles or publicMixGetV2MixMarketHistoryIndexCandles or publicMixGetV2MixMarketHistoryMarkCandles
|
|
46188
46188
|
},
|
|
46189
|
+
'maxDaysPerTimeframe': {
|
|
46190
|
+
'1m': 30,
|
|
46191
|
+
'3m': 30,
|
|
46192
|
+
'5m': 30,
|
|
46193
|
+
'10m': 52,
|
|
46194
|
+
'15m': 52,
|
|
46195
|
+
'30m': 52,
|
|
46196
|
+
'1h': 83,
|
|
46197
|
+
'2h': 120,
|
|
46198
|
+
'4h': 240,
|
|
46199
|
+
'6h': 360,
|
|
46200
|
+
'12h': 360,
|
|
46201
|
+
'1d': 360,
|
|
46202
|
+
'3d': 1000,
|
|
46203
|
+
'1w': 1000,
|
|
46204
|
+
'1M': 1000,
|
|
46205
|
+
},
|
|
46189
46206
|
},
|
|
46190
46207
|
'fetchTrades': {
|
|
46191
46208
|
'spot': {
|
|
@@ -48137,10 +48154,11 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
48137
48154
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
48138
48155
|
*/
|
|
48139
48156
|
await this.loadMarkets();
|
|
48157
|
+
const maxLimit = 1000; // max 1000
|
|
48140
48158
|
let paginate = false;
|
|
48141
48159
|
[paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
|
|
48142
48160
|
if (paginate) {
|
|
48143
|
-
return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params,
|
|
48161
|
+
return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, maxLimit);
|
|
48144
48162
|
}
|
|
48145
48163
|
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
48146
48164
|
let market = undefined;
|
|
@@ -48154,35 +48172,53 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
48154
48172
|
const marketType = market['spot'] ? 'spot' : 'swap';
|
|
48155
48173
|
const timeframes = this.options['timeframes'][marketType];
|
|
48156
48174
|
const selectedTimeframe = this.safeString(timeframes, timeframe, timeframe);
|
|
48175
|
+
const duration = this.parseTimeframe(timeframe) * 1000;
|
|
48157
48176
|
const request = {
|
|
48158
48177
|
'symbol': market['id'],
|
|
48159
48178
|
'granularity': selectedTimeframe,
|
|
48160
48179
|
};
|
|
48161
|
-
const
|
|
48162
|
-
|
|
48180
|
+
const defaultLimit = 100; // by default, exchange returns 100 items
|
|
48181
|
+
const msInDay = 1000 * 60 * 60 * 24;
|
|
48163
48182
|
if (limit !== undefined) {
|
|
48183
|
+
limit = Math.min(limit, maxLimit);
|
|
48164
48184
|
request['limit'] = limit;
|
|
48165
48185
|
}
|
|
48166
|
-
|
|
48167
|
-
|
|
48186
|
+
const until = this.safeInteger2(params, 'until', 'till');
|
|
48187
|
+
params = this.omit(params, ['until', 'till']);
|
|
48188
|
+
if (until !== undefined) {
|
|
48189
|
+
request['endTime'] = until;
|
|
48168
48190
|
}
|
|
48169
48191
|
if (since !== undefined) {
|
|
48170
|
-
|
|
48171
|
-
|
|
48192
|
+
request['startTime'] = since;
|
|
48193
|
+
if (market['spot'] && (until === undefined)) {
|
|
48194
|
+
// for spot we need to send "entTime" too
|
|
48195
|
+
const limitForEnd = (limit !== undefined) ? limit : defaultLimit;
|
|
48196
|
+
const calculatedEnd = this.sum(since, duration * limitForEnd);
|
|
48197
|
+
request['endTime'] = calculatedEnd;
|
|
48172
48198
|
}
|
|
48173
|
-
const duration = this.parseTimeframe(timeframe) * 1000;
|
|
48174
|
-
request['endTime'] = this.sum(since, duration * (limit + 1)) - 1; // limit + 1)) - 1 is needed for when since is not the exact timestamp of a candle
|
|
48175
|
-
}
|
|
48176
|
-
else if (until !== undefined) {
|
|
48177
|
-
request['endTime'] = until;
|
|
48178
|
-
}
|
|
48179
|
-
else {
|
|
48180
|
-
request['endTime'] = this.milliseconds();
|
|
48181
48199
|
}
|
|
48182
48200
|
let response = undefined;
|
|
48183
|
-
const
|
|
48201
|
+
const now = this.milliseconds();
|
|
48202
|
+
// retrievable periods listed here:
|
|
48203
|
+
// - https://www.bitget.com/api-doc/spot/market/Get-Candle-Data#request-parameters
|
|
48204
|
+
// - https://www.bitget.com/api-doc/contract/market/Get-Candle-Data#description
|
|
48205
|
+
const ohlcOptions = this.safeDict(this.options, 'fetchOHLCV', {});
|
|
48206
|
+
const retrievableDaysMap = this.safeDict(ohlcOptions, 'maxDaysPerTimeframe', {});
|
|
48207
|
+
const maxRetrievableDaysForNonHistory = this.safeInteger(retrievableDaysMap, timeframe, 30); // default to safe minimum
|
|
48208
|
+
const endpointTsBoundary = now - maxRetrievableDaysForNonHistory * msInDay;
|
|
48209
|
+
// checks if we need history endpoint
|
|
48210
|
+
let needsHistoryEndpoint = false;
|
|
48211
|
+
const displaceByLimit = (limit === undefined) ? 0 : limit * duration;
|
|
48212
|
+
if (since !== undefined && since < endpointTsBoundary) {
|
|
48213
|
+
// if since it earlier than the allowed diapason
|
|
48214
|
+
needsHistoryEndpoint = true;
|
|
48215
|
+
}
|
|
48216
|
+
else if (until !== undefined && until - displaceByLimit < endpointTsBoundary) {
|
|
48217
|
+
// if until is earlier than the allowed diapason
|
|
48218
|
+
needsHistoryEndpoint = true;
|
|
48219
|
+
}
|
|
48184
48220
|
if (market['spot']) {
|
|
48185
|
-
if (
|
|
48221
|
+
if (needsHistoryEndpoint) {
|
|
48186
48222
|
response = await this.publicSpotGetV2SpotMarketHistoryCandles(this.extend(request, params));
|
|
48187
48223
|
}
|
|
48188
48224
|
else {
|
|
@@ -48190,22 +48226,37 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
48190
48226
|
}
|
|
48191
48227
|
}
|
|
48192
48228
|
else {
|
|
48229
|
+
const maxDistanceDaysForContracts = 90; // maximum 90 days allowed between start-end times
|
|
48230
|
+
let distanceError = false;
|
|
48231
|
+
if (limit !== undefined && limit * duration > maxDistanceDaysForContracts * msInDay) {
|
|
48232
|
+
distanceError = true;
|
|
48233
|
+
}
|
|
48234
|
+
else if (since !== undefined && until !== undefined && until - since > maxDistanceDaysForContracts * msInDay) {
|
|
48235
|
+
distanceError = true;
|
|
48236
|
+
}
|
|
48237
|
+
if (distanceError) {
|
|
48238
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest(this.id + ' fetchOHLCV() between start and end must be less than ' + maxDistanceDaysForContracts.toString() + ' days');
|
|
48239
|
+
}
|
|
48193
48240
|
const priceType = this.safeString(params, 'price');
|
|
48194
48241
|
params = this.omit(params, ['price']);
|
|
48195
48242
|
let productType = undefined;
|
|
48196
48243
|
[productType, params] = this.handleProductTypeAndParams(market, params);
|
|
48197
48244
|
request['productType'] = productType;
|
|
48245
|
+
const extended = this.extend(request, params);
|
|
48246
|
+
// todo: mark & index also have their "recent" endpoints, but not priority now.
|
|
48198
48247
|
if (priceType === 'mark') {
|
|
48199
|
-
response = await this.publicMixGetV2MixMarketHistoryMarkCandles(
|
|
48248
|
+
response = await this.publicMixGetV2MixMarketHistoryMarkCandles(extended);
|
|
48200
48249
|
}
|
|
48201
48250
|
else if (priceType === 'index') {
|
|
48202
|
-
response = await this.publicMixGetV2MixMarketHistoryIndexCandles(
|
|
48203
|
-
}
|
|
48204
|
-
else if ((since !== undefined) && (since < thirtyOneDaysAgo)) {
|
|
48205
|
-
response = await this.publicMixGetV2MixMarketHistoryCandles(this.extend(request, params));
|
|
48251
|
+
response = await this.publicMixGetV2MixMarketHistoryIndexCandles(extended);
|
|
48206
48252
|
}
|
|
48207
48253
|
else {
|
|
48208
|
-
|
|
48254
|
+
if (needsHistoryEndpoint) {
|
|
48255
|
+
response = await this.publicMixGetV2MixMarketHistoryCandles(extended);
|
|
48256
|
+
}
|
|
48257
|
+
else {
|
|
48258
|
+
response = await this.publicMixGetV2MixMarketCandles(extended);
|
|
48259
|
+
}
|
|
48209
48260
|
}
|
|
48210
48261
|
}
|
|
48211
48262
|
if (response === '') {
|
|
@@ -158605,7 +158656,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
|
|
|
158605
158656
|
},
|
|
158606
158657
|
'hostname': 'hyperliquid.xyz',
|
|
158607
158658
|
'urls': {
|
|
158608
|
-
'logo': 'https://
|
|
158659
|
+
'logo': 'https://github.com/ccxt/ccxt/assets/43336371/b371bc6c-4a8c-489f-87f4-20a913dd8d4b',
|
|
158609
158660
|
'api': {
|
|
158610
158661
|
'public': 'https://api.{hostname}',
|
|
158611
158662
|
'private': 'https://api.{hostname}',
|
|
@@ -316326,7 +316377,7 @@ SOFTWARE.
|
|
|
316326
316377
|
|
|
316327
316378
|
//-----------------------------------------------------------------------------
|
|
316328
316379
|
// this is updated by vss.js when building
|
|
316329
|
-
const version = '4.2.
|
|
316380
|
+
const version = '4.2.63';
|
|
316330
316381
|
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
|
|
316331
316382
|
//-----------------------------------------------------------------------------
|
|
316332
316383
|
|