ccxt 4.2.30__py2.py3-none-any.whl → 4.2.34__py2.py3-none-any.whl

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.

Potentially problematic release.


This version of ccxt might be problematic. Click here for more details.

Files changed (244) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/coinbase.py +10 -0
  3. ccxt/abstract/okx.py +12 -1
  4. ccxt/ace.py +4 -3
  5. ccxt/alpaca.py +1 -1
  6. ccxt/ascendex.py +6 -6
  7. ccxt/async_support/__init__.py +1 -1
  8. ccxt/async_support/ace.py +4 -3
  9. ccxt/async_support/alpaca.py +1 -1
  10. ccxt/async_support/ascendex.py +6 -6
  11. ccxt/async_support/base/exchange.py +62 -39
  12. ccxt/async_support/bigone.py +25 -5
  13. ccxt/async_support/binance.py +17 -16
  14. ccxt/async_support/bingx.py +10 -9
  15. ccxt/async_support/bit2c.py +13 -1
  16. ccxt/async_support/bitbank.py +2 -2
  17. ccxt/async_support/bitbns.py +1 -1
  18. ccxt/async_support/bitfinex.py +5 -5
  19. ccxt/async_support/bitfinex2.py +386 -40
  20. ccxt/async_support/bitflyer.py +5 -5
  21. ccxt/async_support/bitforex.py +4 -1
  22. ccxt/async_support/bitget.py +11 -11
  23. ccxt/async_support/bithumb.py +2 -2
  24. ccxt/async_support/bitmart.py +9 -9
  25. ccxt/async_support/bitmex.py +3 -3
  26. ccxt/async_support/bitopro.py +2 -2
  27. ccxt/async_support/bitrue.py +8 -8
  28. ccxt/async_support/bitso.py +4 -4
  29. ccxt/async_support/bitstamp.py +2 -2
  30. ccxt/async_support/bitteam.py +1 -1
  31. ccxt/async_support/bitvavo.py +3 -3
  32. ccxt/async_support/bl3p.py +1 -1
  33. ccxt/async_support/blockchaincom.py +3 -3
  34. ccxt/async_support/btcalpha.py +1 -1
  35. ccxt/async_support/btcbox.py +1 -1
  36. ccxt/async_support/btcmarkets.py +2 -2
  37. ccxt/async_support/btcturk.py +1 -1
  38. ccxt/async_support/bybit.py +9 -9
  39. ccxt/async_support/cex.py +1 -1
  40. ccxt/async_support/coinbase.py +16 -6
  41. ccxt/async_support/coinbasepro.py +2 -2
  42. ccxt/async_support/coincheck.py +1 -1
  43. ccxt/async_support/coinex.py +9 -9
  44. ccxt/async_support/coinlist.py +4 -4
  45. ccxt/async_support/coinmate.py +2 -2
  46. ccxt/async_support/coinmetro.py +2 -2
  47. ccxt/async_support/coinone.py +1 -1
  48. ccxt/async_support/coinsph.py +2 -2
  49. ccxt/async_support/coinspot.py +1 -1
  50. ccxt/async_support/cryptocom.py +14 -14
  51. ccxt/async_support/currencycom.py +1 -1
  52. ccxt/async_support/delta.py +2 -2
  53. ccxt/async_support/deribit.py +5 -4
  54. ccxt/async_support/digifinex.py +6 -6
  55. ccxt/async_support/exmo.py +2 -2
  56. ccxt/async_support/gate.py +41 -37
  57. ccxt/async_support/gemini.py +2 -2
  58. ccxt/async_support/hitbtc.py +5 -5
  59. ccxt/async_support/hollaex.py +2 -2
  60. ccxt/async_support/htx.py +11 -11
  61. ccxt/async_support/huobijp.py +4 -4
  62. ccxt/async_support/idex.py +2 -2
  63. ccxt/async_support/independentreserve.py +2 -2
  64. ccxt/async_support/indodax.py +2 -2
  65. ccxt/async_support/kraken.py +45 -5
  66. ccxt/async_support/krakenfutures.py +8 -5
  67. ccxt/async_support/kucoin.py +8 -8
  68. ccxt/async_support/kucoinfutures.py +4 -4
  69. ccxt/async_support/kuna.py +2 -2
  70. ccxt/async_support/latoken.py +3 -3
  71. ccxt/async_support/lbank.py +5 -4
  72. ccxt/async_support/luno.py +1 -1
  73. ccxt/async_support/lykke.py +2 -2
  74. ccxt/async_support/mercado.py +2 -2
  75. ccxt/async_support/mexc.py +7 -6
  76. ccxt/async_support/ndax.py +2 -2
  77. ccxt/async_support/novadax.py +4 -4
  78. ccxt/async_support/oceanex.py +1 -1
  79. ccxt/async_support/okcoin.py +5 -5
  80. ccxt/async_support/okx.py +26 -12
  81. ccxt/async_support/onetrading.py +2 -2
  82. ccxt/async_support/p2b.py +1 -1
  83. ccxt/async_support/paymium.py +3 -3
  84. ccxt/async_support/phemex.py +13 -13
  85. ccxt/async_support/poloniex.py +4 -4
  86. ccxt/async_support/poloniexfutures.py +4 -1
  87. ccxt/async_support/probit.py +5 -5
  88. ccxt/async_support/timex.py +2 -2
  89. ccxt/async_support/tokocrypto.py +4 -4
  90. ccxt/async_support/upbit.py +2 -2
  91. ccxt/async_support/wavesexchange.py +4 -3
  92. ccxt/async_support/wazirx.py +1 -1
  93. ccxt/async_support/whitebit.py +6 -6
  94. ccxt/async_support/woo.py +6 -6
  95. ccxt/async_support/yobit.py +41 -2
  96. ccxt/async_support/zaif.py +2 -2
  97. ccxt/async_support/zonda.py +4 -4
  98. ccxt/base/exchange.py +77 -44
  99. ccxt/base/types.py +10 -0
  100. ccxt/bigone.py +25 -5
  101. ccxt/binance.py +17 -16
  102. ccxt/bingx.py +10 -9
  103. ccxt/bit2c.py +13 -1
  104. ccxt/bitbank.py +2 -2
  105. ccxt/bitbns.py +1 -1
  106. ccxt/bitfinex.py +5 -5
  107. ccxt/bitfinex2.py +386 -40
  108. ccxt/bitflyer.py +5 -5
  109. ccxt/bitforex.py +4 -1
  110. ccxt/bitget.py +11 -11
  111. ccxt/bithumb.py +2 -2
  112. ccxt/bitmart.py +9 -9
  113. ccxt/bitmex.py +3 -3
  114. ccxt/bitopro.py +2 -2
  115. ccxt/bitrue.py +8 -8
  116. ccxt/bitso.py +4 -4
  117. ccxt/bitstamp.py +2 -2
  118. ccxt/bitteam.py +1 -1
  119. ccxt/bitvavo.py +3 -3
  120. ccxt/bl3p.py +1 -1
  121. ccxt/blockchaincom.py +3 -3
  122. ccxt/btcalpha.py +1 -1
  123. ccxt/btcbox.py +1 -1
  124. ccxt/btcmarkets.py +2 -2
  125. ccxt/btcturk.py +1 -1
  126. ccxt/bybit.py +9 -9
  127. ccxt/cex.py +1 -1
  128. ccxt/coinbase.py +16 -6
  129. ccxt/coinbasepro.py +2 -2
  130. ccxt/coincheck.py +1 -1
  131. ccxt/coinex.py +9 -9
  132. ccxt/coinlist.py +4 -4
  133. ccxt/coinmate.py +2 -2
  134. ccxt/coinmetro.py +2 -2
  135. ccxt/coinone.py +1 -1
  136. ccxt/coinsph.py +2 -2
  137. ccxt/coinspot.py +1 -1
  138. ccxt/cryptocom.py +14 -14
  139. ccxt/currencycom.py +1 -1
  140. ccxt/delta.py +2 -2
  141. ccxt/deribit.py +5 -4
  142. ccxt/digifinex.py +6 -6
  143. ccxt/exmo.py +2 -2
  144. ccxt/gate.py +41 -37
  145. ccxt/gemini.py +2 -2
  146. ccxt/hitbtc.py +5 -5
  147. ccxt/hollaex.py +2 -2
  148. ccxt/htx.py +11 -11
  149. ccxt/huobijp.py +4 -4
  150. ccxt/idex.py +2 -2
  151. ccxt/independentreserve.py +2 -2
  152. ccxt/indodax.py +2 -2
  153. ccxt/kraken.py +45 -5
  154. ccxt/krakenfutures.py +8 -5
  155. ccxt/kucoin.py +8 -8
  156. ccxt/kucoinfutures.py +4 -4
  157. ccxt/kuna.py +2 -2
  158. ccxt/latoken.py +3 -3
  159. ccxt/lbank.py +5 -4
  160. ccxt/luno.py +1 -1
  161. ccxt/lykke.py +2 -2
  162. ccxt/mercado.py +2 -2
  163. ccxt/mexc.py +7 -6
  164. ccxt/ndax.py +2 -2
  165. ccxt/novadax.py +4 -4
  166. ccxt/oceanex.py +1 -1
  167. ccxt/okcoin.py +5 -5
  168. ccxt/okx.py +26 -12
  169. ccxt/onetrading.py +2 -2
  170. ccxt/p2b.py +1 -1
  171. ccxt/paymium.py +3 -3
  172. ccxt/phemex.py +13 -13
  173. ccxt/poloniex.py +4 -4
  174. ccxt/poloniexfutures.py +4 -1
  175. ccxt/pro/__init__.py +1 -1
  176. ccxt/pro/alpaca.py +8 -4
  177. ccxt/pro/ascendex.py +1 -2
  178. ccxt/pro/binance.py +14 -10
  179. ccxt/pro/bingx.py +1 -1
  180. ccxt/pro/bitfinex.py +21 -22
  181. ccxt/pro/bitfinex2.py +13 -15
  182. ccxt/pro/bitget.py +3 -1
  183. ccxt/pro/bitmart.py +3 -7
  184. ccxt/pro/bitmex.py +4 -6
  185. ccxt/pro/bitopro.py +2 -4
  186. ccxt/pro/bitrue.py +1 -1
  187. ccxt/pro/bitstamp.py +2 -3
  188. ccxt/pro/bitvavo.py +10 -5
  189. ccxt/pro/blockchaincom.py +22 -22
  190. ccxt/pro/bybit.py +5 -5
  191. ccxt/pro/cex.py +7 -7
  192. ccxt/pro/coinbase.py +3 -2
  193. ccxt/pro/coinbasepro.py +1 -1
  194. ccxt/pro/coinex.py +15 -13
  195. ccxt/pro/currencycom.py +5 -6
  196. ccxt/pro/deribit.py +4 -4
  197. ccxt/pro/exmo.py +15 -13
  198. ccxt/pro/gate.py +1 -1
  199. ccxt/pro/gemini.py +4 -2
  200. ccxt/pro/hitbtc.py +10 -9
  201. ccxt/pro/hollaex.py +2 -2
  202. ccxt/pro/htx.py +6 -6
  203. ccxt/pro/huobijp.py +3 -4
  204. ccxt/pro/idex.py +1 -1
  205. ccxt/pro/independentreserve.py +14 -13
  206. ccxt/pro/kraken.py +10 -14
  207. ccxt/pro/krakenfutures.py +10 -6
  208. ccxt/pro/kucoin.py +10 -10
  209. ccxt/pro/kucoinfutures.py +11 -10
  210. ccxt/pro/lbank.py +10 -10
  211. ccxt/pro/luno.py +12 -14
  212. ccxt/pro/mexc.py +3 -2
  213. ccxt/pro/ndax.py +7 -11
  214. ccxt/pro/okcoin.py +7 -10
  215. ccxt/pro/okx.py +6 -9
  216. ccxt/pro/onetrading.py +16 -15
  217. ccxt/pro/p2b.py +5 -3
  218. ccxt/pro/phemex.py +16 -11
  219. ccxt/pro/poloniex.py +6 -4
  220. ccxt/pro/poloniexfutures.py +13 -9
  221. ccxt/pro/probit.py +15 -12
  222. ccxt/pro/upbit.py +8 -8
  223. ccxt/pro/wazirx.py +6 -3
  224. ccxt/pro/woo.py +9 -7
  225. ccxt/probit.py +5 -5
  226. ccxt/test/base/test_order_book.py +7 -7
  227. ccxt/test/base/test_shared_methods.py +1 -1
  228. ccxt/test/test_async.py +86 -36
  229. ccxt/test/test_sync.py +86 -36
  230. ccxt/timex.py +2 -2
  231. ccxt/tokocrypto.py +4 -4
  232. ccxt/upbit.py +2 -2
  233. ccxt/wavesexchange.py +4 -3
  234. ccxt/wazirx.py +1 -1
  235. ccxt/whitebit.py +6 -6
  236. ccxt/woo.py +6 -6
  237. ccxt/yobit.py +41 -2
  238. ccxt/zaif.py +2 -2
  239. ccxt/zonda.py +4 -4
  240. {ccxt-4.2.30.dist-info → ccxt-4.2.34.dist-info}/METADATA +10 -10
  241. ccxt-4.2.34.dist-info/RECORD +438 -0
  242. ccxt-4.2.30.dist-info/RECORD +0 -438
  243. {ccxt-4.2.30.dist-info → ccxt-4.2.34.dist-info}/WHEEL +0 -0
  244. {ccxt-4.2.30.dist-info → ccxt-4.2.34.dist-info}/top_level.txt +0 -0
