ccxt 4.2.30 → 4.2.34
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/.gitattributes +1 -0
- package/CONTRIBUTING.md +20 -1
- package/README.md +9 -9
- package/build.sh +9 -2
- package/cleanup.sh +3 -0
- package/dist/ccxt.browser.js +1136 -561
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/ace.js +3 -2
- package/dist/cjs/src/ascendex.js +1 -1
- package/dist/cjs/src/base/Exchange.js +66 -24
- package/dist/cjs/src/bigone.js +21 -1
- package/dist/cjs/src/binance.js +6 -5
- package/dist/cjs/src/bingx.js +4 -3
- package/dist/cjs/src/bit2c.js +12 -0
- package/dist/cjs/src/bitfinex2.js +415 -41
- package/dist/cjs/src/bitforex.js +3 -0
- package/dist/cjs/src/bitget.js +3 -3
- package/dist/cjs/src/bitmart.js +1 -1
- package/dist/cjs/src/bitrue.js +3 -3
- package/dist/cjs/src/blockchaincom.js +1 -1
- package/dist/cjs/src/bybit.js +1 -1
- package/dist/cjs/src/coinbase.js +12 -2
- package/dist/cjs/src/coinex.js +1 -1
- package/dist/cjs/src/cryptocom.js +10 -10
- package/dist/cjs/src/deribit.js +1 -0
- package/dist/cjs/src/gate.js +34 -29
- package/dist/cjs/src/htx.js +1 -1
- package/dist/cjs/src/kraken.js +42 -1
- package/dist/cjs/src/krakenfutures.js +3 -0
- package/dist/cjs/src/kucoin.js +1 -1
- package/dist/cjs/src/lbank.js +27 -26
- package/dist/cjs/src/mexc.js +2 -1
- package/dist/cjs/src/okx.js +20 -5
- package/dist/cjs/src/phemex.js +8 -8
- package/dist/cjs/src/poloniexfutures.js +3 -0
- package/dist/cjs/src/pro/alpaca.js +8 -4
- package/dist/cjs/src/pro/ascendex.js +1 -2
- package/dist/cjs/src/pro/binance.js +14 -10
- package/dist/cjs/src/pro/bingx.js +1 -1
- package/dist/cjs/src/pro/bitfinex.js +21 -24
- package/dist/cjs/src/pro/bitfinex2.js +13 -17
- package/dist/cjs/src/pro/bitget.js +3 -1
- package/dist/cjs/src/pro/bitmart.js +3 -8
- package/dist/cjs/src/pro/bitmex.js +4 -7
- package/dist/cjs/src/pro/bitopro.js +2 -5
- package/dist/cjs/src/pro/bitrue.js +1 -1
- package/dist/cjs/src/pro/bitstamp.js +2 -3
- package/dist/cjs/src/pro/bitvavo.js +12 -5
- package/dist/cjs/src/pro/blockchaincom.js +22 -23
- package/dist/cjs/src/pro/bybit.js +5 -5
- package/dist/cjs/src/pro/cex.js +7 -7
- package/dist/cjs/src/pro/coinbase.js +3 -2
- package/dist/cjs/src/pro/coinbasepro.js +1 -1
- package/dist/cjs/src/pro/coinex.js +15 -13
- package/dist/cjs/src/pro/currencycom.js +5 -7
- package/dist/cjs/src/pro/deribit.js +4 -4
- package/dist/cjs/src/pro/exmo.js +15 -13
- package/dist/cjs/src/pro/gate.js +1 -1
- package/dist/cjs/src/pro/gemini.js +4 -2
- package/dist/cjs/src/pro/hitbtc.js +9 -8
- package/dist/cjs/src/pro/hollaex.js +2 -2
- package/dist/cjs/src/pro/htx.js +6 -7
- package/dist/cjs/src/pro/huobijp.js +3 -5
- package/dist/cjs/src/pro/idex.js +1 -1
- package/dist/cjs/src/pro/independentreserve.js +14 -13
- package/dist/cjs/src/pro/kraken.js +10 -16
- package/dist/cjs/src/pro/krakenfutures.js +10 -6
- package/dist/cjs/src/pro/kucoin.js +10 -11
- package/dist/cjs/src/pro/kucoinfutures.js +12 -11
- package/dist/cjs/src/pro/lbank.js +10 -10
- package/dist/cjs/src/pro/luno.js +12 -14
- package/dist/cjs/src/pro/mexc.js +3 -2
- package/dist/cjs/src/pro/ndax.js +7 -13
- package/dist/cjs/src/pro/okcoin.js +7 -12
- package/dist/cjs/src/pro/okx.js +6 -11
- package/dist/cjs/src/pro/onetrading.js +16 -15
- package/dist/cjs/src/pro/p2b.js +5 -3
- package/dist/cjs/src/pro/phemex.js +16 -11
- package/dist/cjs/src/pro/poloniex.js +6 -4
- package/dist/cjs/src/pro/poloniexfutures.js +14 -9
- package/dist/cjs/src/pro/probit.js +15 -11
- package/dist/cjs/src/pro/upbit.js +8 -8
- package/dist/cjs/src/pro/wazirx.js +6 -3
- package/dist/cjs/src/pro/woo.js +8 -6
- package/dist/cjs/src/probit.js +3 -3
- package/dist/cjs/src/timex.js +1 -1
- package/dist/cjs/src/tokocrypto.js +2 -2
- package/dist/cjs/src/wavesexchange.js +2 -1
- package/dist/cjs/src/whitebit.js +1 -1
- package/dist/cjs/src/woo.js +1 -1
- package/dist/cjs/src/yobit.js +39 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/coinbase.d.ts +10 -0
- package/js/src/abstract/okx.d.ts +12 -1
- package/js/src/ace.d.ts +1 -1
- package/js/src/ace.js +3 -2
- package/js/src/alpaca.d.ts +1 -1
- package/js/src/ascendex.d.ts +5 -15
- package/js/src/ascendex.js +1 -1
- package/js/src/base/Exchange.d.ts +88 -79
- package/js/src/base/Exchange.js +66 -24
- package/js/src/base/types.d.ts +90 -6
- package/js/src/bigone.d.ts +5 -15
- package/js/src/bigone.js +21 -1
- package/js/src/binance.d.ts +13 -23
- package/js/src/binance.js +6 -5
- package/js/src/bingx.d.ts +6 -16
- package/js/src/bingx.js +4 -3
- package/js/src/bit2c.d.ts +1 -1
- package/js/src/bit2c.js +12 -0
- package/js/src/bitbank.d.ts +2 -2
- package/js/src/bitbns.d.ts +1 -1
- package/js/src/bitfinex.d.ts +5 -5
- package/js/src/bitfinex2.d.ts +11 -16
- package/js/src/bitfinex2.js +415 -41
- package/js/src/bitflyer.d.ts +5 -5
- package/js/src/bitforex.d.ts +1 -1
- package/js/src/bitforex.js +3 -0
- package/js/src/bitget.d.ts +8 -38
- package/js/src/bitget.js +3 -3
- package/js/src/bithumb.d.ts +2 -2
- package/js/src/bitmart.d.ts +10 -21
- package/js/src/bitmart.js +1 -1
- package/js/src/bitmex.d.ts +3 -3
- package/js/src/bitopro.d.ts +2 -2
- package/js/src/bitrue.d.ts +5 -15
- package/js/src/bitrue.js +3 -3
- package/js/src/bitso.d.ts +4 -4
- package/js/src/bitstamp.d.ts +2 -2
- package/js/src/bitteam.d.ts +1 -1
- package/js/src/bitvavo.d.ts +3 -3
- package/js/src/bl3p.d.ts +1 -1
- package/js/src/blockchaincom.d.ts +2 -2
- package/js/src/blockchaincom.js +1 -1
- package/js/src/btcalpha.d.ts +1 -1
- package/js/src/btcbox.d.ts +1 -1
- package/js/src/btcmarkets.d.ts +3 -3
- package/js/src/btcturk.d.ts +1 -1
- package/js/src/bybit.d.ts +8 -8
- package/js/src/bybit.js +1 -1
- package/js/src/cex.d.ts +1 -1
- package/js/src/coinbase.d.ts +6 -50
- package/js/src/coinbase.js +12 -2
- package/js/src/coinbasepro.d.ts +2 -2
- package/js/src/coincheck.d.ts +1 -1
- package/js/src/coinex.d.ts +8 -8
- package/js/src/coinex.js +1 -1
- package/js/src/coinlist.d.ts +4 -14
- package/js/src/coinmate.d.ts +2 -2
- package/js/src/coinmetro.d.ts +2 -2
- package/js/src/coinone.d.ts +1 -1
- package/js/src/coinsph.d.ts +2 -2
- package/js/src/coinspot.d.ts +1 -1
- package/js/src/cryptocom.d.ts +4 -4
- package/js/src/cryptocom.js +10 -10
- package/js/src/currencycom.d.ts +2 -2
- package/js/src/delta.d.ts +2 -2
- package/js/src/deribit.d.ts +4 -14
- package/js/src/deribit.js +1 -0
- package/js/src/digifinex.d.ts +10 -38
- package/js/src/exmo.d.ts +2 -2
- package/js/src/gate.d.ts +8 -18
- package/js/src/gate.js +34 -29
- package/js/src/gemini.d.ts +2 -2
- package/js/src/hitbtc.d.ts +6 -16
- package/js/src/hollaex.d.ts +2 -2
- package/js/src/htx.d.ts +11 -21
- package/js/src/htx.js +1 -1
- package/js/src/huobijp.d.ts +4 -4
- package/js/src/idex.d.ts +3 -3
- package/js/src/independentreserve.d.ts +2 -2
- package/js/src/indodax.d.ts +2 -2
- package/js/src/kraken.d.ts +5 -5
- package/js/src/kraken.js +42 -1
- package/js/src/krakenfutures.d.ts +7 -7
- package/js/src/krakenfutures.js +3 -0
- package/js/src/kucoin.d.ts +8 -29
- package/js/src/kucoin.js +1 -1
- package/js/src/kucoinfutures.d.ts +4 -4
- package/js/src/kuna.d.ts +2 -2
- package/js/src/latoken.d.ts +4 -14
- package/js/src/lbank.d.ts +3 -6
- package/js/src/lbank.js +27 -26
- package/js/src/luno.d.ts +1 -1
- package/js/src/lykke.d.ts +2 -2
- package/js/src/mercado.d.ts +2 -2
- package/js/src/mexc.d.ts +6 -6
- package/js/src/mexc.js +2 -1
- package/js/src/ndax.d.ts +2 -2
- package/js/src/novadax.d.ts +4 -15
- package/js/src/oceanex.d.ts +1 -1
- package/js/src/okcoin.d.ts +5 -15
- package/js/src/okx.d.ts +8 -18
- package/js/src/okx.js +20 -5
- package/js/src/onetrading.d.ts +2 -2
- package/js/src/p2b.d.ts +1 -1
- package/js/src/paymium.d.ts +3 -13
- package/js/src/phemex.d.ts +5 -5
- package/js/src/phemex.js +8 -8
- package/js/src/poloniex.d.ts +4 -14
- package/js/src/poloniexfutures.d.ts +1 -1
- package/js/src/poloniexfutures.js +3 -0
- package/js/src/pro/alpaca.d.ts +2 -2
- package/js/src/pro/alpaca.js +8 -4
- package/js/src/pro/ascendex.d.ts +2 -2
- package/js/src/pro/ascendex.js +1 -2
- package/js/src/pro/binance.d.ts +3 -3
- package/js/src/pro/binance.js +14 -10
- package/js/src/pro/bingx.d.ts +1 -1
- package/js/src/pro/bingx.js +1 -1
- package/js/src/pro/bitfinex.d.ts +2 -2
- package/js/src/pro/bitfinex.js +21 -24
- package/js/src/pro/bitfinex2.d.ts +2 -2
- package/js/src/pro/bitfinex2.js +13 -17
- package/js/src/pro/bitget.js +3 -1
- package/js/src/pro/bitmart.d.ts +3 -3
- package/js/src/pro/bitmart.js +3 -8
- package/js/src/pro/bitmex.d.ts +1 -1
- package/js/src/pro/bitmex.js +4 -7
- package/js/src/pro/bitopro.d.ts +1 -1
- package/js/src/pro/bitopro.js +2 -5
- package/js/src/pro/bitrue.js +1 -1
- package/js/src/pro/bitstamp.d.ts +1 -1
- package/js/src/pro/bitstamp.js +2 -3
- package/js/src/pro/bitvavo.d.ts +3 -3
- package/js/src/pro/bitvavo.js +12 -5
- package/js/src/pro/blockchaincom.d.ts +8 -8
- package/js/src/pro/blockchaincom.js +22 -23
- package/js/src/pro/bybit.d.ts +2 -2
- package/js/src/pro/bybit.js +5 -5
- package/js/src/pro/cex.d.ts +1 -1
- package/js/src/pro/cex.js +7 -7
- package/js/src/pro/coinbase.d.ts +1 -1
- package/js/src/pro/coinbase.js +3 -2
- package/js/src/pro/coinbasepro.d.ts +1 -1
- package/js/src/pro/coinbasepro.js +1 -1
- package/js/src/pro/coinex.d.ts +2 -2
- package/js/src/pro/coinex.js +15 -13
- package/js/src/pro/currencycom.d.ts +1 -1
- package/js/src/pro/currencycom.js +5 -7
- package/js/src/pro/deribit.d.ts +2 -2
- package/js/src/pro/deribit.js +4 -4
- package/js/src/pro/exmo.d.ts +2 -2
- package/js/src/pro/exmo.js +15 -13
- package/js/src/pro/gate.js +1 -1
- package/js/src/pro/gemini.d.ts +1 -1
- package/js/src/pro/gemini.js +4 -2
- package/js/src/pro/hitbtc.d.ts +2 -2
- package/js/src/pro/hitbtc.js +9 -8
- package/js/src/pro/hollaex.d.ts +2 -2
- package/js/src/pro/hollaex.js +2 -2
- package/js/src/pro/htx.d.ts +2 -2
- package/js/src/pro/htx.js +6 -7
- package/js/src/pro/huobijp.d.ts +1 -1
- package/js/src/pro/huobijp.js +3 -5
- package/js/src/pro/idex.js +1 -1
- package/js/src/pro/independentreserve.d.ts +1 -1
- package/js/src/pro/independentreserve.js +14 -13
- package/js/src/pro/kraken.d.ts +2 -2
- package/js/src/pro/kraken.js +10 -16
- package/js/src/pro/krakenfutures.d.ts +1 -1
- package/js/src/pro/krakenfutures.js +10 -6
- package/js/src/pro/kucoin.d.ts +3 -3
- package/js/src/pro/kucoin.js +10 -11
- package/js/src/pro/kucoinfutures.d.ts +3 -3
- package/js/src/pro/kucoinfutures.js +12 -11
- package/js/src/pro/lbank.d.ts +1 -1
- package/js/src/pro/lbank.js +10 -10
- package/js/src/pro/luno.d.ts +2 -2
- package/js/src/pro/luno.js +12 -14
- package/js/src/pro/mexc.d.ts +2 -2
- package/js/src/pro/mexc.js +3 -2
- package/js/src/pro/ndax.d.ts +3 -3
- package/js/src/pro/ndax.js +7 -13
- package/js/src/pro/okcoin.d.ts +1 -1
- package/js/src/pro/okcoin.js +7 -12
- package/js/src/pro/okx.d.ts +1 -1
- package/js/src/pro/okx.js +6 -11
- package/js/src/pro/onetrading.d.ts +1 -1
- package/js/src/pro/onetrading.js +16 -15
- package/js/src/pro/p2b.d.ts +1 -1
- package/js/src/pro/p2b.js +5 -3
- package/js/src/pro/phemex.d.ts +3 -3
- package/js/src/pro/phemex.js +16 -11
- package/js/src/pro/poloniex.d.ts +1 -1
- package/js/src/pro/poloniex.js +6 -4
- package/js/src/pro/poloniexfutures.d.ts +4 -4
- package/js/src/pro/poloniexfutures.js +13 -10
- package/js/src/pro/probit.d.ts +1 -1
- package/js/src/pro/probit.js +14 -12
- package/js/src/pro/upbit.js +8 -8
- package/js/src/pro/wazirx.d.ts +1 -1
- package/js/src/pro/wazirx.js +6 -3
- package/js/src/pro/woo.d.ts +3 -3
- package/js/src/pro/woo.js +8 -6
- package/js/src/probit.d.ts +3 -3
- package/js/src/probit.js +3 -3
- package/js/src/timex.d.ts +1 -1
- package/js/src/timex.js +1 -1
- package/js/src/tokocrypto.d.ts +3 -3
- package/js/src/tokocrypto.js +2 -2
- package/js/src/upbit.d.ts +2 -2
- package/js/src/wavesexchange.d.ts +3 -4
- package/js/src/wavesexchange.js +2 -1
- package/js/src/wazirx.d.ts +1 -1
- package/js/src/whitebit.d.ts +5 -15
- package/js/src/whitebit.js +1 -1
- package/js/src/woo.d.ts +5 -15
- package/js/src/woo.js +1 -1
- package/js/src/yobit.d.ts +21 -6
- package/js/src/yobit.js +39 -0
- package/js/src/zaif.d.ts +2 -2
- package/js/src/zonda.d.ts +4 -14
- package/package.json +22 -8
- package/skip-tests.json +9 -1
- package/tests-manager.sh +1 -2
package/js/src/bitfinex2.js
CHANGED
|
@@ -29,11 +29,13 @@ export default class bitfinex2 extends Exchange {
|
|
|
29
29
|
'CORS': undefined,
|
|
30
30
|
'spot': true,
|
|
31
31
|
'margin': undefined,
|
|
32
|
-
'swap':
|
|
32
|
+
'swap': true,
|
|
33
33
|
'future': undefined,
|
|
34
34
|
'option': undefined,
|
|
35
|
+
'addMargin': false,
|
|
35
36
|
'cancelAllOrders': true,
|
|
36
37
|
'cancelOrder': true,
|
|
38
|
+
'cancelOrders': true,
|
|
37
39
|
'createDepositAddress': true,
|
|
38
40
|
'createLimitOrder': true,
|
|
39
41
|
'createMarketOrder': true,
|
|
@@ -42,23 +44,27 @@ export default class bitfinex2 extends Exchange {
|
|
|
42
44
|
'createStopLimitOrder': true,
|
|
43
45
|
'createStopMarketOrder': true,
|
|
44
46
|
'createStopOrder': true,
|
|
45
|
-
'createTriggerOrder': true,
|
|
46
47
|
'createTrailingAmountOrder': true,
|
|
47
48
|
'createTrailingPercentOrder': false,
|
|
48
|
-
'
|
|
49
|
+
'createTriggerOrder': true,
|
|
50
|
+
'editOrder': true,
|
|
49
51
|
'fetchBalance': true,
|
|
50
52
|
'fetchClosedOrder': true,
|
|
51
53
|
'fetchClosedOrders': true,
|
|
52
54
|
'fetchCurrencies': true,
|
|
53
55
|
'fetchDepositAddress': true,
|
|
54
56
|
'fetchDepositsWithdrawals': true,
|
|
57
|
+
'fetchFundingHistory': false,
|
|
55
58
|
'fetchFundingRate': true,
|
|
56
59
|
'fetchFundingRateHistory': true,
|
|
57
60
|
'fetchFundingRates': true,
|
|
58
61
|
'fetchIndexOHLCV': false,
|
|
59
62
|
'fetchLedger': true,
|
|
63
|
+
'fetchLeverage': false,
|
|
64
|
+
'fetchLeverageTiers': false,
|
|
60
65
|
'fetchLiquidations': true,
|
|
61
66
|
'fetchMarginMode': false,
|
|
67
|
+
'fetchMarketLeverageTiers': false,
|
|
62
68
|
'fetchMarkOHLCV': false,
|
|
63
69
|
'fetchMyTrades': true,
|
|
64
70
|
'fetchOHLCV': true,
|
|
@@ -68,7 +74,10 @@ export default class bitfinex2 extends Exchange {
|
|
|
68
74
|
'fetchOpenOrders': true,
|
|
69
75
|
'fetchOrder': true,
|
|
70
76
|
'fetchOrderTrades': true,
|
|
77
|
+
'fetchPosition': false,
|
|
71
78
|
'fetchPositionMode': false,
|
|
79
|
+
'fetchPositions': true,
|
|
80
|
+
'fetchPremiumIndexOHLCV': false,
|
|
72
81
|
'fetchStatus': true,
|
|
73
82
|
'fetchTickers': true,
|
|
74
83
|
'fetchTime': false,
|
|
@@ -76,7 +85,11 @@ export default class bitfinex2 extends Exchange {
|
|
|
76
85
|
'fetchTradingFees': true,
|
|
77
86
|
'fetchTransactionFees': undefined,
|
|
78
87
|
'fetchTransactions': 'emulated',
|
|
88
|
+
'reduceMargin': false,
|
|
89
|
+
'setLeverage': false,
|
|
79
90
|
'setMargin': true,
|
|
91
|
+
'setMarginMode': false,
|
|
92
|
+
'setPositionMode': false,
|
|
80
93
|
'withdraw': true,
|
|
81
94
|
},
|
|
82
95
|
'timeframes': {
|
|
@@ -344,6 +357,7 @@ export default class bitfinex2 extends Exchange {
|
|
|
344
357
|
'margin': 'margin',
|
|
345
358
|
'derivatives': 'margin',
|
|
346
359
|
'future': 'margin',
|
|
360
|
+
'swap': 'margin',
|
|
347
361
|
},
|
|
348
362
|
'withdraw': {
|
|
349
363
|
'includeFee': false,
|
|
@@ -1000,7 +1014,7 @@ export default class bitfinex2 extends Exchange {
|
|
|
1000
1014
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
1001
1015
|
* @see https://docs.bitfinex.com/reference/rest-public-book
|
|
1002
1016
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
1003
|
-
* @param {int} [limit] the maximum amount of order book entries to return
|
|
1017
|
+
* @param {int} [limit] the maximum amount of order book entries to return, bitfinex only allows 1, 25, or 100
|
|
1004
1018
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1005
1019
|
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
1006
1020
|
*/
|
|
@@ -1012,7 +1026,7 @@ export default class bitfinex2 extends Exchange {
|
|
|
1012
1026
|
'precision': precision,
|
|
1013
1027
|
};
|
|
1014
1028
|
if (limit !== undefined) {
|
|
1015
|
-
request['len'] = limit;
|
|
1029
|
+
request['len'] = limit;
|
|
1016
1030
|
}
|
|
1017
1031
|
const fullRequest = this.extend(request, params);
|
|
1018
1032
|
const orderbook = await this.publicGetBookSymbolPrecision(fullRequest);
|
|
@@ -1284,9 +1298,9 @@ export default class bitfinex2 extends Exchange {
|
|
|
1284
1298
|
* @see https://docs.bitfinex.com/reference/rest-public-trades
|
|
1285
1299
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
1286
1300
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
1287
|
-
* @param {int} [limit] the maximum amount of trades to fetch
|
|
1301
|
+
* @param {int} [limit] the maximum amount of trades to fetch, default 120, max 10000
|
|
1288
1302
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1289
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [
|
|
1303
|
+
* @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)
|
|
1290
1304
|
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
1291
1305
|
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
1292
1306
|
*/
|
|
@@ -1333,11 +1347,11 @@ export default class bitfinex2 extends Exchange {
|
|
|
1333
1347
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
1334
1348
|
* @param {string} timeframe the length of time each candle represents
|
|
1335
1349
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
1336
|
-
* @param {int} [limit] the maximum amount of candles to fetch
|
|
1350
|
+
* @param {int} [limit] the maximum amount of candles to fetch, default 100 max 10000
|
|
1337
1351
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1338
1352
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
1339
1353
|
* @param {int} [params.until] timestamp in ms of the latest candle to fetch
|
|
1340
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [
|
|
1354
|
+
* @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)
|
|
1341
1355
|
*/
|
|
1342
1356
|
await this.loadMarkets();
|
|
1343
1357
|
let paginate = false;
|
|
@@ -1347,7 +1361,7 @@ export default class bitfinex2 extends Exchange {
|
|
|
1347
1361
|
}
|
|
1348
1362
|
const market = this.market(symbol);
|
|
1349
1363
|
if (limit === undefined) {
|
|
1350
|
-
limit = 10000;
|
|
1364
|
+
limit = 10000;
|
|
1351
1365
|
}
|
|
1352
1366
|
let request = {
|
|
1353
1367
|
'symbol': market['id'],
|
|
@@ -1495,30 +1509,20 @@ export default class bitfinex2 extends Exchange {
|
|
|
1495
1509
|
'trades': undefined,
|
|
1496
1510
|
}, market);
|
|
1497
1511
|
}
|
|
1498
|
-
|
|
1512
|
+
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
1499
1513
|
/**
|
|
1500
1514
|
* @method
|
|
1501
|
-
* @
|
|
1502
|
-
* @
|
|
1503
|
-
* @
|
|
1504
|
-
* @param {string} symbol unified
|
|
1505
|
-
* @param {string} type '
|
|
1515
|
+
* @ignore
|
|
1516
|
+
* @name bitfinex2#createOrderRequest
|
|
1517
|
+
* @description helper function to build an order request
|
|
1518
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
1519
|
+
* @param {string} type 'market' or 'limit'
|
|
1506
1520
|
* @param {string} side 'buy' or 'sell'
|
|
1507
|
-
* @param {float} amount
|
|
1508
|
-
* @param {float} [price] price of the order
|
|
1521
|
+
* @param {float} amount how much you want to trade in units of the base currency
|
|
1522
|
+
* @param {float} [price] the price of the order, in units of the quote currency, ignored in market orders
|
|
1509
1523
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1510
|
-
* @
|
|
1511
|
-
* @param {string} [params.timeInForce] "GTC", "IOC", "FOK", or "PO"
|
|
1512
|
-
* @param {boolean} [params.postOnly] set to true if you want to make a post only order
|
|
1513
|
-
* @param {boolean} [params.reduceOnly] indicates that the order is to reduce the size of a position
|
|
1514
|
-
* @param {int} [params.flags] additional order parameters: 4096 (Post Only), 1024 (Reduce Only), 16384 (OCO), 64 (Hidden), 512 (Close), 524288 (No Var Rates)
|
|
1515
|
-
* @param {int} [params.lev] leverage for a derivative order, supported by derivative symbol orders only. The value should be between 1 and 100 inclusive.
|
|
1516
|
-
* @param {string} [params.price_aux_limit] order price for stop limit orders
|
|
1517
|
-
* @param {string} [params.price_oco_stop] OCO stop price
|
|
1518
|
-
* @param {string} [params.trailingAmount] *swap only* the quote amount to trail away from the current market price
|
|
1519
|
-
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1524
|
+
* @returns {object} request to be sent to the exchange
|
|
1520
1525
|
*/
|
|
1521
|
-
await this.loadMarkets();
|
|
1522
1526
|
const market = this.market(symbol);
|
|
1523
1527
|
let amountString = this.amountToPrecision(symbol, amount);
|
|
1524
1528
|
amountString = (side === 'buy') ? amountString : Precise.stringNeg(amountString);
|
|
@@ -1532,7 +1536,6 @@ export default class bitfinex2 extends Exchange {
|
|
|
1532
1536
|
const postOnlyParam = this.safeBool(params, 'postOnly', false);
|
|
1533
1537
|
const reduceOnly = this.safeBool(params, 'reduceOnly', false);
|
|
1534
1538
|
const clientOrderId = this.safeValue2(params, 'cid', 'clientOrderId');
|
|
1535
|
-
params = this.omit(params, ['triggerPrice', 'stopPrice', 'timeInForce', 'postOnly', 'reduceOnly', 'trailingAmount', 'clientOrderId']);
|
|
1536
1539
|
let orderType = type.toUpperCase();
|
|
1537
1540
|
if (trailingAmount !== undefined) {
|
|
1538
1541
|
orderType = 'TRAILING STOP';
|
|
@@ -1588,7 +1591,36 @@ export default class bitfinex2 extends Exchange {
|
|
|
1588
1591
|
if (clientOrderId !== undefined) {
|
|
1589
1592
|
request['cid'] = clientOrderId;
|
|
1590
1593
|
}
|
|
1591
|
-
|
|
1594
|
+
params = this.omit(params, ['triggerPrice', 'stopPrice', 'timeInForce', 'postOnly', 'reduceOnly', 'trailingAmount', 'clientOrderId']);
|
|
1595
|
+
return this.extend(request, params);
|
|
1596
|
+
}
|
|
1597
|
+
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
1598
|
+
/**
|
|
1599
|
+
* @method
|
|
1600
|
+
* @name bitfinex2#createOrder
|
|
1601
|
+
* @description create an order on the exchange
|
|
1602
|
+
* @see https://docs.bitfinex.com/reference/rest-auth-submit-order
|
|
1603
|
+
* @param {string} symbol unified CCXT market symbol
|
|
1604
|
+
* @param {string} type 'limit' or 'market'
|
|
1605
|
+
* @param {string} side 'buy' or 'sell'
|
|
1606
|
+
* @param {float} amount the amount of currency to trade
|
|
1607
|
+
* @param {float} [price] price of the order
|
|
1608
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1609
|
+
* @param {float} [params.stopPrice] the price that triggers a trigger order
|
|
1610
|
+
* @param {string} [params.timeInForce] "GTC", "IOC", "FOK", or "PO"
|
|
1611
|
+
* @param {boolean} [params.postOnly] set to true if you want to make a post only order
|
|
1612
|
+
* @param {boolean} [params.reduceOnly] indicates that the order is to reduce the size of a position
|
|
1613
|
+
* @param {int} [params.flags] additional order parameters: 4096 (Post Only), 1024 (Reduce Only), 16384 (OCO), 64 (Hidden), 512 (Close), 524288 (No Var Rates)
|
|
1614
|
+
* @param {int} [params.lev] leverage for a derivative order, supported by derivative symbol orders only. The value should be between 1 and 100 inclusive.
|
|
1615
|
+
* @param {string} [params.price_aux_limit] order price for stop limit orders
|
|
1616
|
+
* @param {string} [params.price_oco_stop] OCO stop price
|
|
1617
|
+
* @param {string} [params.trailingAmount] *swap only* the quote amount to trail away from the current market price
|
|
1618
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1619
|
+
*/
|
|
1620
|
+
await this.loadMarkets();
|
|
1621
|
+
const market = this.market(symbol);
|
|
1622
|
+
const request = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
1623
|
+
const response = await this.privatePostAuthWOrderSubmit(request);
|
|
1592
1624
|
//
|
|
1593
1625
|
// [
|
|
1594
1626
|
// 1653325121, // Timestamp in milliseconds
|
|
@@ -1646,6 +1678,67 @@ export default class bitfinex2 extends Exchange {
|
|
|
1646
1678
|
const order = this.safeList(orders, 0);
|
|
1647
1679
|
return this.parseOrder(order, market);
|
|
1648
1680
|
}
|
|
1681
|
+
async createOrders(orders, params = {}) {
|
|
1682
|
+
/**
|
|
1683
|
+
* @method
|
|
1684
|
+
* @name bitfinex2#createOrders
|
|
1685
|
+
* @description create a list of trade orders
|
|
1686
|
+
* @see https://docs.bitfinex.com/reference/rest-auth-order-multi
|
|
1687
|
+
* @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
|
|
1688
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1689
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1690
|
+
*/
|
|
1691
|
+
await this.loadMarkets();
|
|
1692
|
+
const ordersRequests = [];
|
|
1693
|
+
for (let i = 0; i < orders.length; i++) {
|
|
1694
|
+
const rawOrder = orders[i];
|
|
1695
|
+
const symbol = this.safeString(rawOrder, 'symbol');
|
|
1696
|
+
const type = this.safeString(rawOrder, 'type');
|
|
1697
|
+
const side = this.safeString(rawOrder, 'side');
|
|
1698
|
+
const amount = this.safeNumber(rawOrder, 'amount');
|
|
1699
|
+
const price = this.safeNumber(rawOrder, 'price');
|
|
1700
|
+
const orderParams = this.safeDict(rawOrder, 'params', {});
|
|
1701
|
+
const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, orderParams);
|
|
1702
|
+
ordersRequests.push(['on', orderRequest]);
|
|
1703
|
+
}
|
|
1704
|
+
const request = {
|
|
1705
|
+
'ops': ordersRequests,
|
|
1706
|
+
};
|
|
1707
|
+
const response = await this.privatePostAuthWOrderMulti(request);
|
|
1708
|
+
//
|
|
1709
|
+
// [
|
|
1710
|
+
// 1706762515553,
|
|
1711
|
+
// "ox_multi-req",
|
|
1712
|
+
// null,
|
|
1713
|
+
// null,
|
|
1714
|
+
// [
|
|
1715
|
+
// [
|
|
1716
|
+
// 1706762515,
|
|
1717
|
+
// "on-req",
|
|
1718
|
+
// null,
|
|
1719
|
+
// null,
|
|
1720
|
+
// [
|
|
1721
|
+
// [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,{}]
|
|
1722
|
+
// ],
|
|
1723
|
+
// null,
|
|
1724
|
+
// "SUCCESS",
|
|
1725
|
+
// "Submitting 1 orders."
|
|
1726
|
+
// ],
|
|
1727
|
+
// ],
|
|
1728
|
+
// null,
|
|
1729
|
+
// "SUCCESS",
|
|
1730
|
+
// "Submitting 2 order operations."
|
|
1731
|
+
// ]
|
|
1732
|
+
//
|
|
1733
|
+
const results = [];
|
|
1734
|
+
const data = this.safeList(response, 4, []);
|
|
1735
|
+
for (let i = 0; i < data.length; i++) {
|
|
1736
|
+
const entry = data[i];
|
|
1737
|
+
const individualOrder = entry[4];
|
|
1738
|
+
results.push(individualOrder[0]);
|
|
1739
|
+
}
|
|
1740
|
+
return this.parseOrders(results);
|
|
1741
|
+
}
|
|
1649
1742
|
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
1650
1743
|
/**
|
|
1651
1744
|
* @method
|
|
@@ -1656,6 +1749,7 @@ export default class bitfinex2 extends Exchange {
|
|
|
1656
1749
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1657
1750
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1658
1751
|
*/
|
|
1752
|
+
await this.loadMarkets();
|
|
1659
1753
|
const request = {
|
|
1660
1754
|
'all': 1,
|
|
1661
1755
|
};
|
|
@@ -1674,6 +1768,7 @@ export default class bitfinex2 extends Exchange {
|
|
|
1674
1768
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1675
1769
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1676
1770
|
*/
|
|
1771
|
+
await this.loadMarkets();
|
|
1677
1772
|
const cid = this.safeValue2(params, 'cid', 'clientOrderId'); // client order id
|
|
1678
1773
|
let request = undefined;
|
|
1679
1774
|
if (cid !== undefined) {
|
|
@@ -1696,6 +1791,82 @@ export default class bitfinex2 extends Exchange {
|
|
|
1696
1791
|
const order = this.safeValue(response, 4);
|
|
1697
1792
|
return this.parseOrder(order);
|
|
1698
1793
|
}
|
|
1794
|
+
async cancelOrders(ids, symbol = undefined, params = {}) {
|
|
1795
|
+
/**
|
|
1796
|
+
* @method
|
|
1797
|
+
* @name bitfinex2#cancelOrders
|
|
1798
|
+
* @description cancel multiple orders at the same time
|
|
1799
|
+
* @see https://docs.bitfinex.com/reference/rest-auth-cancel-orders-multiple
|
|
1800
|
+
* @param {string[]} ids order ids
|
|
1801
|
+
* @param {string} symbol unified market symbol, default is undefined
|
|
1802
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1803
|
+
* @returns {object} an array of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1804
|
+
*/
|
|
1805
|
+
await this.loadMarkets();
|
|
1806
|
+
for (let i = 0; i < ids.length; i++) {
|
|
1807
|
+
ids[i] = this.parseToNumeric(ids[i]);
|
|
1808
|
+
}
|
|
1809
|
+
const request = {
|
|
1810
|
+
'id': ids,
|
|
1811
|
+
};
|
|
1812
|
+
let market = undefined;
|
|
1813
|
+
if (symbol !== undefined) {
|
|
1814
|
+
market = this.market(symbol);
|
|
1815
|
+
}
|
|
1816
|
+
const response = await this.privatePostAuthWOrderCancelMulti(this.extend(request, params));
|
|
1817
|
+
//
|
|
1818
|
+
// [
|
|
1819
|
+
// 1706740198811,
|
|
1820
|
+
// "oc_multi-req",
|
|
1821
|
+
// null,
|
|
1822
|
+
// null,
|
|
1823
|
+
// [
|
|
1824
|
+
// [
|
|
1825
|
+
// 139530205057,
|
|
1826
|
+
// null,
|
|
1827
|
+
// 1706740132275,
|
|
1828
|
+
// "tBTCF0:USTF0",
|
|
1829
|
+
// 1706740132276,
|
|
1830
|
+
// 1706740132276,
|
|
1831
|
+
// 0.0001,
|
|
1832
|
+
// 0.0001,
|
|
1833
|
+
// "LIMIT",
|
|
1834
|
+
// null,
|
|
1835
|
+
// null,
|
|
1836
|
+
// null,
|
|
1837
|
+
// 0,
|
|
1838
|
+
// "ACTIVE",
|
|
1839
|
+
// null,
|
|
1840
|
+
// null,
|
|
1841
|
+
// 39000,
|
|
1842
|
+
// 0,
|
|
1843
|
+
// 0,
|
|
1844
|
+
// 0,
|
|
1845
|
+
// null,
|
|
1846
|
+
// null,
|
|
1847
|
+
// null,
|
|
1848
|
+
// 0,
|
|
1849
|
+
// 0,
|
|
1850
|
+
// null,
|
|
1851
|
+
// null,
|
|
1852
|
+
// null,
|
|
1853
|
+
// "API>BFX",
|
|
1854
|
+
// null,
|
|
1855
|
+
// null,
|
|
1856
|
+
// {
|
|
1857
|
+
// "lev": 10,
|
|
1858
|
+
// "$F33": 10
|
|
1859
|
+
// }
|
|
1860
|
+
// ],
|
|
1861
|
+
// ],
|
|
1862
|
+
// null,
|
|
1863
|
+
// "SUCCESS",
|
|
1864
|
+
// "Submitting 2 order cancellations."
|
|
1865
|
+
// ]
|
|
1866
|
+
//
|
|
1867
|
+
const orders = this.safeList(response, 4, []);
|
|
1868
|
+
return this.parseOrders(orders, market);
|
|
1869
|
+
}
|
|
1699
1870
|
async fetchOpenOrder(id, symbol = undefined, params = {}) {
|
|
1700
1871
|
/**
|
|
1701
1872
|
* @method
|
|
@@ -2705,14 +2876,13 @@ export default class bitfinex2 extends Exchange {
|
|
|
2705
2876
|
* @see https://docs.bitfinex.com/reference/rest-auth-ledgers
|
|
2706
2877
|
* @param {string} code unified currency code, default is undefined
|
|
2707
2878
|
* @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
|
|
2708
|
-
* @param {int} [limit] max number of ledger entrys to return, default is undefined
|
|
2879
|
+
* @param {int} [limit] max number of ledger entrys to return, default is undefined max is 2500
|
|
2709
2880
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2710
2881
|
* @param {int} [params.until] timestamp in ms of the latest ledger entry
|
|
2711
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [
|
|
2882
|
+
* @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)
|
|
2712
2883
|
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
|
|
2713
2884
|
*/
|
|
2714
2885
|
await this.loadMarkets();
|
|
2715
|
-
await this.loadMarkets();
|
|
2716
2886
|
let paginate = false;
|
|
2717
2887
|
[paginate, params] = this.handleOptionAndParams(params, 'fetchLedger', 'paginate');
|
|
2718
2888
|
if (paginate) {
|
|
@@ -2724,7 +2894,7 @@ export default class bitfinex2 extends Exchange {
|
|
|
2724
2894
|
request['start'] = since;
|
|
2725
2895
|
}
|
|
2726
2896
|
if (limit !== undefined) {
|
|
2727
|
-
request['limit'] = limit;
|
|
2897
|
+
request['limit'] = limit;
|
|
2728
2898
|
}
|
|
2729
2899
|
[request, params] = this.handleUntilOption('end', request, params);
|
|
2730
2900
|
let response = undefined;
|
|
@@ -2756,7 +2926,7 @@ export default class bitfinex2 extends Exchange {
|
|
|
2756
2926
|
async fetchFundingRate(symbol, params = {}) {
|
|
2757
2927
|
/**
|
|
2758
2928
|
* @method
|
|
2759
|
-
* @name
|
|
2929
|
+
* @name bitfinex2#fetchFundingRate
|
|
2760
2930
|
* @description fetch the current funding rate
|
|
2761
2931
|
* @see https://docs.bitfinex.com/reference/rest-public-derivatives-status
|
|
2762
2932
|
* @param {string} symbol unified market symbol
|
|
@@ -2768,7 +2938,7 @@ export default class bitfinex2 extends Exchange {
|
|
|
2768
2938
|
async fetchFundingRates(symbols = undefined, params = {}) {
|
|
2769
2939
|
/**
|
|
2770
2940
|
* @method
|
|
2771
|
-
* @name
|
|
2941
|
+
* @name bitfinex2#fetchFundingRate
|
|
2772
2942
|
* @description fetch the current funding rate
|
|
2773
2943
|
* @see https://docs.bitfinex.com/reference/rest-public-derivatives-status
|
|
2774
2944
|
* @param {string[]} symbols list of unified market symbols
|
|
@@ -2819,13 +2989,15 @@ export default class bitfinex2 extends Exchange {
|
|
|
2819
2989
|
async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2820
2990
|
/**
|
|
2821
2991
|
* @method
|
|
2822
|
-
* @name
|
|
2992
|
+
* @name bitfinex2#fetchFundingRateHistory
|
|
2823
2993
|
* @description fetches historical funding rate prices
|
|
2824
2994
|
* @see https://docs.bitfinex.com/reference/rest-public-derivatives-status-history
|
|
2825
2995
|
* @param {string} symbol unified market symbol
|
|
2996
|
+
* @param {int} [since] timestamp in ms of the earliest funding rate entry
|
|
2997
|
+
* @param {int} [limit] max number of funding rate entrys to return
|
|
2826
2998
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2827
2999
|
* @param {int} [params.until] timestamp in ms of the latest funding rate
|
|
2828
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [
|
|
3000
|
+
* @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)
|
|
2829
3001
|
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
|
|
2830
3002
|
*/
|
|
2831
3003
|
if (symbol === undefined) {
|
|
@@ -2882,7 +3054,15 @@ export default class bitfinex2 extends Exchange {
|
|
|
2882
3054
|
const rate = this.parseFundingRateHistory(fr, market);
|
|
2883
3055
|
rates.push(rate);
|
|
2884
3056
|
}
|
|
2885
|
-
|
|
3057
|
+
const reversedArray = [];
|
|
3058
|
+
const rawRates = this.filterBySymbolSinceLimit(rates, symbol, since, limit);
|
|
3059
|
+
const rawRatesLength = rawRates.length;
|
|
3060
|
+
const ratesLength = Math.max(rawRatesLength - 1, 0);
|
|
3061
|
+
for (let i = ratesLength; i >= 0; i--) {
|
|
3062
|
+
const valueAtIndex = rawRates[i];
|
|
3063
|
+
reversedArray.push(valueAtIndex);
|
|
3064
|
+
}
|
|
3065
|
+
return reversedArray;
|
|
2886
3066
|
}
|
|
2887
3067
|
parseFundingRate(contract, market = undefined) {
|
|
2888
3068
|
//
|
|
@@ -3032,7 +3212,8 @@ export default class bitfinex2 extends Exchange {
|
|
|
3032
3212
|
// ]
|
|
3033
3213
|
// ]
|
|
3034
3214
|
//
|
|
3035
|
-
|
|
3215
|
+
const oi = this.safeList(response, 0);
|
|
3216
|
+
return this.parseOpenInterest(oi, market);
|
|
3036
3217
|
}
|
|
3037
3218
|
async fetchOpenInterestHistory(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
3038
3219
|
/**
|
|
@@ -3303,4 +3484,197 @@ export default class bitfinex2 extends Exchange {
|
|
|
3303
3484
|
'status': marginStatus,
|
|
3304
3485
|
};
|
|
3305
3486
|
}
|
|
3487
|
+
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
3488
|
+
/**
|
|
3489
|
+
* @method
|
|
3490
|
+
* @name bitfinex2#fetchOrder
|
|
3491
|
+
* @description fetches information on an order made by the user
|
|
3492
|
+
* @see https://docs.bitfinex.com/reference/rest-auth-retrieve-orders
|
|
3493
|
+
* @see https://docs.bitfinex.com/reference/rest-auth-retrieve-orders-by-symbol
|
|
3494
|
+
* @param {string} id the order id
|
|
3495
|
+
* @param {string} [symbol] unified symbol of the market the order was made in
|
|
3496
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3497
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3498
|
+
*/
|
|
3499
|
+
await this.loadMarkets();
|
|
3500
|
+
const request = {
|
|
3501
|
+
'id': [this.parseToNumeric(id)],
|
|
3502
|
+
};
|
|
3503
|
+
let market = undefined;
|
|
3504
|
+
let response = undefined;
|
|
3505
|
+
if (symbol === undefined) {
|
|
3506
|
+
response = await this.privatePostAuthROrders(this.extend(request, params));
|
|
3507
|
+
}
|
|
3508
|
+
else {
|
|
3509
|
+
market = this.market(symbol);
|
|
3510
|
+
request['symbol'] = market['id'];
|
|
3511
|
+
response = await this.privatePostAuthROrdersSymbol(this.extend(request, params));
|
|
3512
|
+
}
|
|
3513
|
+
//
|
|
3514
|
+
// [
|
|
3515
|
+
// [
|
|
3516
|
+
// 139658969116,
|
|
3517
|
+
// null,
|
|
3518
|
+
// 1706843908637,
|
|
3519
|
+
// "tBTCUST",
|
|
3520
|
+
// 1706843908637,
|
|
3521
|
+
// 1706843908638,
|
|
3522
|
+
// 0.0001,
|
|
3523
|
+
// 0.0001,
|
|
3524
|
+
// "EXCHANGE LIMIT",
|
|
3525
|
+
// null,
|
|
3526
|
+
// null,
|
|
3527
|
+
// null,
|
|
3528
|
+
// 0,
|
|
3529
|
+
// "ACTIVE",
|
|
3530
|
+
// null,
|
|
3531
|
+
// null,
|
|
3532
|
+
// 35000,
|
|
3533
|
+
// 0,
|
|
3534
|
+
// 0,
|
|
3535
|
+
// 0,
|
|
3536
|
+
// null,
|
|
3537
|
+
// null,
|
|
3538
|
+
// null,
|
|
3539
|
+
// 0,
|
|
3540
|
+
// 0,
|
|
3541
|
+
// null,
|
|
3542
|
+
// null,
|
|
3543
|
+
// null,
|
|
3544
|
+
// "API>BFX",
|
|
3545
|
+
// null,
|
|
3546
|
+
// null,
|
|
3547
|
+
// {}
|
|
3548
|
+
// ]
|
|
3549
|
+
// ]
|
|
3550
|
+
//
|
|
3551
|
+
const order = this.safeList(response, 0);
|
|
3552
|
+
return this.parseOrder(order, market);
|
|
3553
|
+
}
|
|
3554
|
+
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
3555
|
+
/**
|
|
3556
|
+
* @method
|
|
3557
|
+
* @name bitfinex2#editOrder
|
|
3558
|
+
* @description edit a trade order
|
|
3559
|
+
* @see https://docs.bitfinex.com/reference/rest-auth-update-order
|
|
3560
|
+
* @param {string} id edit order id
|
|
3561
|
+
* @param {string} symbol unified symbol of the market to edit an order in
|
|
3562
|
+
* @param {string} type 'market' or 'limit'
|
|
3563
|
+
* @param {string} side 'buy' or 'sell'
|
|
3564
|
+
* @param {float} amount how much you want to trade in units of the base currency
|
|
3565
|
+
* @param {float} [price] the price that the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
3566
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3567
|
+
* @param {float} [params.stopPrice] the price that triggers a trigger order
|
|
3568
|
+
* @param {boolean} [params.postOnly] set to true if you want to make a post only order
|
|
3569
|
+
* @param {boolean} [params.reduceOnly] indicates that the order is to reduce the size of a position
|
|
3570
|
+
* @param {int} [params.flags] additional order parameters: 4096 (Post Only), 1024 (Reduce Only), 16384 (OCO), 64 (Hidden), 512 (Close), 524288 (No Var Rates)
|
|
3571
|
+
* @param {int} [params.leverage] leverage for a derivative order, supported by derivative symbol orders only, the value should be between 1 and 100 inclusive
|
|
3572
|
+
* @param {int} [params.clientOrderId] a unique client order id for the order
|
|
3573
|
+
* @param {float} [params.trailingAmount] *swap only* the quote amount to trail away from the current market price
|
|
3574
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3575
|
+
*/
|
|
3576
|
+
await this.loadMarkets();
|
|
3577
|
+
const market = this.market(symbol);
|
|
3578
|
+
const request = {
|
|
3579
|
+
'id': this.parseToNumeric(id),
|
|
3580
|
+
};
|
|
3581
|
+
if (amount !== undefined) {
|
|
3582
|
+
let amountString = this.amountToPrecision(symbol, amount);
|
|
3583
|
+
amountString = (side === 'buy') ? amountString : Precise.stringNeg(amountString);
|
|
3584
|
+
request['amount'] = amountString;
|
|
3585
|
+
}
|
|
3586
|
+
const stopPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
|
|
3587
|
+
const trailingAmount = this.safeString(params, 'trailingAmount');
|
|
3588
|
+
const timeInForce = this.safeString(params, 'timeInForce');
|
|
3589
|
+
const postOnlyParam = this.safeBool(params, 'postOnly', false);
|
|
3590
|
+
const reduceOnly = this.safeBool(params, 'reduceOnly', false);
|
|
3591
|
+
const clientOrderId = this.safeInteger2(params, 'cid', 'clientOrderId');
|
|
3592
|
+
if (trailingAmount !== undefined) {
|
|
3593
|
+
request['price_trailing'] = trailingAmount;
|
|
3594
|
+
}
|
|
3595
|
+
else if (stopPrice !== undefined) {
|
|
3596
|
+
// request['price'] is taken as stopPrice for stop orders
|
|
3597
|
+
request['price'] = this.priceToPrecision(symbol, stopPrice);
|
|
3598
|
+
if (type === 'limit') {
|
|
3599
|
+
request['price_aux_limit'] = this.priceToPrecision(symbol, price);
|
|
3600
|
+
}
|
|
3601
|
+
}
|
|
3602
|
+
const postOnly = (postOnlyParam || (timeInForce === 'PO'));
|
|
3603
|
+
if ((type !== 'market') && (stopPrice === undefined)) {
|
|
3604
|
+
request['price'] = this.priceToPrecision(symbol, price);
|
|
3605
|
+
}
|
|
3606
|
+
// flag values may be summed to combine flags
|
|
3607
|
+
let flags = 0;
|
|
3608
|
+
if (postOnly) {
|
|
3609
|
+
flags = this.sum(flags, 4096);
|
|
3610
|
+
}
|
|
3611
|
+
if (reduceOnly) {
|
|
3612
|
+
flags = this.sum(flags, 1024);
|
|
3613
|
+
}
|
|
3614
|
+
if (flags !== 0) {
|
|
3615
|
+
request['flags'] = flags;
|
|
3616
|
+
}
|
|
3617
|
+
if (clientOrderId !== undefined) {
|
|
3618
|
+
request['cid'] = clientOrderId;
|
|
3619
|
+
}
|
|
3620
|
+
const leverage = this.safeInteger2(params, 'leverage', 'lev');
|
|
3621
|
+
if (leverage !== undefined) {
|
|
3622
|
+
request['lev'] = leverage;
|
|
3623
|
+
}
|
|
3624
|
+
params = this.omit(params, ['triggerPrice', 'stopPrice', 'timeInForce', 'postOnly', 'reduceOnly', 'trailingAmount', 'clientOrderId', 'leverage']);
|
|
3625
|
+
const response = await this.privatePostAuthWOrderUpdate(this.extend(request, params));
|
|
3626
|
+
//
|
|
3627
|
+
// [
|
|
3628
|
+
// 1706845376402,
|
|
3629
|
+
// "ou-req",
|
|
3630
|
+
// null,
|
|
3631
|
+
// null,
|
|
3632
|
+
// [
|
|
3633
|
+
// 139658969116,
|
|
3634
|
+
// null,
|
|
3635
|
+
// 1706843908637,
|
|
3636
|
+
// "tBTCUST",
|
|
3637
|
+
// 1706843908637,
|
|
3638
|
+
// 1706843908638,
|
|
3639
|
+
// 0.0002,
|
|
3640
|
+
// 0.0002,
|
|
3641
|
+
// "EXCHANGE LIMIT",
|
|
3642
|
+
// null,
|
|
3643
|
+
// null,
|
|
3644
|
+
// null,
|
|
3645
|
+
// 0,
|
|
3646
|
+
// "ACTIVE",
|
|
3647
|
+
// null,
|
|
3648
|
+
// null,
|
|
3649
|
+
// 35000,
|
|
3650
|
+
// 0,
|
|
3651
|
+
// 0,
|
|
3652
|
+
// 0,
|
|
3653
|
+
// null,
|
|
3654
|
+
// null,
|
|
3655
|
+
// null,
|
|
3656
|
+
// 0,
|
|
3657
|
+
// 0,
|
|
3658
|
+
// null,
|
|
3659
|
+
// null,
|
|
3660
|
+
// null,
|
|
3661
|
+
// "API>BFX",
|
|
3662
|
+
// null,
|
|
3663
|
+
// null,
|
|
3664
|
+
// {}
|
|
3665
|
+
// ],
|
|
3666
|
+
// null,
|
|
3667
|
+
// "SUCCESS",
|
|
3668
|
+
// "Submitting update to exchange limit buy order for 0.0002 BTC."
|
|
3669
|
+
// ]
|
|
3670
|
+
//
|
|
3671
|
+
const status = this.safeString(response, 6);
|
|
3672
|
+
if (status !== 'SUCCESS') {
|
|
3673
|
+
const errorCode = response[5];
|
|
3674
|
+
const errorText = response[7];
|
|
3675
|
+
throw new ExchangeError(this.id + ' ' + response[6] + ': ' + errorText + ' (#' + errorCode + ')');
|
|
3676
|
+
}
|
|
3677
|
+
const order = this.safeList(response, 4, []);
|
|
3678
|
+
return this.parseOrder(order, market);
|
|
3679
|
+
}
|
|
3306
3680
|
}
|