Skip to content

Commit

Permalink
4.2.3
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
Travis CI committed Jan 1, 2024
1 parent 2891bef commit 640f5c3
Show file tree
Hide file tree
Showing 41 changed files with 1,265 additions and 478 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ console.log(version, Object.keys(exchanges));

All-in-one browser bundle (dependencies included), served from a CDN of your choice:

* jsDelivr: https://cdn.jsdelivr.net/npm/[email protected].2/dist/ccxt.browser.js
* unpkg: https://unpkg.com/[email protected].2/dist/ccxt.browser.js
* jsDelivr: https://cdn.jsdelivr.net/npm/[email protected].3/dist/ccxt.browser.js
* unpkg: https://unpkg.com/[email protected].3/dist/ccxt.browser.js

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.

```HTML
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected].2/dist/ccxt.browser.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected].3/dist/ccxt.browser.js"></script>
```

Creates a global `ccxt` object:
Expand Down
133 changes: 111 additions & 22 deletions dist/ccxt.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2536,7 +2536,7 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
'closeAllPositions': false,
'closePosition': false,
'createOrder': true,
'fetchBalance': true,
'fetchBalance': false,
'fetchBidsAsks': false,
'fetchClosedOrders': true,
'fetchCurrencies': false,
Expand Down Expand Up @@ -28776,6 +28776,10 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
const isTrailingAmountOrder = trailingAmount !== undefined;
const isTrailingPercentOrder = trailingPercent !== undefined;
const isTrailing = isTrailingAmountOrder || isTrailingPercentOrder;
const stopLoss = this.safeValue(params, 'stopLoss');
const takeProfit = this.safeValue(params, 'takeProfit');
const isStopLoss = stopLoss !== undefined;
const isTakeProfit = takeProfit !== undefined;
if (((type === 'LIMIT') || (type === 'TRIGGER_LIMIT') || (type === 'STOP') || (type === 'TAKE_PROFIT')) && !isTrailing) {
request['price'] = this.parseToNumeric(this.priceToPrecision(symbol, price));
}
Expand Down Expand Up @@ -28821,6 +28825,42 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
request['priceRate'] = this.parseToNumeric(requestTrailingPercent);
}
}
if (isStopLoss || isTakeProfit) {
if (isStopLoss) {
const slTriggerPrice = this.safeString2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
const slWorkingType = this.safeString(stopLoss, 'workingType', 'MARK_PRICE');
const slType = this.safeString(stopLoss, 'type', 'STOP_MARKET');
const slRequest = {
'stopPrice': this.parseToNumeric(this.priceToPrecision(symbol, slTriggerPrice)),
'workingType': slWorkingType,
'type': slType,
};
const slPrice = this.safeString(stopLoss, 'price');
if (slPrice !== undefined) {
slRequest['price'] = this.parseToNumeric(this.priceToPrecision(symbol, slPrice));
}
const slQuantity = this.safeString(stopLoss, 'quantity', amount);
slRequest['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, slQuantity));
request['stopLoss'] = this.json(slRequest);
}
if (isTakeProfit) {
const tkTriggerPrice = this.safeString2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
const tkWorkingType = this.safeString(takeProfit, 'workingType', 'MARK_PRICE');
const tpType = this.safeString(takeProfit, 'type', 'TAKE_PROFIT_MARKET');
const tpRequest = {
'stopPrice': this.parseToNumeric(this.priceToPrecision(symbol, tkTriggerPrice)),
'workingType': tkWorkingType,
'type': tpType,
};
const slPrice = this.safeString(takeProfit, 'price');
if (slPrice !== undefined) {
tpRequest['price'] = this.parseToNumeric(this.priceToPrecision(symbol, slPrice));
}
const tkQuantity = this.safeString(takeProfit, 'quantity', amount);
tpRequest['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, tkQuantity));
request['takeProfit'] = this.json(tpRequest);
}
}
let positionSide = undefined;
if (reduceOnly) {
positionSide = (side === 'buy') ? 'SHORT' : 'LONG';
Expand All @@ -28830,7 +28870,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
}
request['positionSide'] = positionSide;
request['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, amount));
params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent']);
params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'takeProfit', 'stopLoss']);
}
return this.extend(request, params);
}
Expand All @@ -28840,6 +28880,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
* @name bingx#createOrder
* @description create a trade order
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Trade%20order
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Create%20an%20Order
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
Expand All @@ -28855,6 +28896,10 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
* @param {float} [params.cost] the quote quantity that can be used as an alternative for the amount
* @param {float} [params.trailingAmount] *swap only* the quote amount to trail away from the current market price
* @param {float} [params.trailingPercent] *swap only* the percent to trail away from the current market price
* @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered
* @param {float} [params.takeProfit.triggerPrice] take profit trigger price
* @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
* @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
await this.loadMarkets();
Expand Down Expand Up @@ -28905,6 +28950,9 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
// }
// }
//
if (typeof response === 'string') {
response = JSON.parse(response);
}
const data = this.safeValue(response, 'data', {});
const order = this.safeValue(data, 'order', data);
return this.parseOrder(order, market);
Expand Down Expand Up @@ -29109,6 +29157,24 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
// "orderType": "",
// "workingType": "MARK_PRICE"
// }
// with tp and sl
// {
// orderId: 1741440894764281900,
// symbol: 'LTC-USDT',
// positionSide: 'LONG',
// side: 'BUY',
// type: 'MARKET',
// price: 0,
// quantity: 1,
// stopPrice: 0,
// workingType: 'MARK_PRICE',
// clientOrderID: '',
// timeInForce: 'GTC',
// priceRate: 0,
// stopLoss: '{"stopPrice":50,"workingType":"MARK_PRICE","type":"STOP_MARKET","quantity":1}',
// takeProfit: '{"stopPrice":150,"workingType":"MARK_PRICE","type":"TAKE_PROFIT_MARKET","quantity":1}',
// reduceOnly: false
// }
//
const positionSide = this.safeString2(order, 'positionSide', 'ps');
const marketType = (positionSide === undefined) ? 'spot' : 'swap';
Expand Down Expand Up @@ -29147,6 +29213,30 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
'cost': _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(feeCost),
};
const clientOrderId = this.safeString2(order, 'clientOrderId', 'c');
let stopLoss = this.safeValue(order, 'stopLoss');
let stopLossPrice = undefined;
if (stopLoss !== undefined) {
stopLossPrice = this.safeNumber(stopLoss, 'stopLoss');
}
if ((stopLoss !== undefined) && (typeof stopLoss !== 'number')) {
// stopLoss: '{"stopPrice":50,"workingType":"MARK_PRICE","type":"STOP_MARKET","quantity":1}',
if (typeof stopLoss === 'string') {
stopLoss = JSON.parse(stopLoss);
}
stopLossPrice = this.safeNumber(stopLoss, 'stopPrice');
}
let takeProfit = this.safeValue(order, 'takeProfit');
let takeProfitPrice = undefined;
if (takeProfit !== undefined) {
takeProfitPrice = this.safeNumber(takeProfit, 'takeProfit');
}
if ((takeProfit !== undefined) && (typeof takeProfit !== 'number')) {
// takeProfit: '{"stopPrice":150,"workingType":"MARK_PRICE","type":"TAKE_PROFIT_MARKET","quantity":1}',
if (typeof takeProfit === 'string') {
takeProfit = JSON.parse(takeProfit);
}
takeProfitPrice = this.safeNumber(takeProfit, 'stopPrice');
}
return this.safeOrder({
'info': order,
'id': orderId,
Expand All @@ -29163,8 +29253,8 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
'price': price,
'stopPrice': this.safeNumber(order, 'stopPrice'),
'triggerPrice': this.safeNumber(order, 'stopPrice'),
'stopLossPrice': this.safeNumber(order, 'stopLoss'),
'takeProfitPrice': this.safeNumber(order, 'takeProfit'),
'stopLossPrice': stopLossPrice,
'takeProfitPrice': takeProfitPrice,
'average': average,
'cost': undefined,
'amount': amount,
Expand Down Expand Up @@ -29358,6 +29448,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
* @param {string[]} ids order ids
* @param {string} symbol unified market symbol, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string[]} [params.clientOrderIds] client order ids
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
*/
if (symbol === undefined) {
Expand All @@ -29368,19 +29459,27 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
const request = {
'symbol': market['id'],
};
const clientOrderIds = this.safeValue(params, 'clientOrderIds');
let idsToParse = ids;
const areClientOrderIds = (clientOrderIds !== undefined);
if (areClientOrderIds) {
idsToParse = clientOrderIds;
}
const parsedIds = [];
for (let i = 0; i < ids.length; i++) {
const id = ids[i];
for (let i = 0; i < idsToParse.length; i++) {
const id = idsToParse[i];
const stringId = id.toString();
parsedIds.push(stringId);
}
let response = undefined;
if (market['spot']) {
request['orderIds'] = parsedIds.join(',');
const spotReqKey = areClientOrderIds ? 'clientOrderIds' : 'orderIds';
request[spotReqKey] = parsedIds.join(',');
response = await this.spotV1PrivatePostTradeCancelOrders(this.extend(request, params));
}
else {
request['orderIdList'] = parsedIds;
const swapReqKey = areClientOrderIds ? 'ClientOrderIDList' : 'orderIdList';
request[swapReqKey] = parsedIds;
response = await this.swapV2PrivateDeleteTradeBatchOrders(this.extend(request, params));
}
//
Expand Down Expand Up @@ -223295,7 +223394,7 @@ class bybit extends _bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
*/
await this.loadMarkets();
symbols = this.marketSymbols(symbols, undefined, false);
const messageHash = 'tickers::' + symbols.join(',');
const messageHashes = [];
const url = this.getUrlByMarketType(symbols[0], false, params);
params = this.cleanParams(params);
const options = this.safeValue(this.options, 'watchTickers', {});
Expand All @@ -223305,8 +223404,9 @@ class bybit extends _bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
for (let i = 0; i < marketIds.length; i++) {
const marketId = marketIds[i];
topics.push(topic + '.' + marketId);
messageHashes.push('ticker:' + symbols[i]);
}
const ticker = await this.watchTopics(url, messageHash, topics, params);
const ticker = await this.watchTopics(url, messageHashes, topics, params);
if (this.newUpdates) {
return ticker;
}
Expand Down Expand Up @@ -223442,17 +223542,6 @@ class bybit extends _bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
this.tickers[symbol] = parsed;
const messageHash = 'ticker:' + symbol;
client.resolve(this.tickers[symbol], messageHash);
// watchTickers part
const messageHashes = this.findMessageHashes(client, 'tickers::');
for (let i = 0; i < messageHashes.length; i++) {
const messageHashTicker = messageHashes[i];
const parts = messageHashTicker.split('::');
const symbolsString = parts[1];
const symbols = symbolsString.split(',');
if (this.inArray(parsed['symbol'], symbols)) {
client.resolve(parsed, messageHashTicker);
}
}
}
async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
/**
Expand Down Expand Up @@ -291429,7 +291518,7 @@ SOFTWARE.

//-----------------------------------------------------------------------------
// this is updated by vss.js when building
const version = '4.2.2';
const version = '4.2.3';
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
//-----------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion dist/ccxt.browser.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 640f5c3

Please sign in to comment.