ccxt/bitfinex2.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.bitfinex2 import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currency, Int, Market, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
9
+ from ccxt.base.types import Balances, Currency, Int, Market, Order, TransferEntry, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import PermissionDenied
@@ -45,11 +45,13 @@ class bitfinex2(Exchange, ImplicitAPI):
45
45
  'CORS': None,
46
46
  'spot': True,
47
47
  'margin': None, # has but unimplemented
48
- 'swap': None, # has but unimplemented
48
+ 'swap': True,
49
49
  'future': None,
50
50
  'option': None,
51
+ 'addMargin': False,
51
52
  'cancelAllOrders': True,
52
53
  'cancelOrder': True,
54
+ 'cancelOrders': True,
53
55
  'createDepositAddress': True,
54
56
  'createLimitOrder': True,
55
57
  'createMarketOrder': True,
@@ -61,20 +63,24 @@ class bitfinex2(Exchange, ImplicitAPI):
61
63
  'createTrailingAmountOrder': True,
62
64
  'createTrailingPercentOrder': False,
63
65
  'createTriggerOrder': True,
64
- 'editOrder': False,
66
+ 'editOrder': True,
65
67
  'fetchBalance': True,
66
68
  'fetchClosedOrder': True,
67
69
  'fetchClosedOrders': True,
