ccxt 4.1.67 → 4.1.68
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 +3 -3
- package/dist/ccxt.browser.js +217 -8
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +2 -2
- package/dist/cjs/src/bybit.js +2 -2
- package/dist/cjs/src/gate.js +211 -2
- package/dist/cjs/src/pro/binance.js +1 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.d.ts +1 -1
- package/js/src/base/Exchange.js +2 -2
- package/js/src/bybit.js +2 -2
- package/js/src/gate.d.ts +27 -0
- package/js/src/gate.js +211 -2
- package/js/src/pro/binance.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -211,13 +211,13 @@ console.log(version, Object.keys(exchanges));
|
|
|
211
211
|
|
|
212
212
|
All-in-one browser bundle (dependencies included), served from a CDN of your choice:
|
|
213
213
|
|
|
214
|
-
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.1.
|
|
215
|
-
* unpkg: https://unpkg.com/ccxt@4.1.
|
|
214
|
+
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.1.68/dist/ccxt.browser.js
|
|
215
|
+
* unpkg: https://unpkg.com/ccxt@4.1.68/dist/ccxt.browser.js
|
|
216
216
|
|
|
217
217
|
CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
|
|
218
218
|
|
|
219
219
|
```HTML
|
|
220
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.1.
|
|
220
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.1.68/dist/ccxt.browser.js"></script>
|
|
221
221
|
```
|
|
222
222
|
|
|
223
223
|
Creates a global `ccxt` object:
|
package/dist/ccxt.browser.js
CHANGED
|
@@ -9505,7 +9505,7 @@ class Exchange {
|
|
|
9505
9505
|
'bidVolume': this.safeNumber(ticker, 'bidVolume'),
|
|
9506
9506
|
'ask': this.parseNumber(this.omitZero(this.safeNumber(ticker, 'ask'))),
|
|
9507
9507
|
'askVolume': this.safeNumber(ticker, 'askVolume'),
|
|
9508
|
-
'high': this.parseNumber(this.omitZero(this.safeString(ticker, 'high
|
|
9508
|
+
'high': this.parseNumber(this.omitZero(this.safeString(ticker, 'high'))),
|
|
9509
9509
|
'low': this.parseNumber(this.omitZero(this.safeNumber(ticker, 'low'))),
|
|
9510
9510
|
'open': this.parseNumber(this.omitZero(this.parseNumber(open))),
|
|
9511
9511
|
'close': this.parseNumber(this.omitZero(this.parseNumber(close))),
|
|
@@ -10174,7 +10174,7 @@ class Exchange {
|
|
|
10174
10174
|
throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' watchPositions() is not supported yet');
|
|
10175
10175
|
}
|
|
10176
10176
|
async watchPositionForSymbols(symbols = undefined, since = undefined, limit = undefined, params = {}) {
|
|
10177
|
-
return this.watchPositions(symbols, since, limit, params);
|
|
10177
|
+
return await this.watchPositions(symbols, since, limit, params);
|
|
10178
10178
|
}
|
|
10179
10179
|
async fetchPositionsForSymbol(symbol, params = {}) {
|
|
10180
10180
|
/**
|
|
@@ -77984,8 +77984,8 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
77984
77984
|
}
|
|
77985
77985
|
const request = {
|
|
77986
77986
|
// 'symbol': market['id'],
|
|
77987
|
-
// 'baseCoin': '', Base coin. For option only
|
|
77988
|
-
// 'expDate': '', Expiry date. e.g., 25DEC22. For option only
|
|
77987
|
+
// 'baseCoin': '', // Base coin. For option only
|
|
77988
|
+
// 'expDate': '', // Expiry date. e.g., 25DEC22. For option only
|
|
77989
77989
|
};
|
|
77990
77990
|
let type = undefined;
|
|
77991
77991
|
[type, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
|
|
@@ -121955,8 +121955,6 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
121955
121955
|
'AXIS': 'Axis DeFi',
|
|
121956
121956
|
'BIFI': 'Bitcoin File',
|
|
121957
121957
|
'BOX': 'DefiBox',
|
|
121958
|
-
'BTCBEAR': 'BEAR',
|
|
121959
|
-
'BTCBULL': 'BULL',
|
|
121960
121958
|
'BYN': 'BeyondFi',
|
|
121961
121959
|
'EGG': 'Goose Finance',
|
|
121962
121960
|
'GTC': 'Game.com',
|
|
@@ -122252,6 +122250,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
122252
122250
|
'AUTO_TRIGGER_PRICE_LESS_LAST': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
|
|
122253
122251
|
'AUTO_TRIGGER_PRICE_GREATE_LAST': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
|
|
122254
122252
|
'POSITION_HOLDING': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
|
|
122253
|
+
'USER_LOAN_EXCEEDED': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest, // {"label":"USER_LOAN_EXCEEDED","message":"Max loan amount per user would be exceeded"}
|
|
122255
122254
|
},
|
|
122256
122255
|
'broad': {},
|
|
122257
122256
|
},
|
|
@@ -126971,6 +126970,216 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
126971
126970
|
}
|
|
126972
126971
|
return tiers;
|
|
126973
126972
|
}
|
|
126973
|
+
async repayMargin(code, amount, symbol = undefined, params = {}) {
|
|
126974
|
+
/**
|
|
126975
|
+
* @method
|
|
126976
|
+
* @name gate#repayMargin
|
|
126977
|
+
* @description repay borrowed margin and interest
|
|
126978
|
+
* @see https://www.gate.io/docs/apiv4/en/#repay-cross-margin-loan
|
|
126979
|
+
* @see https://www.gate.io/docs/apiv4/en/#repay-a-loan
|
|
126980
|
+
* @param {string} code unified currency code of the currency to repay
|
|
126981
|
+
* @param {float} amount the amount to repay
|
|
126982
|
+
* @param {string} symbol unified market symbol, required for isolated margin
|
|
126983
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
126984
|
+
* @param {string} [params.mode] 'all' or 'partial' payment mode, extra parameter required for isolated margin
|
|
126985
|
+
* @param {string} [params.id] '34267567' loan id, extra parameter required for isolated margin
|
|
126986
|
+
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
|
|
126987
|
+
*/
|
|
126988
|
+
let marginMode = undefined;
|
|
126989
|
+
[marginMode, params] = this.handleOptionAndParams(params, 'repayMargin', 'marginMode');
|
|
126990
|
+
this.checkRequiredArgument('repayMargin', marginMode, 'marginMode', ['cross', 'isolated']);
|
|
126991
|
+
this.checkRequiredMarginArgument('repayMargin', symbol, marginMode);
|
|
126992
|
+
await this.loadMarkets();
|
|
126993
|
+
const currency = this.currency(code);
|
|
126994
|
+
const request = {
|
|
126995
|
+
'currency': currency['id'].toUpperCase(),
|
|
126996
|
+
'amount': this.currencyToPrecision(code, amount),
|
|
126997
|
+
};
|
|
126998
|
+
let response = undefined;
|
|
126999
|
+
if ((marginMode === 'cross') && (symbol === undefined)) {
|
|
127000
|
+
response = await this.privateMarginPostCrossRepayments(this.extend(request, params));
|
|
127001
|
+
}
|
|
127002
|
+
else if ((marginMode === 'isolated') || (symbol !== undefined)) {
|
|
127003
|
+
if (symbol === undefined) {
|
|
127004
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' repayMargin() requires a symbol argument for isolated margin');
|
|
127005
|
+
}
|
|
127006
|
+
const market = this.market(symbol);
|
|
127007
|
+
request['currency_pair'] = market['id'];
|
|
127008
|
+
request['type'] = 'repay';
|
|
127009
|
+
response = await this.privateMarginPostUniLoans(this.extend(request, params));
|
|
127010
|
+
}
|
|
127011
|
+
//
|
|
127012
|
+
// Cross
|
|
127013
|
+
//
|
|
127014
|
+
// [
|
|
127015
|
+
// {
|
|
127016
|
+
// "id": "17",
|
|
127017
|
+
// "create_time": 1620381696159,
|
|
127018
|
+
// "update_time": 1620381696159,
|
|
127019
|
+
// "currency": "EOS",
|
|
127020
|
+
// "amount": "110.553635",
|
|
127021
|
+
// "text": "web",
|
|
127022
|
+
// "status": 2,
|
|
127023
|
+
// "repaid": "110.506649705159",
|
|
127024
|
+
// "repaid_interest": "0.046985294841",
|
|
127025
|
+
// "unpaid_interest": "0.0000074393366667"
|
|
127026
|
+
// }
|
|
127027
|
+
// ]
|
|
127028
|
+
//
|
|
127029
|
+
// Isolated
|
|
127030
|
+
//
|
|
127031
|
+
// {
|
|
127032
|
+
// "id": "34267567",
|
|
127033
|
+
// "create_time": "1656394778",
|
|
127034
|
+
// "expire_time": "1657258778",
|
|
127035
|
+
// "status": "finished",
|
|
127036
|
+
// "side": "borrow",
|
|
127037
|
+
// "currency": "USDT",
|
|
127038
|
+
// "rate": "0.0002",
|
|
127039
|
+
// "amount": "100",
|
|
127040
|
+
// "days": 10,
|
|
127041
|
+
// "auto_renew": false,
|
|
127042
|
+
// "currency_pair": "LTC_USDT",
|
|
127043
|
+
// "left": "0",
|
|
127044
|
+
// "repaid": "100",
|
|
127045
|
+
// "paid_interest": "0.003333333333",
|
|
127046
|
+
// "unpaid_interest": "0"
|
|
127047
|
+
// }
|
|
127048
|
+
//
|
|
127049
|
+
if (marginMode === 'cross') {
|
|
127050
|
+
response = response[0];
|
|
127051
|
+
}
|
|
127052
|
+
return this.parseMarginLoan(response, currency);
|
|
127053
|
+
}
|
|
127054
|
+
async borrowMargin(code, amount, symbol = undefined, params = {}) {
|
|
127055
|
+
/**
|
|
127056
|
+
* @method
|
|
127057
|
+
* @name gate#borrowMargin
|
|
127058
|
+
* @description create a loan to borrow margin
|
|
127059
|
+
* @see https://www.gate.io/docs/apiv4/en/#create-a-cross-margin-borrow-loan
|
|
127060
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#marginuni
|
|
127061
|
+
* @param {string} code unified currency code of the currency to borrow
|
|
127062
|
+
* @param {float} amount the amount to borrow
|
|
127063
|
+
* @param {string} symbol unified market symbol, required for isolated margin
|
|
127064
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
127065
|
+
* @param {string} [params.rate] '0.0002' or '0.002' extra parameter required for isolated margin
|
|
127066
|
+
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
|
|
127067
|
+
*/
|
|
127068
|
+
let marginMode = undefined;
|
|
127069
|
+
[marginMode, params] = this.handleOptionAndParams(params, 'borrowMargin', 'marginMode');
|
|
127070
|
+
this.checkRequiredArgument('borrowMargin', marginMode, 'marginMode', ['cross', 'isolated']);
|
|
127071
|
+
this.checkRequiredMarginArgument('borrowMargin', symbol, marginMode);
|
|
127072
|
+
await this.loadMarkets();
|
|
127073
|
+
const currency = this.currency(code);
|
|
127074
|
+
const request = {
|
|
127075
|
+
'currency': currency['id'].toUpperCase(),
|
|
127076
|
+
'amount': this.currencyToPrecision(code, amount),
|
|
127077
|
+
};
|
|
127078
|
+
let response = undefined;
|
|
127079
|
+
if ((marginMode === 'cross') && (symbol === undefined)) {
|
|
127080
|
+
response = await this.privateMarginPostCrossLoans(this.extend(request, params));
|
|
127081
|
+
}
|
|
127082
|
+
else if ((marginMode === 'isolated') || (symbol !== undefined)) {
|
|
127083
|
+
if (symbol === undefined) {
|
|
127084
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' borrowMargin() requires a symbol argument for isolated margin');
|
|
127085
|
+
}
|
|
127086
|
+
const market = this.market(symbol);
|
|
127087
|
+
request['currency_pair'] = market['id'];
|
|
127088
|
+
request['type'] = 'borrow';
|
|
127089
|
+
response = await this.privateMarginPostUniLoans(this.extend(request, params));
|
|
127090
|
+
}
|
|
127091
|
+
//
|
|
127092
|
+
// Cross
|
|
127093
|
+
//
|
|
127094
|
+
// {
|
|
127095
|
+
// "id": "17",
|
|
127096
|
+
// "create_time": 1620381696159,
|
|
127097
|
+
// "update_time": 1620381696159,
|
|
127098
|
+
// "currency": "EOS",
|
|
127099
|
+
// "amount": "110.553635",
|
|
127100
|
+
// "text": "web",
|
|
127101
|
+
// "status": 2,
|
|
127102
|
+
// "repaid": "110.506649705159",
|
|
127103
|
+
// "repaid_interest": "0.046985294841",
|
|
127104
|
+
// "unpaid_interest": "0.0000074393366667"
|
|
127105
|
+
// }
|
|
127106
|
+
//
|
|
127107
|
+
// Isolated
|
|
127108
|
+
//
|
|
127109
|
+
// {
|
|
127110
|
+
// "id": "34267567",
|
|
127111
|
+
// "create_time": "1656394778",
|
|
127112
|
+
// "expire_time": "1657258778",
|
|
127113
|
+
// "status": "loaned",
|
|
127114
|
+
// "side": "borrow",
|
|
127115
|
+
// "currency": "USDT",
|
|
127116
|
+
// "rate": "0.0002",
|
|
127117
|
+
// "amount": "100",
|
|
127118
|
+
// "days": 10,
|
|
127119
|
+
// "auto_renew": false,
|
|
127120
|
+
// "currency_pair": "LTC_USDT",
|
|
127121
|
+
// "left": "0",
|
|
127122
|
+
// "repaid": "0",
|
|
127123
|
+
// "paid_interest": "0",
|
|
127124
|
+
// "unpaid_interest": "0.003333333333"
|
|
127125
|
+
// }
|
|
127126
|
+
//
|
|
127127
|
+
return this.parseMarginLoan(response, currency);
|
|
127128
|
+
}
|
|
127129
|
+
parseMarginLoan(info, currency = undefined) {
|
|
127130
|
+
//
|
|
127131
|
+
// Cross
|
|
127132
|
+
//
|
|
127133
|
+
// {
|
|
127134
|
+
// "id": "17",
|
|
127135
|
+
// "create_time": 1620381696159,
|
|
127136
|
+
// "update_time": 1620381696159,
|
|
127137
|
+
// "currency": "EOS",
|
|
127138
|
+
// "amount": "110.553635",
|
|
127139
|
+
// "text": "web",
|
|
127140
|
+
// "status": 2,
|
|
127141
|
+
// "repaid": "110.506649705159",
|
|
127142
|
+
// "repaid_interest": "0.046985294841",
|
|
127143
|
+
// "unpaid_interest": "0.0000074393366667"
|
|
127144
|
+
// }
|
|
127145
|
+
//
|
|
127146
|
+
// Isolated
|
|
127147
|
+
//
|
|
127148
|
+
// {
|
|
127149
|
+
// "id": "34267567",
|
|
127150
|
+
// "create_time": "1656394778",
|
|
127151
|
+
// "expire_time": "1657258778",
|
|
127152
|
+
// "status": "loaned",
|
|
127153
|
+
// "side": "borrow",
|
|
127154
|
+
// "currency": "USDT",
|
|
127155
|
+
// "rate": "0.0002",
|
|
127156
|
+
// "amount": "100",
|
|
127157
|
+
// "days": 10,
|
|
127158
|
+
// "auto_renew": false,
|
|
127159
|
+
// "currency_pair": "LTC_USDT",
|
|
127160
|
+
// "left": "0",
|
|
127161
|
+
// "repaid": "0",
|
|
127162
|
+
// "paid_interest": "0",
|
|
127163
|
+
// "unpaid_interest": "0.003333333333"
|
|
127164
|
+
// }
|
|
127165
|
+
//
|
|
127166
|
+
const marginMode = this.safeString2(this.options, 'defaultMarginMode', 'marginMode', 'cross');
|
|
127167
|
+
let timestamp = this.safeInteger(info, 'create_time');
|
|
127168
|
+
if (marginMode === 'isolated') {
|
|
127169
|
+
timestamp = this.safeTimestamp(info, 'create_time');
|
|
127170
|
+
}
|
|
127171
|
+
const currencyId = this.safeString(info, 'currency');
|
|
127172
|
+
const marketId = this.safeString(info, 'currency_pair');
|
|
127173
|
+
return {
|
|
127174
|
+
'id': this.safeInteger(info, 'id'),
|
|
127175
|
+
'currency': this.safeCurrencyCode(currencyId, currency),
|
|
127176
|
+
'amount': this.safeNumber(info, 'amount'),
|
|
127177
|
+
'symbol': this.safeSymbol(marketId, undefined, '_', 'margin'),
|
|
127178
|
+
'timestamp': timestamp,
|
|
127179
|
+
'datetime': this.iso8601(timestamp),
|
|
127180
|
+
'info': info,
|
|
127181
|
+
};
|
|
127182
|
+
}
|
|
126974
127183
|
sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
126975
127184
|
const authentication = api[0]; // public, private
|
|
126976
127185
|
const type = api[1]; // spot, margin, future, delivery
|
|
@@ -204611,7 +204820,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
204611
204820
|
handleTrade(client, message) {
|
|
204612
204821
|
// the trade streams push raw trade information in real-time
|
|
204613
204822
|
// each trade has a unique buyer and seller
|
|
204614
|
-
const isSpot = ((client.url.indexOf('
|
|
204823
|
+
const isSpot = ((client.url.indexOf('wss://stream.binance.com') > -1) || (client.url.indexOf('/testnet.binance') > -1));
|
|
204615
204824
|
const marketType = (isSpot) ? 'spot' : 'contract';
|
|
204616
204825
|
const marketId = this.safeString(message, 's');
|
|
204617
204826
|
const market = this.safeMarket(marketId, undefined, undefined, marketType);
|
|
@@ -287753,7 +287962,7 @@ SOFTWARE.
|
|
|
287753
287962
|
|
|
287754
287963
|
//-----------------------------------------------------------------------------
|
|
287755
287964
|
// this is updated by vss.js when building
|
|
287756
|
-
const version = '4.1.
|
|
287965
|
+
const version = '4.1.68';
|
|
287757
287966
|
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
|
|
287758
287967
|
//-----------------------------------------------------------------------------
|
|
287759
287968
|
|