ccxt 4.2.29 → 4.2.31
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 +5 -6
- package/dist/ccxt.browser.js +2196 -601
- package/dist/ccxt.browser.min.js +7 -7
- package/dist/cjs/ccxt.js +3 -1
- package/dist/cjs/src/ascendex.js +5 -5
- package/dist/cjs/src/base/Exchange.js +33 -25
- package/dist/cjs/src/base/errors.js +3 -3
- package/dist/cjs/src/base/functions/type.js +12 -0
- package/dist/cjs/src/bigone.js +2 -2
- package/dist/cjs/src/binance.js +897 -218
- package/dist/cjs/src/bingx.js +1 -1
- package/dist/cjs/src/bitfinex.js +1 -1
- package/dist/cjs/src/bitfinex2.js +457 -93
- package/dist/cjs/src/bitforex.js +3 -0
- package/dist/cjs/src/bitget.js +8 -4
- package/dist/cjs/src/bitmart.js +3 -3
- package/dist/cjs/src/bitmex.js +4 -4
- package/dist/cjs/src/bitrue.js +1 -1
- package/dist/cjs/src/bitso.js +1 -1
- package/dist/cjs/src/bitteam.js +2 -2
- package/dist/cjs/src/btcalpha.js +1 -1
- package/dist/cjs/src/bybit.js +3 -3
- package/dist/cjs/src/coinbase.js +22 -5
- package/dist/cjs/src/coincheck.js +1 -1
- package/dist/cjs/src/coinex.js +2 -2
- package/dist/cjs/src/coinlist.js +1 -1
- package/dist/cjs/src/coinmate.js +1 -1
- package/dist/cjs/src/coinmetro.js +2 -2
- package/dist/cjs/src/coinsph.js +1 -1
- package/dist/cjs/src/cryptocom.js +3 -3
- package/dist/cjs/src/deribit.js +1 -0
- package/dist/cjs/src/digifinex.js +6 -4
- package/dist/cjs/src/exmo.js +2 -2
- package/dist/cjs/src/gate.js +5 -5
- package/dist/cjs/src/gemini.js +3 -3
- package/dist/cjs/src/hitbtc.js +14 -20
- package/dist/cjs/src/hollaex.js +2 -2
- package/dist/cjs/src/htx.js +6 -6
- package/dist/cjs/src/huobijp.js +1 -1
- package/dist/cjs/src/kraken.js +3 -1
- package/dist/cjs/src/krakenfutures.js +4 -1
- package/dist/cjs/src/kucoin.js +17 -17
- package/dist/cjs/src/kucoinfutures.js +3 -3
- package/dist/cjs/src/lbank.js +28 -27
- package/dist/cjs/src/mexc.js +7 -7
- package/dist/cjs/src/novadax.js +1 -1
- package/dist/cjs/src/okcoin.js +2 -2
- package/dist/cjs/src/okx.js +23 -8
- package/dist/cjs/src/p2b.js +1 -0
- package/dist/cjs/src/phemex.js +3 -3
- package/dist/cjs/src/poloniexfutures.js +6 -3
- package/dist/cjs/src/pro/alpaca.js +1 -1
- package/dist/cjs/src/pro/binance.js +4 -4
- package/dist/cjs/src/pro/bitget.js +1 -1
- package/dist/cjs/src/pro/bitmart.js +1 -1
- package/dist/cjs/src/pro/bitmex.js +49 -6
- package/dist/cjs/src/pro/bitvavo.js +1 -1
- package/dist/cjs/src/pro/bybit.js +2 -2
- package/dist/cjs/src/pro/cex.js +2 -2
- package/dist/cjs/src/pro/independentreserve.js +1 -1
- package/dist/cjs/src/pro/okx.js +1 -1
- package/dist/cjs/src/pro/onetrading.js +2 -2
- package/dist/cjs/src/pro/p2b.js +432 -0
- package/dist/cjs/src/pro/probit.js +5 -5
- package/dist/cjs/src/pro/whitebit.js +1 -1
- package/dist/cjs/src/probit.js +1 -1
- package/dist/cjs/src/timex.js +2 -2
- package/dist/cjs/src/tokocrypto.js +3 -3
- package/dist/cjs/src/wavesexchange.js +2 -2
- package/dist/cjs/src/whitebit.js +3 -3
- package/dist/cjs/src/woo.js +3 -3
- package/dist/cjs/src/yobit.js +1 -1
- package/dist/cjs/src/zaif.js +1 -1
- package/dist/cjs/src/zonda.js +3 -3
- package/js/ccxt.d.ts +4 -1
- package/js/ccxt.js +3 -1
- package/js/src/abstract/bybit.d.ts +2 -2
- package/js/src/abstract/coinbase.d.ts +10 -0
- package/js/src/abstract/okx.d.ts +12 -1
- package/js/src/ascendex.js +5 -5
- package/js/src/base/Exchange.d.ts +2 -2
- package/js/src/base/Exchange.js +33 -25
- package/js/src/base/errorHierarchy.d.ts +7 -6
- package/js/src/base/errorHierarchy.js +7 -6
- package/js/src/base/errors.d.ts +3 -3
- package/js/src/base/errors.js +3 -3
- package/js/src/base/functions/type.js +12 -0
- package/js/src/bigone.js +2 -2
- package/js/src/binance.d.ts +1 -0
- package/js/src/binance.js +898 -219
- package/js/src/bingx.js +1 -1
- package/js/src/bitfinex.js +1 -1
- package/js/src/bitfinex2.d.ts +6 -1
- package/js/src/bitfinex2.js +457 -93
- package/js/src/bitforex.js +3 -0
- package/js/src/bitget.js +8 -4
- package/js/src/bitmart.js +3 -3
- package/js/src/bitmex.js +4 -4
- package/js/src/bitrue.js +1 -1
- package/js/src/bitso.d.ts +1 -1
- package/js/src/bitso.js +1 -1
- package/js/src/bitteam.js +2 -2
- package/js/src/btcalpha.js +1 -1
- package/js/src/bybit.js +3 -3
- package/js/src/coinbase.js +22 -5
- package/js/src/coincheck.js +1 -1
- package/js/src/coinex.js +2 -2
- package/js/src/coinlist.js +1 -1
- package/js/src/coinmate.js +1 -1
- package/js/src/coinmetro.d.ts +1 -1
- package/js/src/coinmetro.js +2 -2
- package/js/src/coinsph.js +1 -1
- package/js/src/cryptocom.js +3 -3
- package/js/src/deribit.js +1 -0
- package/js/src/digifinex.js +6 -4
- package/js/src/exmo.js +2 -2
- package/js/src/gate.js +5 -5
- package/js/src/gemini.d.ts +1 -1
- package/js/src/gemini.js +3 -3
- package/js/src/hitbtc.js +14 -20
- package/js/src/hollaex.js +2 -2
- package/js/src/htx.js +6 -6
- package/js/src/huobijp.js +1 -1
- package/js/src/kraken.js +3 -1
- package/js/src/krakenfutures.js +4 -1
- package/js/src/kucoin.js +17 -17
- package/js/src/kucoinfutures.js +3 -3
- package/js/src/lbank.d.ts +1 -1
- package/js/src/lbank.js +28 -27
- package/js/src/mexc.js +7 -7
- package/js/src/novadax.js +1 -1
- package/js/src/okcoin.js +2 -2
- package/js/src/okx.js +23 -8
- package/js/src/p2b.js +1 -0
- package/js/src/phemex.js +3 -3
- package/js/src/poloniexfutures.js +6 -3
- package/js/src/pro/alpaca.js +1 -1
- package/js/src/pro/binance.js +4 -4
- package/js/src/pro/bitget.js +1 -1
- package/js/src/pro/bitmart.js +1 -1
- package/js/src/pro/bitmex.d.ts +2 -1
- package/js/src/pro/bitmex.js +49 -6
- package/js/src/pro/bitvavo.js +1 -1
- package/js/src/pro/bybit.js +2 -2
- package/js/src/pro/cex.js +2 -2
- package/js/src/pro/independentreserve.js +1 -1
- package/js/src/pro/okx.js +1 -1
- package/js/src/pro/onetrading.js +2 -2
- package/js/src/pro/p2b.d.ts +23 -0
- package/js/src/pro/p2b.js +433 -0
- package/js/src/pro/probit.js +5 -5
- package/js/src/pro/whitebit.js +1 -1
- package/js/src/probit.js +1 -1
- package/js/src/timex.js +2 -2
- package/js/src/tokocrypto.js +3 -3
- package/js/src/wavesexchange.js +2 -2
- package/js/src/whitebit.js +3 -3
- package/js/src/woo.js +3 -3
- package/js/src/yobit.js +1 -1
- package/js/src/zaif.js +1 -1
- package/js/src/zonda.d.ts +1 -1
- package/js/src/zonda.js +3 -3
- package/package.json +1 -1
- package/skip-tests.json +3 -10
|
@@ -26,32 +26,42 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
26
26
|
'CORS': undefined,
|
|
27
27
|
'spot': true,
|
|
28
28
|
'margin': undefined,
|
|
29
|
-
'swap':
|
|
29
|
+
'swap': true,
|
|
30
30
|
'future': undefined,
|
|
31
31
|
'option': undefined,
|
|
32
|
+
'addMargin': false,
|
|
32
33
|
'cancelAllOrders': true,
|
|
33
34
|
'cancelOrder': true,
|
|
35
|
+
'cancelOrders': true,
|
|
34
36
|
'createDepositAddress': true,
|
|
35
37
|
'createLimitOrder': true,
|
|
36
38
|
'createMarketOrder': true,
|
|
37
39
|
'createOrder': true,
|
|
40
|
+
'createReduceOnlyOrder': true,
|
|
38
41
|
'createStopLimitOrder': true,
|
|
39
42
|
'createStopMarketOrder': true,
|
|
40
43
|
'createStopOrder': true,
|
|
41
|
-
'
|
|
44
|
+
'createTrailingAmountOrder': true,
|
|
45
|
+
'createTrailingPercentOrder': false,
|
|
46
|
+
'createTriggerOrder': true,
|
|
47
|
+
'editOrder': true,
|
|
42
48
|
'fetchBalance': true,
|
|
43
49
|
'fetchClosedOrder': true,
|
|
44
50
|
'fetchClosedOrders': true,
|
|
45
51
|
'fetchCurrencies': true,
|
|
46
52
|
'fetchDepositAddress': true,
|
|
47
53
|
'fetchDepositsWithdrawals': true,
|
|
54
|
+
'fetchFundingHistory': false,
|
|
48
55
|
'fetchFundingRate': true,
|
|
49
56
|
'fetchFundingRateHistory': true,
|
|
50
57
|
'fetchFundingRates': true,
|
|
51
58
|
'fetchIndexOHLCV': false,
|
|
52
59
|
'fetchLedger': true,
|
|
60
|
+
'fetchLeverage': false,
|
|
61
|
+
'fetchLeverageTiers': false,
|
|
53
62
|
'fetchLiquidations': true,
|
|
54
63
|
'fetchMarginMode': false,
|
|
64
|
+
'fetchMarketLeverageTiers': false,
|
|
55
65
|
'fetchMarkOHLCV': false,
|
|
56
66
|
'fetchMyTrades': true,
|
|
57
67
|
'fetchOHLCV': true,
|
|
@@ -61,7 +71,10 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
61
71
|
'fetchOpenOrders': true,
|
|
62
72
|
'fetchOrder': true,
|
|
63
73
|
'fetchOrderTrades': true,
|
|
74
|
+
'fetchPosition': false,
|
|
64
75
|
'fetchPositionMode': false,
|
|
76
|
+
'fetchPositions': true,
|
|
77
|
+
'fetchPremiumIndexOHLCV': false,
|
|
65
78
|
'fetchStatus': true,
|
|
66
79
|
'fetchTickers': true,
|
|
67
80
|
'fetchTime': false,
|
|
@@ -69,7 +82,11 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
69
82
|
'fetchTradingFees': true,
|
|
70
83
|
'fetchTransactionFees': undefined,
|
|
71
84
|
'fetchTransactions': 'emulated',
|
|
85
|
+
'reduceMargin': false,
|
|
86
|
+
'setLeverage': false,
|
|
72
87
|
'setMargin': true,
|
|
88
|
+
'setMarginMode': false,
|
|
89
|
+
'setPositionMode': false,
|
|
73
90
|
'withdraw': true,
|
|
74
91
|
},
|
|
75
92
|
'timeframes': {
|
|
@@ -337,6 +354,7 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
337
354
|
'margin': 'margin',
|
|
338
355
|
'derivatives': 'margin',
|
|
339
356
|
'future': 'margin',
|
|
357
|
+
'swap': 'margin',
|
|
340
358
|
},
|
|
341
359
|
'withdraw': {
|
|
342
360
|
'includeFee': false,
|
|
@@ -993,7 +1011,7 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
993
1011
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
994
1012
|
* @see https://docs.bitfinex.com/reference/rest-public-book
|
|
995
1013
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
996
|
-
* @param {int} [limit] the maximum amount of order book entries to return
|
|
1014
|
+
* @param {int} [limit] the maximum amount of order book entries to return, bitfinex only allows 1, 25, or 100
|
|
997
1015
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
998
1016
|
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
999
1017
|
*/
|
|
@@ -1005,7 +1023,7 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
1005
1023
|
'precision': precision,
|
|
1006
1024
|
};
|
|
1007
1025
|
if (limit !== undefined) {
|
|
1008
|
-
request['len'] = limit;
|
|
1026
|
+
request['len'] = limit;
|
|
1009
1027
|
}
|
|
1010
1028
|
const fullRequest = this.extend(request, params);
|
|
1011
1029
|
const orderbook = await this.publicGetBookSymbolPrecision(fullRequest);
|
|
@@ -1277,9 +1295,9 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
1277
1295
|
* @see https://docs.bitfinex.com/reference/rest-public-trades
|
|
1278
1296
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
1279
1297
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
1280
|
-
* @param {int} [limit] the maximum amount of trades to fetch
|
|
1298
|
+
* @param {int} [limit] the maximum amount of trades to fetch, default 120, max 10000
|
|
1281
1299
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1282
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [
|
|
1300
|
+
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
1283
1301
|
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
1284
1302
|
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
1285
1303
|
*/
|
|
@@ -1326,11 +1344,11 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
1326
1344
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
1327
1345
|
* @param {string} timeframe the length of time each candle represents
|
|
1328
1346
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
1329
|
-
* @param {int} [limit] the maximum amount of candles to fetch
|
|
1347
|
+
* @param {int} [limit] the maximum amount of candles to fetch, default 100 max 10000
|
|
1330
1348
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1331
1349
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
1332
1350
|
* @param {int} [params.until] timestamp in ms of the latest candle to fetch
|
|
1333
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [
|
|
1351
|
+
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
1334
1352
|
*/
|
|
1335
1353
|
await this.loadMarkets();
|
|
1336
1354
|
let paginate = false;
|
|
@@ -1340,7 +1358,7 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
1340
1358
|
}
|
|
1341
1359
|
const market = this.market(symbol);
|
|
1342
1360
|
if (limit === undefined) {
|
|
1343
|
-
limit = 10000;
|
|
1361
|
+
limit = 10000;
|
|
1344
1362
|
}
|
|
1345
1363
|
let request = {
|
|
1346
1364
|
'symbol': market['id'],
|
|
@@ -1488,98 +1506,74 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
1488
1506
|
'trades': undefined,
|
|
1489
1507
|
}, market);
|
|
1490
1508
|
}
|
|
1491
|
-
|
|
1509
|
+
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
1492
1510
|
/**
|
|
1493
1511
|
* @method
|
|
1494
|
-
* @
|
|
1495
|
-
* @
|
|
1496
|
-
* @
|
|
1497
|
-
* @param {string} symbol
|
|
1498
|
-
* @param {string} type '
|
|
1512
|
+
* @ignore
|
|
1513
|
+
* @name bitfinex2#createOrderRequest
|
|
1514
|
+
* @description helper function to build an order request
|
|
1515
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
1516
|
+
* @param {string} type 'market' or 'limit'
|
|
1499
1517
|
* @param {string} side 'buy' or 'sell'
|
|
1500
|
-
* @param {float} amount
|
|
1501
|
-
* @param {float} [price] price of order
|
|
1502
|
-
* @param {object} [params]
|
|
1503
|
-
* @
|
|
1504
|
-
* @param {string} [params.timeInForce] "GTC", "IOC", "FOK", or "PO"
|
|
1505
|
-
* @param {bool} params.postOnly
|
|
1506
|
-
* @param {bool} [params.reduceOnly] Ensures that the executed order does not flip the opened position.
|
|
1507
|
-
* @param {int} [params.flags] additional order parameters: 4096 (Post Only), 1024 (Reduce Only), 16384 (OCO), 64 (Hidden), 512 (Close), 524288 (No Var Rates)
|
|
1508
|
-
* @param {int} [params.lev] leverage for a derivative order, supported by derivative symbol orders only. The value should be between 1 and 100 inclusive.
|
|
1509
|
-
* @param {string} [params.price_traling] The trailing price for a trailing stop order
|
|
1510
|
-
* @param {string} [params.price_aux_limit] Order price for stop limit orders
|
|
1511
|
-
* @param {string} [params.price_oco_stop] OCO stop price
|
|
1512
|
-
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1518
|
+
* @param {float} amount how much you want to trade in units of the base currency
|
|
1519
|
+
* @param {float} [price] the price of the order, in units of the quote currency, ignored in market orders
|
|
1520
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1521
|
+
* @returns {object} request to be sent to the exchange
|
|
1513
1522
|
*/
|
|
1514
|
-
await this.loadMarkets();
|
|
1515
1523
|
const market = this.market(symbol);
|
|
1516
|
-
// order types "limit" and "market" immediatley parsed "EXCHANGE LIMIT" and "EXCHANGE MARKET"
|
|
1517
|
-
// note: same order types exist for margin orders without the EXCHANGE prefix
|
|
1518
|
-
const orderTypes = this.safeValue(this.options, 'orderTypes', {});
|
|
1519
|
-
let orderType = type.toUpperCase();
|
|
1520
|
-
if (market['spot']) {
|
|
1521
|
-
// although they claim that type needs to be 'exchange limit' or 'exchange market'
|
|
1522
|
-
// in fact that's not the case for swap markets
|
|
1523
|
-
orderType = this.safeStringUpper(orderTypes, type, type);
|
|
1524
|
-
}
|
|
1525
|
-
const stopPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
|
|
1526
|
-
const timeInForce = this.safeString(params, 'timeInForce');
|
|
1527
|
-
const postOnlyParam = this.safeValue(params, 'postOnly', false);
|
|
1528
|
-
const reduceOnly = this.safeValue(params, 'reduceOnly', false);
|
|
1529
|
-
const clientOrderId = this.safeValue2(params, 'cid', 'clientOrderId');
|
|
1530
|
-
params = this.omit(params, ['triggerPrice', 'stopPrice', 'timeInForce', 'postOnly', 'reduceOnly', 'price_aux_limit']);
|
|
1531
1524
|
let amountString = this.amountToPrecision(symbol, amount);
|
|
1532
1525
|
amountString = (side === 'buy') ? amountString : Precise["default"].stringNeg(amountString);
|
|
1533
1526
|
const request = {
|
|
1534
|
-
// 'gid': 0123456789, // int32, optional group id for the order
|
|
1535
|
-
// 'cid': 0123456789, // int32 client order id
|
|
1536
|
-
'type': orderType,
|
|
1537
1527
|
'symbol': market['id'],
|
|
1538
|
-
// 'price': this.numberToString (price),
|
|
1539
1528
|
'amount': amountString,
|
|
1540
|
-
// 'flags': 0, // int32, https://docs.bitfinex.com/v2/docs/flag-values
|
|
1541
|
-
// 'lev': 10, // leverage for a derivative orders, the value should be between 1 and 100 inclusive, optional, 10 by default
|
|
1542
|
-
// 'price_trailing': this.numberToString (priceTrailing),
|
|
1543
|
-
// 'price_aux_limit': this.numberToString (stopPrice),
|
|
1544
|
-
// 'price_oco_stop': this.numberToString (ocoStopPrice),
|
|
1545
|
-
// 'tif': '2020-01-01 10:45:23', // datetime for automatic order cancellation
|
|
1546
|
-
// 'meta': {
|
|
1547
|
-
// 'aff_code': 'AFF_CODE_HERE'
|
|
1548
|
-
// },
|
|
1549
1529
|
};
|
|
1550
|
-
const
|
|
1551
|
-
const
|
|
1552
|
-
const
|
|
1553
|
-
const
|
|
1554
|
-
const
|
|
1555
|
-
const
|
|
1530
|
+
const stopPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
|
|
1531
|
+
const trailingAmount = this.safeString(params, 'trailingAmount');
|
|
1532
|
+
const timeInForce = this.safeString(params, 'timeInForce');
|
|
1533
|
+
const postOnlyParam = this.safeBool(params, 'postOnly', false);
|
|
1534
|
+
const reduceOnly = this.safeBool(params, 'reduceOnly', false);
|
|
1535
|
+
const clientOrderId = this.safeValue2(params, 'cid', 'clientOrderId');
|
|
1536
|
+
let orderType = type.toUpperCase();
|
|
1537
|
+
if (trailingAmount !== undefined) {
|
|
1538
|
+
orderType = 'TRAILING STOP';
|
|
1539
|
+
request['price_trailing'] = trailingAmount;
|
|
1540
|
+
}
|
|
1541
|
+
else if (stopPrice !== undefined) {
|
|
1542
|
+
// request['price'] is taken as stopPrice for stop orders
|
|
1543
|
+
request['price'] = this.priceToPrecision(symbol, stopPrice);
|
|
1544
|
+
if (type === 'limit') {
|
|
1545
|
+
orderType = 'STOP LIMIT';
|
|
1546
|
+
request['price_aux_limit'] = this.priceToPrecision(symbol, price);
|
|
1547
|
+
}
|
|
1548
|
+
else {
|
|
1549
|
+
orderType = 'STOP';
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
const ioc = (timeInForce === 'IOC');
|
|
1553
|
+
const fok = (timeInForce === 'FOK');
|
|
1556
1554
|
const postOnly = (postOnlyParam || (timeInForce === 'PO'));
|
|
1557
1555
|
if ((ioc || fok) && (price === undefined)) {
|
|
1558
1556
|
throw new errors.InvalidOrder(this.id + ' createOrder() requires a price argument with IOC and FOK orders');
|
|
1559
1557
|
}
|
|
1560
|
-
if ((ioc || fok) &&
|
|
1558
|
+
if ((ioc || fok) && (type === 'market')) {
|
|
1561
1559
|
throw new errors.InvalidOrder(this.id + ' createOrder() does not allow market IOC and FOK orders');
|
|
1562
1560
|
}
|
|
1563
|
-
if ((
|
|
1561
|
+
if ((type !== 'market') && (stopPrice === undefined)) {
|
|
1564
1562
|
request['price'] = this.priceToPrecision(symbol, price);
|
|
1565
1563
|
}
|
|
1566
|
-
if (stopLimit || stopMarket) {
|
|
1567
|
-
// request['price'] is taken as stopPrice for stop orders
|
|
1568
|
-
request['price'] = this.priceToPrecision(symbol, stopPrice);
|
|
1569
|
-
if (stopMarket) {
|
|
1570
|
-
request['type'] = 'EXCHANGE STOP';
|
|
1571
|
-
}
|
|
1572
|
-
else if (stopLimit) {
|
|
1573
|
-
request['type'] = 'EXCHANGE STOP LIMIT';
|
|
1574
|
-
request['price_aux_limit'] = this.priceToPrecision(symbol, price);
|
|
1575
|
-
}
|
|
1576
|
-
}
|
|
1577
1564
|
if (ioc) {
|
|
1578
|
-
|
|
1565
|
+
orderType = 'IOC';
|
|
1579
1566
|
}
|
|
1580
1567
|
else if (fok) {
|
|
1581
|
-
|
|
1568
|
+
orderType = 'FOK';
|
|
1569
|
+
}
|
|
1570
|
+
let marginMode = undefined;
|
|
1571
|
+
[marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
|
|
1572
|
+
if (market['spot'] && (marginMode === undefined)) {
|
|
1573
|
+
// The EXCHANGE prefix is only required for non margin spot markets
|
|
1574
|
+
orderType = 'EXCHANGE ' + orderType;
|
|
1582
1575
|
}
|
|
1576
|
+
request['type'] = orderType;
|
|
1583
1577
|
// flag values may be summed to combine flags
|
|
1584
1578
|
let flags = 0;
|
|
1585
1579
|
if (postOnly) {
|
|
@@ -1593,9 +1587,37 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
1593
1587
|
}
|
|
1594
1588
|
if (clientOrderId !== undefined) {
|
|
1595
1589
|
request['cid'] = clientOrderId;
|
|
1596
|
-
params = this.omit(params, ['cid', 'clientOrderId']);
|
|
1597
1590
|
}
|
|
1598
|
-
|
|
1591
|
+
params = this.omit(params, ['triggerPrice', 'stopPrice', 'timeInForce', 'postOnly', 'reduceOnly', 'trailingAmount', 'clientOrderId']);
|
|
1592
|
+
return this.extend(request, params);
|
|
1593
|
+
}
|
|
1594
|
+
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
1595
|
+
/**
|
|
1596
|
+
* @method
|
|
1597
|
+
* @name bitfinex2#createOrder
|
|
1598
|
+
* @description create an order on the exchange
|
|
1599
|
+
* @see https://docs.bitfinex.com/reference/rest-auth-submit-order
|
|
1600
|
+
* @param {string} symbol unified CCXT market symbol
|
|
1601
|
+
* @param {string} type 'limit' or 'market'
|
|
1602
|
+
* @param {string} side 'buy' or 'sell'
|
|
1603
|
+
* @param {float} amount the amount of currency to trade
|
|
1604
|
+
* @param {float} [price] price of the order
|
|
1605
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1606
|
+
* @param {float} [params.stopPrice] the price that triggers a trigger order
|
|
1607
|
+
* @param {string} [params.timeInForce] "GTC", "IOC", "FOK", or "PO"
|
|
1608
|
+
* @param {boolean} [params.postOnly] set to true if you want to make a post only order
|
|
1609
|
+
* @param {boolean} [params.reduceOnly] indicates that the order is to reduce the size of a position
|
|
1610
|
+
* @param {int} [params.flags] additional order parameters: 4096 (Post Only), 1024 (Reduce Only), 16384 (OCO), 64 (Hidden), 512 (Close), 524288 (No Var Rates)
|
|
1611
|
+
* @param {int} [params.lev] leverage for a derivative order, supported by derivative symbol orders only. The value should be between 1 and 100 inclusive.
|
|
1612
|
+
* @param {string} [params.price_aux_limit] order price for stop limit orders
|
|
1613
|
+
* @param {string} [params.price_oco_stop] OCO stop price
|
|
1614
|
+
* @param {string} [params.trailingAmount] *swap only* the quote amount to trail away from the current market price
|
|
1615
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1616
|
+
*/
|
|
1617
|
+
await this.loadMarkets();
|
|
1618
|
+
const market = this.market(symbol);
|
|
1619
|
+
const request = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
1620
|
+
const response = await this.privatePostAuthWOrderSubmit(request);
|
|
1599
1621
|
//
|
|
1600
1622
|
// [
|
|
1601
1623
|
// 1653325121, // Timestamp in milliseconds
|
|
@@ -1649,10 +1671,71 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
1649
1671
|
const errorText = response[7];
|
|
1650
1672
|
throw new errors.ExchangeError(this.id + ' ' + response[6] + ': ' + errorText + ' (#' + errorCode + ')');
|
|
1651
1673
|
}
|
|
1652
|
-
const orders = this.
|
|
1653
|
-
const order = this.
|
|
1674
|
+
const orders = this.safeList(response, 4, []);
|
|
1675
|
+
const order = this.safeList(orders, 0);
|
|
1654
1676
|
return this.parseOrder(order, market);
|
|
1655
1677
|
}
|
|
1678
|
+
async createOrders(orders, params = {}) {
|
|
1679
|
+
/**
|
|
1680
|
+
* @method
|
|
1681
|
+
* @name bitfinex2#createOrders
|
|
1682
|
+
* @description create a list of trade orders
|
|
1683
|
+
* @see https://docs.bitfinex.com/reference/rest-auth-order-multi
|
|
1684
|
+
* @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
|
|
1685
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1686
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1687
|
+
*/
|
|
1688
|
+
await this.loadMarkets();
|
|
1689
|
+
const ordersRequests = [];
|
|
1690
|
+
for (let i = 0; i < orders.length; i++) {
|
|
1691
|
+
const rawOrder = orders[i];
|
|
1692
|
+
const symbol = this.safeString(rawOrder, 'symbol');
|
|
1693
|
+
const type = this.safeString(rawOrder, 'type');
|
|
1694
|
+
const side = this.safeString(rawOrder, 'side');
|
|
1695
|
+
const amount = this.safeNumber(rawOrder, 'amount');
|
|
1696
|
+
const price = this.safeNumber(rawOrder, 'price');
|
|
1697
|
+
const orderParams = this.safeDict(rawOrder, 'params', {});
|
|
1698
|
+
const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, orderParams);
|
|
1699
|
+
ordersRequests.push(['on', orderRequest]);
|
|
1700
|
+
}
|
|
1701
|
+
const request = {
|
|
1702
|
+
'ops': ordersRequests,
|
|
1703
|
+
};
|
|
1704
|
+
const response = await this.privatePostAuthWOrderMulti(request);
|
|
1705
|
+
//
|
|
1706
|
+
// [
|
|
1707
|
+
// 1706762515553,
|
|
1708
|
+
// "ox_multi-req",
|
|
1709
|
+
// null,
|
|
1710
|
+
// null,
|
|
1711
|
+
// [
|
|
1712
|
+
// [
|
|
1713
|
+
// 1706762515,
|
|
1714
|
+
// "on-req",
|
|
1715
|
+
// null,
|
|
1716
|
+
// null,
|
|
1717
|
+
// [
|
|
1718
|
+
// [139567428547,null,1706762515551,"tBTCUST",1706762515551,1706762515551,0.0001,0.0001,"EXCHANGE LIMIT",null,null,null,0,"ACTIVE",null,null,35000,0,0,0,null,null,null,0,0,null,null,null,"API>BFX",null,null,{}]
|
|
1719
|
+
// ],
|
|
1720
|
+
// null,
|
|
1721
|
+
// "SUCCESS",
|
|
1722
|
+
// "Submitting 1 orders."
|
|
1723
|
+
// ],
|
|
1724
|
+
// ],
|
|
1725
|
+
// null,
|
|
1726
|
+
// "SUCCESS",
|
|
1727
|
+
// "Submitting 2 order operations."
|
|
1728
|
+
// ]
|
|
1729
|
+
//
|
|
1730
|
+
const results = [];
|
|
1731
|
+
const data = this.safeList(response, 4, []);
|
|
1732
|
+
for (let i = 0; i < data.length; i++) {
|
|
1733
|
+
const entry = data[i];
|
|
1734
|
+
const individualOrder = entry[4];
|
|
1735
|
+
results.push(individualOrder[0]);
|
|
1736
|
+
}
|
|
1737
|
+
return this.parseOrders(results);
|
|
1738
|
+
}
|
|
1656
1739
|
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
1657
1740
|
/**
|
|
1658
1741
|
* @method
|
|
@@ -1663,6 +1746,7 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
1663
1746
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1664
1747
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1665
1748
|
*/
|
|
1749
|
+
await this.loadMarkets();
|
|
1666
1750
|
const request = {
|
|
1667
1751
|
'all': 1,
|
|
1668
1752
|
};
|
|
@@ -1681,6 +1765,7 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
1681
1765
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1682
1766
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1683
1767
|
*/
|
|
1768
|
+
await this.loadMarkets();
|
|
1684
1769
|
const cid = this.safeValue2(params, 'cid', 'clientOrderId'); // client order id
|
|
1685
1770
|
let request = undefined;
|
|
1686
1771
|
if (cid !== undefined) {
|
|
@@ -1703,6 +1788,82 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
1703
1788
|
const order = this.safeValue(response, 4);
|
|
1704
1789
|
return this.parseOrder(order);
|
|
1705
1790
|
}
|
|
1791
|
+
async cancelOrders(ids, symbol = undefined, params = {}) {
|
|
1792
|
+
/**
|
|
1793
|
+
* @method
|
|
1794
|
+
* @name bitfinex2#cancelOrders
|
|
1795
|
+
* @description cancel multiple orders at the same time
|
|
1796
|
+
* @see https://docs.bitfinex.com/reference/rest-auth-cancel-orders-multiple
|
|
1797
|
+
* @param {string[]} ids order ids
|
|
1798
|
+
* @param {string} symbol unified market symbol, default is undefined
|
|
1799
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1800
|
+
* @returns {object} an array of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1801
|
+
*/
|
|
1802
|
+
await this.loadMarkets();
|
|
1803
|
+
for (let i = 0; i < ids.length; i++) {
|
|
1804
|
+
ids[i] = this.parseToNumeric(ids[i]);
|
|
1805
|
+
}
|
|
1806
|
+
const request = {
|
|
1807
|
+
'id': ids,
|
|
1808
|
+
};
|
|
1809
|
+
let market = undefined;
|
|
1810
|
+
if (symbol !== undefined) {
|
|
1811
|
+
market = this.market(symbol);
|
|
1812
|
+
}
|
|
1813
|
+
const response = await this.privatePostAuthWOrderCancelMulti(this.extend(request, params));
|
|
1814
|
+
//
|
|
1815
|
+
// [
|
|
1816
|
+
// 1706740198811,
|
|
1817
|
+
// "oc_multi-req",
|
|
1818
|
+
// null,
|
|
1819
|
+
// null,
|
|
1820
|
+
// [
|
|
1821
|
+
// [
|
|
1822
|
+
// 139530205057,
|
|
1823
|
+
// null,
|
|
1824
|
+
// 1706740132275,
|
|
1825
|
+
// "tBTCF0:USTF0",
|
|
1826
|
+
// 1706740132276,
|
|
1827
|
+
// 1706740132276,
|
|
1828
|
+
// 0.0001,
|
|
1829
|
+
// 0.0001,
|
|
1830
|
+
// "LIMIT",
|
|
1831
|
+
// null,
|
|
1832
|
+
// null,
|
|
1833
|
+
// null,
|
|
1834
|
+
// 0,
|
|
1835
|
+
// "ACTIVE",
|
|
1836
|
+
// null,
|
|
1837
|
+
// null,
|
|
1838
|
+
// 39000,
|
|
1839
|
+
// 0,
|
|
1840
|
+
// 0,
|
|
1841
|
+
// 0,
|
|
1842
|
+
// null,
|
|
1843
|
+
// null,
|
|
1844
|
+
// null,
|
|
1845
|
+
// 0,
|
|
1846
|
+
// 0,
|
|
1847
|
+
// null,
|
|
1848
|
+
// null,
|
|
1849
|
+
// null,
|
|
1850
|
+
// "API>BFX",
|
|
1851
|
+
// null,
|
|
1852
|
+
// null,
|
|
1853
|
+
// {
|
|
1854
|
+
// "lev": 10,
|
|
1855
|
+
// "$F33": 10
|
|
1856
|
+
// }
|
|
1857
|
+
// ],
|
|
1858
|
+
// ],
|
|
1859
|
+
// null,
|
|
1860
|
+
// "SUCCESS",
|
|
1861
|
+
// "Submitting 2 order cancellations."
|
|
1862
|
+
// ]
|
|
1863
|
+
//
|
|
1864
|
+
const orders = this.safeList(response, 4, []);
|
|
1865
|
+
return this.parseOrders(orders, market);
|
|
1866
|
+
}
|
|
1706
1867
|
async fetchOpenOrder(id, symbol = undefined, params = {}) {
|
|
1707
1868
|
/**
|
|
1708
1869
|
* @method
|
|
@@ -2398,7 +2559,7 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
2398
2559
|
request['payment_id'] = tag;
|
|
2399
2560
|
}
|
|
2400
2561
|
const withdrawOptions = this.safeValue(this.options, 'withdraw', {});
|
|
2401
|
-
const includeFee = this.
|
|
2562
|
+
const includeFee = this.safeBool(withdrawOptions, 'includeFee', false);
|
|
2402
2563
|
if (includeFee) {
|
|
2403
2564
|
request['fee_deduct'] = 1;
|
|
2404
2565
|
}
|
|
@@ -2712,14 +2873,13 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
2712
2873
|
* @see https://docs.bitfinex.com/reference/rest-auth-ledgers
|
|
2713
2874
|
* @param {string} code unified currency code, default is undefined
|
|
2714
2875
|
* @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
|
|
2715
|
-
* @param {int} [limit] max number of ledger entrys to return, default is undefined
|
|
2876
|
+
* @param {int} [limit] max number of ledger entrys to return, default is undefined max is 2500
|
|
2716
2877
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2717
2878
|
* @param {int} [params.until] timestamp in ms of the latest ledger entry
|
|
2718
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [
|
|
2879
|
+
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
2719
2880
|
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
|
|
2720
2881
|
*/
|
|
2721
2882
|
await this.loadMarkets();
|
|
2722
|
-
await this.loadMarkets();
|
|
2723
2883
|
let paginate = false;
|
|
2724
2884
|
[paginate, params] = this.handleOptionAndParams(params, 'fetchLedger', 'paginate');
|
|
2725
2885
|
if (paginate) {
|
|
@@ -2731,7 +2891,7 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
2731
2891
|
request['start'] = since;
|
|
2732
2892
|
}
|
|
2733
2893
|
if (limit !== undefined) {
|
|
2734
|
-
request['limit'] = limit;
|
|
2894
|
+
request['limit'] = limit;
|
|
2735
2895
|
}
|
|
2736
2896
|
[request, params] = this.handleUntilOption('end', request, params);
|
|
2737
2897
|
let response = undefined;
|
|
@@ -2763,7 +2923,7 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
2763
2923
|
async fetchFundingRate(symbol, params = {}) {
|
|
2764
2924
|
/**
|
|
2765
2925
|
* @method
|
|
2766
|
-
* @name
|
|
2926
|
+
* @name bitfinex2#fetchFundingRate
|
|
2767
2927
|
* @description fetch the current funding rate
|
|
2768
2928
|
* @see https://docs.bitfinex.com/reference/rest-public-derivatives-status
|
|
2769
2929
|
* @param {string} symbol unified market symbol
|
|
@@ -2775,7 +2935,7 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
2775
2935
|
async fetchFundingRates(symbols = undefined, params = {}) {
|
|
2776
2936
|
/**
|
|
2777
2937
|
* @method
|
|
2778
|
-
* @name
|
|
2938
|
+
* @name bitfinex2#fetchFundingRate
|
|
2779
2939
|
* @description fetch the current funding rate
|
|
2780
2940
|
* @see https://docs.bitfinex.com/reference/rest-public-derivatives-status
|
|
2781
2941
|
* @param {string[]} symbols list of unified market symbols
|
|
@@ -2826,13 +2986,15 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
2826
2986
|
async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2827
2987
|
/**
|
|
2828
2988
|
* @method
|
|
2829
|
-
* @name
|
|
2989
|
+
* @name bitfinex2#fetchFundingRateHistory
|
|
2830
2990
|
* @description fetches historical funding rate prices
|
|
2831
2991
|
* @see https://docs.bitfinex.com/reference/rest-public-derivatives-status-history
|
|
2832
2992
|
* @param {string} symbol unified market symbol
|
|
2993
|
+
* @param {int} [since] timestamp in ms of the earliest funding rate entry
|
|
2994
|
+
* @param {int} [limit] max number of funding rate entrys to return
|
|
2833
2995
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2834
2996
|
* @param {int} [params.until] timestamp in ms of the latest funding rate
|
|
2835
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [
|
|
2997
|
+
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
2836
2998
|
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
|
|
2837
2999
|
*/
|
|
2838
3000
|
if (symbol === undefined) {
|
|
@@ -2889,7 +3051,15 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
2889
3051
|
const rate = this.parseFundingRateHistory(fr, market);
|
|
2890
3052
|
rates.push(rate);
|
|
2891
3053
|
}
|
|
2892
|
-
|
|
3054
|
+
const reversedArray = [];
|
|
3055
|
+
const rawRates = this.filterBySymbolSinceLimit(rates, symbol, since, limit);
|
|
3056
|
+
const rawRatesLength = rawRates.length;
|
|
3057
|
+
const ratesLength = Math.max(rawRatesLength - 1, 0);
|
|
3058
|
+
for (let i = ratesLength; i >= 0; i--) {
|
|
3059
|
+
const valueAtIndex = rawRates[i];
|
|
3060
|
+
reversedArray.push(valueAtIndex);
|
|
3061
|
+
}
|
|
3062
|
+
return reversedArray;
|
|
2893
3063
|
}
|
|
2894
3064
|
parseFundingRate(contract, market = undefined) {
|
|
2895
3065
|
//
|
|
@@ -3039,7 +3209,8 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
3039
3209
|
// ]
|
|
3040
3210
|
// ]
|
|
3041
3211
|
//
|
|
3042
|
-
|
|
3212
|
+
const oi = this.safeList(response, 0);
|
|
3213
|
+
return this.parseOpenInterest(oi, market);
|
|
3043
3214
|
}
|
|
3044
3215
|
async fetchOpenInterestHistory(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
3045
3216
|
/**
|
|
@@ -3310,6 +3481,199 @@ class bitfinex2 extends bitfinex2$1 {
|
|
|
3310
3481
|
'status': marginStatus,
|
|
3311
3482
|
};
|
|
3312
3483
|
}
|
|
3484
|
+
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
3485
|
+
/**
|
|
3486
|
+
* @method
|
|
3487
|
+
* @name bitfinex2#fetchOrder
|
|
3488
|
+
* @description fetches information on an order made by the user
|
|
3489
|
+
* @see https://docs.bitfinex.com/reference/rest-auth-retrieve-orders
|
|
3490
|
+
* @see https://docs.bitfinex.com/reference/rest-auth-retrieve-orders-by-symbol
|
|
3491
|
+
* @param {string} id the order id
|
|
3492
|
+
* @param {string} [symbol] unified symbol of the market the order was made in
|
|
3493
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3494
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3495
|
+
*/
|
|
3496
|
+
await this.loadMarkets();
|
|
3497
|
+
const request = {
|
|
3498
|
+
'id': [this.parseToNumeric(id)],
|
|
3499
|
+
};
|
|
3500
|
+
let market = undefined;
|
|
3501
|
+
let response = undefined;
|
|
3502
|
+
if (symbol === undefined) {
|
|
3503
|
+
response = await this.privatePostAuthROrders(this.extend(request, params));
|
|
3504
|
+
}
|
|
3505
|
+
else {
|
|
3506
|
+
market = this.market(symbol);
|
|
3507
|
+
request['symbol'] = market['id'];
|
|
3508
|
+
response = await this.privatePostAuthROrdersSymbol(this.extend(request, params));
|
|
3509
|
+
}
|
|
3510
|
+
//
|
|
3511
|
+
// [
|
|
3512
|
+
// [
|
|
3513
|
+
// 139658969116,
|
|
3514
|
+
// null,
|
|
3515
|
+
// 1706843908637,
|
|
3516
|
+
// "tBTCUST",
|
|
3517
|
+
// 1706843908637,
|
|
3518
|
+
// 1706843908638,
|
|
3519
|
+
// 0.0001,
|
|
3520
|
+
// 0.0001,
|
|
3521
|
+
// "EXCHANGE LIMIT",
|
|
3522
|
+
// null,
|
|
3523
|
+
// null,
|
|
3524
|
+
// null,
|
|
3525
|
+
// 0,
|
|
3526
|
+
// "ACTIVE",
|
|
3527
|
+
// null,
|
|
3528
|
+
// null,
|
|
3529
|
+
// 35000,
|
|
3530
|
+
// 0,
|
|
3531
|
+
// 0,
|
|
3532
|
+
// 0,
|
|
3533
|
+
// null,
|
|
3534
|
+
// null,
|
|
3535
|
+
// null,
|
|
3536
|
+
// 0,
|
|
3537
|
+
// 0,
|
|
3538
|
+
// null,
|
|
3539
|
+
// null,
|
|
3540
|
+
// null,
|
|
3541
|
+
// "API>BFX",
|
|
3542
|
+
// null,
|
|
3543
|
+
// null,
|
|
3544
|
+
// {}
|
|
3545
|
+
// ]
|
|
3546
|
+
// ]
|
|
3547
|
+
//
|
|
3548
|
+
const order = this.safeList(response, 0);
|
|
3549
|
+
return this.parseOrder(order, market);
|
|
3550
|
+
}
|
|
3551
|
+
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
3552
|
+
/**
|
|
3553
|
+
* @method
|
|
3554
|
+
* @name bitfinex2#editOrder
|
|
3555
|
+
* @description edit a trade order
|
|
3556
|
+
* @see https://docs.bitfinex.com/reference/rest-auth-update-order
|
|
3557
|
+
* @param {string} id edit order id
|
|
3558
|
+
* @param {string} symbol unified symbol of the market to edit an order in
|
|
3559
|
+
* @param {string} type 'market' or 'limit'
|
|
3560
|
+
* @param {string} side 'buy' or 'sell'
|
|
3561
|
+
* @param {float} amount how much you want to trade in units of the base currency
|
|
3562
|
+
* @param {float} [price] the price that the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
3563
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3564
|
+
* @param {float} [params.stopPrice] the price that triggers a trigger order
|
|
3565
|
+
* @param {boolean} [params.postOnly] set to true if you want to make a post only order
|
|
3566
|
+
* @param {boolean} [params.reduceOnly] indicates that the order is to reduce the size of a position
|
|
3567
|
+
* @param {int} [params.flags] additional order parameters: 4096 (Post Only), 1024 (Reduce Only), 16384 (OCO), 64 (Hidden), 512 (Close), 524288 (No Var Rates)
|
|
3568
|
+
* @param {int} [params.leverage] leverage for a derivative order, supported by derivative symbol orders only, the value should be between 1 and 100 inclusive
|
|
3569
|
+
* @param {int} [params.clientOrderId] a unique client order id for the order
|
|
3570
|
+
* @param {float} [params.trailingAmount] *swap only* the quote amount to trail away from the current market price
|
|
3571
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3572
|
+
*/
|
|
3573
|
+
await this.loadMarkets();
|
|
3574
|
+
const market = this.market(symbol);
|
|
3575
|
+
const request = {
|
|
3576
|
+
'id': this.parseToNumeric(id),
|
|
3577
|
+
};
|
|
3578
|
+
if (amount !== undefined) {
|
|
3579
|
+
let amountString = this.amountToPrecision(symbol, amount);
|
|
3580
|
+
amountString = (side === 'buy') ? amountString : Precise["default"].stringNeg(amountString);
|
|
3581
|
+
request['amount'] = amountString;
|
|
3582
|
+
}
|
|
3583
|
+
const stopPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
|
|
3584
|
+
const trailingAmount = this.safeString(params, 'trailingAmount');
|
|
3585
|
+
const timeInForce = this.safeString(params, 'timeInForce');
|
|
3586
|
+
const postOnlyParam = this.safeBool(params, 'postOnly', false);
|
|
3587
|
+
const reduceOnly = this.safeBool(params, 'reduceOnly', false);
|
|
3588
|
+
const clientOrderId = this.safeInteger2(params, 'cid', 'clientOrderId');
|
|
3589
|
+
if (trailingAmount !== undefined) {
|
|
3590
|
+
request['price_trailing'] = trailingAmount;
|
|
3591
|
+
}
|
|
3592
|
+
else if (stopPrice !== undefined) {
|
|
3593
|
+
// request['price'] is taken as stopPrice for stop orders
|
|
3594
|
+
request['price'] = this.priceToPrecision(symbol, stopPrice);
|
|
3595
|
+
if (type === 'limit') {
|
|
3596
|
+
request['price_aux_limit'] = this.priceToPrecision(symbol, price);
|
|
3597
|
+
}
|
|
3598
|
+
}
|
|
3599
|
+
const postOnly = (postOnlyParam || (timeInForce === 'PO'));
|
|
3600
|
+
if ((type !== 'market') && (stopPrice === undefined)) {
|
|
3601
|
+
request['price'] = this.priceToPrecision(symbol, price);
|
|
3602
|
+
}
|
|
3603
|
+
// flag values may be summed to combine flags
|
|
3604
|
+
let flags = 0;
|
|
3605
|
+
if (postOnly) {
|
|
3606
|
+
flags = this.sum(flags, 4096);
|
|
3607
|
+
}
|
|
3608
|
+
if (reduceOnly) {
|
|
3609
|
+
flags = this.sum(flags, 1024);
|
|
3610
|
+
}
|
|
3611
|
+
if (flags !== 0) {
|
|
3612
|
+
request['flags'] = flags;
|
|
3613
|
+
}
|
|
3614
|
+
if (clientOrderId !== undefined) {
|
|
3615
|
+
request['cid'] = clientOrderId;
|
|
3616
|
+
}
|
|
3617
|
+
const leverage = this.safeInteger2(params, 'leverage', 'lev');
|
|
3618
|
+
if (leverage !== undefined) {
|
|
3619
|
+
request['lev'] = leverage;
|
|
3620
|
+
}
|
|
3621
|
+
params = this.omit(params, ['triggerPrice', 'stopPrice', 'timeInForce', 'postOnly', 'reduceOnly', 'trailingAmount', 'clientOrderId', 'leverage']);
|
|
3622
|
+
const response = await this.privatePostAuthWOrderUpdate(this.extend(request, params));
|
|
3623
|
+
//
|
|
3624
|
+
// [
|
|
3625
|
+
// 1706845376402,
|
|
3626
|
+
// "ou-req",
|
|
3627
|
+
// null,
|
|
3628
|
+
// null,
|
|
3629
|
+
// [
|
|
3630
|
+
// 139658969116,
|
|
3631
|
+
// null,
|
|
3632
|
+
// 1706843908637,
|
|
3633
|
+
// "tBTCUST",
|
|
3634
|
+
// 1706843908637,
|
|
3635
|
+
// 1706843908638,
|
|
3636
|
+
// 0.0002,
|
|
3637
|
+
// 0.0002,
|
|
3638
|
+
// "EXCHANGE LIMIT",
|
|
3639
|
+
// null,
|
|
3640
|
+
// null,
|
|
3641
|
+
// null,
|
|
3642
|
+
// 0,
|
|
3643
|
+
// "ACTIVE",
|
|
3644
|
+
// null,
|
|
3645
|
+
// null,
|
|
3646
|
+
// 35000,
|
|
3647
|
+
// 0,
|
|
3648
|
+
// 0,
|
|
3649
|
+
// 0,
|
|
3650
|
+
// null,
|
|
3651
|
+
// null,
|
|
3652
|
+
// null,
|
|
3653
|
+
// 0,
|
|
3654
|
+
// 0,
|
|
3655
|
+
// null,
|
|
3656
|
+
// null,
|
|
3657
|
+
// null,
|
|
3658
|
+
// "API>BFX",
|
|
3659
|
+
// null,
|
|
3660
|
+
// null,
|
|
3661
|
+
// {}
|
|
3662
|
+
// ],
|
|
3663
|
+
// null,
|
|
3664
|
+
// "SUCCESS",
|
|
3665
|
+
// "Submitting update to exchange limit buy order for 0.0002 BTC."
|
|
3666
|
+
// ]
|
|
3667
|
+
//
|
|
3668
|
+
const status = this.safeString(response, 6);
|
|
3669
|
+
if (status !== 'SUCCESS') {
|
|
3670
|
+
const errorCode = response[5];
|
|
3671
|
+
const errorText = response[7];
|
|
3672
|
+
throw new errors.ExchangeError(this.id + ' ' + response[6] + ': ' + errorText + ' (#' + errorCode + ')');
|
|
3673
|
+
}
|
|
3674
|
+
const order = this.safeList(response, 4, []);
|
|
3675
|
+
return this.parseOrder(order, market);
|
|
3676
|
+
}
|
|
3313
3677
|
}
|
|
3314
3678
|
|
|
3315
3679
|
module.exports = bitfinex2;
|