68
70
  'fetchCurrencies': True,
69
71
  'fetchDepositAddress': True,
70
72
  'fetchDepositsWithdrawals': True,
73
+ 'fetchFundingHistory': False,
71
74
  'fetchFundingRate': True,
72
75
  'fetchFundingRateHistory': True,
73
76
  'fetchFundingRates': True,
74
77
  'fetchIndexOHLCV': False,
75
78
  'fetchLedger': True,
79
+ 'fetchLeverage': False,
80
+ 'fetchLeverageTiers': False,
76
81
  'fetchLiquidations': True,
77
82
  'fetchMarginMode': False,
83
+ 'fetchMarketLeverageTiers': False,
78
84
  'fetchMarkOHLCV': False,
79
85
  'fetchMyTrades': True,
80
86
  'fetchOHLCV': True,
@@ -84,7 +90,10 @@ class bitfinex2(Exchange, ImplicitAPI):
84
90
  'fetchOpenOrders': True,
85
91
  'fetchOrder': True,
86
92
  'fetchOrderTrades': True,
93
+ 'fetchPosition': False,
87
94
  'fetchPositionMode': False,
95
+ 'fetchPositions': True,
96
+ 'fetchPremiumIndexOHLCV': False,
88
97
  'fetchStatus': True,
89
98
  'fetchTickers': True,
90
99
  'fetchTime': False,
@@ -92,7 +101,11 @@ class bitfinex2(Exchange, ImplicitAPI):
92
101
  'fetchTradingFees': True,
