ccxt 4.4.68__py2.py3-none-any.whl → 4.4.70__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.
Files changed (43) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/bybit.py +4 -0
  3. ccxt/abstract/myokx.py +3 -0
  4. ccxt/abstract/okx.py +3 -0
  5. ccxt/abstract/paradex.py +23 -0
  6. ccxt/abstract/tradeogre.py +2 -1
  7. ccxt/async_support/__init__.py +1 -1
  8. ccxt/async_support/base/exchange.py +5 -1
  9. ccxt/async_support/binance.py +17 -3
  10. ccxt/async_support/bitget.py +47 -262
  11. ccxt/async_support/bitstamp.py +2 -3
  12. ccxt/async_support/bybit.py +7 -0
  13. ccxt/async_support/coinbase.py +24 -9
  14. ccxt/async_support/cryptomus.py +122 -6
  15. ccxt/async_support/hyperliquid.py +17 -8
  16. ccxt/async_support/okx.py +4 -0
  17. ccxt/async_support/paradex.py +173 -5
  18. ccxt/async_support/phemex.py +2 -2
  19. ccxt/async_support/tradeogre.py +31 -11
  20. ccxt/async_support/whitebit.py +210 -2
  21. ccxt/base/exchange.py +1 -2
  22. ccxt/binance.py +17 -3
  23. ccxt/bitget.py +47 -262
  24. ccxt/bitstamp.py +2 -3
  25. ccxt/bybit.py +7 -0
  26. ccxt/coinbase.py +24 -9
  27. ccxt/cryptomus.py +122 -6
  28. ccxt/hyperliquid.py +17 -8
  29. ccxt/okx.py +4 -0
  30. ccxt/paradex.py +173 -5
  31. ccxt/phemex.py +2 -2
  32. ccxt/pro/__init__.py +1 -1
  33. ccxt/pro/bitget.py +28 -3
  34. ccxt/pro/bybit.py +81 -37
  35. ccxt/test/tests_async.py +25 -3
  36. ccxt/test/tests_sync.py +25 -3
  37. ccxt/tradeogre.py +31 -11
  38. ccxt/whitebit.py +210 -2
  39. {ccxt-4.4.68.dist-info → ccxt-4.4.70.dist-info}/METADATA +4 -4
  40. {ccxt-4.4.68.dist-info → ccxt-4.4.70.dist-info}/RECORD +43 -43
  41. {ccxt-4.4.68.dist-info → ccxt-4.4.70.dist-info}/LICENSE.txt +0 -0
  42. {ccxt-4.4.68.dist-info → ccxt-4.4.70.dist-info}/WHEEL +0 -0
  43. {ccxt-4.4.68.dist-info → ccxt-4.4.70.dist-info}/top_level.txt +0 -0
@@ -3581,14 +3581,14 @@ class phemex(Exchange, ImplicitAPI):
3581
3581
 
3582
3582
  :param str[] [symbols]: list of unified market symbols
3583
3583
  :param dict [params]: extra parameters specific to the exchange API endpoint
3584
- :param str [params.code]: the currency code to fetch positions for, USD, BTC or USDT, USD is the default
3584
+ :param str [params.code]: the currency code to fetch positions for, USD, BTC or USDT, USDT is the default
3585
3585
  :param str [params.method]: *USDT contracts only* 'privateGetGAccountsAccountPositions' or 'privateGetAccountsPositions' default is 'privateGetGAccountsAccountPositions'
3586
3586
  :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
