ccxt 4.2.7 → 4.2.9
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/build.sh +18 -2
- package/dist/ccxt.browser.js +250 -51
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/binance.js +18 -5
- package/dist/cjs/src/bingx.js +15 -0
- package/dist/cjs/src/bitmart.js +94 -15
- package/dist/cjs/src/bybit.js +23 -3
- package/dist/cjs/src/okx.js +46 -15
- package/dist/cjs/src/pro/binance.js +17 -1
- package/dist/cjs/src/pro/bitget.js +3 -1
- package/dist/cjs/src/pro/bitmart.js +18 -3
- package/dist/cjs/src/pro/bybit.js +3 -1
- package/dist/cjs/src/pro/coinbasepro.js +1 -2
- package/dist/cjs/src/pro/cryptocom.js +9 -3
- package/dist/cjs/src/pro/poloniex.js +2 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/binance.js +18 -5
- package/js/src/bingx.d.ts +1 -0
- package/js/src/bingx.js +16 -1
- package/js/src/bitmart.js +95 -16
- package/js/src/bybit.js +23 -3
- package/js/src/okx.js +46 -15
- package/js/src/pro/binance.js +17 -1
- package/js/src/pro/bitget.js +3 -1
- package/js/src/pro/bitmart.js +18 -3
- package/js/src/pro/bybit.js +3 -1
- package/js/src/pro/coinbasepro.js +1 -2
- package/js/src/pro/cryptocom.js +9 -3
- package/js/src/pro/poloniex.js +2 -1
- package/package.json +1 -1
|
@@ -222,7 +222,9 @@ class bybit extends bybit$1 {
|
|
|
222
222
|
}
|
|
223
223
|
const ticker = await this.watchTopics(url, messageHashes, topics, params);
|
|
224
224
|
if (this.newUpdates) {
|
|
225
|
-
|
|
225
|
+
const result = {};
|
|
226
|
+
result[ticker['symbol']] = ticker;
|
|
227
|
+
return result;
|
|
226
228
|
}
|
|
227
229
|
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
228
230
|
}
|
|
@@ -121,8 +121,7 @@ class coinbasepro extends coinbasepro$1 {
|
|
|
121
121
|
async watchTickers(symbols = undefined, params = {}) {
|
|
122
122
|
/**
|
|
123
123
|
* @method
|
|
124
|
-
* @name
|
|
125
|
-
* @see https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-tickers-channel
|
|
124
|
+
* @name coinbasepro#watchTickers
|
|
126
125
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
|
|
127
126
|
* @param {string[]} [symbols] unified symbol of the market to fetch the ticker for
|
|
128
127
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -89,13 +89,19 @@ class cryptocom extends cryptocom$1 {
|
|
|
89
89
|
await this.loadMarkets();
|
|
90
90
|
symbols = this.marketSymbols(symbols);
|
|
91
91
|
const topics = [];
|
|
92
|
+
const messageHashes = [];
|
|
93
|
+
if (!limit) {
|
|
94
|
+
limit = 150;
|
|
95
|
+
}
|
|
92
96
|
for (let i = 0; i < symbols.length; i++) {
|
|
93
97
|
const symbol = symbols[i];
|
|
94
98
|
const market = this.market(symbol);
|
|
95
|
-
const currentTopic = 'book' + '.' + market['id'];
|
|
99
|
+
const currentTopic = 'book' + '.' + market['id'] + '.' + limit;
|
|
100
|
+
const messageHash = 'orderbook:' + market['symbol'];
|
|
101
|
+
messageHashes.push(messageHash);
|
|
96
102
|
topics.push(currentTopic);
|
|
97
103
|
}
|
|
98
|
-
const orderbook = await this.watchPublicMultiple(
|
|
104
|
+
const orderbook = await this.watchPublicMultiple(messageHashes, topics, params);
|
|
99
105
|
return orderbook.limit();
|
|
100
106
|
}
|
|
101
107
|
handleOrderBookSnapshot(client, message) {
|
|
@@ -120,7 +126,6 @@ class cryptocom extends cryptocom$1 {
|
|
|
120
126
|
// ]
|
|
121
127
|
// }
|
|
122
128
|
//
|
|
123
|
-
const messageHash = this.safeString(message, 'subscription');
|
|
124
129
|
const marketId = this.safeString(message, 'instrument_name');
|
|
125
130
|
const market = this.safeMarket(marketId);
|
|
126
131
|
const symbol = market['symbol'];
|
|
@@ -136,6 +141,7 @@ class cryptocom extends cryptocom$1 {
|
|
|
136
141
|
}
|
|
137
142
|
orderbook.reset(snapshot);
|
|
138
143
|
this.orderbooks[symbol] = orderbook;
|
|
144
|
+
const messageHash = 'orderbook:' + symbol;
|
|
139
145
|
client.resolve(orderbook, messageHash);
|
|
140
146
|
}
|
|
141
147
|
async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
@@ -539,7 +539,8 @@ class poloniex extends poloniex$1 {
|
|
|
539
539
|
const marketId = this.safeString(data, 'symbol');
|
|
540
540
|
const symbol = this.safeSymbol(marketId);
|
|
541
541
|
const market = this.safeMarket(symbol);
|
|
542
|
-
const
|
|
542
|
+
const timeframes = this.safeValue(this.options, 'timeframes', {});
|
|
543
|
+
const timeframe = this.findTimeframe(channel, timeframes);
|
|
543
544
|
const messageHash = channel + '::' + symbol;
|
|
544
545
|
const parsed = this.parseWsOHLCV(data, market);
|
|
545
546
|
this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol, {});
|
package/js/ccxt.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
|
|
|
4
4
|
import * as errors from './src/base/errors.js';
|
|
5
5
|
import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } from './src/base/types.js';
|
|
6
6
|
import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
|
|
7
|
-
declare const version = "4.2.
|
|
7
|
+
declare const version = "4.2.8";
|
|
8
8
|
import ace from './src/ace.js';
|
|
9
9
|
import alpaca from './src/alpaca.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|
package/js/ccxt.js
CHANGED
|
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
|
|
|
38
38
|
import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
|
|
39
39
|
//-----------------------------------------------------------------------------
|
|
40
40
|
// this is updated by vss.js when building
|
|
41
|
-
const version = '4.2.
|
|
41
|
+
const version = '4.2.9';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
package/js/src/binance.js
CHANGED
|
@@ -4417,6 +4417,8 @@ export default class binance extends Exchange {
|
|
|
4417
4417
|
* @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
|
|
4418
4418
|
* @param {boolean} [params.sor] *spot only* whether to use SOR (Smart Order Routing) or not, default is false
|
|
4419
4419
|
* @param {boolean} [params.test] *spot only* whether to use the test endpoint or not, default is false
|
|
4420
|
+
* @param {float} [params.trailingPercent] the percent to trail away from the current market price
|
|
4421
|
+
* @param {float} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
|
|
4420
4422
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4421
4423
|
*/
|
|
4422
4424
|
await this.loadMarkets();
|
|
@@ -4465,6 +4467,8 @@ export default class binance extends Exchange {
|
|
|
4465
4467
|
* @param {float|undefined} price the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
4466
4468
|
* @param {object} params extra parameters specific to the exchange API endpoint
|
|
4467
4469
|
* @param {string|undefined} params.marginMode 'cross' or 'isolated', for spot margin trading
|
|
4470
|
+
* @param {float} [params.trailingPercent] the percent to trail away from the current market price
|
|
4471
|
+
* @param {float} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
|
|
4468
4472
|
* @returns {object} request to be sent to the exchange
|
|
4469
4473
|
*/
|
|
4470
4474
|
const market = this.market(symbol);
|
|
@@ -4478,9 +4482,12 @@ export default class binance extends Exchange {
|
|
|
4478
4482
|
const stopLossPrice = this.safeValue(params, 'stopLossPrice', triggerPrice); // fallback to stopLoss
|
|
4479
4483
|
const takeProfitPrice = this.safeValue(params, 'takeProfitPrice');
|
|
4480
4484
|
const trailingDelta = this.safeValue(params, 'trailingDelta');
|
|
4485
|
+
const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activationPrice', price);
|
|
4486
|
+
const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
|
|
4487
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
4481
4488
|
const isStopLoss = stopLossPrice !== undefined || trailingDelta !== undefined;
|
|
4482
4489
|
const isTakeProfit = takeProfitPrice !== undefined;
|
|
4483
|
-
params = this.omit(params, ['type', 'newClientOrderId', 'clientOrderId', 'postOnly', 'stopLossPrice', 'takeProfitPrice', 'stopPrice', 'triggerPrice']);
|
|
4490
|
+
params = this.omit(params, ['type', 'newClientOrderId', 'clientOrderId', 'postOnly', 'stopLossPrice', 'takeProfitPrice', 'stopPrice', 'triggerPrice', 'trailingTriggerPrice', 'trailingPercent']);
|
|
4484
4491
|
const [marginMode, query] = this.handleMarginModeAndParams('createOrder', params);
|
|
4485
4492
|
const request = {
|
|
4486
4493
|
'symbol': market['id'],
|
|
@@ -4501,7 +4508,14 @@ export default class binance extends Exchange {
|
|
|
4501
4508
|
}
|
|
4502
4509
|
let uppercaseType = type.toUpperCase();
|
|
4503
4510
|
let stopPrice = undefined;
|
|
4504
|
-
if (
|
|
4511
|
+
if (isTrailingPercentOrder) {
|
|
4512
|
+
uppercaseType = 'TRAILING_STOP_MARKET';
|
|
4513
|
+
request['callbackRate'] = trailingPercent;
|
|
4514
|
+
if (trailingTriggerPrice !== undefined) {
|
|
4515
|
+
request['activationPrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
|
|
4516
|
+
}
|
|
4517
|
+
}
|
|
4518
|
+
else if (isStopLoss) {
|
|
4505
4519
|
stopPrice = stopLossPrice;
|
|
4506
4520
|
if (isMarketOrder) {
|
|
4507
4521
|
// spot STOP_LOSS market orders are not a valid order type
|
|
@@ -4645,9 +4659,8 @@ export default class binance extends Exchange {
|
|
|
4645
4659
|
}
|
|
4646
4660
|
else if (uppercaseType === 'TRAILING_STOP_MARKET') {
|
|
4647
4661
|
quantityIsRequired = true;
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
throw new InvalidOrder(this.id + ' createOrder() requires a callbackRate extra param for a ' + type + ' order');
|
|
4662
|
+
if (trailingPercent === undefined) {
|
|
4663
|
+
throw new InvalidOrder(this.id + ' createOrder() requires a trailingPercent param for a ' + type + ' order');
|
|
4651
4664
|
}
|
|
4652
4665
|
}
|
|
4653
4666
|
if (quantityIsRequired) {
|
package/js/src/bingx.d.ts
CHANGED
|
@@ -66,6 +66,7 @@ export default class bingx extends Exchange {
|
|
|
66
66
|
createMarketSellOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
|
|
67
67
|
createOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): any;
|
|
68
68
|
createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
|
|
69
|
+
fixStringifiedJsonMembers(content: any): any;
|
|
69
70
|
createOrders(orders: OrderRequest[], params?: {}): Promise<Order[]>;
|
|
70
71
|
parseOrderSide(side: any): string;
|
|
71
72
|
parseOrder(order: any, market?: Market): Order;
|
package/js/src/bingx.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import Exchange from './abstract/bingx.js';
|
|
9
|
-
import { AuthenticationError, ExchangeNotAvailable, PermissionDenied, ExchangeError, InsufficientFunds, BadRequest, OrderNotFound, DDoSProtection, BadSymbol, ArgumentsRequired } from './base/errors.js';
|
|
9
|
+
import { AuthenticationError, ExchangeNotAvailable, PermissionDenied, AccountSuspended, ExchangeError, InsufficientFunds, BadRequest, OrderNotFound, DDoSProtection, BadSymbol, ArgumentsRequired } from './base/errors.js';
|
|
10
10
|
import { Precise } from './base/Precise.js';
|
|
11
11
|
import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
|
|
12
12
|
import { DECIMAL_PLACES } from './base/functions/number.js';
|
|
@@ -355,6 +355,7 @@ export default class bingx extends Exchange {
|
|
|
355
355
|
'80014': BadRequest,
|
|
356
356
|
'80016': OrderNotFound,
|
|
357
357
|
'80017': OrderNotFound,
|
|
358
|
+
'100414': AccountSuspended,
|
|
358
359
|
'100437': BadRequest, // {"code":100437,"msg":"The withdrawal amount is lower than the minimum limit, please re-enter.","timestamp":1689258588845}
|
|
359
360
|
},
|
|
360
361
|
'broad': {},
|
|
@@ -1898,12 +1899,26 @@ export default class bingx extends Exchange {
|
|
|
1898
1899
|
// }
|
|
1899
1900
|
//
|
|
1900
1901
|
if (typeof response === 'string') {
|
|
1902
|
+
// broken api engine : order-ids are too long numbers (i.e. 1742930526912864656)
|
|
1903
|
+
// and JSON.parse can not handle them in JS, so we have to use .parseJson
|
|
1904
|
+
// however, when order has an attached SL/TP, their value types need extra parsing
|
|
1905
|
+
response = this.fixStringifiedJsonMembers(response);
|
|
1901
1906
|
response = this.parseJson(response);
|
|
1902
1907
|
}
|
|
1903
1908
|
const data = this.safeValue(response, 'data', {});
|
|
1904
1909
|
const order = this.safeValue(data, 'order', data);
|
|
1905
1910
|
return this.parseOrder(order, market);
|
|
1906
1911
|
}
|
|
1912
|
+
fixStringifiedJsonMembers(content) {
|
|
1913
|
+
// when stringified json has members with their values also stringified, like:
|
|
1914
|
+
// '{"code":0, "data":{"order":{"orderId":1742968678528512345,"symbol":"BTC-USDT", "takeProfit":"{\"type\":\"TAKE_PROFIT\",\"stopPrice\":43320.1}","reduceOnly":false}}}'
|
|
1915
|
+
// we can fix with below manipulations
|
|
1916
|
+
// @ts-ignore
|
|
1917
|
+
let modifiedContent = content.replaceAll('\\', '');
|
|
1918
|
+
modifiedContent = modifiedContent.replaceAll('"{', '{');
|
|
1919
|
+
modifiedContent = modifiedContent.replaceAll('}"', '}');
|
|
1920
|
+
return modifiedContent;
|
|
1921
|
+
}
|
|
1907
1922
|
async createOrders(orders, params = {}) {
|
|
1908
1923
|
/**
|
|
1909
1924
|
* @method
|
package/js/src/bitmart.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import Exchange from './abstract/bitmart.js';
|
|
9
|
-
import { AuthenticationError, ExchangeNotAvailable, AccountSuspended, PermissionDenied, RateLimitExceeded, InvalidNonce, InvalidAddress, ArgumentsRequired, ExchangeError, InvalidOrder, InsufficientFunds, BadRequest, OrderNotFound, BadSymbol, NotSupported } from './base/errors.js';
|
|
9
|
+
import { AuthenticationError, ExchangeNotAvailable, OnMaintenance, AccountSuspended, PermissionDenied, RateLimitExceeded, InvalidNonce, InvalidAddress, ArgumentsRequired, ExchangeError, InvalidOrder, InsufficientFunds, BadRequest, OrderNotFound, BadSymbol, NotSupported } from './base/errors.js';
|
|
10
10
|
import { Precise } from './base/Precise.js';
|
|
11
11
|
import { TICK_SIZE, TRUNCATE } from './base/functions/number.js';
|
|
12
12
|
import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
|
|
@@ -309,7 +309,11 @@ export default class bitmart extends Exchange {
|
|
|
309
309
|
'30012': AuthenticationError,
|
|
310
310
|
'30013': RateLimitExceeded,
|
|
311
311
|
'30014': ExchangeNotAvailable,
|
|
312
|
-
|
|
312
|
+
'30016': OnMaintenance,
|
|
313
|
+
'30017': RateLimitExceeded,
|
|
314
|
+
'30018': BadRequest,
|
|
315
|
+
'30019': PermissionDenied,
|
|
316
|
+
// funding account & sub account errors
|
|
313
317
|
'60000': BadRequest,
|
|
314
318
|
'60001': BadRequest,
|
|
315
319
|
'60002': BadRequest,
|
|
@@ -326,13 +330,31 @@ export default class bitmart extends Exchange {
|
|
|
326
330
|
'60020': PermissionDenied,
|
|
327
331
|
'60021': PermissionDenied,
|
|
328
332
|
'60022': PermissionDenied,
|
|
333
|
+
'60026': PermissionDenied,
|
|
334
|
+
'60027': PermissionDenied,
|
|
335
|
+
'60028': AccountSuspended,
|
|
336
|
+
'60029': AccountSuspended,
|
|
329
337
|
'60030': BadRequest,
|
|
330
338
|
'60031': BadRequest,
|
|
331
339
|
'60050': ExchangeError,
|
|
332
340
|
'60051': ExchangeError,
|
|
333
341
|
'61001': InsufficientFunds,
|
|
334
342
|
'61003': BadRequest,
|
|
335
|
-
|
|
343
|
+
'61004': BadRequest,
|
|
344
|
+
'61005': BadRequest,
|
|
345
|
+
'61006': NotSupported,
|
|
346
|
+
'61007': ExchangeError,
|
|
347
|
+
'61008': ExchangeError,
|
|
348
|
+
// spot public errors
|
|
349
|
+
'70000': ExchangeError,
|
|
350
|
+
'70001': BadRequest,
|
|
351
|
+
'70002': BadSymbol,
|
|
352
|
+
'71001': BadRequest,
|
|
353
|
+
'71002': BadRequest,
|
|
354
|
+
'71003': BadRequest,
|
|
355
|
+
'71004': BadRequest,
|
|
356
|
+
'71005': BadRequest,
|
|
357
|
+
// spot & margin errors
|
|
336
358
|
'50000': BadRequest,
|
|
337
359
|
'50001': BadSymbol,
|
|
338
360
|
'50002': BadRequest,
|
|
@@ -352,26 +374,75 @@ export default class bitmart extends Exchange {
|
|
|
352
374
|
'50016': BadRequest,
|
|
353
375
|
'50017': BadRequest,
|
|
354
376
|
'50018': BadRequest,
|
|
355
|
-
'50019':
|
|
356
|
-
'51004': InsufficientFunds,
|
|
357
|
-
// '50019': ExchangeError, // 400, Invalid status. validate status is [1=Failed, 2=Success, 3=Frozen Failed, 4=Frozen Success, 5=Partially Filled, 6=Fully Fulled, 7=Canceling, 8=Canceled
|
|
377
|
+
'50019': ExchangeError,
|
|
358
378
|
'50020': InsufficientFunds,
|
|
359
379
|
'50021': BadRequest,
|
|
360
380
|
'50022': ExchangeNotAvailable,
|
|
361
381
|
'50023': BadSymbol,
|
|
382
|
+
'50024': BadRequest,
|
|
383
|
+
'50025': BadRequest,
|
|
384
|
+
'50026': BadRequest,
|
|
385
|
+
'50027': BadRequest,
|
|
386
|
+
'50028': BadRequest,
|
|
362
387
|
'50029': InvalidOrder,
|
|
363
|
-
'50030':
|
|
388
|
+
'50030': OrderNotFound,
|
|
389
|
+
'50031': OrderNotFound,
|
|
364
390
|
'50032': OrderNotFound,
|
|
391
|
+
'50033': InvalidOrder,
|
|
365
392
|
// below Error codes used interchangeably for both failed postOnly and IOC orders depending on market price and order side
|
|
366
|
-
'50035': InvalidOrder,
|
|
367
393
|
'50034': InvalidOrder,
|
|
394
|
+
'50035': InvalidOrder,
|
|
395
|
+
'50036': ExchangeError,
|
|
396
|
+
'50037': BadRequest,
|
|
397
|
+
'50038': BadRequest,
|
|
398
|
+
'50039': BadRequest,
|
|
399
|
+
'50040': BadSymbol,
|
|
400
|
+
'50041': ExchangeError,
|
|
401
|
+
'50042': BadRequest,
|
|
402
|
+
'51000': BadSymbol,
|
|
403
|
+
'51001': ExchangeError,
|
|
404
|
+
'51002': ExchangeError,
|
|
405
|
+
'51003': ExchangeError,
|
|
406
|
+
'51004': InsufficientFunds,
|
|
407
|
+
'51005': InvalidOrder,
|
|
408
|
+
'51006': InvalidOrder,
|
|
409
|
+
'51007': BadRequest,
|
|
410
|
+
'51008': ExchangeError,
|
|
411
|
+
'51009': InvalidOrder,
|
|
412
|
+
'51010': InvalidOrder,
|
|
368
413
|
'51011': InvalidOrder,
|
|
414
|
+
'51012': InvalidOrder,
|
|
415
|
+
'51013': InvalidOrder,
|
|
416
|
+
'51014': InvalidOrder,
|
|
417
|
+
'51015': InvalidOrder,
|
|
418
|
+
'52000': BadRequest,
|
|
419
|
+
'52001': BadRequest,
|
|
420
|
+
'52002': BadRequest,
|
|
421
|
+
'52003': BadRequest,
|
|
422
|
+
'52004': BadRequest,
|
|
369
423
|
'53000': AccountSuspended,
|
|
370
424
|
'53001': AccountSuspended,
|
|
425
|
+
'53002': PermissionDenied,
|
|
426
|
+
'53003': PermissionDenied,
|
|
427
|
+
'53005': PermissionDenied,
|
|
428
|
+
'53006': PermissionDenied,
|
|
429
|
+
'53007': PermissionDenied,
|
|
430
|
+
'53008': PermissionDenied,
|
|
431
|
+
'53009': PermissionDenied,
|
|
432
|
+
'53010': PermissionDenied,
|
|
371
433
|
'57001': BadRequest,
|
|
372
434
|
'58001': BadRequest,
|
|
373
435
|
'59001': ExchangeError,
|
|
374
436
|
'59002': ExchangeError,
|
|
437
|
+
'59003': ExchangeError,
|
|
438
|
+
'59004': ExchangeError,
|
|
439
|
+
'59005': PermissionDenied,
|
|
440
|
+
'59006': ExchangeError,
|
|
441
|
+
'59007': ExchangeError,
|
|
442
|
+
'59008': ExchangeError,
|
|
443
|
+
'59009': ExchangeError,
|
|
444
|
+
'59010': InsufficientFunds,
|
|
445
|
+
'59011': ExchangeError,
|
|
375
446
|
// contract errors
|
|
376
447
|
'40001': ExchangeError,
|
|
377
448
|
'40002': ExchangeError,
|
|
@@ -407,14 +478,22 @@ export default class bitmart extends Exchange {
|
|
|
407
478
|
'40032': InvalidOrder,
|
|
408
479
|
'40033': InvalidOrder,
|
|
409
480
|
'40034': BadSymbol,
|
|
410
|
-
'
|
|
411
|
-
'
|
|
412
|
-
'
|
|
413
|
-
'
|
|
414
|
-
'
|
|
415
|
-
'
|
|
416
|
-
'
|
|
417
|
-
'
|
|
481
|
+
'40035': OrderNotFound,
|
|
482
|
+
'40036': InvalidOrder,
|
|
483
|
+
'40037': OrderNotFound,
|
|
484
|
+
'40038': BadRequest,
|
|
485
|
+
'40039': BadRequest,
|
|
486
|
+
'40040': InvalidOrder,
|
|
487
|
+
'40041': InvalidOrder,
|
|
488
|
+
'40042': InvalidOrder,
|
|
489
|
+
'40043': InvalidOrder,
|
|
490
|
+
'40044': InvalidOrder,
|
|
491
|
+
'40045': InvalidOrder,
|
|
492
|
+
'40046': PermissionDenied,
|
|
493
|
+
'40047': PermissionDenied,
|
|
494
|
+
'40048': BadRequest,
|
|
495
|
+
'40049': BadRequest,
|
|
496
|
+
'40050': InvalidOrder, // 403, Client OrderId duplicated with existing orders
|
|
418
497
|
},
|
|
419
498
|
'broad': {},
|
|
420
499
|
},
|
package/js/src/bybit.js
CHANGED
|
@@ -3502,6 +3502,7 @@ export default class bybit extends Exchange {
|
|
|
3502
3502
|
* @name bybit#createOrder
|
|
3503
3503
|
* @description create a trade order
|
|
3504
3504
|
* @see https://bybit-exchange.github.io/docs/v5/order/create-order
|
|
3505
|
+
* @see https://bybit-exchange.github.io/docs/v5/position/trading-stop
|
|
3505
3506
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
3506
3507
|
* @param {string} type 'market' or 'limit'
|
|
3507
3508
|
* @param {string} side 'buy' or 'sell'
|
|
@@ -3523,6 +3524,8 @@ export default class bybit extends Exchange {
|
|
|
3523
3524
|
* @param {float} [params.takeProfit.triggerPrice] take profit trigger price
|
|
3524
3525
|
* @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
|
|
3525
3526
|
* @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
|
|
3527
|
+
* @param {string} [params.trailingAmount] the quote amount to trail away from the current market price
|
|
3528
|
+
* @param {string} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
|
|
3526
3529
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3527
3530
|
*/
|
|
3528
3531
|
await this.loadMarkets();
|
|
@@ -3533,8 +3536,16 @@ export default class bybit extends Exchange {
|
|
|
3533
3536
|
if (isUsdcSettled && !isUnifiedAccount) {
|
|
3534
3537
|
return await this.createUsdcOrder(symbol, type, side, amount, price, params);
|
|
3535
3538
|
}
|
|
3539
|
+
const trailingAmount = this.safeString2(params, 'trailingAmount', 'trailingStop');
|
|
3540
|
+
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
3536
3541
|
const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
3537
|
-
|
|
3542
|
+
let response = undefined;
|
|
3543
|
+
if (isTrailingAmountOrder) {
|
|
3544
|
+
response = await this.privatePostV5PositionTradingStop(orderRequest);
|
|
3545
|
+
}
|
|
3546
|
+
else {
|
|
3547
|
+
response = await this.privatePostV5OrderCreate(orderRequest); // already extended inside createOrderRequest
|
|
3548
|
+
}
|
|
3538
3549
|
//
|
|
3539
3550
|
// {
|
|
3540
3551
|
// "retCode": 0,
|
|
@@ -3644,12 +3655,21 @@ export default class bybit extends Exchange {
|
|
|
3644
3655
|
const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
|
|
3645
3656
|
const stopLoss = this.safeValue(params, 'stopLoss');
|
|
3646
3657
|
const takeProfit = this.safeValue(params, 'takeProfit');
|
|
3658
|
+
const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activePrice', price);
|
|
3659
|
+
const trailingAmount = this.safeString2(params, 'trailingAmount', 'trailingStop');
|
|
3660
|
+
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
3647
3661
|
const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
|
|
3648
3662
|
const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
|
|
3649
3663
|
const isStopLoss = stopLoss !== undefined;
|
|
3650
3664
|
const isTakeProfit = takeProfit !== undefined;
|
|
3651
3665
|
const isBuy = side === 'buy';
|
|
3652
|
-
if (
|
|
3666
|
+
if (isTrailingAmountOrder) {
|
|
3667
|
+
if (trailingTriggerPrice !== undefined) {
|
|
3668
|
+
request['activePrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
|
|
3669
|
+
}
|
|
3670
|
+
request['trailingStop'] = trailingAmount;
|
|
3671
|
+
}
|
|
3672
|
+
else if (triggerPrice !== undefined) {
|
|
3653
3673
|
const triggerDirection = this.safeString(params, 'triggerDirection');
|
|
3654
3674
|
params = this.omit(params, ['triggerPrice', 'stopPrice', 'triggerDirection']);
|
|
3655
3675
|
if (market['spot']) {
|
|
@@ -3704,7 +3724,7 @@ export default class bybit extends Exchange {
|
|
|
3704
3724
|
// mandatory field for options
|
|
3705
3725
|
request['orderLinkId'] = this.uuid16();
|
|
3706
3726
|
}
|
|
3707
|
-
params = this.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit']);
|
|
3727
|
+
params = this.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingAmount', 'trailingTriggerPrice']);
|
|
3708
3728
|
return this.extend(request, params);
|
|
3709
3729
|
}
|
|
3710
3730
|
async createOrders(orders, params = {}) {
|