93
102
  'fetchTransactionFees': None,
94
103
  'fetchTransactions': 'emulated',
104
+ 'reduceMargin': False,
105
+ 'setLeverage': False,
95
106
  'setMargin': True,
107
+ 'setMarginMode': False,
108
+ 'setPositionMode': False,
96
109
  'withdraw': True,
97
110
  },
98
111
  'timeframes': {
@@ -360,6 +373,7 @@ class bitfinex2(Exchange, ImplicitAPI):
360
373
  'margin': 'margin',
361
374
  'derivatives': 'margin',
362
375
  'future': 'margin',
376
+ 'swap': 'margin',
363
377
  },
364
378
  'withdraw': {
365
379
  'includeFee': False,
@@ -839,7 +853,7 @@ class bitfinex2(Exchange, ImplicitAPI):
839
853
  result[code] = account
840
854
  return self.safe_balance(result)
841
855
 
842
- def transfer(self, code: str, amount, fromAccount, toAccount, params={}):
856
+ def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
843
857
  """
844
858
  transfer currency internally between wallets on the same account
845
859
  :see: https://docs.bitfinex.com/reference/rest-auth-transfer
@@ -981,7 +995,7 @@ class bitfinex2(Exchange, ImplicitAPI):
981
995
  fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
982
996
  :see: https://docs.bitfinex.com/reference/rest-public-book
983
997
  :param str symbol: unified symbol of the market to fetch the order book for
984
- :param int [limit]: the maximum amount of order book entries to return
998
+ :param int [limit]: the maximum amount of order book entries to return, bitfinex only allows 1, 25, or 100
985
999
  :param dict [params]: extra parameters specific to the exchange API endpoint
986
1000
  :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
987
1001
  """
@@ -993,7 +1007,7 @@ class bitfinex2(Exchange, ImplicitAPI):
993
1007
  'precision': precision,
994
1008
  }
995
1009
  if limit is not None:
996
- request['len'] = limit # 25 or 100
1010
+ request['len'] = limit
997
1011
  fullRequest = self.extend(request, params)
998
1012
  orderbook = self.publicGetBookSymbolPrecision(fullRequest)
999
1013
  timestamp = self.milliseconds()
@@ -1251,9 +1265,9 @@ class bitfinex2(Exchange, ImplicitAPI):
1251
1265
  :see: https://docs.bitfinex.com/reference/rest-public-trades
1252
1266
  :param str symbol: unified symbol of the market to fetch trades for
1253
1267
  :param int [since]: timestamp in ms of the earliest trade to fetch
1254
- :param int [limit]: the maximum amount of trades to fetch
1268
+ :param int [limit]: the maximum amount of trades to fetch, default 120, max 10000
1255
1269
  :param dict [params]: extra parameters specific to the exchange API endpoint
1256
- :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1270
+ :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1257
1271
  :param int [params.until]: the latest time in ms to fetch entries for
1258
1272
  :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
1259
1273
  """
@@ -1288,18 +1302,18 @@ class bitfinex2(Exchange, ImplicitAPI):
1288
1302
  trades = self.sort_by(response, 1)
1289
1303
  return self.parse_trades(trades, market, None, limit)
1290
1304
 
1291
- def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit=100, params={}) -> List[list]:
1305
+ def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = 100, params={}) -> List[list]:
1292
1306
  """
1293
1307
  fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1294
1308
  :see: https://docs.bitfinex.com/reference/rest-public-candles
1295
1309
  :param str symbol: unified symbol of the market to fetch OHLCV data for
1296
1310
  :param str timeframe: the length of time each candle represents
1297
1311
  :param int [since]: timestamp in ms of the earliest candle to fetch
1298
- :param int [limit]: the maximum amount of candles to fetch
1312
+ :param int [limit]: the maximum amount of candles to fetch, default 100 max 10000
1299
1313
  :param dict [params]: extra parameters specific to the exchange API endpoint
1300
1314
  :returns int[][]: A list of candles ordered, open, high, low, close, volume
1301
1315
  :param int [params.until]: timestamp in ms of the latest candle to fetch
1302
- :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1316
+ :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1303
1317
  """
1304
1318
  self.load_markets()
1305
1319
  paginate = False
@@ -1308,7 +1322,7 @@ class bitfinex2(Exchange, ImplicitAPI):
1308
1322
  return self.fetch_paginated_call_deterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 10000)
1309
1323
  market = self.market(symbol)
1310
1324
  if limit is None:
1311
- limit = 10000 # default 100, max 5000
1325
+ limit = 10000
1312
1326
  request = {
1313
1327
  'symbol': market['id'],
1314
1328
  'timeframe': self.safe_string(self.timeframes, timeframe, timeframe),
@@ -1448,28 +1462,18 @@ class bitfinex2(Exchange, ImplicitAPI):
1448
1462
  'trades': None,
1449
1463
  }, market)
1450
1464
 
1451
- def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount, price=None, params={}):
1465
+ def create_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: float = None, params={}):
1452
1466
  """
1453
- create an order on the exchange
1454
- :see: https://docs.bitfinex.com/reference/rest-auth-submit-order
1455
- :param str symbol: unified CCXT market symbol
1456
- :param str type: 'limit' or 'market'
1467
+ * @ignore
1468
+ helper function to build an order request
1469
+ :param str symbol: unified symbol of the market to create an order in
1470
+ :param str type: 'market' or 'limit'
1457
1471
  :param str side: 'buy' or 'sell'