3587
3587
  """
3588
3588
  await self.load_markets()
3589
3589
  symbols = self.market_symbols(symbols)
3590
3590
  subType = None
3591
- code = self.safe_string_2(params, 'currency', 'code', 'USD')
3591
+ code = self.safe_string_2(params, 'currency', 'code', 'USDT')
3592
3592
  params = self.omit(params, ['currency', 'code'])
3593
3593
  settle = None
3594
3594
  market = None
@@ -134,12 +134,12 @@ class tradeogre(Exchange, ImplicitAPI):
134
134
  'orders/{market}': 1,
135
135
  'ticker/{market}': 1,
136
136
  'history/{market}': 1,
137
+ 'chart/{interval}/{market}/{timestamp}': 1,
137
138
  'chart/{interval}/{market}': 1,
138
139
  },
139
140
  },
140
141
  'private': {
141
142
  'get': {
142
- 'account/balance': 1,
143
143
  'account/balances': 1,
144
144
  'account/order/{uuid}': 1,
145
145
  },
@@ -149,6 +149,7 @@ class tradeogre(Exchange, ImplicitAPI):
149
149
  'order/cancel': 1,
150
150
  'orders': 1,
151
151
  'account/orders': 1,
152
+ 'account/balance': 1,
152
153
  },
153
154
  },
154
155
  },
@@ -422,15 +423,15 @@ class tradeogre(Exchange, ImplicitAPI):
422
423
  'ask': self.safe_string(ticker, 'ask'),
423
424
  'askVolume': None,
424
425
  'vwap': None,
425
- 'open': self.safe_string(ticker, 'open'),
426
- 'close': None,
426
+ 'open': self.safe_string(ticker, 'initialprice'),
427
+ 'close': self.safe_string(ticker, 'price'),
427
428
  'last': None,
428
429
  'previousClose': None,
429
430
  'change': None,
430
431
  'percentage': None,
431
432
  'average': None,
432
- 'baseVolume': self.safe_string(ticker, 'volume'),
433
- 'quoteVolume': None,
433
+ 'baseVolume': None,
434
+ 'quoteVolume': self.safe_string(ticker, 'volume'),
434
435
  'info': ticker,
435
436
  }, market)
436
437
 
@@ -451,11 +452,14 @@ class tradeogre(Exchange, ImplicitAPI):
451
452
  'market': market['id'],
452
453
  'interval': self.safe_string(self.timeframes, timeframe, timeframe),
453
454
  }
455
+ response = None
454
456
  until = self.safe_integer(params, 'until')
455
457
  if until is not None:
456
458
  params = self.omit(params, 'until')
457
- request['timestamp'] = until
458
- response = await self.publicGetChartIntervalMarket(self.extend(request, params))
459
+ request['timestamp'] = self.parse_to_int(until / 1000)
460
+ response = await self.publicGetChartIntervalMarketTimestamp(self.extend(request, params))
461
+ else:
462
+ response = await self.publicGetChartIntervalMarket(self.extend(request, params))
459
463
  #
460
464
  # [
461
465
  # [
@@ -484,9 +488,9 @@ class tradeogre(Exchange, ImplicitAPI):
484
488
  return [
485
489
  self.safe_timestamp(ohlcv, 0),
486
490
  self.safe_number(ohlcv, 1),
491
+ self.safe_number(ohlcv, 2),
487
492
  self.safe_number(ohlcv, 3),
488
493
  self.safe_number(ohlcv, 4),
489
- self.safe_number(ohlcv, 2),
490
494
  self.safe_number(ohlcv, 5),
491
495
  ]
492
496
 
@@ -584,10 +588,26 @@ class tradeogre(Exchange, ImplicitAPI):
584
588
  """
585
589
  query for balance and get the amount of funds available for trading or funds locked in orders
586
590
  :param dict [params]: extra parameters specific to the exchange API endpoint
591
+ :param str [params.currency]: currency to fetch the balance for
587
592
  :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
