ccxt 4.1.24 → 4.1.25
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 +1172 -200
- package/dist/ccxt.browser.min.js +4 -4
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/ace.js +1 -1
- package/dist/cjs/src/base/Exchange.js +7 -3
- package/dist/cjs/src/base/functions/crypto.js +11 -2
- package/dist/cjs/src/base/functions/generic.js +5 -3
- package/dist/cjs/src/base/functions.js +1 -0
- package/dist/cjs/src/binance.js +108 -5
- package/dist/cjs/src/bitget.js +289 -21
- package/dist/cjs/src/bybit.js +132 -15
- package/dist/cjs/src/cryptocom.js +262 -15
- package/dist/cjs/src/gate.js +191 -88
- package/dist/cjs/src/krakenfutures.js +86 -20
- package/dist/cjs/src/oceanex.js +0 -12
- package/dist/cjs/src/okx.js +60 -1
- package/dist/cjs/src/pro/bybit.js +1 -1
- package/dist/cjs/src/static_dependencies/noble-curves/abstract/edwards.js +8 -6
- package/dist/cjs/src/wavesexchange.js +6 -6
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/gate.d.ts +2 -7
- package/js/src/abstract/gateio.d.ts +2 -7
- package/js/src/ace.js +1 -1
- package/js/src/base/Exchange.d.ts +4 -2
- package/js/src/base/Exchange.js +7 -3
- package/js/src/base/functions/crypto.d.ts +3 -2
- package/js/src/base/functions/crypto.js +11 -3
- package/js/src/base/functions/generic.d.ts +1 -1
- package/js/src/base/functions/generic.js +5 -3
- package/js/src/base/types.d.ts +8 -0
- package/js/src/binance.d.ts +2 -1
- package/js/src/binance.js +108 -5
- package/js/src/bitget.d.ts +15 -1
- package/js/src/bitget.js +289 -21
- package/js/src/bybit.d.ts +4 -2
- package/js/src/bybit.js +132 -15
- package/js/src/cryptocom.d.ts +4 -1
- package/js/src/cryptocom.js +262 -15
- package/js/src/gate.d.ts +3 -1
- package/js/src/gate.js +191 -88
- package/js/src/krakenfutures.d.ts +3 -1
- package/js/src/krakenfutures.js +86 -20
- package/js/src/oceanex.d.ts +0 -1
- package/js/src/oceanex.js +0 -12
- package/js/src/okx.d.ts +2 -1
- package/js/src/okx.js +60 -1
- package/js/src/pro/bybit.js +1 -1
- package/js/src/static_dependencies/noble-curves/abstract/edwards.d.ts +1 -0
- package/js/src/static_dependencies/noble-curves/abstract/edwards.js +5 -3
- package/js/src/wavesexchange.js +7 -7
- package/package.json +1 -1
- package/skip-tests.json +2 -3
package/dist/ccxt.browser.js
CHANGED
|
@@ -2482,7 +2482,7 @@ class ace extends _abstract_ace_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
2482
2482
|
'timeStamp': nonce,
|
|
2483
2483
|
}, params);
|
|
2484
2484
|
const dataKeys = Object.keys(data);
|
|
2485
|
-
const sortedDataKeys = this.sortBy(dataKeys, 0);
|
|
2485
|
+
const sortedDataKeys = this.sortBy(dataKeys, 0, false, '');
|
|
2486
2486
|
for (let i = 0; i < sortedDataKeys.length; i++) {
|
|
2487
2487
|
const key = sortedDataKeys[i];
|
|
2488
2488
|
auth += this.safeString(data, key);
|
|
@@ -6868,6 +6868,7 @@ class Exchange {
|
|
|
6868
6868
|
'createLimitOrder': true,
|
|
6869
6869
|
'createMarketOrder': true,
|
|
6870
6870
|
'createOrder': true,
|
|
6871
|
+
'createOrders': undefined,
|
|
6871
6872
|
'createPostOnlyOrder': undefined,
|
|
6872
6873
|
'createReduceOnlyOrder': undefined,
|
|
6873
6874
|
'createStopOrder': undefined,
|
|
@@ -8142,7 +8143,7 @@ class Exchange {
|
|
|
8142
8143
|
this.markets_by_id = {};
|
|
8143
8144
|
// handle marketId conflicts
|
|
8144
8145
|
// we insert spot markets first
|
|
8145
|
-
const marketValues = this.sortBy(this.toArray(markets), 'spot', true);
|
|
8146
|
+
const marketValues = this.sortBy(this.toArray(markets), 'spot', true, true);
|
|
8146
8147
|
for (let i = 0; i < marketValues.length; i++) {
|
|
8147
8148
|
const value = marketValues[i];
|
|
8148
8149
|
if (value['id'] in this.markets_by_id) {
|
|
@@ -8192,8 +8193,8 @@ class Exchange {
|
|
|
8192
8193
|
quoteCurrencies.push(currency);
|
|
8193
8194
|
}
|
|
8194
8195
|
}
|
|
8195
|
-
baseCurrencies = this.sortBy(baseCurrencies, 'code');
|
|
8196
|
-
quoteCurrencies = this.sortBy(quoteCurrencies, 'code');
|
|
8196
|
+
baseCurrencies = this.sortBy(baseCurrencies, 'code', false, '');
|
|
8197
|
+
quoteCurrencies = this.sortBy(quoteCurrencies, 'code', false, '');
|
|
8197
8198
|
this.baseCurrencies = this.indexBy(baseCurrencies, 'code');
|
|
8198
8199
|
this.quoteCurrencies = this.indexBy(quoteCurrencies, 'code');
|
|
8199
8200
|
const allCurrencies = this.arrayConcat(baseCurrencies, quoteCurrencies);
|
|
@@ -9855,6 +9856,9 @@ class Exchange {
|
|
|
9855
9856
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
9856
9857
|
throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' createOrder() is not supported yet');
|
|
9857
9858
|
}
|
|
9859
|
+
async createOrders(orders, params = {}) {
|
|
9860
|
+
throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' createOrders() is not supported yet');
|
|
9861
|
+
}
|
|
9858
9862
|
async createOrderWs(symbol, type, side, amount, price = undefined, params = {}) {
|
|
9859
9863
|
throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' createOrderWs() is not supported yet');
|
|
9860
9864
|
}
|
|
@@ -11633,6 +11637,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
11633
11637
|
/* harmony export */ "arrayConcat": () => (/* reexport safe */ _functions_generic_js__WEBPACK_IMPORTED_MODULE_1__.oE),
|
|
11634
11638
|
/* harmony export */ "asFloat": () => (/* reexport safe */ _functions_type_js__WEBPACK_IMPORTED_MODULE_3__.GX),
|
|
11635
11639
|
/* harmony export */ "asInteger": () => (/* reexport safe */ _functions_type_js__WEBPACK_IMPORTED_MODULE_3__.xJ),
|
|
11640
|
+
/* harmony export */ "axolotl": () => (/* reexport safe */ _functions_crypto_js__WEBPACK_IMPORTED_MODULE_6__.gC),
|
|
11636
11641
|
/* harmony export */ "base16ToBinary": () => (/* reexport safe */ _functions_encode_js__WEBPACK_IMPORTED_MODULE_5__.aj),
|
|
11637
11642
|
/* harmony export */ "base58ToBinary": () => (/* reexport safe */ _functions_encode_js__WEBPACK_IMPORTED_MODULE_5__.ZA),
|
|
11638
11643
|
/* harmony export */ "base64ToBinary": () => (/* reexport safe */ _functions_encode_js__WEBPACK_IMPORTED_MODULE_5__.R5),
|
|
@@ -11790,14 +11795,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
11790
11795
|
/* harmony export */ "UZ": () => (/* binding */ eddsa),
|
|
11791
11796
|
/* harmony export */ "bD": () => (/* binding */ hmac),
|
|
11792
11797
|
/* harmony export */ "bu": () => (/* binding */ ecdsa),
|
|
11798
|
+
/* harmony export */ "gC": () => (/* binding */ axolotl),
|
|
11793
11799
|
/* harmony export */ "kn": () => (/* binding */ crc32),
|
|
11794
11800
|
/* harmony export */ "vp": () => (/* binding */ hash)
|
|
11795
11801
|
/* harmony export */ });
|
|
11796
11802
|
/* harmony import */ var _static_dependencies_noble_hashes_hmac_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(138);
|
|
11797
11803
|
/* harmony import */ var _static_dependencies_scure_base_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9651);
|
|
11804
|
+
/* harmony import */ var _static_dependencies_jsencrypt_lib_asn1js_base64_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9285);
|
|
11798
11805
|
/* ------------------------------------------------------------------------ */
|
|
11799
11806
|
|
|
11800
11807
|
|
|
11808
|
+
|
|
11801
11809
|
/* ------------------------------------------------------------------------ */
|
|
11802
11810
|
const encoders = {
|
|
11803
11811
|
binary: x => x,
|
|
@@ -11826,11 +11834,18 @@ function ecdsa(request, secret, curve, prehash = null) {
|
|
|
11826
11834
|
'v': signature.recovery,
|
|
11827
11835
|
};
|
|
11828
11836
|
}
|
|
11829
|
-
function
|
|
11837
|
+
function axolotl(request, secret, curve) {
|
|
11830
11838
|
// used for waves.exchange (that's why the output is base58)
|
|
11831
|
-
const signature = curve.
|
|
11839
|
+
const signature = curve.signModified(request, secret);
|
|
11832
11840
|
return _static_dependencies_scure_base_index_js__WEBPACK_IMPORTED_MODULE_0__/* .base58.encode */ .Jq.encode(signature);
|
|
11833
11841
|
}
|
|
11842
|
+
function eddsa(request, secret, curve) {
|
|
11843
|
+
// secret is the base64 pem encoded key
|
|
11844
|
+
// we get the last 32 bytes
|
|
11845
|
+
const privateKey = new Uint8Array(_static_dependencies_jsencrypt_lib_asn1js_base64_js__WEBPACK_IMPORTED_MODULE_2__/* .Base64.unarmor */ .D.unarmor(secret).slice(16));
|
|
11846
|
+
const signature = curve.sign(request, privateKey);
|
|
11847
|
+
return _static_dependencies_scure_base_index_js__WEBPACK_IMPORTED_MODULE_0__/* .base64.encode */ .US.encode(signature);
|
|
11848
|
+
}
|
|
11834
11849
|
/* ------------------------------------------------------------------------ */
|
|
11835
11850
|
// source: https://stackoverflow.com/a/18639975/1067003
|
|
11836
11851
|
function crc32(str, signed = false) {
|
|
@@ -12009,11 +12024,13 @@ const filterBy = (x, k, value = undefined, out = []) => {
|
|
|
12009
12024
|
}
|
|
12010
12025
|
return out;
|
|
12011
12026
|
};
|
|
12012
|
-
const sortBy = (array, key, descending = false, direction = descending ? -1 : 1) => array.sort((a, b) => {
|
|
12013
|
-
|
|
12027
|
+
const sortBy = (array, key, descending = false, defaultValue = 0, direction = descending ? -1 : 1) => array.sort((a, b) => {
|
|
12028
|
+
const first = (key in a) ? a[key] : defaultValue;
|
|
12029
|
+
const second = (key in b) ? b[key] : defaultValue;
|
|
12030
|
+
if (first < second) {
|
|
12014
12031
|
return -direction;
|
|
12015
12032
|
}
|
|
12016
|
-
else if (
|
|
12033
|
+
else if (first > second) {
|
|
12017
12034
|
return direction;
|
|
12018
12035
|
}
|
|
12019
12036
|
else {
|
|
@@ -16133,6 +16150,8 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
16133
16150
|
/* harmony import */ var _base_functions_number_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9292);
|
|
16134
16151
|
/* harmony import */ var _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1372);
|
|
16135
16152
|
/* harmony import */ var _base_functions_rsa_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5981);
|
|
16153
|
+
/* harmony import */ var _base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(6890);
|
|
16154
|
+
/* harmony import */ var _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(8817);
|
|
16136
16155
|
// ---------------------------------------------------------------------------
|
|
16137
16156
|
|
|
16138
16157
|
|
|
@@ -16140,6 +16159,8 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
16140
16159
|
|
|
16141
16160
|
|
|
16142
16161
|
|
|
16162
|
+
|
|
16163
|
+
|
|
16143
16164
|
// ---------------------------------------------------------------------------
|
|
16144
16165
|
/**
|
|
16145
16166
|
* @class binance
|
|
@@ -16169,6 +16190,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
16169
16190
|
'cancelOrders': true,
|
|
16170
16191
|
'createDepositAddress': false,
|
|
16171
16192
|
'createOrder': true,
|
|
16193
|
+
'createOrders': true,
|
|
16172
16194
|
'createPostOnlyOrder': true,
|
|
16173
16195
|
'createReduceOnlyOrder': true,
|
|
16174
16196
|
'createStopLimitOrder': true,
|
|
@@ -20397,7 +20419,17 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
20397
20419
|
// "lastTrade": {"id":"69","time":"1676084430567","price":"24.9","qty":"1.00"},
|
|
20398
20420
|
// "mmp": false
|
|
20399
20421
|
// }
|
|
20422
|
+
// {
|
|
20423
|
+
// cancelOrders/createOrders
|
|
20424
|
+
// "code": -4005,
|
|
20425
|
+
// "msg": "Quantity greater than max quantity."
|
|
20426
|
+
// },
|
|
20400
20427
|
//
|
|
20428
|
+
const code = this.safeString(order, 'code');
|
|
20429
|
+
if (code !== undefined) {
|
|
20430
|
+
// cancelOrders/createOrders might have a partial success
|
|
20431
|
+
return this.safeOrder({ 'info': order, 'status': 'rejected' }, market);
|
|
20432
|
+
}
|
|
20401
20433
|
const status = this.parseOrderStatus(this.safeString(order, 'status'));
|
|
20402
20434
|
const marketId = this.safeString(order, 'symbol');
|
|
20403
20435
|
const marketType = ('closePosition' in order) ? 'contract' : 'spot';
|
|
@@ -20471,6 +20503,85 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
20471
20503
|
'trades': fills,
|
|
20472
20504
|
}, market);
|
|
20473
20505
|
}
|
|
20506
|
+
async createOrders(orders, params = {}) {
|
|
20507
|
+
/**
|
|
20508
|
+
* @method
|
|
20509
|
+
* @name binance#createOrders
|
|
20510
|
+
* @description *contract only* create a list of trade orders
|
|
20511
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#place-multiple-orders-trade
|
|
20512
|
+
* @param {array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
|
20513
|
+
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
20514
|
+
*/
|
|
20515
|
+
await this.loadMarkets();
|
|
20516
|
+
const ordersRequests = [];
|
|
20517
|
+
let orderSymbols = [];
|
|
20518
|
+
for (let i = 0; i < orders.length; i++) {
|
|
20519
|
+
const rawOrder = orders[i];
|
|
20520
|
+
const marketId = this.safeString(rawOrder, 'symbol');
|
|
20521
|
+
orderSymbols.push(marketId);
|
|
20522
|
+
const type = this.safeString(rawOrder, 'type');
|
|
20523
|
+
const side = this.safeString(rawOrder, 'side');
|
|
20524
|
+
const amount = this.safeValue(rawOrder, 'amount');
|
|
20525
|
+
const price = this.safeValue(rawOrder, 'price');
|
|
20526
|
+
const orderParams = this.safeValue(rawOrder, 'params', {});
|
|
20527
|
+
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
|
|
20528
|
+
ordersRequests.push(orderRequest);
|
|
20529
|
+
}
|
|
20530
|
+
orderSymbols = this.marketSymbols(orderSymbols, undefined, false, true, true);
|
|
20531
|
+
const market = this.market(orderSymbols[0]);
|
|
20532
|
+
if (market['spot']) {
|
|
20533
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' createOrders() does not support ' + market['type'] + ' orders');
|
|
20534
|
+
}
|
|
20535
|
+
let response = undefined;
|
|
20536
|
+
let request = {
|
|
20537
|
+
'batchOrders': ordersRequests,
|
|
20538
|
+
};
|
|
20539
|
+
request = this.extend(request, params);
|
|
20540
|
+
if (market['linear']) {
|
|
20541
|
+
response = await this.fapiPrivatePostBatchOrders(request);
|
|
20542
|
+
}
|
|
20543
|
+
else if (market['option']) {
|
|
20544
|
+
response = await this.eapiPrivatePostBatchOrders(request);
|
|
20545
|
+
}
|
|
20546
|
+
else {
|
|
20547
|
+
response = await this.dapiPrivatePostBatchOrders(request);
|
|
20548
|
+
}
|
|
20549
|
+
//
|
|
20550
|
+
// [
|
|
20551
|
+
// {
|
|
20552
|
+
// "code": -4005,
|
|
20553
|
+
// "msg": "Quantity greater than max quantity."
|
|
20554
|
+
// },
|
|
20555
|
+
// {
|
|
20556
|
+
// "orderId": 650640530,
|
|
20557
|
+
// "symbol": "LTCUSDT",
|
|
20558
|
+
// "status": "NEW",
|
|
20559
|
+
// "clientOrderId": "x-xcKtGhcu32184eb13585491289bbaf",
|
|
20560
|
+
// "price": "54.00",
|
|
20561
|
+
// "avgPrice": "0.00",
|
|
20562
|
+
// "origQty": "0.100",
|
|
20563
|
+
// "executedQty": "0.000",
|
|
20564
|
+
// "cumQty": "0.000",
|
|
20565
|
+
// "cumQuote": "0.00000",
|
|
20566
|
+
// "timeInForce": "GTC",
|
|
20567
|
+
// "type": "LIMIT",
|
|
20568
|
+
// "reduceOnly": false,
|
|
20569
|
+
// "closePosition": false,
|
|
20570
|
+
// "side": "BUY",
|
|
20571
|
+
// "positionSide": "BOTH",
|
|
20572
|
+
// "stopPrice": "0.00",
|
|
20573
|
+
// "workingType": "CONTRACT_PRICE",
|
|
20574
|
+
// "priceProtect": false,
|
|
20575
|
+
// "origType": "LIMIT",
|
|
20576
|
+
// "priceMatch": "NONE",
|
|
20577
|
+
// "selfTradePreventionMode": "NONE",
|
|
20578
|
+
// "goodTillDate": 0,
|
|
20579
|
+
// "updateTime": 1698073926929
|
|
20580
|
+
// }
|
|
20581
|
+
// ]
|
|
20582
|
+
//
|
|
20583
|
+
return this.parseOrders(response);
|
|
20584
|
+
}
|
|
20474
20585
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
20475
20586
|
/**
|
|
20476
20587
|
* @method
|
|
@@ -24566,6 +24677,12 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
24566
24677
|
}
|
|
24567
24678
|
}
|
|
24568
24679
|
let query = undefined;
|
|
24680
|
+
// handle batchOrders
|
|
24681
|
+
if ((path === 'batchOrders') && (method === 'POST')) {
|
|
24682
|
+
const batchOrders = this.safeValue(params, 'batchOrders');
|
|
24683
|
+
const queryBatch = (this.json(batchOrders));
|
|
24684
|
+
params['batchOrders'] = queryBatch;
|
|
24685
|
+
}
|
|
24569
24686
|
const defaultRecvWindow = this.safeInteger(this.options, 'recvWindow');
|
|
24570
24687
|
let extendedParams = this.extend({
|
|
24571
24688
|
'timestamp': this.nonce(),
|
|
@@ -24604,7 +24721,12 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
24604
24721
|
}
|
|
24605
24722
|
let signature = undefined;
|
|
24606
24723
|
if (this.secret.indexOf('PRIVATE KEY') > -1) {
|
|
24607
|
-
|
|
24724
|
+
if (this.secret.length > 120) {
|
|
24725
|
+
signature = this.encodeURIComponent((0,_base_functions_rsa_js__WEBPACK_IMPORTED_MODULE_4__/* .rsa */ .j)(query, this.secret, _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_5__/* .sha256 */ .J));
|
|
24726
|
+
}
|
|
24727
|
+
else {
|
|
24728
|
+
signature = this.encodeURIComponent((0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_6__/* .eddsa */ .UZ)(this.encode(query), this.secret, _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_7__/* .ed25519 */ .UN));
|
|
24729
|
+
}
|
|
24608
24730
|
}
|
|
24609
24731
|
else {
|
|
24610
24732
|
signature = this.hmac(this.encode(query), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_5__/* .sha256 */ .J);
|
|
@@ -24703,10 +24825,10 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
24703
24825
|
}
|
|
24704
24826
|
if (Array.isArray(response)) {
|
|
24705
24827
|
// cancelOrders returns an array like this: [{"code":-2011,"msg":"Unknown order sent."}]
|
|
24706
|
-
const
|
|
24707
|
-
if (
|
|
24708
|
-
const
|
|
24709
|
-
const errorCode = this.safeString(
|
|
24828
|
+
const arrayLength = response.length;
|
|
24829
|
+
if (arrayLength === 1) { // when there's a single error we can throw, otherwise we have a partial success
|
|
24830
|
+
const element = response[0];
|
|
24831
|
+
const errorCode = this.safeString(element, 'code');
|
|
24710
24832
|
if (errorCode !== undefined) {
|
|
24711
24833
|
this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, this.id + ' ' + body);
|
|
24712
24834
|
}
|
|
@@ -38711,6 +38833,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
38711
38833
|
'cancelOrder': true,
|
|
38712
38834
|
'cancelOrders': true,
|
|
38713
38835
|
'createOrder': true,
|
|
38836
|
+
'createOrders': true,
|
|
38714
38837
|
'createReduceOnlyOrder': false,
|
|
38715
38838
|
'editOrder': true,
|
|
38716
38839
|
'fetchAccounts': false,
|
|
@@ -38736,10 +38859,12 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
38736
38859
|
'fetchLedger': true,
|
|
38737
38860
|
'fetchLeverage': true,
|
|
38738
38861
|
'fetchLeverageTiers': false,
|
|
38862
|
+
'fetchLiquidations': false,
|
|
38739
38863
|
'fetchMarginMode': undefined,
|
|
38740
38864
|
'fetchMarketLeverageTiers': true,
|
|
38741
38865
|
'fetchMarkets': true,
|
|
38742
38866
|
'fetchMarkOHLCV': true,
|
|
38867
|
+
'fetchMyLiquidations': true,
|
|
38743
38868
|
'fetchMyTrades': true,
|
|
38744
38869
|
'fetchOHLCV': true,
|
|
38745
38870
|
'fetchOpenInterest': true,
|
|
@@ -41657,7 +41782,23 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
41657
41782
|
// "fillTotalAmount": "0",
|
|
41658
41783
|
// "ctime": "1697773902588"
|
|
41659
41784
|
// }
|
|
41785
|
+
// cancelOrders failing
|
|
41660
41786
|
//
|
|
41787
|
+
// {
|
|
41788
|
+
// "orderId": "1627293504611",
|
|
41789
|
+
// "clientOid": "BITGET#1627293504611",
|
|
41790
|
+
// "errorMsg":"Duplicate clientOid"
|
|
41791
|
+
// }
|
|
41792
|
+
//
|
|
41793
|
+
const errorMessage = this.safeString(order, 'errorMsg');
|
|
41794
|
+
if (errorMessage !== undefined) {
|
|
41795
|
+
return this.safeOrder({
|
|
41796
|
+
'info': order,
|
|
41797
|
+
'id': this.safeString(order, 'orderId'),
|
|
41798
|
+
'clientOrderId': this.safeString(order, 'clientOrderId'),
|
|
41799
|
+
'status': 'rejected',
|
|
41800
|
+
}, market);
|
|
41801
|
+
}
|
|
41661
41802
|
const marketId = this.safeString(order, 'symbol');
|
|
41662
41803
|
market = this.safeMarket(marketId, market);
|
|
41663
41804
|
const timestamp = this.safeInteger2(order, 'cTime', 'ctime');
|
|
@@ -41748,9 +41889,60 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
41748
41889
|
*/
|
|
41749
41890
|
await this.loadMarkets();
|
|
41750
41891
|
const market = this.market(symbol);
|
|
41751
|
-
let marketType = undefined;
|
|
41752
41892
|
let marginMode = undefined;
|
|
41893
|
+
[marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
|
|
41894
|
+
const triggerPrice = this.safeValue2(params, 'stopPrice', 'triggerPrice');
|
|
41895
|
+
const stopLossTriggerPrice = this.safeValue(params, 'stopLossPrice');
|
|
41896
|
+
const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
|
|
41897
|
+
const isTriggerOrder = triggerPrice !== undefined;
|
|
41898
|
+
const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
|
|
41899
|
+
const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
|
|
41900
|
+
const isStopLossOrTakeProfitTrigger = isStopLossTriggerOrder || isTakeProfitTriggerOrder;
|
|
41901
|
+
const request = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
41753
41902
|
let response = undefined;
|
|
41903
|
+
if (market['spot']) {
|
|
41904
|
+
if (isTriggerOrder) {
|
|
41905
|
+
response = await this.privateSpotPostPlanPlacePlan(request);
|
|
41906
|
+
}
|
|
41907
|
+
else if (marginMode === 'isolated') {
|
|
41908
|
+
response = await this.privateMarginPostIsolatedOrderPlaceOrder(request);
|
|
41909
|
+
}
|
|
41910
|
+
else if (marginMode === 'cross') {
|
|
41911
|
+
response = await this.privateMarginPostCrossOrderPlaceOrder(request);
|
|
41912
|
+
}
|
|
41913
|
+
else {
|
|
41914
|
+
response = await this.privateSpotPostTradeOrders(request);
|
|
41915
|
+
}
|
|
41916
|
+
}
|
|
41917
|
+
else {
|
|
41918
|
+
if (isTriggerOrder) {
|
|
41919
|
+
response = await this.privateMixPostPlanPlacePlan(request);
|
|
41920
|
+
}
|
|
41921
|
+
else if (isStopLossOrTakeProfitTrigger) {
|
|
41922
|
+
response = await this.privateMixPostPlanPlacePositionsTPSL(request);
|
|
41923
|
+
}
|
|
41924
|
+
else {
|
|
41925
|
+
response = await this.privateMixPostOrderPlaceOrder(request);
|
|
41926
|
+
}
|
|
41927
|
+
}
|
|
41928
|
+
//
|
|
41929
|
+
// {
|
|
41930
|
+
// "code": "00000",
|
|
41931
|
+
// "msg": "success",
|
|
41932
|
+
// "requestTime": 1645932209602,
|
|
41933
|
+
// "data": {
|
|
41934
|
+
// "orderId": "881669078313766912",
|
|
41935
|
+
// "clientOrderId": "iauIBf#a45b595f96474d888d0ada"
|
|
41936
|
+
// }
|
|
41937
|
+
// }
|
|
41938
|
+
//
|
|
41939
|
+
const data = this.safeValue(response, 'data', {});
|
|
41940
|
+
return this.parseOrder(data, market);
|
|
41941
|
+
}
|
|
41942
|
+
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
41943
|
+
const market = this.market(symbol);
|
|
41944
|
+
let marketType = undefined;
|
|
41945
|
+
let marginMode = undefined;
|
|
41754
41946
|
[marketType, params] = this.handleMarketTypeAndParams('createOrder', market, params);
|
|
41755
41947
|
[marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
|
|
41756
41948
|
const marketId = market['id'];
|
|
@@ -41848,7 +42040,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
41848
42040
|
if (price !== undefined) {
|
|
41849
42041
|
request['executePrice'] = this.priceToPrecision(symbol, price);
|
|
41850
42042
|
}
|
|
41851
|
-
response = await this.privateMixPostPlanPlacePlan(this.extend(request, params));
|
|
41852
42043
|
}
|
|
41853
42044
|
else if (isStopLossOrTakeProfitTrigger) {
|
|
41854
42045
|
if (isStopLossTriggerOrder) {
|
|
@@ -41859,7 +42050,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
41859
42050
|
request['triggerPrice'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
|
|
41860
42051
|
request['planType'] = 'pos_profit';
|
|
41861
42052
|
}
|
|
41862
|
-
response = await this.privateMixPostPlanPlacePositionsTPSL(this.extend(request, params));
|
|
41863
42053
|
}
|
|
41864
42054
|
else {
|
|
41865
42055
|
if (isStopLoss) {
|
|
@@ -41870,7 +42060,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
41870
42060
|
const tpTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice');
|
|
41871
42061
|
request['presetTakeProfitPrice'] = this.priceToPrecision(symbol, tpTriggerPrice);
|
|
41872
42062
|
}
|
|
41873
|
-
response = await this.privateMixPostOrderPlaceOrder(this.extend(request, params));
|
|
41874
42063
|
}
|
|
41875
42064
|
}
|
|
41876
42065
|
else if (marketType === 'spot') {
|
|
@@ -41906,7 +42095,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
41906
42095
|
if (clientOrderId !== undefined) {
|
|
41907
42096
|
request['clientOrderId'] = clientOrderId;
|
|
41908
42097
|
}
|
|
41909
|
-
response = await this.privateSpotPostPlanPlacePlan(this.extend(request, params));
|
|
41910
42098
|
}
|
|
41911
42099
|
else if (marginMode !== undefined) {
|
|
41912
42100
|
request['loanType'] = 'normal';
|
|
@@ -41919,12 +42107,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
41919
42107
|
else {
|
|
41920
42108
|
request['baseQuantity'] = quantity;
|
|
41921
42109
|
}
|
|
41922
|
-
if (marginMode === 'isolated') {
|
|
41923
|
-
response = await this.privateMarginPostIsolatedOrderPlaceOrder(this.extend(request, params));
|
|
41924
|
-
}
|
|
41925
|
-
else if (marginMode === 'cross') {
|
|
41926
|
-
response = await this.privateMarginPostCrossOrderPlaceOrder(this.extend(request, params));
|
|
41927
|
-
}
|
|
41928
42110
|
}
|
|
41929
42111
|
else {
|
|
41930
42112
|
if (clientOrderId !== undefined) {
|
|
@@ -41933,25 +42115,86 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
41933
42115
|
if (quantity !== undefined) {
|
|
41934
42116
|
request['quantity'] = quantity;
|
|
41935
42117
|
}
|
|
41936
|
-
response = await this.privateSpotPostTradeOrders(this.extend(request, params));
|
|
41937
42118
|
}
|
|
41938
42119
|
}
|
|
41939
42120
|
else {
|
|
41940
42121
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' createOrder() does not support ' + marketType + ' orders');
|
|
41941
42122
|
}
|
|
42123
|
+
return this.extend(request, params);
|
|
42124
|
+
}
|
|
42125
|
+
async createOrders(orders, params = {}) {
|
|
42126
|
+
/**
|
|
42127
|
+
* @method
|
|
42128
|
+
* @name bitget#createOrders
|
|
42129
|
+
* @description create a list of trade orders (all orders should be of the same symbol)
|
|
42130
|
+
* @see https://bitgetlimited.github.io/apidoc/en/spot/#batch-order
|
|
42131
|
+
* @see https://bitgetlimited.github.io/apidoc/en/mix/#batch-order
|
|
42132
|
+
* @param {array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
|
42133
|
+
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
42134
|
+
*/
|
|
42135
|
+
await this.loadMarkets();
|
|
42136
|
+
const ordersRequests = [];
|
|
42137
|
+
let symbol = undefined;
|
|
42138
|
+
for (let i = 0; i < orders.length; i++) {
|
|
42139
|
+
const rawOrder = orders[i];
|
|
42140
|
+
const marketId = this.safeString(rawOrder, 'symbol');
|
|
42141
|
+
if (symbol === undefined) {
|
|
42142
|
+
symbol = marketId;
|
|
42143
|
+
}
|
|
42144
|
+
else {
|
|
42145
|
+
if (symbol !== marketId) {
|
|
42146
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest(this.id + ' createOrders() requires all orders to have the same symbol');
|
|
42147
|
+
}
|
|
42148
|
+
}
|
|
42149
|
+
const type = this.safeString(rawOrder, 'type');
|
|
42150
|
+
const side = this.safeString(rawOrder, 'side');
|
|
42151
|
+
const amount = this.safeValue(rawOrder, 'amount');
|
|
42152
|
+
const price = this.safeValue(rawOrder, 'price');
|
|
42153
|
+
const orderParams = this.safeValue(rawOrder, 'params', {});
|
|
42154
|
+
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
|
|
42155
|
+
ordersRequests.push(orderRequest);
|
|
42156
|
+
}
|
|
42157
|
+
const market = this.market(symbol);
|
|
42158
|
+
const request = {
|
|
42159
|
+
'symbol': market['id'],
|
|
42160
|
+
};
|
|
42161
|
+
let response = undefined;
|
|
42162
|
+
if (market['spot']) {
|
|
42163
|
+
request['orderList'] = ordersRequests;
|
|
42164
|
+
response = await this.privateSpotPostTradeBatchOrders(request);
|
|
42165
|
+
}
|
|
42166
|
+
else {
|
|
42167
|
+
request['orderDataList'] = ordersRequests;
|
|
42168
|
+
request['marginCoin'] = market['settleId'];
|
|
42169
|
+
response = await this.privateMixPostOrderBatchOrders(request);
|
|
42170
|
+
}
|
|
41942
42171
|
//
|
|
41943
|
-
//
|
|
41944
|
-
//
|
|
41945
|
-
//
|
|
41946
|
-
//
|
|
41947
|
-
//
|
|
41948
|
-
//
|
|
41949
|
-
//
|
|
42172
|
+
// {
|
|
42173
|
+
// "code": "00000",
|
|
42174
|
+
// "data": {
|
|
42175
|
+
// "orderInfo": [
|
|
42176
|
+
// {
|
|
42177
|
+
// "orderId": "1627293504612",
|
|
42178
|
+
// "clientOid": "BITGET#1627293504612"
|
|
41950
42179
|
// }
|
|
41951
|
-
//
|
|
42180
|
+
// ],
|
|
42181
|
+
// "failure":[
|
|
42182
|
+
// {
|
|
42183
|
+
// "orderId": "1627293504611",
|
|
42184
|
+
// "clientOid": "BITGET#1627293504611",
|
|
42185
|
+
// "errorMsg":"Duplicate clientOid"
|
|
42186
|
+
// }
|
|
42187
|
+
// ]
|
|
42188
|
+
// },
|
|
42189
|
+
// "msg": "success",
|
|
42190
|
+
// "requestTime": 1627293504612
|
|
42191
|
+
// }
|
|
41952
42192
|
//
|
|
41953
42193
|
const data = this.safeValue(response, 'data', {});
|
|
41954
|
-
|
|
42194
|
+
const failure = this.safeValue(data, 'failure', []);
|
|
42195
|
+
const orderInfo = this.safeValue2(data, 'orderInfo', 'resultList', []);
|
|
42196
|
+
const both = this.arrayConcat(orderInfo, failure);
|
|
42197
|
+
return this.parseOrders(both);
|
|
41955
42198
|
}
|
|
41956
42199
|
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
41957
42200
|
/**
|
|
@@ -44587,6 +44830,153 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
44587
44830
|
'info': info,
|
|
44588
44831
|
};
|
|
44589
44832
|
}
|
|
44833
|
+
async fetchMyLiquidations(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
44834
|
+
/**
|
|
44835
|
+
* @method
|
|
44836
|
+
* @name bitget#fetchMyLiquidations
|
|
44837
|
+
* @description retrieves the users liquidated positions
|
|
44838
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-isolated-liquidation-records
|
|
44839
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-cross-liquidation-records
|
|
44840
|
+
* @param {string} [symbol] unified CCXT market symbol
|
|
44841
|
+
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
44842
|
+
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
44843
|
+
* @param {object} [params] exchange specific parameters for the bitget api endpoint
|
|
44844
|
+
* @param {int} [params.until] timestamp in ms of the latest liquidation
|
|
44845
|
+
* @param {string} [params.marginMode] 'cross' or 'isolated' default value is 'cross'
|
|
44846
|
+
* @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
|
|
44847
|
+
*/
|
|
44848
|
+
await this.loadMarkets();
|
|
44849
|
+
let market = undefined;
|
|
44850
|
+
if (symbol !== undefined) {
|
|
44851
|
+
market = this.market(symbol);
|
|
44852
|
+
}
|
|
44853
|
+
let type = undefined;
|
|
44854
|
+
[type, params] = this.handleMarketTypeAndParams('fetchMyLiquidations', market, params);
|
|
44855
|
+
if (type !== 'spot') {
|
|
44856
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' fetchMyLiquidations() supports spot margin markets only');
|
|
44857
|
+
}
|
|
44858
|
+
let request = {};
|
|
44859
|
+
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
44860
|
+
if (since !== undefined) {
|
|
44861
|
+
request['startTime'] = since;
|
|
44862
|
+
}
|
|
44863
|
+
else {
|
|
44864
|
+
request['startTime'] = this.milliseconds() - 7776000000;
|
|
44865
|
+
}
|
|
44866
|
+
if (limit !== undefined) {
|
|
44867
|
+
request['pageSize'] = limit;
|
|
44868
|
+
}
|
|
44869
|
+
let response = undefined;
|
|
44870
|
+
let marginMode = undefined;
|
|
44871
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchMyLiquidations', params, 'cross');
|
|
44872
|
+
if (marginMode === 'isolated') {
|
|
44873
|
+
this.checkRequiredSymbol('fetchMyLiquidations', symbol);
|
|
44874
|
+
request['symbol'] = market['info']['symbolName'];
|
|
44875
|
+
response = await this.privateMarginGetIsolatedLiquidationList(this.extend(request, params));
|
|
44876
|
+
}
|
|
44877
|
+
else if (marginMode === 'cross') {
|
|
44878
|
+
response = await this.privateMarginGetCrossLiquidationList(this.extend(request, params));
|
|
44879
|
+
}
|
|
44880
|
+
//
|
|
44881
|
+
// isolated
|
|
44882
|
+
//
|
|
44883
|
+
// {
|
|
44884
|
+
// "code": "00000",
|
|
44885
|
+
// "msg": "success",
|
|
44886
|
+
// "requestTime": 1698114119193,
|
|
44887
|
+
// "data": {
|
|
44888
|
+
// "resultList": [
|
|
44889
|
+
// {
|
|
44890
|
+
// "liqId": "123",
|
|
44891
|
+
// "symbol": "BTCUSDT",
|
|
44892
|
+
// "liqStartTime": "1653453245342",
|
|
44893
|
+
// "liqEndTime": "16312423423432",
|
|
44894
|
+
// "liqRisk": "1.01",
|
|
44895
|
+
// "totalAssets": "1242.34",
|
|
44896
|
+
// "totalDebt": "1100",
|
|
44897
|
+
// "LiqFee": "1.2",
|
|
44898
|
+
// "cTime": "1653453245342"
|
|
44899
|
+
// }
|
|
44900
|
+
// ],
|
|
44901
|
+
// "maxId": "0",
|
|
44902
|
+
// "minId": "0"
|
|
44903
|
+
// }
|
|
44904
|
+
// }
|
|
44905
|
+
//
|
|
44906
|
+
// cross
|
|
44907
|
+
//
|
|
44908
|
+
// {
|
|
44909
|
+
// "code": "00000",
|
|
44910
|
+
// "msg": "success",
|
|
44911
|
+
// "requestTime": 1698114119193,
|
|
44912
|
+
// "data": {
|
|
44913
|
+
// "resultList": [
|
|
44914
|
+
// {
|
|
44915
|
+
// "liqId": "123",
|
|
44916
|
+
// "liqStartTime": "1653453245342",
|
|
44917
|
+
// "liqEndTime": "16312423423432",
|
|
44918
|
+
// "liqRisk": "1.01",
|
|
44919
|
+
// "totalAssets": "1242.34",
|
|
44920
|
+
// "totalDebt": "1100",
|
|
44921
|
+
// "LiqFee": "1.2",
|
|
44922
|
+
// "cTime": "1653453245342"
|
|
44923
|
+
// }
|
|
44924
|
+
// ],
|
|
44925
|
+
// "maxId": "0",
|
|
44926
|
+
// "minId": "0"
|
|
44927
|
+
// }
|
|
44928
|
+
// }
|
|
44929
|
+
//
|
|
44930
|
+
const data = this.safeValue(response, 'data', {});
|
|
44931
|
+
const liquidations = this.safeValue(data, 'resultList', []);
|
|
44932
|
+
return this.parseLiquidations(liquidations, market, since, limit);
|
|
44933
|
+
}
|
|
44934
|
+
parseLiquidation(liquidation, market = undefined) {
|
|
44935
|
+
//
|
|
44936
|
+
// isolated
|
|
44937
|
+
//
|
|
44938
|
+
// {
|
|
44939
|
+
// "liqId": "123",
|
|
44940
|
+
// "symbol": "BTCUSDT",
|
|
44941
|
+
// "liqStartTime": "1653453245342",
|
|
44942
|
+
// "liqEndTime": "16312423423432",
|
|
44943
|
+
// "liqRisk": "1.01",
|
|
44944
|
+
// "totalAssets": "1242.34",
|
|
44945
|
+
// "totalDebt": "1100",
|
|
44946
|
+
// "LiqFee": "1.2",
|
|
44947
|
+
// "cTime": "1653453245342"
|
|
44948
|
+
// }
|
|
44949
|
+
//
|
|
44950
|
+
// cross
|
|
44951
|
+
//
|
|
44952
|
+
// {
|
|
44953
|
+
// "liqId": "123",
|
|
44954
|
+
// "liqStartTime": "1653453245342",
|
|
44955
|
+
// "liqEndTime": "16312423423432",
|
|
44956
|
+
// "liqRisk": "1.01",
|
|
44957
|
+
// "totalAssets": "1242.34",
|
|
44958
|
+
// "totalDebt": "1100",
|
|
44959
|
+
// "LiqFee": "1.2",
|
|
44960
|
+
// "cTime": "1653453245342"
|
|
44961
|
+
// }
|
|
44962
|
+
//
|
|
44963
|
+
const marketId = this.safeString(liquidation, 'symbol');
|
|
44964
|
+
const timestamp = this.safeInteger(liquidation, 'liqEndTime');
|
|
44965
|
+
const liquidationFee = this.safeString(liquidation, 'LiqFee');
|
|
44966
|
+
const totalDebt = this.safeString(liquidation, 'totalDebt');
|
|
44967
|
+
const quoteValueString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringAdd */ .O.stringAdd(liquidationFee, totalDebt);
|
|
44968
|
+
return {
|
|
44969
|
+
'info': liquidation,
|
|
44970
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
44971
|
+
'contracts': undefined,
|
|
44972
|
+
'contractSize': undefined,
|
|
44973
|
+
'price': undefined,
|
|
44974
|
+
'baseValue': undefined,
|
|
44975
|
+
'quoteValue': this.parseNumber(quoteValueString),
|
|
44976
|
+
'timestamp': timestamp,
|
|
44977
|
+
'datetime': this.iso8601(timestamp),
|
|
44978
|
+
};
|
|
44979
|
+
}
|
|
44590
44980
|
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
44591
44981
|
if (!response) {
|
|
44592
44982
|
return undefined; // fallback to default error handler
|
|
@@ -73044,6 +73434,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
73044
73434
|
'cancelAllOrders': true,
|
|
73045
73435
|
'cancelOrder': true,
|
|
73046
73436
|
'createOrder': true,
|
|
73437
|
+
'createOrders': true,
|
|
73047
73438
|
'createPostOnlyOrder': true,
|
|
73048
73439
|
'createReduceOnlyOrder': true,
|
|
73049
73440
|
'createStopLimitOrder': true,
|
|
@@ -74459,7 +74850,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
74459
74850
|
}
|
|
74460
74851
|
return super.safeMarket(marketId, market, delimiter, marketType);
|
|
74461
74852
|
}
|
|
74462
|
-
getBybitType(method, market, params) {
|
|
74853
|
+
getBybitType(method, market, params = {}) {
|
|
74463
74854
|
let type = undefined;
|
|
74464
74855
|
[type, params] = this.handleMarketTypeAndParams(method, market, params);
|
|
74465
74856
|
let subType = undefined;
|
|
@@ -76522,7 +76913,31 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
76522
76913
|
// "createdTime": "1684476068369",
|
|
76523
76914
|
// "updatedTime": "1684476068372"
|
|
76524
76915
|
// }
|
|
76916
|
+
// createOrders failed order
|
|
76917
|
+
// {
|
|
76918
|
+
// category: 'linear',
|
|
76919
|
+
// symbol: 'LTCUSDT',
|
|
76920
|
+
// orderId: '',
|
|
76921
|
+
// orderLinkId: '',
|
|
76922
|
+
// createAt: '',
|
|
76923
|
+
// code: '10001',
|
|
76924
|
+
// msg: 'The number of contracts exceeds maximum limit allowed: too large'
|
|
76925
|
+
// }
|
|
76525
76926
|
//
|
|
76927
|
+
const code = this.safeString(order, 'code');
|
|
76928
|
+
if (code !== undefined) {
|
|
76929
|
+
if (code !== '0') {
|
|
76930
|
+
const category = this.safeString(order, 'category');
|
|
76931
|
+
const inferedMarketType = (category === 'spot') ? 'spot' : 'contract';
|
|
76932
|
+
return this.safeOrder({
|
|
76933
|
+
'info': order,
|
|
76934
|
+
'status': 'rejected',
|
|
76935
|
+
'id': this.safeString(order, 'orderId'),
|
|
76936
|
+
'clientOrderId': this.safeString(order, 'orderLinkId'),
|
|
76937
|
+
'symbol': this.safeSymbol(this.safeString(order, 'symbol'), undefined, undefined, inferedMarketType),
|
|
76938
|
+
});
|
|
76939
|
+
}
|
|
76940
|
+
}
|
|
76526
76941
|
const marketId = this.safeString(order, 'symbol');
|
|
76527
76942
|
const isContract = ('tpslMode' in order);
|
|
76528
76943
|
let marketType = undefined;
|
|
@@ -76682,13 +77097,32 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
76682
77097
|
*/
|
|
76683
77098
|
await this.loadMarkets();
|
|
76684
77099
|
const market = this.market(symbol);
|
|
76685
|
-
symbol = market['symbol'];
|
|
76686
77100
|
const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
|
|
76687
77101
|
const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
|
|
76688
77102
|
const isUsdcSettled = market['settle'] === 'USDC';
|
|
76689
77103
|
if (isUsdcSettled && !isUnifiedAccount) {
|
|
76690
77104
|
return await this.createUsdcOrder(symbol, type, side, amount, price, params);
|
|
76691
77105
|
}
|
|
77106
|
+
const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
77107
|
+
const response = await this.privatePostV5OrderCreate(orderRequest); // already extended inside createOrderRequest
|
|
77108
|
+
//
|
|
77109
|
+
// {
|
|
77110
|
+
// "retCode": 0,
|
|
77111
|
+
// "retMsg": "OK",
|
|
77112
|
+
// "result": {
|
|
77113
|
+
// "orderId": "1321003749386327552",
|
|
77114
|
+
// "orderLinkId": "spot-test-postonly"
|
|
77115
|
+
// },
|
|
77116
|
+
// "retExtInfo": {},
|
|
77117
|
+
// "time": 1672211918471
|
|
77118
|
+
// }
|
|
77119
|
+
//
|
|
77120
|
+
const order = this.safeValue(response, 'result', {});
|
|
77121
|
+
return this.parseOrder(order, market);
|
|
77122
|
+
}
|
|
77123
|
+
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
77124
|
+
const market = this.market(symbol);
|
|
77125
|
+
symbol = market['symbol'];
|
|
76692
77126
|
const lowerCaseType = type.toLowerCase();
|
|
76693
77127
|
if ((price === undefined) && (lowerCaseType === 'limit')) {
|
|
76694
77128
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' createOrder requires a price argument for limit orders');
|
|
@@ -76830,21 +77264,94 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
76830
77264
|
request['orderLinkId'] = this.uuid16();
|
|
76831
77265
|
}
|
|
76832
77266
|
params = this.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit']);
|
|
76833
|
-
|
|
77267
|
+
return this.extend(request, params);
|
|
77268
|
+
}
|
|
77269
|
+
async createOrders(orders, params = {}) {
|
|
77270
|
+
/**
|
|
77271
|
+
* @method
|
|
77272
|
+
* @name bybit#createOrders
|
|
77273
|
+
* @description create a list of trade orders
|
|
77274
|
+
* @see https://bybit-exchange.github.io/docs/v5/order/batch-place
|
|
77275
|
+
* @param {array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
|
77276
|
+
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
77277
|
+
*/
|
|
77278
|
+
await this.loadMarkets();
|
|
77279
|
+
const ordersRequests = [];
|
|
77280
|
+
const orderSymbols = [];
|
|
77281
|
+
for (let i = 0; i < orders.length; i++) {
|
|
77282
|
+
const rawOrder = orders[i];
|
|
77283
|
+
const marketId = this.safeString(rawOrder, 'symbol');
|
|
77284
|
+
orderSymbols.push(marketId);
|
|
77285
|
+
const type = this.safeString(rawOrder, 'type');
|
|
77286
|
+
const side = this.safeString(rawOrder, 'side');
|
|
77287
|
+
const amount = this.safeValue(rawOrder, 'amount');
|
|
77288
|
+
const price = this.safeValue(rawOrder, 'price');
|
|
77289
|
+
const orderParams = this.safeValue(rawOrder, 'params', {});
|
|
77290
|
+
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
|
|
77291
|
+
ordersRequests.push(orderRequest);
|
|
77292
|
+
}
|
|
77293
|
+
const symbols = this.marketSymbols(orderSymbols, undefined, false, true, true);
|
|
77294
|
+
const market = this.market(symbols[0]);
|
|
77295
|
+
let category = undefined;
|
|
77296
|
+
[category, params] = this.getBybitType('createOrders', market, params);
|
|
77297
|
+
if ((category === 'spot') || (category === 'inverse')) {
|
|
77298
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' createOrders does not allow spot or inverse orders');
|
|
77299
|
+
}
|
|
77300
|
+
const request = {
|
|
77301
|
+
'category': category,
|
|
77302
|
+
'request': ordersRequests,
|
|
77303
|
+
};
|
|
77304
|
+
const response = await this.privatePostV5OrderCreateBatch(this.extend(request, params));
|
|
77305
|
+
const result = this.safeValue(response, 'result', {});
|
|
77306
|
+
const data = this.safeValue(result, 'list', []);
|
|
77307
|
+
const retInfo = this.safeValue(response, 'retExtInfo', {});
|
|
77308
|
+
const codes = this.safeValue(retInfo, 'list', []);
|
|
77309
|
+
// extend the error with the unsuccessful orders
|
|
77310
|
+
for (let i = 0; i < codes.length; i++) {
|
|
77311
|
+
const code = codes[i];
|
|
77312
|
+
const retCode = this.safeInteger(code, 'code');
|
|
77313
|
+
if (retCode !== 0) {
|
|
77314
|
+
data[i] = this.extend(data[i], code);
|
|
77315
|
+
}
|
|
77316
|
+
}
|
|
76834
77317
|
//
|
|
76835
|
-
//
|
|
76836
|
-
//
|
|
76837
|
-
//
|
|
76838
|
-
//
|
|
76839
|
-
//
|
|
76840
|
-
//
|
|
76841
|
-
//
|
|
76842
|
-
//
|
|
76843
|
-
//
|
|
76844
|
-
//
|
|
77318
|
+
// {
|
|
77319
|
+
// "retCode":0,
|
|
77320
|
+
// "retMsg":"OK",
|
|
77321
|
+
// "result":{
|
|
77322
|
+
// "list":[
|
|
77323
|
+
// {
|
|
77324
|
+
// "category":"linear",
|
|
77325
|
+
// "symbol":"LTCUSDT",
|
|
77326
|
+
// "orderId":"",
|
|
77327
|
+
// "orderLinkId":"",
|
|
77328
|
+
// "createAt":""
|
|
77329
|
+
// },
|
|
77330
|
+
// {
|
|
77331
|
+
// "category":"linear",
|
|
77332
|
+
// "symbol":"LTCUSDT",
|
|
77333
|
+
// "orderId":"3c9f65b6-01ad-4ac0-9741-df17e02a4223",
|
|
77334
|
+
// "orderLinkId":"",
|
|
77335
|
+
// "createAt":"1698075516029"
|
|
77336
|
+
// }
|
|
77337
|
+
// ]
|
|
77338
|
+
// },
|
|
77339
|
+
// "retExtInfo":{
|
|
77340
|
+
// "list":[
|
|
77341
|
+
// {
|
|
77342
|
+
// "code":10001,
|
|
77343
|
+
// "msg":"The number of contracts exceeds maximum limit allowed: too large"
|
|
77344
|
+
// },
|
|
77345
|
+
// {
|
|
77346
|
+
// "code":0,
|
|
77347
|
+
// "msg":"OK"
|
|
77348
|
+
// }
|
|
77349
|
+
// ]
|
|
77350
|
+
// },
|
|
77351
|
+
// "time":1698075516029
|
|
77352
|
+
// }
|
|
76845
77353
|
//
|
|
76846
|
-
|
|
76847
|
-
return this.parseOrder(order, market);
|
|
77354
|
+
return this.parseOrders(data);
|
|
76848
77355
|
}
|
|
76849
77356
|
async createUsdcOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
76850
77357
|
await this.loadMarkets();
|
|
@@ -98360,6 +98867,7 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
|
|
|
98360
98867
|
'cancelAllOrders': true,
|
|
98361
98868
|
'cancelOrder': true,
|
|
98362
98869
|
'createOrder': true,
|
|
98870
|
+
'createOrders': true,
|
|
98363
98871
|
'fetchAccounts': true,
|
|
98364
98872
|
'fetchBalance': true,
|
|
98365
98873
|
'fetchBidsAsks': false,
|
|
@@ -99494,6 +100002,210 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
|
|
|
99494
100002
|
const result = this.safeValue(response, 'result', {});
|
|
99495
100003
|
return this.parseOrder(result, market);
|
|
99496
100004
|
}
|
|
100005
|
+
async createOrders(orders, params = {}) {
|
|
100006
|
+
/**
|
|
100007
|
+
* @method
|
|
100008
|
+
* @name cryptocom#createOrders
|
|
100009
|
+
* @description create a list of trade orders
|
|
100010
|
+
* @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-order-list-list
|
|
100011
|
+
* @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-order-list-oco
|
|
100012
|
+
* @param {array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
|
100013
|
+
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
100014
|
+
*/
|
|
100015
|
+
await this.loadMarkets();
|
|
100016
|
+
const ordersRequests = [];
|
|
100017
|
+
for (let i = 0; i < orders.length; i++) {
|
|
100018
|
+
const rawOrder = orders[i];
|
|
100019
|
+
const marketId = this.safeString(rawOrder, 'symbol');
|
|
100020
|
+
const type = this.safeString(rawOrder, 'type');
|
|
100021
|
+
const side = this.safeString(rawOrder, 'side');
|
|
100022
|
+
const amount = this.safeValue(rawOrder, 'amount');
|
|
100023
|
+
const price = this.safeValue(rawOrder, 'price');
|
|
100024
|
+
const orderParams = this.safeValue(rawOrder, 'params', {});
|
|
100025
|
+
const orderRequest = this.createAdvancedOrderRequest(marketId, type, side, amount, price, orderParams);
|
|
100026
|
+
ordersRequests.push(orderRequest);
|
|
100027
|
+
}
|
|
100028
|
+
const contigency = this.safeString(params, 'contingency_type', 'LIST');
|
|
100029
|
+
const request = {
|
|
100030
|
+
'contingency_type': contigency,
|
|
100031
|
+
'order_list': ordersRequests,
|
|
100032
|
+
};
|
|
100033
|
+
const response = await this.v1PrivatePostPrivateCreateOrderList(this.extend(request, params));
|
|
100034
|
+
//
|
|
100035
|
+
// {
|
|
100036
|
+
// "id": 12,
|
|
100037
|
+
// "method": "private/create-order-list",
|
|
100038
|
+
// "code": 10001,
|
|
100039
|
+
// "result": {
|
|
100040
|
+
// "result_list": [
|
|
100041
|
+
// {
|
|
100042
|
+
// "index": 0,
|
|
100043
|
+
// "code": 0,
|
|
100044
|
+
// "order_id": "2015106383706015873",
|
|
100045
|
+
// "client_oid": "my_order_0001"
|
|
100046
|
+
// },
|
|
100047
|
+
// {
|
|
100048
|
+
// "index": 1,
|
|
100049
|
+
// "code": 20007,
|
|
100050
|
+
// "message": "INVALID_REQUEST",
|
|
100051
|
+
// "client_oid": "my_order_0002"
|
|
100052
|
+
// }
|
|
100053
|
+
// ]
|
|
100054
|
+
// }
|
|
100055
|
+
// }
|
|
100056
|
+
//
|
|
100057
|
+
// {
|
|
100058
|
+
// "id" : 1698068111133,
|
|
100059
|
+
// "method" : "private/create-order-list",
|
|
100060
|
+
// "code" : 0,
|
|
100061
|
+
// "result" : [ {
|
|
100062
|
+
// "code" : 0,
|
|
100063
|
+
// "index" : 0,
|
|
100064
|
+
// "client_oid" : "1698068111133_0",
|
|
100065
|
+
// "order_id" : "6142909896519488206"
|
|
100066
|
+
// }, {
|
|
100067
|
+
// "code" : 306,
|
|
100068
|
+
// "index" : 1,
|
|
100069
|
+
// "client_oid" : "1698068111133_1",
|
|
100070
|
+
// "message" : "INSUFFICIENT_AVAILABLE_BALANCE",
|
|
100071
|
+
// "order_id" : "6142909896519488207"
|
|
100072
|
+
// } ]
|
|
100073
|
+
// }
|
|
100074
|
+
//
|
|
100075
|
+
const result = this.safeValue(response, 'result', []);
|
|
100076
|
+
const listId = this.safeString(result, 'list_id');
|
|
100077
|
+
if (listId !== undefined) {
|
|
100078
|
+
const ocoOrders = [{ 'order_id': listId }];
|
|
100079
|
+
return this.parseOrders(ocoOrders);
|
|
100080
|
+
}
|
|
100081
|
+
return this.parseOrders(result);
|
|
100082
|
+
}
|
|
100083
|
+
createAdvancedOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
100084
|
+
// differs slightly from createOrderRequest
|
|
100085
|
+
// since the advanced order endpoint requires a different set of parameters
|
|
100086
|
+
// namely here we don't support ref_price or spot_margin
|
|
100087
|
+
// and market-buy orders need to send notional instead of quantity
|
|
100088
|
+
const market = this.market(symbol);
|
|
100089
|
+
const uppercaseType = type.toUpperCase();
|
|
100090
|
+
const request = {
|
|
100091
|
+
'instrument_name': market['id'],
|
|
100092
|
+
'side': side.toUpperCase(),
|
|
100093
|
+
};
|
|
100094
|
+
if ((uppercaseType === 'LIMIT') || (uppercaseType === 'STOP_LIMIT') || (uppercaseType === 'TAKE_PROFIT_LIMIT')) {
|
|
100095
|
+
request['price'] = this.priceToPrecision(symbol, price);
|
|
100096
|
+
}
|
|
100097
|
+
const broker = this.safeString(this.options, 'broker', 'CCXT');
|
|
100098
|
+
request['broker_id'] = broker;
|
|
100099
|
+
const timeInForce = this.safeStringUpper2(params, 'timeInForce', 'time_in_force');
|
|
100100
|
+
if (timeInForce !== undefined) {
|
|
100101
|
+
if (timeInForce === 'GTC') {
|
|
100102
|
+
request['time_in_force'] = 'GOOD_TILL_CANCEL';
|
|
100103
|
+
}
|
|
100104
|
+
else if (timeInForce === 'IOC') {
|
|
100105
|
+
request['time_in_force'] = 'IMMEDIATE_OR_CANCEL';
|
|
100106
|
+
}
|
|
100107
|
+
else if (timeInForce === 'FOK') {
|
|
100108
|
+
request['time_in_force'] = 'FILL_OR_KILL';
|
|
100109
|
+
}
|
|
100110
|
+
else {
|
|
100111
|
+
request['time_in_force'] = timeInForce;
|
|
100112
|
+
}
|
|
100113
|
+
}
|
|
100114
|
+
const postOnly = this.safeValue(params, 'postOnly', false);
|
|
100115
|
+
if ((postOnly) || (timeInForce === 'PO')) {
|
|
100116
|
+
request['exec_inst'] = ['POST_ONLY'];
|
|
100117
|
+
request['time_in_force'] = 'GOOD_TILL_CANCEL';
|
|
100118
|
+
}
|
|
100119
|
+
const triggerPrice = this.safeStringN(params, ['stopPrice', 'triggerPrice', 'ref_price']);
|
|
100120
|
+
const stopLossPrice = this.safeNumber(params, 'stopLossPrice');
|
|
100121
|
+
const takeProfitPrice = this.safeNumber(params, 'takeProfitPrice');
|
|
100122
|
+
const isTrigger = (triggerPrice !== undefined);
|
|
100123
|
+
const isStopLossTrigger = (stopLossPrice !== undefined);
|
|
100124
|
+
const isTakeProfitTrigger = (takeProfitPrice !== undefined);
|
|
100125
|
+
if (isTrigger) {
|
|
100126
|
+
price = price.toString();
|
|
100127
|
+
if ((uppercaseType === 'LIMIT') || (uppercaseType === 'STOP_LIMIT') || (uppercaseType === 'TAKE_PROFIT_LIMIT')) {
|
|
100128
|
+
if (side === 'buy') {
|
|
100129
|
+
if (_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringLt */ .O.stringLt(price, triggerPrice)) {
|
|
100130
|
+
request['type'] = 'TAKE_PROFIT_LIMIT';
|
|
100131
|
+
}
|
|
100132
|
+
else {
|
|
100133
|
+
request['type'] = 'STOP_LIMIT';
|
|
100134
|
+
}
|
|
100135
|
+
}
|
|
100136
|
+
else {
|
|
100137
|
+
if (_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringLt */ .O.stringLt(price, triggerPrice)) {
|
|
100138
|
+
request['type'] = 'STOP_LIMIT';
|
|
100139
|
+
}
|
|
100140
|
+
else {
|
|
100141
|
+
request['type'] = 'TAKE_PROFIT_LIMIT';
|
|
100142
|
+
}
|
|
100143
|
+
}
|
|
100144
|
+
}
|
|
100145
|
+
else {
|
|
100146
|
+
if (side === 'buy') {
|
|
100147
|
+
if (_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringLt */ .O.stringLt(price, triggerPrice)) {
|
|
100148
|
+
request['type'] = 'TAKE_PROFIT';
|
|
100149
|
+
}
|
|
100150
|
+
else {
|
|
100151
|
+
request['type'] = 'STOP_LOSS';
|
|
100152
|
+
}
|
|
100153
|
+
}
|
|
100154
|
+
else {
|
|
100155
|
+
if (_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringLt */ .O.stringLt(price, triggerPrice)) {
|
|
100156
|
+
request['type'] = 'STOP_LOSS';
|
|
100157
|
+
}
|
|
100158
|
+
else {
|
|
100159
|
+
request['type'] = 'TAKE_PROFIT';
|
|
100160
|
+
}
|
|
100161
|
+
}
|
|
100162
|
+
}
|
|
100163
|
+
}
|
|
100164
|
+
else if (isStopLossTrigger) {
|
|
100165
|
+
if ((uppercaseType === 'LIMIT') || (uppercaseType === 'STOP_LIMIT')) {
|
|
100166
|
+
request['type'] = 'STOP_LIMIT';
|
|
100167
|
+
}
|
|
100168
|
+
else {
|
|
100169
|
+
request['type'] = 'STOP_LOSS';
|
|
100170
|
+
}
|
|
100171
|
+
}
|
|
100172
|
+
else if (isTakeProfitTrigger) {
|
|
100173
|
+
if ((uppercaseType === 'LIMIT') || (uppercaseType === 'TAKE_PROFIT_LIMIT')) {
|
|
100174
|
+
request['type'] = 'TAKE_PROFIT_LIMIT';
|
|
100175
|
+
}
|
|
100176
|
+
else {
|
|
100177
|
+
request['type'] = 'TAKE_PROFIT';
|
|
100178
|
+
}
|
|
100179
|
+
}
|
|
100180
|
+
else {
|
|
100181
|
+
request['type'] = uppercaseType;
|
|
100182
|
+
}
|
|
100183
|
+
if ((side === 'buy') && ((uppercaseType === 'MARKET') || (uppercaseType === 'STOP_LOSS') || (uppercaseType === 'TAKE_PROFIT'))) {
|
|
100184
|
+
// use createmarketBuy logic here
|
|
100185
|
+
if (this.options['createMarketBuyOrderRequiresPrice']) {
|
|
100186
|
+
const cost = this.safeNumber2(params, 'cost', 'notional');
|
|
100187
|
+
params = this.omit(params, 'cost');
|
|
100188
|
+
if (price === undefined && cost === undefined) {
|
|
100189
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder(this.id + ' createOrder() requires the price argument with market buy orders to calculate total order cost (amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options["createMarketBuyOrderRequiresPrice"] = false to supply the cost in the amount argument (the exchange-specific behaviour)');
|
|
100190
|
+
}
|
|
100191
|
+
else {
|
|
100192
|
+
const amountString = this.numberToString(amount);
|
|
100193
|
+
const priceString = this.numberToString(price);
|
|
100194
|
+
const quoteAmount = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringMul */ .O.stringMul(amountString, priceString);
|
|
100195
|
+
amount = (cost !== undefined) ? cost : this.parseNumber(quoteAmount);
|
|
100196
|
+
request['notional'] = this.costToPrecision(symbol, amount);
|
|
100197
|
+
}
|
|
100198
|
+
}
|
|
100199
|
+
else {
|
|
100200
|
+
request['notional'] = this.costToPrecision(symbol, amount);
|
|
100201
|
+
}
|
|
100202
|
+
}
|
|
100203
|
+
else {
|
|
100204
|
+
request['quantity'] = this.amountToPrecision(symbol, amount);
|
|
100205
|
+
}
|
|
100206
|
+
params = this.omit(params, ['postOnly', 'clientOrderId', 'timeInForce', 'stopPrice', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice']);
|
|
100207
|
+
return this.extend(request, params);
|
|
100208
|
+
}
|
|
99497
100209
|
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
99498
100210
|
/**
|
|
99499
100211
|
* @method
|
|
@@ -100334,12 +101046,31 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
|
|
|
100334
101046
|
// "update_time": 1686806053993
|
|
100335
101047
|
// }
|
|
100336
101048
|
//
|
|
101049
|
+
// createOrders
|
|
101050
|
+
// {
|
|
101051
|
+
// "code" : 306,
|
|
101052
|
+
// "index" : 1,
|
|
101053
|
+
// "client_oid" : "1698068111133_1",
|
|
101054
|
+
// "message" : "INSUFFICIENT_AVAILABLE_BALANCE",
|
|
101055
|
+
// "order_id" : "6142909896519488207"
|
|
101056
|
+
// }
|
|
101057
|
+
//
|
|
101058
|
+
const code = this.safeInteger(order, 'code');
|
|
101059
|
+
if ((code !== undefined) && (code !== 0)) {
|
|
101060
|
+
return this.safeOrder({
|
|
101061
|
+
'id': this.safeString(order, 'order_id'),
|
|
101062
|
+
'clientOrderId': this.safeString(order, 'client_oid'),
|
|
101063
|
+
'info': order,
|
|
101064
|
+
'status': 'rejected',
|
|
101065
|
+
});
|
|
101066
|
+
}
|
|
100337
101067
|
const created = this.safeInteger(order, 'create_time');
|
|
100338
101068
|
const marketId = this.safeString(order, 'instrument_name');
|
|
100339
101069
|
const symbol = this.safeSymbol(marketId, market);
|
|
100340
101070
|
const execInst = this.safeValue(order, 'exec_inst');
|
|
100341
|
-
let postOnly =
|
|
101071
|
+
let postOnly = undefined;
|
|
100342
101072
|
if (execInst !== undefined) {
|
|
101073
|
+
postOnly = false;
|
|
100343
101074
|
for (let i = 0; i < execInst.length; i++) {
|
|
100344
101075
|
const inst = execInst[i];
|
|
100345
101076
|
if (inst === 'POST_ONLY') {
|
|
@@ -101261,6 +101992,41 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
|
|
|
101261
101992
|
nonce() {
|
|
101262
101993
|
return this.milliseconds();
|
|
101263
101994
|
}
|
|
101995
|
+
paramsToString(object, level) {
|
|
101996
|
+
const maxLevel = 3;
|
|
101997
|
+
if (level >= maxLevel) {
|
|
101998
|
+
return object.toString();
|
|
101999
|
+
}
|
|
102000
|
+
if (typeof object === 'string') {
|
|
102001
|
+
return object;
|
|
102002
|
+
}
|
|
102003
|
+
let returnString = '';
|
|
102004
|
+
let paramsKeys = undefined;
|
|
102005
|
+
if (Array.isArray(object)) {
|
|
102006
|
+
paramsKeys = object;
|
|
102007
|
+
}
|
|
102008
|
+
else {
|
|
102009
|
+
const sorted = this.keysort(object);
|
|
102010
|
+
paramsKeys = Object.keys(sorted);
|
|
102011
|
+
}
|
|
102012
|
+
for (let i = 0; i < paramsKeys.length; i++) {
|
|
102013
|
+
const key = paramsKeys[i];
|
|
102014
|
+
returnString += key;
|
|
102015
|
+
const value = object[key];
|
|
102016
|
+
if (value === 'undefined') {
|
|
102017
|
+
returnString += 'null';
|
|
102018
|
+
}
|
|
102019
|
+
else if (Array.isArray(value)) {
|
|
102020
|
+
for (let j = 0; j < value.length; j++) {
|
|
102021
|
+
returnString += this.paramsToString(value[j], level + 1);
|
|
102022
|
+
}
|
|
102023
|
+
}
|
|
102024
|
+
else {
|
|
102025
|
+
returnString += value.toString();
|
|
102026
|
+
}
|
|
102027
|
+
}
|
|
102028
|
+
return returnString;
|
|
102029
|
+
}
|
|
101264
102030
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
101265
102031
|
const type = this.safeString(api, 0);
|
|
101266
102032
|
const access = this.safeString(api, 1);
|
|
@@ -101275,20 +102041,8 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
|
|
|
101275
102041
|
this.checkRequiredCredentials();
|
|
101276
102042
|
const nonce = this.nonce().toString();
|
|
101277
102043
|
const requestParams = this.extend({}, params);
|
|
101278
|
-
const
|
|
101279
|
-
const
|
|
101280
|
-
let strSortKey = '';
|
|
101281
|
-
for (let i = 0; i < paramsKeys.length; i++) {
|
|
101282
|
-
const key = paramsKeys[i].toString();
|
|
101283
|
-
let value = requestParams[paramsKeys[i]];
|
|
101284
|
-
if (Array.isArray(value)) {
|
|
101285
|
-
value = value.join(',');
|
|
101286
|
-
}
|
|
101287
|
-
else {
|
|
101288
|
-
value = value.toString();
|
|
101289
|
-
}
|
|
101290
|
-
strSortKey = strSortKey + key + value;
|
|
101291
|
-
}
|
|
102044
|
+
const paramsKeys = Object.keys(requestParams);
|
|
102045
|
+
const strSortKey = this.paramsToString(requestParams, 0);
|
|
101292
102046
|
const payload = path + nonce + this.apiKey + strSortKey + nonce;
|
|
101293
102047
|
const signature = this.hmac(this.encode(payload), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_4__/* .sha256 */ .J);
|
|
101294
102048
|
const paramsKeysLength = paramsKeys.length;
|
|
@@ -116251,6 +117005,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
116251
117005
|
'cancelOrder': true,
|
|
116252
117006
|
'createMarketOrder': true,
|
|
116253
117007
|
'createOrder': true,
|
|
117008
|
+
'createOrders': true,
|
|
116254
117009
|
'createPostOnlyOrder': true,
|
|
116255
117010
|
'createReduceOnlyOrder': true,
|
|
116256
117011
|
'createStopLimitOrder': true,
|
|
@@ -116456,8 +117211,6 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
116456
117211
|
},
|
|
116457
117212
|
'portfolio': {
|
|
116458
117213
|
'get': {
|
|
116459
|
-
'spot/currency_pairs': 20 / 15,
|
|
116460
|
-
'spot/currency_pairs/{currency_pair}': 20 / 15,
|
|
116461
117214
|
'accounts': 20 / 15,
|
|
116462
117215
|
'account_mode': 20 / 15,
|
|
116463
117216
|
'borrowable': 20 / 15,
|
|
@@ -116465,19 +117218,10 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
116465
117218
|
'loans': 20 / 15,
|
|
116466
117219
|
'loan_records': 20 / 15,
|
|
116467
117220
|
'interest_records': 20 / 15,
|
|
116468
|
-
'spot/orders': 20 / 15,
|
|
116469
|
-
'spot/orders/{order_id}': 20 / 15,
|
|
116470
117221
|
},
|
|
116471
117222
|
'post': {
|
|
116472
117223
|
'account_mode': 20 / 15,
|
|
116473
|
-
'loans': 200 / 15,
|
|
116474
|
-
'spot/orders': 20 / 15,
|
|
116475
|
-
},
|
|
116476
|
-
'delete': {
|
|
116477
|
-
'spot/orders/{order_id}': 20 / 15,
|
|
116478
|
-
},
|
|
116479
|
-
'patch': {
|
|
116480
|
-
'spot/orders/{order_id}': 20 / 15,
|
|
117224
|
+
'loans': 200 / 15, // 15r/10s cost = 20 / 1.5 = 13.33
|
|
116481
117225
|
},
|
|
116482
117226
|
},
|
|
116483
117227
|
'spot': {
|
|
@@ -116500,6 +117244,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
116500
117244
|
'orders': 0.4,
|
|
116501
117245
|
'cancel_batch_orders': 20 / 75,
|
|
116502
117246
|
'countdown_cancel_all': 20 / 75,
|
|
117247
|
+
'amend_batch_orders': 0.4,
|
|
116503
117248
|
'price_orders': 0.4,
|
|
116504
117249
|
},
|
|
116505
117250
|
'delete': {
|
|
@@ -116670,6 +117415,9 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
116670
117415
|
'post': {
|
|
116671
117416
|
'uni/lends': 20 / 15,
|
|
116672
117417
|
},
|
|
117418
|
+
'put': {
|
|
117419
|
+
'uni/interest_reinvest': 20 / 15,
|
|
117420
|
+
},
|
|
116673
117421
|
'patch': {
|
|
116674
117422
|
'uni/lends': 20 / 15,
|
|
116675
117423
|
},
|
|
@@ -119834,6 +120582,156 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
119834
120582
|
* @returns {object|undefined} [An order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
119835
120583
|
*/
|
|
119836
120584
|
await this.loadMarkets();
|
|
120585
|
+
const market = this.market(symbol);
|
|
120586
|
+
const trigger = this.safeValue(params, 'trigger');
|
|
120587
|
+
const triggerPrice = this.safeValue2(params, 'triggerPrice', 'stopPrice');
|
|
120588
|
+
const stopLossPrice = this.safeValue(params, 'stopLossPrice', triggerPrice);
|
|
120589
|
+
const takeProfitPrice = this.safeValue(params, 'takeProfitPrice');
|
|
120590
|
+
const isStopLossOrder = stopLossPrice !== undefined;
|
|
120591
|
+
const isTakeProfitOrder = takeProfitPrice !== undefined;
|
|
120592
|
+
const isStopOrder = isStopLossOrder || isTakeProfitOrder;
|
|
120593
|
+
const nonTriggerOrder = !isStopOrder && (trigger === undefined);
|
|
120594
|
+
const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
120595
|
+
let response = undefined;
|
|
120596
|
+
if (market['spot'] || market['margin']) {
|
|
120597
|
+
if (nonTriggerOrder) {
|
|
120598
|
+
response = await this.privateSpotPostOrders(orderRequest);
|
|
120599
|
+
}
|
|
120600
|
+
else {
|
|
120601
|
+
response = await this.privateSpotPostPriceOrders(orderRequest);
|
|
120602
|
+
}
|
|
120603
|
+
}
|
|
120604
|
+
else if (market['swap']) {
|
|
120605
|
+
if (nonTriggerOrder) {
|
|
120606
|
+
response = await this.privateFuturesPostSettleOrders(orderRequest);
|
|
120607
|
+
}
|
|
120608
|
+
else {
|
|
120609
|
+
response = await this.privateFuturesPostSettlePriceOrders(orderRequest);
|
|
120610
|
+
}
|
|
120611
|
+
}
|
|
120612
|
+
else if (market['future']) {
|
|
120613
|
+
if (nonTriggerOrder) {
|
|
120614
|
+
response = await this.privateDeliveryPostSettleOrders(orderRequest);
|
|
120615
|
+
}
|
|
120616
|
+
else {
|
|
120617
|
+
response = await this.privateDeliveryPostSettlePriceOrders(orderRequest);
|
|
120618
|
+
}
|
|
120619
|
+
}
|
|
120620
|
+
else {
|
|
120621
|
+
response = await this.privateOptionsPostOrders(orderRequest);
|
|
120622
|
+
}
|
|
120623
|
+
// const response = await this[method] (this.deepExtend (request, params));
|
|
120624
|
+
//
|
|
120625
|
+
// spot
|
|
120626
|
+
//
|
|
120627
|
+
// {
|
|
120628
|
+
// "id": "95282841887",
|
|
120629
|
+
// "text": "apiv4",
|
|
120630
|
+
// "create_time": "1637383156",
|
|
120631
|
+
// "update_time": "1637383156",
|
|
120632
|
+
// "create_time_ms": 1637383156017,
|
|
120633
|
+
// "update_time_ms": 1637383156017,
|
|
120634
|
+
// "status": "open",
|
|
120635
|
+
// "currency_pair": "ETH_USDT",
|
|
120636
|
+
// "type": "limit",
|
|
120637
|
+
// "account": "spot",
|
|
120638
|
+
// "side": "buy",
|
|
120639
|
+
// "amount": "0.01",
|
|
120640
|
+
// "price": "3500",
|
|
120641
|
+
// "time_in_force": "gtc",
|
|
120642
|
+
// "iceberg": "0",
|
|
120643
|
+
// "left": "0.01",
|
|
120644
|
+
// "fill_price": "0",
|
|
120645
|
+
// "filled_total": "0",
|
|
120646
|
+
// "fee": "0",
|
|
120647
|
+
// "fee_currency": "ETH",
|
|
120648
|
+
// "point_fee": "0",
|
|
120649
|
+
// "gt_fee": "0",
|
|
120650
|
+
// "gt_discount": false,
|
|
120651
|
+
// "rebated_fee": "0",
|
|
120652
|
+
// "rebated_fee_currency": "USDT"
|
|
120653
|
+
// }
|
|
120654
|
+
//
|
|
120655
|
+
// spot conditional
|
|
120656
|
+
//
|
|
120657
|
+
// {"id": 5891843}
|
|
120658
|
+
//
|
|
120659
|
+
// futures, perpetual swaps and options
|
|
120660
|
+
//
|
|
120661
|
+
// {
|
|
120662
|
+
// "id": 95938572327,
|
|
120663
|
+
// "contract": "ETH_USDT",
|
|
120664
|
+
// "mkfr": "0",
|
|
120665
|
+
// "tkfr": "0.0005",
|
|
120666
|
+
// "tif": "gtc",
|
|
120667
|
+
// "is_reduce_only": false,
|
|
120668
|
+
// "create_time": 1637384600.08,
|
|
120669
|
+
// "price": "3000",
|
|
120670
|
+
// "size": 1,
|
|
120671
|
+
// "refr": "0",
|
|
120672
|
+
// "left": 1,
|
|
120673
|
+
// "text": "api",
|
|
120674
|
+
// "fill_price": "0",
|
|
120675
|
+
// "user": 2436035,
|
|
120676
|
+
// "status": "open",
|
|
120677
|
+
// "is_liq": false,
|
|
120678
|
+
// "refu": 0,
|
|
120679
|
+
// "is_close": false,
|
|
120680
|
+
// "iceberg": 0
|
|
120681
|
+
// }
|
|
120682
|
+
//
|
|
120683
|
+
// futures and perpetual swaps conditionals
|
|
120684
|
+
//
|
|
120685
|
+
// {"id": 7615567}
|
|
120686
|
+
//
|
|
120687
|
+
return this.parseOrder(response, market);
|
|
120688
|
+
}
|
|
120689
|
+
async createOrders(orders, params = {}) {
|
|
120690
|
+
/**
|
|
120691
|
+
* @method
|
|
120692
|
+
* @name gate#createOrders
|
|
120693
|
+
* @description create a list of trade orders
|
|
120694
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#get-a-single-order-2
|
|
120695
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#create-a-batch-of-orders
|
|
120696
|
+
* @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
|
120697
|
+
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
120698
|
+
*/
|
|
120699
|
+
await this.loadMarkets();
|
|
120700
|
+
const ordersRequests = [];
|
|
120701
|
+
const orderSymbols = [];
|
|
120702
|
+
for (let i = 0; i < orders.length; i++) {
|
|
120703
|
+
const rawOrder = orders[i];
|
|
120704
|
+
const marketId = this.safeString(rawOrder, 'symbol');
|
|
120705
|
+
orderSymbols.push(marketId);
|
|
120706
|
+
const type = this.safeString(rawOrder, 'type');
|
|
120707
|
+
const side = this.safeString(rawOrder, 'side');
|
|
120708
|
+
const amount = this.safeValue(rawOrder, 'amount');
|
|
120709
|
+
const price = this.safeValue(rawOrder, 'price');
|
|
120710
|
+
const orderParams = this.safeValue(rawOrder, 'params', {});
|
|
120711
|
+
const extendedParams = this.extend(orderParams, params); // the request does not accept extra params since it's a list, so we're extending each order with the common params
|
|
120712
|
+
const triggerValue = this.safeValueN(orderParams, ['triggerPrice', 'stopPrice', 'takeProfitPrice', 'stopLossPrice']);
|
|
120713
|
+
if (triggerValue !== undefined) {
|
|
120714
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' createOrders() does not support advanced order properties (stopPrice, takeProfitPrice, stopLossPrice)');
|
|
120715
|
+
}
|
|
120716
|
+
extendedParams['textIsRequired'] = true; // Gate.io requires a text parameter for each order here
|
|
120717
|
+
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, extendedParams);
|
|
120718
|
+
ordersRequests.push(orderRequest);
|
|
120719
|
+
}
|
|
120720
|
+
const symbols = this.marketSymbols(orderSymbols, undefined, false, true, true);
|
|
120721
|
+
const market = this.market(symbols[0]);
|
|
120722
|
+
if (market['future'] || market['option']) {
|
|
120723
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' createOrders() does not support futures or options markets');
|
|
120724
|
+
}
|
|
120725
|
+
let response = undefined;
|
|
120726
|
+
if (market['spot']) {
|
|
120727
|
+
response = await this.privateSpotPostBatchOrders(ordersRequests);
|
|
120728
|
+
}
|
|
120729
|
+
else if (market['swap']) {
|
|
120730
|
+
response = await this.privateFuturesPostSettleBatchOrders(ordersRequests);
|
|
120731
|
+
}
|
|
120732
|
+
return this.parseOrders(response);
|
|
120733
|
+
}
|
|
120734
|
+
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
119837
120735
|
const market = this.market(symbol);
|
|
119838
120736
|
const contract = market['contract'];
|
|
119839
120737
|
const trigger = this.safeValue(params, 'trigger');
|
|
@@ -119846,7 +120744,6 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
119846
120744
|
if (isStopLossOrder && isTakeProfitOrder) {
|
|
119847
120745
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(this.id + ' createOrder() stopLossPrice and takeProfitPrice cannot both be defined');
|
|
119848
120746
|
}
|
|
119849
|
-
let methodTail = 'Orders';
|
|
119850
120747
|
const reduceOnly = this.safeValue(params, 'reduceOnly');
|
|
119851
120748
|
const exchangeSpecificTimeInForce = this.safeStringLowerN(params, ['timeInForce', 'tif', 'time_in_force']);
|
|
119852
120749
|
let postOnly = undefined;
|
|
@@ -119959,6 +120856,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
119959
120856
|
}
|
|
119960
120857
|
}
|
|
119961
120858
|
let clientOrderId = this.safeString2(params, 'text', 'clientOrderId');
|
|
120859
|
+
const textIsRequired = this.safeValue(params, 'textIsRequired', false);
|
|
119962
120860
|
if (clientOrderId !== undefined) {
|
|
119963
120861
|
// user-defined, must follow the rules if not empty
|
|
119964
120862
|
// prefixed with t-
|
|
@@ -119967,12 +120865,18 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
119967
120865
|
if (clientOrderId.length > 28) {
|
|
119968
120866
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' createOrder () clientOrderId or text param must be up to 28 characters');
|
|
119969
120867
|
}
|
|
119970
|
-
params = this.omit(params, ['text', 'clientOrderId']);
|
|
120868
|
+
params = this.omit(params, ['text', 'clientOrderId', 'textIsRequired']);
|
|
119971
120869
|
if (clientOrderId[0] !== 't') {
|
|
119972
120870
|
clientOrderId = 't-' + clientOrderId;
|
|
119973
120871
|
}
|
|
119974
120872
|
request['text'] = clientOrderId;
|
|
119975
120873
|
}
|
|
120874
|
+
else {
|
|
120875
|
+
if (textIsRequired) {
|
|
120876
|
+
// batchOrders requires text in the request
|
|
120877
|
+
request['text'] = 't-' + this.uuid16();
|
|
120878
|
+
}
|
|
120879
|
+
}
|
|
119976
120880
|
}
|
|
119977
120881
|
else {
|
|
119978
120882
|
if (market['option']) {
|
|
@@ -120066,80 +120970,8 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
120066
120970
|
};
|
|
120067
120971
|
}
|
|
120068
120972
|
}
|
|
120069
|
-
methodTail = 'PriceOrders';
|
|
120070
120973
|
}
|
|
120071
|
-
|
|
120072
|
-
'spot': 'privateSpotPost' + methodTail,
|
|
120073
|
-
'margin': 'privateSpotPost' + methodTail,
|
|
120074
|
-
'swap': 'privateFuturesPostSettle' + methodTail,
|
|
120075
|
-
'future': 'privateDeliveryPostSettle' + methodTail,
|
|
120076
|
-
'option': 'privateOptionsPostOrders',
|
|
120077
|
-
});
|
|
120078
|
-
const response = await this[method](this.deepExtend(request, params));
|
|
120079
|
-
//
|
|
120080
|
-
// spot
|
|
120081
|
-
//
|
|
120082
|
-
// {
|
|
120083
|
-
// "id": "95282841887",
|
|
120084
|
-
// "text": "apiv4",
|
|
120085
|
-
// "create_time": "1637383156",
|
|
120086
|
-
// "update_time": "1637383156",
|
|
120087
|
-
// "create_time_ms": 1637383156017,
|
|
120088
|
-
// "update_time_ms": 1637383156017,
|
|
120089
|
-
// "status": "open",
|
|
120090
|
-
// "currency_pair": "ETH_USDT",
|
|
120091
|
-
// "type": "limit",
|
|
120092
|
-
// "account": "spot",
|
|
120093
|
-
// "side": "buy",
|
|
120094
|
-
// "amount": "0.01",
|
|
120095
|
-
// "price": "3500",
|
|
120096
|
-
// "time_in_force": "gtc",
|
|
120097
|
-
// "iceberg": "0",
|
|
120098
|
-
// "left": "0.01",
|
|
120099
|
-
// "fill_price": "0",
|
|
120100
|
-
// "filled_total": "0",
|
|
120101
|
-
// "fee": "0",
|
|
120102
|
-
// "fee_currency": "ETH",
|
|
120103
|
-
// "point_fee": "0",
|
|
120104
|
-
// "gt_fee": "0",
|
|
120105
|
-
// "gt_discount": false,
|
|
120106
|
-
// "rebated_fee": "0",
|
|
120107
|
-
// "rebated_fee_currency": "USDT"
|
|
120108
|
-
// }
|
|
120109
|
-
//
|
|
120110
|
-
// spot conditional
|
|
120111
|
-
//
|
|
120112
|
-
// {"id": 5891843}
|
|
120113
|
-
//
|
|
120114
|
-
// futures, perpetual swaps and options
|
|
120115
|
-
//
|
|
120116
|
-
// {
|
|
120117
|
-
// "id": 95938572327,
|
|
120118
|
-
// "contract": "ETH_USDT",
|
|
120119
|
-
// "mkfr": "0",
|
|
120120
|
-
// "tkfr": "0.0005",
|
|
120121
|
-
// "tif": "gtc",
|
|
120122
|
-
// "is_reduce_only": false,
|
|
120123
|
-
// "create_time": 1637384600.08,
|
|
120124
|
-
// "price": "3000",
|
|
120125
|
-
// "size": 1,
|
|
120126
|
-
// "refr": "0",
|
|
120127
|
-
// "left": 1,
|
|
120128
|
-
// "text": "api",
|
|
120129
|
-
// "fill_price": "0",
|
|
120130
|
-
// "user": 2436035,
|
|
120131
|
-
// "status": "open",
|
|
120132
|
-
// "is_liq": false,
|
|
120133
|
-
// "refu": 0,
|
|
120134
|
-
// "is_close": false,
|
|
120135
|
-
// "iceberg": 0
|
|
120136
|
-
// }
|
|
120137
|
-
//
|
|
120138
|
-
// futures and perpetual swaps conditionals
|
|
120139
|
-
//
|
|
120140
|
-
// {"id": 7615567}
|
|
120141
|
-
//
|
|
120142
|
-
return this.parseOrder(response, market);
|
|
120974
|
+
return this.extend(request, params);
|
|
120143
120975
|
}
|
|
120144
120976
|
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
120145
120977
|
/**
|
|
@@ -120365,6 +121197,22 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
120365
121197
|
// "order_type": ""
|
|
120366
121198
|
// }
|
|
120367
121199
|
//
|
|
121200
|
+
// {
|
|
121201
|
+
// "text": "t-d18baf9ac44d82e2",
|
|
121202
|
+
// "succeeded": false,
|
|
121203
|
+
// "label": "BALANCE_NOT_ENOUGH",
|
|
121204
|
+
// "message": "Not enough balance"
|
|
121205
|
+
// }
|
|
121206
|
+
//
|
|
121207
|
+
const succeeded = this.safeValue(order, 'succeeded', true);
|
|
121208
|
+
if (!succeeded) {
|
|
121209
|
+
// cancelOrders response
|
|
121210
|
+
return this.safeOrder({
|
|
121211
|
+
'clientOrderId': this.safeString(order, 'text'),
|
|
121212
|
+
'info': order,
|
|
121213
|
+
'status': 'rejected',
|
|
121214
|
+
});
|
|
121215
|
+
}
|
|
120368
121216
|
const put = this.safeValue2(order, 'put', 'initial', {});
|
|
120369
121217
|
const trigger = this.safeValue(order, 'trigger', {});
|
|
120370
121218
|
let contract = this.safeString(put, 'contract');
|
|
@@ -121804,7 +122652,16 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
121804
122652
|
const authentication = api[0]; // public, private
|
|
121805
122653
|
const type = api[1]; // spot, margin, future, delivery
|
|
121806
122654
|
let query = this.omit(params, this.extractParams(path));
|
|
121807
|
-
|
|
122655
|
+
if (Array.isArray(params)) {
|
|
122656
|
+
// endpoints like createOrders use an array instead of an object
|
|
122657
|
+
// so we infer the settle from one of the elements
|
|
122658
|
+
// they have to be all the same so relying on the first one is fine
|
|
122659
|
+
const first = this.safeValue(params, 0, {});
|
|
122660
|
+
path = this.implodeParams(path, first);
|
|
122661
|
+
}
|
|
122662
|
+
else {
|
|
122663
|
+
path = this.implodeParams(path, params);
|
|
122664
|
+
}
|
|
121808
122665
|
const endPart = (path === '') ? '' : ('/' + path);
|
|
121809
122666
|
let entirePath = '/' + type + endPart;
|
|
121810
122667
|
if ((type === 'subAccounts') || (type === 'withdrawals')) {
|
|
@@ -147008,24 +147865,7 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
|
|
|
147008
147865
|
'fee': undefined,
|
|
147009
147866
|
});
|
|
147010
147867
|
}
|
|
147011
|
-
|
|
147012
|
-
/**
|
|
147013
|
-
* @method
|
|
147014
|
-
* @name krakenfutures#createOrder
|
|
147015
|
-
* @description Create an order on the exchange
|
|
147016
|
-
* @param {string} symbol market symbol
|
|
147017
|
-
* @param {string} type One of 'limit', 'market', 'take_profit'
|
|
147018
|
-
* @param {string} side buy or sell
|
|
147019
|
-
* @param {int} amount Contract quantity
|
|
147020
|
-
* @param {float} [price] Limit order price
|
|
147021
|
-
* @param {float} [params.stopPrice] The stop price associated with a stop or take profit order, Required if orderType is stp or take_profit, Must not have more than 2 decimal places, Note that for stop orders, limitPrice denotes the worst price at which the stop or take_profit order can get filled at. If no limitPrice is provided the stop or take_profit order will trigger a market order,
|
|
147022
|
-
* @param {bool} [params.reduceOnly] Set as true if you wish the order to only reduce an existing position, Any order which increases an existing position will be rejected, Default false,
|
|
147023
|
-
* @param {bool} [params.postOnly] Set as true if you wish to make a postOnly order, Default false
|
|
147024
|
-
* @param {string} [params.triggerSignal] If placing a stp or take_profit, the signal used for trigger, One of: 'mark', 'index', 'last', last is market price
|
|
147025
|
-
* @param {string} [params.cliOrdId] UUID The order identity that is specified from the user, It must be globally unique
|
|
147026
|
-
* @param {string} [params.clientOrderId] UUID The order identity that is specified from the user, It must be globally unique
|
|
147027
|
-
*/
|
|
147028
|
-
await this.loadMarkets();
|
|
147868
|
+
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
147029
147869
|
type = this.safeString(params, 'orderType', type);
|
|
147030
147870
|
const timeInForce = this.safeString(params, 'timeInForce');
|
|
147031
147871
|
const stopPrice = this.safeString(params, 'stopPrice');
|
|
@@ -147063,7 +147903,28 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
|
|
|
147063
147903
|
if (clientOrderId !== undefined) {
|
|
147064
147904
|
request['cliOrdId'] = clientOrderId;
|
|
147065
147905
|
}
|
|
147066
|
-
|
|
147906
|
+
return this.extend(request, params);
|
|
147907
|
+
}
|
|
147908
|
+
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
147909
|
+
/**
|
|
147910
|
+
* @method
|
|
147911
|
+
* @name krakenfutures#createOrder
|
|
147912
|
+
* @description Create an order on the exchange
|
|
147913
|
+
* @param {string} symbol market symbol
|
|
147914
|
+
* @param {string} type One of 'limit', 'market', 'take_profit'
|
|
147915
|
+
* @param {string} side buy or sell
|
|
147916
|
+
* @param {int} amount Contract quantity
|
|
147917
|
+
* @param {float} [price] Limit order price
|
|
147918
|
+
* @param {float} [params.stopPrice] The stop price associated with a stop or take profit order, Required if orderType is stp or take_profit, Must not have more than 2 decimal places, Note that for stop orders, limitPrice denotes the worst price at which the stop or take_profit order can get filled at. If no limitPrice is provided the stop or take_profit order will trigger a market order,
|
|
147919
|
+
* @param {bool} [params.reduceOnly] Set as true if you wish the order to only reduce an existing position, Any order which increases an existing position will be rejected, Default false,
|
|
147920
|
+
* @param {bool} [params.postOnly] Set as true if you wish to make a postOnly order, Default false
|
|
147921
|
+
* @param {string} [params.triggerSignal] If placing a stp or take_profit, the signal used for trigger, One of: 'mark', 'index', 'last', last is market price
|
|
147922
|
+
* @param {string} [params.cliOrdId] UUID The order identity that is specified from the user, It must be globally unique
|
|
147923
|
+
* @param {string} [params.clientOrderId] UUID The order identity that is specified from the user, It must be globally unique
|
|
147924
|
+
*/
|
|
147925
|
+
await this.loadMarkets();
|
|
147926
|
+
const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
147927
|
+
const response = await this.privatePostSendorder(orderRequest);
|
|
147067
147928
|
//
|
|
147068
147929
|
// {
|
|
147069
147930
|
// "result": "success",
|
|
@@ -147099,6 +147960,57 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
|
|
|
147099
147960
|
this.verifyOrderActionSuccess(status, 'createOrder', ['filled']);
|
|
147100
147961
|
return this.parseOrder(sendStatus);
|
|
147101
147962
|
}
|
|
147963
|
+
async createOrders(orders, params = {}) {
|
|
147964
|
+
/**
|
|
147965
|
+
* @method
|
|
147966
|
+
* @name krakenfutures#createOrders
|
|
147967
|
+
* @description create a list of trade orders
|
|
147968
|
+
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-batch-order-management
|
|
147969
|
+
* @param {array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
|
147970
|
+
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
147971
|
+
*/
|
|
147972
|
+
await this.loadMarkets();
|
|
147973
|
+
const ordersRequests = [];
|
|
147974
|
+
for (let i = 0; i < orders.length; i++) {
|
|
147975
|
+
const rawOrder = orders[i];
|
|
147976
|
+
const marketId = this.safeString(rawOrder, 'symbol');
|
|
147977
|
+
const type = this.safeString(rawOrder, 'type');
|
|
147978
|
+
const side = this.safeString(rawOrder, 'side');
|
|
147979
|
+
const amount = this.safeValue(rawOrder, 'amount');
|
|
147980
|
+
const price = this.safeValue(rawOrder, 'price');
|
|
147981
|
+
const orderParams = this.safeValue(rawOrder, 'params', {});
|
|
147982
|
+
const extendedParams = this.extend(orderParams, params); // the request does not accept extra params since it's a list, so we're extending each order with the common params
|
|
147983
|
+
if (!('order_tag' in extendedParams)) {
|
|
147984
|
+
// order tag is mandatory so we will generate one if not provided
|
|
147985
|
+
extendedParams['order_tag'] = this.sum(i, 1).toString(); // sequential counter
|
|
147986
|
+
}
|
|
147987
|
+
extendedParams['order'] = 'send';
|
|
147988
|
+
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, extendedParams);
|
|
147989
|
+
ordersRequests.push(orderRequest);
|
|
147990
|
+
}
|
|
147991
|
+
const request = {
|
|
147992
|
+
'batchOrder': ordersRequests,
|
|
147993
|
+
};
|
|
147994
|
+
const response = await this.privatePostBatchorder(this.extend(request, params));
|
|
147995
|
+
//
|
|
147996
|
+
// {
|
|
147997
|
+
// "result": "success",
|
|
147998
|
+
// "serverTime": "2023-10-24T08:40:57.339Z",
|
|
147999
|
+
// "batchStatus": [
|
|
148000
|
+
// {
|
|
148001
|
+
// "status": "requiredArgumentMissing",
|
|
148002
|
+
// "orderEvents": []
|
|
148003
|
+
// },
|
|
148004
|
+
// {
|
|
148005
|
+
// "status": "requiredArgumentMissing",
|
|
148006
|
+
// "orderEvents": []
|
|
148007
|
+
// }
|
|
148008
|
+
// ]
|
|
148009
|
+
// }
|
|
148010
|
+
//
|
|
148011
|
+
const data = this.safeValue(response, 'batchStatus', []);
|
|
148012
|
+
return this.parseOrders(data);
|
|
148013
|
+
}
|
|
147102
148014
|
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
147103
148015
|
/**
|
|
147104
148016
|
* @method
|
|
@@ -147485,14 +148397,25 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
|
|
|
147485
148397
|
// "lastUpdateTime": "2019-09-05T17:01:17.410Z"
|
|
147486
148398
|
// }
|
|
147487
148399
|
//
|
|
148400
|
+
// createOrders error
|
|
148401
|
+
// {
|
|
148402
|
+
// "status": "requiredArgumentMissing",
|
|
148403
|
+
// "orderEvents": []
|
|
148404
|
+
// }
|
|
148405
|
+
//
|
|
147488
148406
|
const orderEvents = this.safeValue(order, 'orderEvents', []);
|
|
148407
|
+
const errorStatus = this.safeString(order, 'status');
|
|
148408
|
+
const orderEventsLength = orderEvents.length;
|
|
148409
|
+
if (('orderEvents' in order) && (errorStatus !== undefined) && (orderEventsLength === 0)) {
|
|
148410
|
+
// creteOrders error response
|
|
148411
|
+
return this.safeOrder({ 'info': order, 'status': 'rejected' });
|
|
148412
|
+
}
|
|
147489
148413
|
let details = undefined;
|
|
147490
148414
|
let isPrior = false;
|
|
147491
148415
|
let fixed = false;
|
|
147492
148416
|
let statusId = undefined;
|
|
147493
148417
|
let price = undefined;
|
|
147494
148418
|
let trades = [];
|
|
147495
|
-
const orderEventsLength = orderEvents.length;
|
|
147496
148419
|
if (orderEventsLength) {
|
|
147497
148420
|
const executions = [];
|
|
147498
148421
|
for (let i = 0; i < orderEvents.length; i++) {
|
|
@@ -175007,18 +175930,6 @@ class oceanex extends _abstract_oceanex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
175007
175930
|
};
|
|
175008
175931
|
return this.safeString(statuses, status, status);
|
|
175009
175932
|
}
|
|
175010
|
-
async createOrders(symbol, orders, params = {}) {
|
|
175011
|
-
await this.loadMarkets();
|
|
175012
|
-
const market = this.market(symbol);
|
|
175013
|
-
const request = {
|
|
175014
|
-
'market': market['id'],
|
|
175015
|
-
'orders': orders,
|
|
175016
|
-
};
|
|
175017
|
-
// orders: [{"side":"buy", "volume":.2, "price":1001}, {"side":"sell", "volume":0.2, "price":1002}]
|
|
175018
|
-
const response = await this.privatePostOrdersMulti(this.extend(request, params));
|
|
175019
|
-
const data = response['data'];
|
|
175020
|
-
return this.parseOrders(data);
|
|
175021
|
-
}
|
|
175022
175933
|
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
175023
175934
|
/**
|
|
175024
175935
|
* @method
|
|
@@ -178276,6 +179187,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
178276
179187
|
'cancelOrders': true,
|
|
178277
179188
|
'createDepositAddress': false,
|
|
178278
179189
|
'createOrder': true,
|
|
179190
|
+
'createOrders': true,
|
|
178279
179191
|
'createPostOnlyOrder': true,
|
|
178280
179192
|
'createReduceOnlyOrder': true,
|
|
178281
179193
|
'createStopLimitOrder': true,
|
|
@@ -181009,6 +181921,55 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
181009
181921
|
order['side'] = side;
|
|
181010
181922
|
return order;
|
|
181011
181923
|
}
|
|
181924
|
+
async createOrders(orders, params = {}) {
|
|
181925
|
+
/**
|
|
181926
|
+
* @method
|
|
181927
|
+
* @name okx#createOrders
|
|
181928
|
+
* @description create a list of trade orders
|
|
181929
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-multiple-orders
|
|
181930
|
+
* @param {array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
|
181931
|
+
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
181932
|
+
*/
|
|
181933
|
+
await this.loadMarkets();
|
|
181934
|
+
const ordersRequests = [];
|
|
181935
|
+
for (let i = 0; i < orders.length; i++) {
|
|
181936
|
+
const rawOrder = orders[i];
|
|
181937
|
+
const marketId = this.safeString(rawOrder, 'symbol');
|
|
181938
|
+
const type = this.safeString(rawOrder, 'type');
|
|
181939
|
+
const side = this.safeString(rawOrder, 'side');
|
|
181940
|
+
const amount = this.safeValue(rawOrder, 'amount');
|
|
181941
|
+
const price = this.safeValue(rawOrder, 'price');
|
|
181942
|
+
const orderParams = this.safeValue(rawOrder, 'params', {});
|
|
181943
|
+
const extendedParams = this.extend(orderParams, params); // the request does not accept extra params since it's a list, so we're extending each order with the common params
|
|
181944
|
+
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, extendedParams);
|
|
181945
|
+
ordersRequests.push(orderRequest);
|
|
181946
|
+
}
|
|
181947
|
+
const response = await this.privatePostTradeBatchOrders(ordersRequests);
|
|
181948
|
+
// {
|
|
181949
|
+
// "code": "0",
|
|
181950
|
+
// "data": [
|
|
181951
|
+
// {
|
|
181952
|
+
// "clOrdId": "e847386590ce4dBCc7f2a1b4c4509f82",
|
|
181953
|
+
// "ordId": "636305438765568000",
|
|
181954
|
+
// "sCode": "0",
|
|
181955
|
+
// "sMsg": "Order placed",
|
|
181956
|
+
// "tag": "e847386590ce4dBC"
|
|
181957
|
+
// },
|
|
181958
|
+
// {
|
|
181959
|
+
// "clOrdId": "e847386590ce4dBC0b9993fe642d8f62",
|
|
181960
|
+
// "ordId": "636305438765568001",
|
|
181961
|
+
// "sCode": "0",
|
|
181962
|
+
// "sMsg": "Order placed",
|
|
181963
|
+
// "tag": "e847386590ce4dBC"
|
|
181964
|
+
// }
|
|
181965
|
+
// ],
|
|
181966
|
+
// "inTime": "1697979038584486",
|
|
181967
|
+
// "msg": "",
|
|
181968
|
+
// "outTime": "1697979038586493"
|
|
181969
|
+
// }
|
|
181970
|
+
const data = this.safeValue(response, 'data', []);
|
|
181971
|
+
return this.parseOrders(data);
|
|
181972
|
+
}
|
|
181012
181973
|
editOrderRequest(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
181013
181974
|
const market = this.market(symbol);
|
|
181014
181975
|
const request = {
|
|
@@ -181387,6 +182348,15 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
181387
182348
|
// "uly": "BTC-USDT"
|
|
181388
182349
|
// }
|
|
181389
182350
|
//
|
|
182351
|
+
const scode = this.safeString(order, 'sCode');
|
|
182352
|
+
if ((scode !== undefined) && (scode !== '0')) {
|
|
182353
|
+
return this.safeOrder({
|
|
182354
|
+
'id': this.safeString(order, 'ordId'),
|
|
182355
|
+
'clientOrderId': this.safeString(order, 'clOrdId'),
|
|
182356
|
+
'status': 'rejected',
|
|
182357
|
+
'info': order,
|
|
182358
|
+
});
|
|
182359
|
+
}
|
|
181390
182360
|
const id = this.safeString2(order, 'algoId', 'ordId');
|
|
181391
182361
|
const timestamp = this.safeInteger(order, 'cTime');
|
|
181392
182362
|
const lastUpdateTimestamp = this.safeInteger(order, 'uTime');
|
|
@@ -185129,7 +186099,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
185129
186099
|
// }
|
|
185130
186100
|
//
|
|
185131
186101
|
const code = this.safeString(response, 'code');
|
|
185132
|
-
if (code !== '0') {
|
|
186102
|
+
if ((code !== '0') && (code !== '2')) { // 2 means that bulk operation partially succeeded
|
|
185133
186103
|
const feedback = this.id + ' ' + body;
|
|
185134
186104
|
const data = this.safeValue(response, 'data', []);
|
|
185135
186105
|
for (let i = 0; i < data.length; i++) {
|
|
@@ -210580,7 +211550,7 @@ class bybit extends _bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
|
210580
211550
|
const topic = this.safeString(message, 'topic', '');
|
|
210581
211551
|
const updateType = this.safeString(message, 'type', '');
|
|
210582
211552
|
const data = this.safeValue(message, 'data', {});
|
|
210583
|
-
const isSpot = this.safeString(data, '
|
|
211553
|
+
const isSpot = this.safeString(data, 'fundingRate') === undefined;
|
|
210584
211554
|
const type = isSpot ? 'spot' : 'contract';
|
|
210585
211555
|
let symbol = undefined;
|
|
210586
211556
|
let parsed = undefined;
|
|
@@ -248097,18 +249067,19 @@ function twistedEdwards(curveDef) {
|
|
|
248097
249067
|
}
|
|
248098
249068
|
/** Signs message with privateKey. RFC8032 5.1.6 */
|
|
248099
249069
|
function sign(msg, privKey, context) {
|
|
248100
|
-
|
|
248101
|
-
|
|
248102
|
-
|
|
249070
|
+
msg = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.ensureBytes)('message', msg);
|
|
249071
|
+
if (preHash)
|
|
249072
|
+
msg = preHash(msg); // for ed25519ph etc.
|
|
248103
249073
|
const { prefix, scalar, pointBytes } = getExtendedPublicKey(privKey);
|
|
248104
249074
|
const r = hashDomainToScalar(context, prefix, msg); // r = dom2(F, C) || prefix || PH(M)
|
|
248105
249075
|
const R = G.multiply(r).toRawBytes(); // R = rG
|
|
248106
249076
|
const k = hashDomainToScalar(context, R, pointBytes, msg); // R || A || PH(M)
|
|
248107
249077
|
const s = modN(r + k * scalar); // S = (r + k * s) mod L
|
|
248108
249078
|
assertGE0(s); // 0 <= s < l
|
|
248109
|
-
const res =
|
|
248110
|
-
return ensureBytes('result', res, nByteLength * 2); // 64-byte signature
|
|
248111
|
-
|
|
249079
|
+
const res = _utils_js__WEBPACK_IMPORTED_MODULE_1__.concatBytes(R, _utils_js__WEBPACK_IMPORTED_MODULE_1__.numberToBytesLE(s, Fp.BYTES));
|
|
249080
|
+
return (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.ensureBytes)('result', res, nByteLength * 2); // 64-byte signature
|
|
249081
|
+
}
|
|
249082
|
+
function signModified(msg, privKey, context) {
|
|
248112
249083
|
msg = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.ensureBytes)('message', msg);
|
|
248113
249084
|
const privKeyBytes = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.ensureBytes)('privKey', privKey);
|
|
248114
249085
|
const privKeyNumber = _utils_js__WEBPACK_IMPORTED_MODULE_1__.bytesToNumberLE(privKeyBytes);
|
|
@@ -248161,6 +249132,7 @@ function twistedEdwards(curveDef) {
|
|
|
248161
249132
|
CURVE,
|
|
248162
249133
|
getPublicKey,
|
|
248163
249134
|
sign,
|
|
249135
|
+
signModified,
|
|
248164
249136
|
verify,
|
|
248165
249137
|
ExtendedPoint: Point,
|
|
248166
249138
|
utils,
|
|
@@ -260511,7 +261483,7 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_
|
|
|
260511
261483
|
const messageHex = this.binaryToBase16(this.encode(message));
|
|
260512
261484
|
const payload = prefix + messageHex;
|
|
260513
261485
|
const hexKey = this.binaryToBase16(this.base58ToBinary(this.secret));
|
|
260514
|
-
const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .
|
|
261486
|
+
const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .axolotl */ .gC)(payload, hexKey, _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_5__/* .ed25519 */ .UN);
|
|
260515
261487
|
const request = {
|
|
260516
261488
|
'grant_type': 'password',
|
|
260517
261489
|
'scope': 'general',
|
|
@@ -261180,7 +262152,7 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_
|
|
|
261180
262152
|
if ((serializedOrder[0] === '"') && (serializedOrder[(serializedOrder.length - 1)] === '"')) {
|
|
261181
262153
|
serializedOrder = serializedOrder.slice(1, serializedOrder.length - 1);
|
|
261182
262154
|
}
|
|
261183
|
-
const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .
|
|
262155
|
+
const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .axolotl */ .gC)(this.binaryToBase16(this.base58ToBinary(serializedOrder)), this.binaryToBase16(this.base58ToBinary(this.secret)), _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_5__/* .ed25519 */ .UN);
|
|
261184
262156
|
body['signature'] = signature;
|
|
261185
262157
|
//
|
|
261186
262158
|
// {
|
|
@@ -261295,7 +262267,7 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_
|
|
|
261295
262267
|
];
|
|
261296
262268
|
const binary = this.binaryConcatArray(byteArray);
|
|
261297
262269
|
const hexSecret = this.binaryToBase16(this.base58ToBinary(this.secret));
|
|
261298
|
-
const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .
|
|
262270
|
+
const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .axolotl */ .gC)(this.binaryToBase16(binary), hexSecret, _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_5__/* .ed25519 */ .UN);
|
|
261299
262271
|
const request = {
|
|
261300
262272
|
'Timestamp': timestamp.toString(),
|
|
261301
262273
|
'Signature': signature,
|
|
@@ -261330,7 +262302,7 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_
|
|
|
261330
262302
|
];
|
|
261331
262303
|
const binary = this.binaryConcatArray(byteArray);
|
|
261332
262304
|
const hexSecret = this.binaryToBase16(this.base58ToBinary(this.secret));
|
|
261333
|
-
const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .
|
|
262305
|
+
const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .axolotl */ .gC)(this.binaryToBase16(binary), hexSecret, _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_5__/* .ed25519 */ .UN);
|
|
261334
262306
|
const request = {
|
|
261335
262307
|
'Accept': 'application/json',
|
|
261336
262308
|
'Timestamp': timestamp.toString(),
|
|
@@ -261694,7 +262666,7 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_
|
|
|
261694
262666
|
];
|
|
261695
262667
|
const binary = this.binaryConcatArray(byteArray);
|
|
261696
262668
|
const hexSecret = this.binaryToBase16(this.base58ToBinary(this.secret));
|
|
261697
|
-
const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .
|
|
262669
|
+
const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .axolotl */ .gC)(this.binaryToBase16(binary), hexSecret, _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_5__/* .ed25519 */ .UN);
|
|
261698
262670
|
const matcherRequest = {
|
|
261699
262671
|
'publicKey': this.apiKey,
|
|
261700
262672
|
'signature': signature,
|
|
@@ -262292,7 +263264,7 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_
|
|
|
262292
263264
|
];
|
|
262293
263265
|
const binary = this.binaryConcatArray(byteArray);
|
|
262294
263266
|
const hexSecret = this.binaryToBase16(this.base58ToBinary(this.secret));
|
|
262295
|
-
const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .
|
|
263267
|
+
const signature = (0,_base_functions_crypto_js__WEBPACK_IMPORTED_MODULE_4__/* .axolotl */ .gC)(this.binaryToBase16(binary), hexSecret, _static_dependencies_noble_curves_ed25519_js__WEBPACK_IMPORTED_MODULE_5__/* .ed25519 */ .UN);
|
|
262296
263268
|
const request = {
|
|
262297
263269
|
'senderPublicKey': this.apiKey,
|
|
262298
263270
|
'amount': amountInteger,
|
|
@@ -277746,7 +278718,7 @@ SOFTWARE.
|
|
|
277746
278718
|
|
|
277747
278719
|
//-----------------------------------------------------------------------------
|
|
277748
278720
|
// this is updated by vss.js when building
|
|
277749
|
-
const version = '4.1.
|
|
278721
|
+
const version = '4.1.25';
|
|
277750
278722
|
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
|
|
277751
278723
|
//-----------------------------------------------------------------------------
|
|
277752
278724
|
|