1458
- :param float amount: the amount of currency to trade
1459
- :param float [price]: price of the order
1472
+ :param float amount: how much you want to trade in units of the base currency
1473
+ :param float [price]: the price of the order, in units of the quote currency, ignored in market orders
1460
1474
  :param dict [params]: extra parameters specific to the exchange API endpoint
1461
- :param float [params.stopPrice]: the price that triggers a trigger order
1462
- :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1463
- :param boolean [params.postOnly]: set to True if you want to make a post only order
1464
- :param boolean [params.reduceOnly]: indicates that the order is to reduce the size of a position
1465
- :param int [params.flags]: additional order parameters: 4096(Post Only), 1024(Reduce Only), 16384(OCO), 64(Hidden), 512(Close), 524288(No Var Rates)
1466
- :param int [params.lev]: leverage for a derivative order, supported by derivative symbol orders only. The value should be between 1 and 100 inclusive.
1467
- :param str [params.price_aux_limit]: order price for stop limit orders
1468
- :param str [params.price_oco_stop]: OCO stop price
1469
- :param str [params.trailingAmount]: *swap only* the quote amount to trail away from the current market price
1470
- :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1475
+ :returns dict: request to be sent to the exchange
1471
1476
  """
1472
- self.load_markets()
1473
1477
  market = self.market(symbol)
1474
1478
  amountString = self.amount_to_precision(symbol, amount)
1475
1479
  amountString = amountString if (side == 'buy') else Precise.string_neg(amountString)
@@ -1483,7 +1487,6 @@ class bitfinex2(Exchange, ImplicitAPI):
1483
1487
  postOnlyParam = self.safe_bool(params, 'postOnly', False)
1484
1488
  reduceOnly = self.safe_bool(params, 'reduceOnly', False)
1485
1489
  clientOrderId = self.safe_value_2(params, 'cid', 'clientOrderId')
1486
- params = self.omit(params, ['triggerPrice', 'stopPrice', 'timeInForce', 'postOnly', 'reduceOnly', 'trailingAmount', 'clientOrderId'])
1487
1490
  orderType = type.upper()
1488
1491
  if trailingAmount is not None:
1489
1492
  orderType = 'TRAILING STOP'
@@ -1525,7 +1528,34 @@ class bitfinex2(Exchange, ImplicitAPI):
1525
1528
  request['flags'] = flags
1526
1529
  if clientOrderId is not None:
1527
1530
  request['cid'] = clientOrderId
1528
- response = self.privatePostAuthWOrderSubmit(self.extend(request, params))
1531
+ params = self.omit(params, ['triggerPrice', 'stopPrice', 'timeInForce', 'postOnly', 'reduceOnly', 'trailingAmount', 'clientOrderId'])
1532
+ return self.extend(request, params)
1533
+
1534
+ def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: float = None, params={}):
1535
+ """
1536
+ create an order on the exchange
1537
+ :see: https://docs.bitfinex.com/reference/rest-auth-submit-order
1538
+ :param str symbol: unified CCXT market symbol
1539
+ :param str type: 'limit' or 'market'
1540
+ :param str side: 'buy' or 'sell'
1541
+ :param float amount: the amount of currency to trade
1542
+ :param float [price]: price of the order
1543
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1544
+ :param float [params.stopPrice]: the price that triggers a trigger order
1545
+ :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1546
+ :param boolean [params.postOnly]: set to True if you want to make a post only order
1547
+ :param boolean [params.reduceOnly]: indicates that the order is to reduce the size of a position
1548
+ :param int [params.flags]: additional order parameters: 4096(Post Only), 1024(Reduce Only), 16384(OCO), 64(Hidden), 512(Close), 524288(No Var Rates)
1549
+ :param int [params.lev]: leverage for a derivative order, supported by derivative symbol orders only. The value should be between 1 and 100 inclusive.
1550
+ :param str [params.price_aux_limit]: order price for stop limit orders
1551
+ :param str [params.price_oco_stop]: OCO stop price
1552
+ :param str [params.trailingAmount]: *swap only* the quote amount to trail away from the current market price
1553
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1554
+ """
1555
+ self.load_markets()
1556
+ market = self.market(symbol)
1557
+ request = self.create_order_request(symbol, type, side, amount, price, params)
1558
+ response = self.privatePostAuthWOrderSubmit(request)
1529
1559
  #
1530
1560
  # [
1531
1561
  # 1653325121, # Timestamp in milliseconds
@@ -1582,6 +1612,63 @@ class bitfinex2(Exchange, ImplicitAPI):
1582
1612
  order = self.safe_list(orders, 0)
1583
1613
  return self.parse_order(order, market)
1584
1614
 
1615
+ def create_orders(self, orders: List[OrderRequest], params={}):
1616
+ """
1617
+ create a list of trade orders
1618
+ :see: https://docs.bitfinex.com/reference/rest-auth-order-multi
1619
+ :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
1620
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1621
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1622
+ """
1623
+ self.load_markets()
1624
+ ordersRequests = []
1625
+ for i in range(0, len(orders)):
1626
+ rawOrder = orders[i]
1627
+ symbol = self.safe_string(rawOrder, 'symbol')
1628
+ type = self.safe_string(rawOrder, 'type')
1629
+ side = self.safe_string(rawOrder, 'side')
1630
+ amount = self.safe_number(rawOrder, 'amount')
1631
+ price = self.safe_number(rawOrder, 'price')
1632
+ orderParams = self.safe_dict(rawOrder, 'params', {})
1633
+ orderRequest = self.create_order_request(symbol, type, side, amount, price, orderParams)
1634
+ ordersRequests.append(['on', orderRequest])
1635
+ request = {
1636
+ 'ops': ordersRequests,
1637
+ }
1638
+ response = self.privatePostAuthWOrderMulti(request)
1639
+ #
1640
+ # [
1641
+ # 1706762515553,
1642
+ # "ox_multi-req",
1643
+ # null,
1644
+ # null,
1645
+ # [
1646
+ # [
1647
+ # 1706762515,
1648
+ # "on-req",
1649
+ # null,
1650
+ # null,
1651
+ # [
1652
+ # [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,{}]
1653
+ # ],
1654
+ # null,
1655
+ # "SUCCESS",
1656
+ # "Submitting 1 orders."
1657
+ # ],
1658
+ # ],
1659
+ # null,
1660
+ # "SUCCESS",
1661
+ # "Submitting 2 order operations."
1662
+ # ]
1663
+ #
1664
+ results = []
1665
+ data = self.safe_list(response, 4, [])
1666
+ for i in range(0, len(data)):
1667
+ entry = data[i]
1668
+ individualOrder = entry[4]
1669
+ results.append(individualOrder[0])
1670
+ return self.parse_orders(results)
1671
+
1585
1672
  def cancel_all_orders(self, symbol: Str = None, params={}):
1586
1673
  """
