ccxt 4.1.47 → 4.1.48
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 +124 -124
- package/dist/ccxt.browser.js +545 -384
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +6 -1
- package/dist/cjs/src/abstract/htx.js +9 -0
- package/dist/cjs/src/binance.js +2 -0
- package/dist/cjs/src/bitmart.js +183 -62
- package/dist/cjs/src/htx.js +8505 -0
- package/dist/cjs/src/huobi.js +5 -8503
- package/dist/cjs/src/kraken.js +0 -4
- package/dist/cjs/src/pro/htx.js +2356 -0
- package/dist/cjs/src/pro/huobi.js +5 -2345
- package/dist/cjs/src/timex.js +1 -1
- package/js/ccxt.d.ts +8 -2
- package/js/ccxt.js +6 -2
- package/js/src/abstract/binance.d.ts +2 -0
- package/js/src/abstract/binancecoinm.d.ts +2 -0
- package/js/src/abstract/binanceus.d.ts +2 -0
- package/js/src/abstract/binanceusdm.d.ts +2 -0
- package/js/src/abstract/htx.d.ts +544 -0
- package/js/src/abstract/htx.js +11 -0
- package/js/src/abstract/huobi.d.ts +4 -4
- package/js/src/ace.d.ts +2 -2
- package/js/src/ascendex.d.ts +2 -2
- package/js/src/base/Exchange.d.ts +2 -2
- package/js/src/base/types.d.ts +0 -1
- package/js/src/bigone.d.ts +2 -2
- package/js/src/binance.d.ts +3 -56
- package/js/src/binance.js +2 -0
- package/js/src/bingx.d.ts +3 -55
- package/js/src/bitbns.d.ts +2 -2
- package/js/src/bitfinex.d.ts +2 -2
- package/js/src/bitfinex2.d.ts +2 -2
- package/js/src/bitget.d.ts +3 -53
- package/js/src/bithumb.d.ts +2 -2
- package/js/src/bitmart.d.ts +4 -2
- package/js/src/bitmart.js +183 -62
- package/js/src/bitmex.d.ts +2 -2
- package/js/src/bitopro.d.ts +2 -2
- package/js/src/bitpanda.d.ts +2 -2
- package/js/src/bitrue.d.ts +2 -2
- package/js/src/bitstamp.d.ts +2 -2
- package/js/src/bittrex.d.ts +2 -2
- package/js/src/bitvavo.d.ts +2 -2
- package/js/src/blockchaincom.d.ts +2 -2
- package/js/src/btcalpha.d.ts +2 -2
- package/js/src/btcturk.d.ts +2 -2
- package/js/src/bybit.d.ts +2 -2
- package/js/src/cex.d.ts +2 -2
- package/js/src/coinbase.d.ts +2 -2
- package/js/src/coinbasepro.d.ts +2 -2
- package/js/src/coinex.d.ts +2 -2
- package/js/src/coinfalcon.d.ts +2 -2
- package/js/src/coinlist.d.ts +2 -2
- package/js/src/coinone.d.ts +2 -2
- package/js/src/coinsph.d.ts +2 -2
- package/js/src/coinspot.d.ts +2 -2
- package/js/src/cryptocom.d.ts +2 -2
- package/js/src/currencycom.d.ts +2 -2
- package/js/src/delta.d.ts +2 -2
- package/js/src/deribit.d.ts +2 -2
- package/js/src/digifinex.d.ts +2 -2
- package/js/src/exmo.d.ts +2 -2
- package/js/src/gate.d.ts +2 -2
- package/js/src/gemini.d.ts +3 -51
- package/js/src/hitbtc.d.ts +2 -2
- package/js/src/hollaex.d.ts +2 -2
- package/js/src/htx.d.ts +257 -0
- package/js/src/htx.js +8506 -0
- package/js/src/huobi.d.ts +2 -255
- package/js/src/huobi.js +5 -8503
- package/js/src/huobijp.d.ts +2 -2
- package/js/src/idex.d.ts +2 -2
- package/js/src/indodax.d.ts +2 -2
- package/js/src/kraken.d.ts +2 -2
- package/js/src/kraken.js +0 -4
- package/js/src/krakenfutures.d.ts +2 -2
- package/js/src/kucoin.d.ts +2 -2
- package/js/src/kuna.d.ts +2 -2
- package/js/src/latoken.d.ts +2 -2
- package/js/src/lbank.d.ts +2 -2
- package/js/src/lbank2.d.ts +2 -2
- package/js/src/luno.d.ts +2 -2
- package/js/src/lykke.d.ts +2 -2
- package/js/src/mexc.d.ts +2 -2
- package/js/src/novadax.d.ts +2 -2
- package/js/src/oceanex.d.ts +2 -2
- package/js/src/okcoin.d.ts +3 -3
- package/js/src/okx.d.ts +3 -3
- package/js/src/phemex.d.ts +2 -2
- package/js/src/poloniex.d.ts +2 -2
- package/js/src/poloniexfutures.d.ts +2 -2
- package/js/src/pro/htx.d.ts +45 -0
- package/js/src/pro/htx.js +2357 -0
- package/js/src/pro/huobi.d.ts +2 -43
- package/js/src/pro/huobi.js +5 -2345
- package/js/src/probit.d.ts +2 -2
- package/js/src/tidex.d.ts +2 -2
- package/js/src/timex.d.ts +3 -53
- package/js/src/timex.js +1 -1
- package/js/src/tokocrypto.d.ts +2 -2
- package/js/src/upbit.d.ts +2 -2
- package/js/src/wavesexchange.d.ts +2 -2
- package/js/src/wazirx.d.ts +2 -2
- package/js/src/whitebit.d.ts +2 -2
- package/js/src/yobit.d.ts +2 -2
- package/js/src/zonda.d.ts +2 -2
- package/package.json +1 -1
- package/skip-tests.json +4 -4
package/dist/cjs/ccxt.js
CHANGED
|
@@ -76,6 +76,7 @@ var gemini = require('./src/gemini.js');
|
|
|
76
76
|
var hitbtc = require('./src/hitbtc.js');
|
|
77
77
|
var hitbtc3 = require('./src/hitbtc3.js');
|
|
78
78
|
var hollaex = require('./src/hollaex.js');
|
|
79
|
+
var htx = require('./src/htx.js');
|
|
79
80
|
var huobi = require('./src/huobi.js');
|
|
80
81
|
var huobijp = require('./src/huobijp.js');
|
|
81
82
|
var huobipro = require('./src/huobipro.js');
|
|
@@ -154,6 +155,7 @@ var gateio$1 = require('./src/pro/gateio.js');
|
|
|
154
155
|
var gemini$1 = require('./src/pro/gemini.js');
|
|
155
156
|
var hitbtc$1 = require('./src/pro/hitbtc.js');
|
|
156
157
|
var hollaex$1 = require('./src/pro/hollaex.js');
|
|
158
|
+
var htx$1 = require('./src/pro/htx.js');
|
|
157
159
|
var huobi$1 = require('./src/pro/huobi.js');
|
|
158
160
|
var huobijp$1 = require('./src/pro/huobijp.js');
|
|
159
161
|
var huobipro$1 = require('./src/pro/huobipro.js');
|
|
@@ -181,7 +183,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
181
183
|
|
|
182
184
|
//-----------------------------------------------------------------------------
|
|
183
185
|
// this is updated by vss.js when building
|
|
184
|
-
const version = '4.1.
|
|
186
|
+
const version = '4.1.48';
|
|
185
187
|
Exchange["default"].ccxtVersion = version;
|
|
186
188
|
const exchanges = {
|
|
187
189
|
'ace': ace,
|
|
@@ -248,6 +250,7 @@ const exchanges = {
|
|
|
248
250
|
'hitbtc': hitbtc,
|
|
249
251
|
'hitbtc3': hitbtc3,
|
|
250
252
|
'hollaex': hollaex,
|
|
253
|
+
'htx': htx,
|
|
251
254
|
'huobi': huobi,
|
|
252
255
|
'huobijp': huobijp,
|
|
253
256
|
'huobipro': huobipro,
|
|
@@ -328,6 +331,7 @@ const pro = {
|
|
|
328
331
|
'gemini': gemini$1,
|
|
329
332
|
'hitbtc': hitbtc$1,
|
|
330
333
|
'hollaex': hollaex$1,
|
|
334
|
+
'htx': htx$1,
|
|
331
335
|
'huobi': huobi$1,
|
|
332
336
|
'huobijp': huobijp$1,
|
|
333
337
|
'huobipro': huobipro$1,
|
|
@@ -458,6 +462,7 @@ exports.gemini = gemini;
|
|
|
458
462
|
exports.hitbtc = hitbtc;
|
|
459
463
|
exports.hitbtc3 = hitbtc3;
|
|
460
464
|
exports.hollaex = hollaex;
|
|
465
|
+
exports.htx = htx;
|
|
461
466
|
exports.huobi = huobi;
|
|
462
467
|
exports.huobijp = huobijp;
|
|
463
468
|
exports.huobipro = huobipro;
|
package/dist/cjs/src/binance.js
CHANGED
|
@@ -985,9 +985,11 @@ class binance extends binance$1 {
|
|
|
985
985
|
'um/order': 1,
|
|
986
986
|
'um/conditional/order': 1,
|
|
987
987
|
'um/allOpenOrders': 1,
|
|
988
|
+
'um/conditional/allOpenOrders': 1,
|
|
988
989
|
'cm/order': 1,
|
|
989
990
|
'cm/conditional/order': 1,
|
|
990
991
|
'cm/allOpenOrders': 1,
|
|
992
|
+
'cm/conditional/allOpenOrders': 1,
|
|
991
993
|
'margin/order': 1,
|
|
992
994
|
'margin/allOpenOrders': 5,
|
|
993
995
|
'margin/orderList': 2,
|
package/dist/cjs/src/bitmart.js
CHANGED
|
@@ -575,6 +575,7 @@ class bitmart extends bitmart$1 {
|
|
|
575
575
|
'swap': 'swap',
|
|
576
576
|
},
|
|
577
577
|
'createMarketBuyOrderRequiresPrice': true,
|
|
578
|
+
'brokerId': 'CCXTxBitmart000',
|
|
578
579
|
},
|
|
579
580
|
});
|
|
580
581
|
}
|
|
@@ -1981,6 +1982,12 @@ class bitmart extends bitmart$1 {
|
|
|
1981
1982
|
// "order_id": 2707217580
|
|
1982
1983
|
// }
|
|
1983
1984
|
//
|
|
1985
|
+
// swap
|
|
1986
|
+
// "data": {
|
|
1987
|
+
// "order_id": 231116359426639,
|
|
1988
|
+
// "price": "market price"
|
|
1989
|
+
// },
|
|
1990
|
+
//
|
|
1984
1991
|
// cancelOrder
|
|
1985
1992
|
//
|
|
1986
1993
|
// "2707217580" // order id
|
|
@@ -2063,6 +2070,10 @@ class bitmart extends bitmart$1 {
|
|
|
2063
2070
|
type = 'limit';
|
|
2064
2071
|
timeInForce = 'IOC';
|
|
2065
2072
|
}
|
|
2073
|
+
let priceString = this.safeString(order, 'price');
|
|
2074
|
+
if (priceString === 'market price') {
|
|
2075
|
+
priceString = undefined;
|
|
2076
|
+
}
|
|
2066
2077
|
return this.safeOrder({
|
|
2067
2078
|
'id': id,
|
|
2068
2079
|
'clientOrderId': this.safeString(order, 'client_order_id'),
|
|
@@ -2075,7 +2086,7 @@ class bitmart extends bitmart$1 {
|
|
|
2075
2086
|
'timeInForce': timeInForce,
|
|
2076
2087
|
'postOnly': postOnly,
|
|
2077
2088
|
'side': this.parseOrderSide(this.safeString(order, 'side')),
|
|
2078
|
-
'price': this.omitZero(
|
|
2089
|
+
'price': this.omitZero(priceString),
|
|
2079
2090
|
'stopPrice': undefined,
|
|
2080
2091
|
'triggerPrice': undefined,
|
|
2081
2092
|
'amount': this.omitZero(this.safeString(order, 'size')),
|
|
@@ -2129,6 +2140,7 @@ class bitmart extends bitmart$1 {
|
|
|
2129
2140
|
* @description create a trade order
|
|
2130
2141
|
* @see https://developer-pro.bitmart.com/en/spot/#place-spot-order
|
|
2131
2142
|
* @see https://developer-pro.bitmart.com/en/spot/#place-margin-order
|
|
2143
|
+
* @see https://developer-pro.bitmart.com/en/futures/#submit-order-signed
|
|
2132
2144
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
2133
2145
|
* @param {string} type 'market' or 'limit'
|
|
2134
2146
|
* @param {string} side 'buy' or 'sell'
|
|
@@ -2136,11 +2148,153 @@ class bitmart extends bitmart$1 {
|
|
|
2136
2148
|
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
2137
2149
|
* @param {object} [params] extra parameters specific to the bitmart api endpoint
|
|
2138
2150
|
* @param {string} [params.marginMode] 'cross' or 'isolated'
|
|
2151
|
+
* @param {string} [params.leverage] *swap only* leverage level
|
|
2152
|
+
* @param {string} [params.clientOrderId] client order id of the order
|
|
2153
|
+
* @param {boolean} [params.reduceOnly] *swap only* reduce only
|
|
2154
|
+
* @param {boolean} [params.postOnly] make sure the order is posted to the order book and not matched immediately
|
|
2139
2155
|
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
2140
2156
|
*/
|
|
2141
2157
|
await this.loadMarkets();
|
|
2142
2158
|
const market = this.market(symbol);
|
|
2143
|
-
const
|
|
2159
|
+
const result = this.handleMarginModeAndParams('createOrder', params);
|
|
2160
|
+
const marginMode = this.safeString(result, 0);
|
|
2161
|
+
let response = undefined;
|
|
2162
|
+
if (market['spot']) {
|
|
2163
|
+
const spotRequest = this.createSpotOrderRequest(symbol, type, side, amount, price, params);
|
|
2164
|
+
if (marginMode === 'isolated') {
|
|
2165
|
+
response = await this.privatePostSpotV1MarginSubmitOrder(spotRequest);
|
|
2166
|
+
}
|
|
2167
|
+
else {
|
|
2168
|
+
response = await this.privatePostSpotV2SubmitOrder(spotRequest);
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
else {
|
|
2172
|
+
const swapRequest = this.createSwapOrderRequest(symbol, type, side, amount, price, params);
|
|
2173
|
+
response = await this.privatePostContractPrivateSubmitOrder(swapRequest);
|
|
2174
|
+
}
|
|
2175
|
+
//
|
|
2176
|
+
// spot and margin
|
|
2177
|
+
//
|
|
2178
|
+
// {
|
|
2179
|
+
// "code": 1000,
|
|
2180
|
+
// "trace":"886fb6ae-456b-4654-b4e0-d681ac05cea1",
|
|
2181
|
+
// "message": "OK",
|
|
2182
|
+
// "data": {
|
|
2183
|
+
// "order_id": 2707217580
|
|
2184
|
+
// }
|
|
2185
|
+
// }
|
|
2186
|
+
//
|
|
2187
|
+
// swap
|
|
2188
|
+
// {"code":1000,"message":"Ok","data":{"order_id":231116359426639,"price":"market price"},"trace":"7f9c94e10f9d4513bc08a7bfc2a5559a.62.16996369620521911"}
|
|
2189
|
+
//
|
|
2190
|
+
const data = this.safeValue(response, 'data', {});
|
|
2191
|
+
const order = this.parseOrder(data, market);
|
|
2192
|
+
order['type'] = type;
|
|
2193
|
+
order['side'] = side;
|
|
2194
|
+
order['amount'] = amount;
|
|
2195
|
+
order['price'] = price;
|
|
2196
|
+
return order;
|
|
2197
|
+
}
|
|
2198
|
+
createSwapOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
2199
|
+
/**
|
|
2200
|
+
* @method
|
|
2201
|
+
* @name bitmart#createSwapOrderRequest
|
|
2202
|
+
* @description create a trade order
|
|
2203
|
+
* @see https://developer-pro.bitmart.com/en/futures/#submit-order-signed
|
|
2204
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
2205
|
+
* @param {string} type 'market' or 'limit'
|
|
2206
|
+
* @param {string} side 'buy' or 'sell'
|
|
2207
|
+
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
2208
|
+
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
2209
|
+
* @param {object} [params] extra parameters specific to the bitmart api endpoint
|
|
2210
|
+
* @param {int} [params.leverage] leverage level
|
|
2211
|
+
* @param {boolean} [params.reduceOnly] *swap only* reduce only
|
|
2212
|
+
* @param {string} [params.marginMode] 'cross' or 'isolated', default is 'cross'
|
|
2213
|
+
* @param {string} [params.clientOrderId] client order id of the order
|
|
2214
|
+
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
2215
|
+
*/
|
|
2216
|
+
const market = this.market(symbol);
|
|
2217
|
+
const request = {
|
|
2218
|
+
'symbol': market['id'],
|
|
2219
|
+
'type': type,
|
|
2220
|
+
'size': parseInt(this.amountToPrecision(symbol, amount)),
|
|
2221
|
+
};
|
|
2222
|
+
const timeInForce = this.safeString(params, 'timeInForce');
|
|
2223
|
+
const mode = this.safeInteger(params, 'mode'); // only for swap
|
|
2224
|
+
const isMarketOrder = type === 'market';
|
|
2225
|
+
let postOnly = undefined;
|
|
2226
|
+
const reduceOnly = this.safeValue(params, 'reduceOnly');
|
|
2227
|
+
const isExchangeSpecificPo = (mode === 4);
|
|
2228
|
+
[postOnly, params] = this.handlePostOnly(isMarketOrder, isExchangeSpecificPo, params);
|
|
2229
|
+
params = this.omit(params, ['timeInForce', 'postOnly', 'reduceOnly']);
|
|
2230
|
+
const ioc = ((timeInForce === 'IOC') || (mode === 3));
|
|
2231
|
+
const isLimitOrder = (type === 'limit') || postOnly || ioc;
|
|
2232
|
+
if (timeInForce === 'GTC') {
|
|
2233
|
+
request['mode'] = 1;
|
|
2234
|
+
}
|
|
2235
|
+
else if (timeInForce === 'FOK') {
|
|
2236
|
+
request['mode'] = 2;
|
|
2237
|
+
}
|
|
2238
|
+
else if (timeInForce === 'IOC') {
|
|
2239
|
+
request['mode'] = 3;
|
|
2240
|
+
}
|
|
2241
|
+
if (postOnly) {
|
|
2242
|
+
request['mode'] = 4;
|
|
2243
|
+
}
|
|
2244
|
+
if (isLimitOrder) {
|
|
2245
|
+
request['price'] = this.priceToPrecision(symbol, price);
|
|
2246
|
+
}
|
|
2247
|
+
if (side === 'buy') {
|
|
2248
|
+
if (reduceOnly) {
|
|
2249
|
+
request['side'] = 2; // sell close long
|
|
2250
|
+
}
|
|
2251
|
+
else {
|
|
2252
|
+
request['side'] = 1; // buy open long
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
else if (side === 'sell') {
|
|
2256
|
+
if (reduceOnly) {
|
|
2257
|
+
request['side'] = 3; // sell close long
|
|
2258
|
+
}
|
|
2259
|
+
else {
|
|
2260
|
+
request['side'] = 4; // sell open short
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
let marginMode = undefined;
|
|
2264
|
+
[marginMode, params] = this.handleMarginModeAndParams('createOrder', params, 'cross');
|
|
2265
|
+
request['open_type'] = marginMode;
|
|
2266
|
+
const clientOrderId = this.safeString(params, 'clientOrderId');
|
|
2267
|
+
if (clientOrderId !== undefined) {
|
|
2268
|
+
params = this.omit(params, 'clientOrderId');
|
|
2269
|
+
request['client_order_id'] = clientOrderId;
|
|
2270
|
+
}
|
|
2271
|
+
const leverage = this.safeInteger(params, 'leverage', 1);
|
|
2272
|
+
params = this.omit(params, 'leverage');
|
|
2273
|
+
request['leverage'] = this.numberToString(leverage);
|
|
2274
|
+
return this.extend(request, params);
|
|
2275
|
+
}
|
|
2276
|
+
createSpotOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
2277
|
+
/**
|
|
2278
|
+
* @method
|
|
2279
|
+
* @name bitmart#createSpotOrderRequest
|
|
2280
|
+
* @description create a spot order request
|
|
2281
|
+
* @see https://developer-pro.bitmart.com/en/spot/#place-spot-order
|
|
2282
|
+
* @see https://developer-pro.bitmart.com/en/spot/#place-margin-order
|
|
2283
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
2284
|
+
* @param {string} type 'market' or 'limit'
|
|
2285
|
+
* @param {string} side 'buy' or 'sell'
|
|
2286
|
+
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
2287
|
+
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
2288
|
+
* @param {object} [params] extra parameters specific to the bitmart api endpoint
|
|
2289
|
+
* @param {string} [params.marginMode] 'cross' or 'isolated'
|
|
2290
|
+
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
2291
|
+
*/
|
|
2292
|
+
const market = this.market(symbol);
|
|
2293
|
+
const request = {
|
|
2294
|
+
'symbol': market['id'],
|
|
2295
|
+
'side': side,
|
|
2296
|
+
'type': type,
|
|
2297
|
+
};
|
|
2144
2298
|
const timeInForce = this.safeString(params, 'timeInForce');
|
|
2145
2299
|
if (timeInForce === 'FOK') {
|
|
2146
2300
|
throw new errors.InvalidOrder(this.id + ' createOrder() only accepts timeInForce parameter values of IOC or PO');
|
|
@@ -2153,45 +2307,36 @@ class bitmart extends bitmart$1 {
|
|
|
2153
2307
|
params = this.omit(params, ['timeInForce', 'postOnly']);
|
|
2154
2308
|
const ioc = ((timeInForce === 'IOC') || (type === 'ioc'));
|
|
2155
2309
|
const isLimitOrder = (type === 'limit') || postOnly || ioc;
|
|
2156
|
-
|
|
2157
|
-
if (
|
|
2158
|
-
request['
|
|
2159
|
-
request['
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
if (price !== undefined) {
|
|
2173
|
-
if (notional === undefined) {
|
|
2174
|
-
const amountString = this.numberToString(amount);
|
|
2175
|
-
const priceString = this.numberToString(price);
|
|
2176
|
-
notional = this.parseNumber(Precise["default"].stringMul(amountString, priceString));
|
|
2177
|
-
}
|
|
2178
|
-
}
|
|
2179
|
-
else if (notional === undefined) {
|
|
2180
|
-
throw new errors.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 and supply the total cost value in the 'amount' argument or in the 'notional' extra parameter (the exchange-specific behaviour)");
|
|
2310
|
+
// method = 'privatePostSpotV2SubmitOrder';
|
|
2311
|
+
if (isLimitOrder) {
|
|
2312
|
+
request['size'] = this.amountToPrecision(symbol, amount);
|
|
2313
|
+
request['price'] = this.priceToPrecision(symbol, price);
|
|
2314
|
+
}
|
|
2315
|
+
else if (isMarketOrder) {
|
|
2316
|
+
// for market buy it requires the amount of quote currency to spend
|
|
2317
|
+
if (side === 'buy') {
|
|
2318
|
+
let notional = this.safeNumber(params, 'notional');
|
|
2319
|
+
const createMarketBuyOrderRequiresPrice = this.safeValue(this.options, 'createMarketBuyOrderRequiresPrice', true);
|
|
2320
|
+
if (createMarketBuyOrderRequiresPrice) {
|
|
2321
|
+
if (price !== undefined) {
|
|
2322
|
+
if (notional === undefined) {
|
|
2323
|
+
const amountString = this.numberToString(amount);
|
|
2324
|
+
const priceString = this.numberToString(price);
|
|
2325
|
+
notional = this.parseNumber(Precise["default"].stringMul(amountString, priceString));
|
|
2181
2326
|
}
|
|
2182
2327
|
}
|
|
2183
|
-
else {
|
|
2184
|
-
|
|
2328
|
+
else if (notional === undefined) {
|
|
2329
|
+
throw new errors.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 and supply the total cost value in the 'amount' argument or in the 'notional' extra parameter (the exchange-specific behaviour)");
|
|
2185
2330
|
}
|
|
2186
|
-
request['notional'] = this.decimalToPrecision(notional, number.TRUNCATE, market['precision']['price'], this.precisionMode);
|
|
2187
2331
|
}
|
|
2188
|
-
else
|
|
2189
|
-
|
|
2332
|
+
else {
|
|
2333
|
+
notional = (notional === undefined) ? amount : notional;
|
|
2190
2334
|
}
|
|
2335
|
+
request['notional'] = this.decimalToPrecision(notional, number.TRUNCATE, market['precision']['price'], this.precisionMode);
|
|
2336
|
+
}
|
|
2337
|
+
else if (side === 'sell') {
|
|
2338
|
+
request['size'] = this.amountToPrecision(symbol, amount);
|
|
2191
2339
|
}
|
|
2192
|
-
}
|
|
2193
|
-
else if (market['swap']) {
|
|
2194
|
-
throw new errors.NotSupported(this.id + ' createOrder() does not accept swap orders, only spot orders are allowed');
|
|
2195
2340
|
}
|
|
2196
2341
|
if (postOnly) {
|
|
2197
2342
|
request['type'] = 'limit_maker';
|
|
@@ -2199,33 +2344,7 @@ class bitmart extends bitmart$1 {
|
|
|
2199
2344
|
if (ioc) {
|
|
2200
2345
|
request['type'] = 'ioc';
|
|
2201
2346
|
}
|
|
2202
|
-
|
|
2203
|
-
if (marginMode !== undefined) {
|
|
2204
|
-
if (marginMode !== 'isolated') {
|
|
2205
|
-
throw new errors.NotSupported(this.id + ' only isolated margin is supported');
|
|
2206
|
-
}
|
|
2207
|
-
method = 'privatePostSpotV1MarginSubmitOrder';
|
|
2208
|
-
}
|
|
2209
|
-
const response = await this[method](this.extend(request, query));
|
|
2210
|
-
//
|
|
2211
|
-
// spot and margin
|
|
2212
|
-
//
|
|
2213
|
-
// {
|
|
2214
|
-
// "code": 1000,
|
|
2215
|
-
// "trace":"886fb6ae-456b-4654-b4e0-d681ac05cea1",
|
|
2216
|
-
// "message": "OK",
|
|
2217
|
-
// "data": {
|
|
2218
|
-
// "order_id": 2707217580
|
|
2219
|
-
// }
|
|
2220
|
-
// }
|
|
2221
|
-
//
|
|
2222
|
-
const data = this.safeValue(response, 'data', {});
|
|
2223
|
-
const order = this.parseOrder(data, market);
|
|
2224
|
-
order['type'] = type;
|
|
2225
|
-
order['side'] = side;
|
|
2226
|
-
order['amount'] = amount;
|
|
2227
|
-
order['price'] = price;
|
|
2228
|
-
return order;
|
|
2347
|
+
return this.extend(request, params);
|
|
2229
2348
|
}
|
|
2230
2349
|
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
2231
2350
|
/**
|
|
@@ -4061,9 +4180,11 @@ class bitmart extends bitmart$1 {
|
|
|
4061
4180
|
if (api === 'private') {
|
|
4062
4181
|
this.checkRequiredCredentials();
|
|
4063
4182
|
const timestamp = this.milliseconds().toString();
|
|
4183
|
+
const brokerId = this.safeString(this.options, 'brokerId', 'CCXTxBitmart000');
|
|
4064
4184
|
headers = {
|
|
4065
4185
|
'X-BM-KEY': this.apiKey,
|
|
4066
4186
|
'X-BM-TIMESTAMP': timestamp,
|
|
4187
|
+
'X-BM-BROKER-ID': brokerId,
|
|
4067
4188
|
'Content-Type': 'application/json',
|
|
4068
4189
|
};
|
|
4069
4190
|
if (!getOrDelete) {
|