588
593
  """
589
594
  await self.load_markets()
590
- response = await self.privateGetAccountBalances(params)
595
+ response = None
596
+ currency = self.safe_string(params, 'currency')
597
+ if currency is not None:
598
+ response = await self.privatePostAccountBalance(params)
599
+ singleCurrencyresult: dict = {
600
+ 'info': response,
601
+ }
602
+ code = self.safe_currency_code(currency)
603
+ account = {
604
+ 'total': self.safe_number(response, 'balance'),
605
+ 'free': self.safe_number(response, 'available'),
606
+ }
607
+ singleCurrencyresult[code] = account
608
+ return self.safe_balance(singleCurrencyresult)
609
+ else:
610
+ response = await self.privateGetAccountBalances(params)
591
611
  result = self.safe_dict(response, 'balances', {})
592
612
  return self.parse_balance(result)
593
613
 
@@ -740,11 +760,11 @@ class tradeogre(Exchange, ImplicitAPI):
740
760
  'side': self.safe_string(order, 'type'),
741
761
  'price': self.safe_string(order, 'price'),
742
762
  'triggerPrice': None,
743
- 'amount': self.safe_string(order, 'quantity'),
763
+ 'amount': None,
744
764
  'cost': None,
745
765
  'average': None,
746
766
  'filled': self.safe_string(order, 'fulfilled'),
747
- 'remaining': None,
767
+ 'remaining': self.safe_string(order, 'quantity'),
748
768
  'status': None,
749
769
  'fee': {
750
770
  'currency': None,
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.whitebit import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Any, Balances, BorrowInterest, Bool, Conversion, Currencies, Currency, DepositAddress, FundingHistory, Int, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Any, Balances, BorrowInterest, Bool, Conversion, Currencies, Currency, DepositAddress, FundingHistory, Int, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFees, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -38,7 +38,7 @@ class whitebit(Exchange, ImplicitAPI):
38
38
  'CORS': None,
39
39
  'spot': True,
40
40
  'margin': True,
41
- 'swap': False,
41
+ 'swap': True,
42
42
  'future': False,
43
43
  'option': False,
44
44
  'cancelAllOrders': True,
@@ -88,7 +88,10 @@ class whitebit(Exchange, ImplicitAPI):
88
88
  'fetchOpenOrders': True,
89
89
  'fetchOrderBook': True,
90
90
  'fetchOrderTrades': True,
91
+ 'fetchPosition': True,
92
+ 'fetchPositionHistory': True,
91
93
  'fetchPositionMode': False,
94
+ 'fetchPositions': True,
92
95
  'fetchPremiumIndexOHLCV': False,
93
96
  'fetchStatus': True,
94
97
  'fetchTicker': True,
@@ -2859,6 +2862,211 @@ class whitebit(Exchange, ImplicitAPI):
2859
2862
  'fee': None,
2860
2863
  }
2861
2864
 
2865
+ async def fetch_position_history(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Position]:
2866
+ """
2867
+ fetches historical positions
2868
+
2869
+ https://docs.whitebit.com/private/http-trade-v4/#positions-history
2870
+
2871
+ :param str symbol: unified contract symbol
2872
+ :param int [since]: the earliest time in ms to fetch positions for
2873
+ :param int [limit]: the maximum amount of records to fetch
2874
+ :param dict [params]: extra parameters specific to the exchange api endpoint
2875
+ :param int [params.positionId]: the id of the requested position
2876
+ :returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
2877
+ """
2878
+ await self.load_markets()
2879
+ market = self.market(symbol)
2880
+ request: dict = {
2881
+ 'market': market['id'],
2882
+ }
2883
+ if since is not None:
2884
+ request['startDate'] = since
2885
+ if limit is not None:
2886
+ request['limit'] = since
2887
+ request, params = self.handle_until_option('endDate', request, params)
2888
+ response = await self.v4PrivatePostCollateralAccountPositionsHistory(self.extend(request, params))
2889
+ #
2890
+ # [
2891
+ # {
2892
+ # "positionId": 479975679,
2893
+ # "market": "BTC_PERP",
2894
+ # "openDate": 1741941025.309887,
2895
+ # "modifyDate": 1741941025.309887,
2896
+ # "amount": "0.001",
2897
+ # "basePrice": "82498.7",
2898
+ # "realizedFunding": "0",
2899
+ # "liquidationPrice": "0",
2900
+ # "liquidationState": null,
2901
+ # "orderDetail": {
2902
+ # "id": 1224727949521,
2903
+ # "tradeAmount": "0.001",
2904
+ # "price": "82498.7",
2905
+ # "tradeFee": "0.028874545",
2906
+ # "fundingFee": "0",
2907
+ # "realizedPnl": "-0.028874545"
2908
+ # }
2909
+ # }
2910
+ # ]
2911
+ #
2912
+ positions = self.parse_positions(response)
2913
+ return self.filter_by_symbol_since_limit(positions, symbol, since, limit)
2914
+
2915
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
2916
+ """
2917
+ fetch all open positions
2918
+
2919
+ https://docs.whitebit.com/private/http-trade-v4/#open-positions
2920
+
2921
+ :param str[] [symbols]: list of unified market symbols
2922
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2923
+ :returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
2924
+ """
2925
+ await self.load_markets()
2926
+ symbols = self.market_symbols(symbols)
2927
+ response = await self.v4PrivatePostCollateralAccountPositionsOpen(params)
2928
+ #
2929
+ # [
2930
+ # {
2931
+ # "positionId": 479975679,
2932
+ # "market": "BTC_PERP",
2933
+ # "openDate": 1741941025.3098869,
2934
+ # "modifyDate": 1741941025.3098869,
2935
+ # "amount": "0.001",
2936
+ # "basePrice": "82498.7",
2937
+ # "liquidationPrice": "70177.2",
2938
+ # "pnl": "0",
2939
+ # "pnlPercent": "0.00",
2940
+ # "margin": "4.2",
2941
+ # "freeMargin": "9.9",
2942
+ # "funding": "0",
2943
+ # "unrealizedFunding": "0",
2944
+ # "liquidationState": null,
2945
+ # "tpsl": null
2946
+ # }
2947
+ # ]
2948
+ #
2949
+ return self.parse_positions(response, symbols)
2950
+
2951
+ async def fetch_position(self, symbol: str, params={}) -> Position:
2952
+ """
2953
+ fetch data on a single open contract trade position
2954
+
2955
+ https://docs.whitebit.com/private/http-trade-v4/#open-positions
2956
+
2957
+ :param str symbol: unified market symbol of the market the position is held in
2958
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2959
+ :returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
2960
+ """
2961
+ await self.load_markets()
2962
+ market = self.market(symbol)
2963
+ request: dict = {
2964
+ 'symbol': market['id'],
2965
+ }
2966
+ response = await self.v4PrivatePostCollateralAccountPositionsOpen(self.extend(request, params))
2967
+ #
2968
+ # [
2969
+ # {
2970
+ # "positionId": 479975679,
2971
+ # "market": "BTC_PERP",
2972
+ # "openDate": 1741941025.3098869,
2973
+ # "modifyDate": 1741941025.3098869,
2974
+ # "amount": "0.001",
2975
+ # "basePrice": "82498.7",
2976
+ # "liquidationPrice": "70177.2",
2977
+ # "pnl": "0",
2978
+ # "pnlPercent": "0.00",
2979
+ # "margin": "4.2",
2980
+ # "freeMargin": "9.9",
2981
+ # "funding": "0",
2982
+ # "unrealizedFunding": "0",
2983
+ # "liquidationState": null,
2984
+ # "tpsl": null
2985
+ # }
2986
+ # ]
2987
+ #
2988
+ data = self.safe_dict(response, 0, {})
2989
+ return self.parse_position(data, market)
2990
+
2991
+ def parse_position(self, position: dict, market: Market = None) -> Position:
2992
+ #
2993
+ # fetchPosition, fetchPositions
2994
+ #
2995
+ # {
2996
+ # "positionId": 479975679,
2997
+ # "market": "BTC_PERP",
2998
+ # "openDate": 1741941025.3098869,
2999
+ # "modifyDate": 1741941025.3098869,
3000
+ # "amount": "0.001",
3001
+ # "basePrice": "82498.7",
3002
+ # "liquidationPrice": "70177.2",
3003
+ # "pnl": "0",
3004
+ # "pnlPercent": "0.00",
3005
+ # "margin": "4.2",
3006
+ # "freeMargin": "9.9",
3007
+ # "funding": "0",
3008
+ # "unrealizedFunding": "0",
3009
+ # "liquidationState": null,
3010
+ # "tpsl": null
3011
+ # }
3012
+ #
3013
+ # fetchPositionHistory
3014
+ #
3015
+ # {
3016
+ # "positionId": 479975679,
3017
+ # "market": "BTC_PERP",
3018
+ # "openDate": 1741941025.309887,
3019
+ # "modifyDate": 1741941025.309887,
3020
+ # "amount": "0.001",
3021
+ # "basePrice": "82498.7",
3022
+ # "realizedFunding": "0",
3023
+ # "liquidationPrice": "0",
3024
+ # "liquidationState": null,
3025
+ # "orderDetail": {
3026
+ # "id": 1224727949521,
3027
+ # "tradeAmount": "0.001",
3028
+ # "price": "82498.7",
3029
+ # "tradeFee": "0.028874545",
3030
+ # "fundingFee": "0",
3031
+ # "realizedPnl": "-0.028874545"
3032
+ # }
3033
+ # }
3034
+ #
3035
+ marketId = self.safe_string(position, 'market')
3036
+ timestamp = self.safe_timestamp(position, 'openDate')
3037
+ tpsl = self.safe_dict(position, 'tpsl', {})
3038
+ orderDetail = self.safe_dict(position, 'orderDetail', {})
3039
+ return self.safe_position({
3040
+ 'info': position,
3041
+ 'id': self.safe_string(position, 'positionId'),
3042
+ 'symbol': self.safe_symbol(marketId, market),
3043
+ 'notional': None,
3044
+ 'marginMode': None,
3045
+ 'liquidationPrice': self.safe_number(position, 'liquidationPrice'),
3046
+ 'entryPrice': self.safe_number(position, 'basePrice'),
3047
+ 'unrealizedPnl': self.safe_number(position, 'pnl'),
3048
+ 'realizedPnl': self.safe_number(orderDetail, 'realizedPnl'),
3049
+ 'percentage': self.safe_number(position, 'pnlPercent'),
3050
+ 'contracts': None,
3051
+ 'contractSize': None,
3052
+ 'markPrice': None,
3053
+ 'lastPrice': None,
3054
+ 'side': None,
3055
+ 'hedged': None,
3056
+ 'timestamp': timestamp,
3057
+ 'datetime': self.iso8601(timestamp),
3058
+ 'lastUpdateTimestamp': self.safe_timestamp(position, 'modifyDate'),
3059
+ 'maintenanceMargin': None,
3060
+ 'maintenanceMarginPercentage': None,
3061
+ 'collateral': self.safe_number(position, 'margin'),
3062
+ 'initialMargin': None,
3063
+ 'initialMarginPercentage': None,
3064
+ 'leverage': None,
3065
+ 'marginRatio': None,
3066
+ 'stopLossPrice': self.safe_number(tpsl, 'stopLoss'),
3067
+ 'takeProfitPrice': self.safe_number(tpsl, 'takeProfit'),
3068
+ })
3069
+
2862
3070
  def is_fiat(self, currency: str) -> bool:
2863
3071
  fiatCurrencies = self.safe_value(self.options, 'fiatCurrencies', [])
2864
3072
  return self.in_array(currency, fiatCurrencies)
ccxt/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.4.68'
7
+ __version__ = '4.4.70'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -2099,7 +2099,6 @@ class Exchange(object):
2099
2099
  },
2100
2100
  'commonCurrencies': {
2101
2101
  'XBT': 'BTC',
2102
- 'BCC': 'BCH',
2103
2102
  'BCHSV': 'BSV',
2104
2103
  },
2105
2104
  'precisionMode': TICK_SIZE,
ccxt/binance.py CHANGED
@@ -8275,7 +8275,7 @@ class binance(Exchange, ImplicitAPI):
8275
8275
  internalInteger = self.safe_integer(transaction, 'transferType')
8276
8276
  internal = None
8277
8277
  if internalInteger is not None:
8278
- internal = True if internalInteger else False
8278
+ internal = True if (internalInteger != 0) else False
8279
8279
  network = self.safe_string(transaction, 'network')
8280
8280
  return {
8281
8281
  'info': transaction,
@@ -11325,8 +11325,22 @@ class binance(Exchange, ImplicitAPI):
11325
11325
  query = None
11326
11326
  # handle batchOrders
11327
11327
  if (path == 'batchOrders') and ((method == 'POST') or (method == 'PUT')):
11328
- batchOrders = self.safe_value(params, 'batchOrders')
11329
- queryBatch = (self.json(batchOrders))
11328
+ batchOrders = self.safe_list(params, 'batchOrders')
11329
+ checkedBatchOrders = batchOrders
11330
+ if method == 'POST' and api == 'fapiPrivate':
11331
+ # check broker id if batchOrders are called with fapiPrivatePostBatchOrders
11332
+ checkedBatchOrders = []
11333
+ for i in range(0, len(batchOrders)):
11334
+ batchOrder = batchOrders[i]
11335
+ newClientOrderId = self.safe_string(batchOrder, 'newClientOrderId')
11336
+ if newClientOrderId is None:
11337
+ defaultId = 'x-xcKtGhcu' # batchOrders can not be spot or margin
11338
+ broker = self.safe_dict(self.options, 'broker', {})
11339
+ brokerId = self.safe_string(broker, 'future', defaultId)
11340
+ newClientOrderId = brokerId + self.uuid22()
11341
+ batchOrder['newClientOrderId'] = newClientOrderId
11342
+ checkedBatchOrders.append(batchOrder)
11343
+ queryBatch = (self.json(checkedBatchOrders))
11330
11344
  params['batchOrders'] = queryBatch
11331
11345
  defaultRecvWindow = self.safe_integer(self.options, 'recvWindow')
11332
11346
  extendedParams = self.extend({