1587
1674
  cancel all open orders
@@ -1590,6 +1677,7 @@ class bitfinex2(Exchange, ImplicitAPI):
1590
1677
  :param dict [params]: extra parameters specific to the exchange API endpoint
1591
1678
  :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1592
1679
  """
1680
+ self.load_markets()
1593
1681
  request = {
1594
1682
  'all': 1,
1595
1683
  }
@@ -1606,6 +1694,7 @@ class bitfinex2(Exchange, ImplicitAPI):
1606
1694
  :param dict [params]: extra parameters specific to the exchange API endpoint
1607
1695
  :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1608
1696
  """
1697
+ self.load_markets()
1609
1698
  cid = self.safe_value_2(params, 'cid', 'clientOrderId') # client order id
1610
1699
  request = None
1611
1700
  if cid is not None:
@@ -1625,6 +1714,78 @@ class bitfinex2(Exchange, ImplicitAPI):
1625
1714
  order = self.safe_value(response, 4)
1626
1715
  return self.parse_order(order)
1627
1716
 
1717
+ def cancel_orders(self, ids, symbol: Str = None, params={}):
1718
+ """
1719
+ cancel multiple orders at the same time
1720
+ :see: https://docs.bitfinex.com/reference/rest-auth-cancel-orders-multiple
1721
+ :param str[] ids: order ids
1722
+ :param str symbol: unified market symbol, default is None
1723
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1724
+ :returns dict: an array of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1725
+ """
1726
+ self.load_markets()
1727
+ for i in range(0, len(ids)):
1728
+ ids[i] = self.parse_to_numeric(ids[i])
1729
+ request = {
1730
+ 'id': ids,
1731
+ }
1732
+ market = None
1733
+ if symbol is not None:
1734
+ market = self.market(symbol)
1735
+ response = self.privatePostAuthWOrderCancelMulti(self.extend(request, params))
1736
+ #
1737
+ # [
1738
+ # 1706740198811,
1739
+ # "oc_multi-req",
1740
+ # null,
1741
+ # null,
1742
+ # [
1743
+ # [
1744
+ # 139530205057,
1745
+ # null,
1746
+ # 1706740132275,
1747
+ # "tBTCF0:USTF0",
1748
+ # 1706740132276,
1749
+ # 1706740132276,
1750
+ # 0.0001,
1751
+ # 0.0001,
1752
+ # "LIMIT",
1753
+ # null,
1754
+ # null,
1755
+ # null,
1756
+ # 0,
1757
+ # "ACTIVE",
1758
+ # null,
1759
+ # null,
1760
+ # 39000,
1761
+ # 0,
1762
+ # 0,
1763
+ # 0,
1764
+ # null,
1765
+ # null,
1766
+ # null,
1767
+ # 0,
1768
+ # 0,
1769
+ # null,
1770
+ # null,
1771
+ # null,
1772
+ # "API>BFX",
1773
+ # null,
1774
+ # null,
1775
+ # {
1776
+ # "lev": 10,
1777
+ # "$F33": 10
1778
+ # }
1779
+ # ],
1780
+ # ],
1781
+ # null,
1782
+ # "SUCCESS",
1783
+ # "Submitting 2 order cancellations."
1784
+ # ]
1785
+ #
1786
+ orders = self.safe_list(response, 4, [])
1787
+ return self.parse_orders(orders, market)
1788
+
1628
1789
  def fetch_open_order(self, id: str, symbol: Str = None, params={}):
1629
1790
  """
1630
1791
  fetch an open order by it's id
@@ -2231,7 +2392,7 @@ class bitfinex2(Exchange, ImplicitAPI):
2231
2392
  #
2232
2393
  return self.parse_transactions(response, currency, since, limit)
2233
2394
 
2234
- def withdraw(self, code: str, amount, address, tag=None, params={}):
2395
+ def withdraw(self, code: str, amount: float, address, tag=None, params={}):
2235
2396
  """
2236
2397
  make a withdrawal
2237
2398
  :see: https://docs.bitfinex.com/reference/rest-auth-withdraw
@@ -2552,14 +2713,13 @@ class bitfinex2(Exchange, ImplicitAPI):
2552
2713
  :see: https://docs.bitfinex.com/reference/rest-auth-ledgers
2553
2714
  :param str code: unified currency code, default is None
2554
2715
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
2555
- :param int [limit]: max number of ledger entrys to return, default is None
2716
+ :param int [limit]: max number of ledger entrys to return, default is None max is 2500
2556
2717
  :param dict [params]: extra parameters specific to the exchange API endpoint
2557
2718
  :param int [params.until]: timestamp in ms of the latest ledger entry
2558
- :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2719
+ :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2559
2720
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
2560
2721
  """
2561
2722
  self.load_markets()
2562
- self.load_markets()
2563
2723
  paginate = False
2564
2724
  paginate, params = self.handle_option_and_params(params, 'fetchLedger', 'paginate')
2565
2725
  if paginate:
@@ -2569,7 +2729,7 @@ class bitfinex2(Exchange, ImplicitAPI):
2569
2729
  if since is not None:
2570
2730
  request['start'] = since
2571
2731
  if limit is not None:
2572
- request['limit'] = limit # max 2500
2732
+ request['limit'] = limit
2573
2733
  request, params = self.handle_until_option('end', request, params)
2574
2734
  response = None
2575
2735
  if code is not None:
@@ -2658,9 +2818,11 @@ class bitfinex2(Exchange, ImplicitAPI):
2658
2818
  fetches historical funding rate prices
2659
2819
  :see: https://docs.bitfinex.com/reference/rest-public-derivatives-status-history
2660
2820
  :param str symbol: unified market symbol
2821
+ :param int [since]: timestamp in ms of the earliest funding rate entry
2822
+ :param int [limit]: max number of funding rate entrys to return
2661
2823
  :param dict [params]: extra parameters specific to the exchange API endpoint
2662
2824
  :param int [params.until]: timestamp in ms of the latest funding rate
2663
- :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2825
+ :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2664
2826
  :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
2665
2827
  """
2666
2828
  if symbol is None:
@@ -2713,7 +2875,14 @@ class bitfinex2(Exchange, ImplicitAPI):
2713
2875
  fr = response[i]
2714
2876
  rate = self.parse_funding_rate_history(fr, market)
2715
2877
  rates.append(rate)
2716
- return self.filter_by_symbol_since_limit(rates, symbol, since, limit)
2878
+ reversedArray = []
2879
+ rawRates = self.filter_by_symbol_since_limit(rates, symbol, since, limit)
2880
+ rawRatesLength = len(rawRates)
2881
+ ratesLength = max(rawRatesLength - 1, 0)
2882
+ for i in range(ratesLength, 0):
2883
+ valueAtIndex = rawRates[i]
2884
+ reversedArray.append(valueAtIndex)
2885
+ return reversedArray
2717
2886
 
2718
2887
  def parse_funding_rate(self, contract, market: Market = None):
2719
2888
  #
@@ -2861,7 +3030,8 @@ class bitfinex2(Exchange, ImplicitAPI):
2861
3030
  # ]
2862
3031
  # ]
2863
3032
  #
2864
- return self.parse_open_interest(response[0], market)
3033
+ oi = self.safe_list(response, 0)
3034
+ return self.parse_open_interest(oi, market)
2865
3035
 
2866
3036
  def fetch_open_interest_history(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}):
2867
3037
  """
@@ -3118,3 +3288,179 @@ class bitfinex2(Exchange, ImplicitAPI):
3118
3288
  'symbol': market['symbol'],
3119
3289
  'status': marginStatus,
3120
3290
  }
3291
+
3292
+ def fetch_order(self, id: str, symbol: str = None, params={}):
3293
+ """
3294
+ fetches information on an order made by the user
3295
+ :see: https://docs.bitfinex.com/reference/rest-auth-retrieve-orders
3296
+ :see: https://docs.bitfinex.com/reference/rest-auth-retrieve-orders-by-symbol
3297
+ :param str id: the order id
3298
+ :param str [symbol]: unified symbol of the market the order was made in
3299
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3300
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
3301
+ """
3302
+ self.load_markets()
3303
+ request = {
3304
+ 'id': [self.parse_to_numeric(id)],
3305
+ }
3306
+ market = None
3307
+ response = None
3308
+ if symbol is None:
3309
+ response = self.privatePostAuthROrders(self.extend(request, params))
3310
+ else:
3311
+ market = self.market(symbol)
3312
+ request['symbol'] = market['id']
3313
+ response = self.privatePostAuthROrdersSymbol(self.extend(request, params))
3314
+ #
3315
+ # [
3316
+ # [
3317
+ # 139658969116,
3318
+ # null,
3319
+ # 1706843908637,
3320
+ # "tBTCUST",
3321
+ # 1706843908637,
3322
+ # 1706843908638,
3323
+ # 0.0001,
3324
+ # 0.0001,
3325
+ # "EXCHANGE LIMIT",
3326
+ # null,
3327
+ # null,
3328
+ # null,
3329
+ # 0,
3330
+ # "ACTIVE",
3331
+ # null,
3332
+ # null,
3333
+ # 35000,
3334
+ # 0,
3335
+ # 0,
3336
+ # 0,
3337
+ # null,
3338
+ # null,
3339
+ # null,
3340
+ # 0,
3341
+ # 0,
3342
+ # null,
3343
+ # null,
3344
+ # null,
3345
+ # "API>BFX",
3346
+ # null,
3347
+ # null,
3348
+ # {}
3349
+ # ]
3350
+ # ]
3351
+ #
3352
+ order = self.safe_list(response, 0)
3353
+ return self.parse_order(order, market)
3354
+
3355
+ def edit_order(self, id: str, symbol, type, side, amount=None, price=None, params={}):
3356
+ """
3357
+ edit a trade order
3358
+ :see: https://docs.bitfinex.com/reference/rest-auth-update-order
3359
+ :param str id: edit order id
3360
+ :param str symbol: unified symbol of the market to edit an order in
3361
+ :param str type: 'market' or 'limit'
3362
+ :param str side: 'buy' or 'sell'
3363
+ :param float amount: how much you want to trade in units of the base currency
3364
+ :param float [price]: the price that the order is to be fullfilled, in units of the quote currency, ignored in market orders
3365
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3366
+ :param float [params.stopPrice]: the price that triggers a trigger order
3367
+ :param boolean [params.postOnly]: set to True if you want to make a post only order
3368
+ :param boolean [params.reduceOnly]: indicates that the order is to reduce the size of a position
3369
+ :param int [params.flags]: additional order parameters: 4096(Post Only), 1024(Reduce Only), 16384(OCO), 64(Hidden), 512(Close), 524288(No Var Rates)
3370
+ :param int [params.leverage]: leverage for a derivative order, supported by derivative symbol orders only, the value should be between 1 and 100 inclusive
3371
+ :param int [params.clientOrderId]: a unique client order id for the order
3372
+ :param float [params.trailingAmount]: *swap only* the quote amount to trail away from the current market price
3373
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
3374
+ """
3375
+ self.load_markets()
3376
+ market = self.market(symbol)
3377
+ request = {
3378
+ 'id': self.parse_to_numeric(id),
3379
+ }
3380
+ if amount is not None:
3381
+ amountString = self.amount_to_precision(symbol, amount)
3382
+ amountString = amountString if (side == 'buy') else Precise.string_neg(amountString)
3383
+ request['amount'] = amountString
3384
+ stopPrice = self.safe_string_2(params, 'stopPrice', 'triggerPrice')
3385
+ trailingAmount = self.safe_string(params, 'trailingAmount')
3386
+ timeInForce = self.safe_string(params, 'timeInForce')
3387
+ postOnlyParam = self.safe_bool(params, 'postOnly', False)
3388
+ reduceOnly = self.safe_bool(params, 'reduceOnly', False)
3389
+ clientOrderId = self.safe_integer_2(params, 'cid', 'clientOrderId')
3390
+ if trailingAmount is not None:
3391
+ request['price_trailing'] = trailingAmount
3392
+ elif stopPrice is not None:
3393
+ # request['price'] is taken for stop orders
3394
+ request['price'] = self.price_to_precision(symbol, stopPrice)
3395
+ if type == 'limit':
3396
+ request['price_aux_limit'] = self.price_to_precision(symbol, price)
3397
+ postOnly = (postOnlyParam or (timeInForce == 'PO'))
3398
+ if (type != 'market') and (stopPrice is None):
3399
+ request['price'] = self.price_to_precision(symbol, price)
3400
+ # flag values may be summed to combine flags
3401
+ flags = 0
3402
+ if postOnly:
3403
+ flags = self.sum(flags, 4096)
3404
+ if reduceOnly:
3405
+ flags = self.sum(flags, 1024)
3406
+ if flags != 0:
3407
+ request['flags'] = flags
3408
+ if clientOrderId is not None:
3409
+ request['cid'] = clientOrderId
3410
+ leverage = self.safe_integer_2(params, 'leverage', 'lev')
3411
+ if leverage is not None:
3412
+ request['lev'] = leverage
3413
+ params = self.omit(params, ['triggerPrice', 'stopPrice', 'timeInForce', 'postOnly', 'reduceOnly', 'trailingAmount', 'clientOrderId', 'leverage'])
3414
+ response = self.privatePostAuthWOrderUpdate(self.extend(request, params))
3415
+ #
3416
+ # [
3417
+ # 1706845376402,
3418
+ # "ou-req",
3419
+ # null,
3420
+ # null,
3421
+ # [
3422
+ # 139658969116,
3423
+ # null,
3424
+ # 1706843908637,
3425
+ # "tBTCUST",
3426
+ # 1706843908637,
3427
+ # 1706843908638,
3428
+ # 0.0002,
3429
+ # 0.0002,
3430
+ # "EXCHANGE LIMIT",
3431
+ # null,
3432
+ # null,
3433
+ # null,
3434
+ # 0,
3435
+ # "ACTIVE",
3436
+ # null,
3437
+ # null,
3438
+ # 35000,
3439
+ # 0,
3440
+ # 0,
3441
+ # 0,
3442
+ # null,
3443
+ # null,
3444
+ # null,
3445
+ # 0,
3446
+ # 0,
3447
+ # null,
3448
+ # null,
3449
+ # null,
3450
+ # "API>BFX",
3451
+ # null,
3452
+ # null,
3453
+ # {}
3454
+ # ],
3455
+ # null,
3456
+ # "SUCCESS",
3457
+ # "Submitting update to exchange limit buy order for 0.0002 BTC."
3458
+ # ]
3459
+ #
3460
+ status = self.safe_string(response, 6)
3461
+ if status != 'SUCCESS':
3462
+ errorCode = response[5]
3463
+ errorText = response[7]
3464
+ raise ExchangeError(self.id + ' ' + response[6] + ': ' + errorText + '(#' + errorCode + ')')
3465
+ order = self.safe_list(response, 4, [])
3466
+ return self.parse_order(order, market)