ccxt 4.4.67__py2.py3-none-any.whl → 4.4.69__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.
ccxt/test/tests_async.py CHANGED
@@ -1180,6 +1180,28 @@ class testMainClass:
1180
1180
  assert client_order_id_swap.startswith(swap_id_string), 'binance - swap clientOrderId: ' + client_order_id_swap + ' does not start with swapId' + swap_id_string
1181
1181
  client_order_id_inverse = swap_inverse_order_request['newClientOrderId']
1182
1182
  assert client_order_id_inverse.startswith(swap_id_string), 'binance - swap clientOrderIdInverse: ' + client_order_id_inverse + ' does not start with swapId' + swap_id_string
1183
+ create_orders_request = None
1184
+ try:
1185
+ orders = [{
1186
+ 'symbol': 'BTC/USDT:USDT',
1187
+ 'type': 'limit',
1188
+ 'side': 'sell',
1189
+ 'amount': 1,
1190
+ 'price': 100000,
1191
+ }, {
1192
+ 'symbol': 'BTC/USDT:USDT',
1193
+ 'type': 'market',
1194
+ 'side': 'buy',
1195
+ 'amount': 1,
1196
+ }]
1197
+ await exchange.create_orders(orders)
1198
+ except Exception as e:
1199
+ create_orders_request = self.urlencoded_to_dict(exchange.last_request_body)
1200
+ batch_orders = create_orders_request['batchOrders']
1201
+ for i in range(0, len(batch_orders)):
1202
+ current = batch_orders[i]
1203
+ current_client_order_id = current['newClientOrderId']
1204
+ assert current_client_order_id.startswith(swap_id_string), 'binance createOrders - clientOrderId: ' + current_client_order_id + ' does not start with swapId' + swap_id_string
1183
1205
  if not is_sync():
1184
1206
  await close(exchange)
1185
1207
  return True
ccxt/test/tests_sync.py CHANGED
@@ -1177,6 +1177,28 @@ class testMainClass:
1177
1177
  assert client_order_id_swap.startswith(swap_id_string), 'binance - swap clientOrderId: ' + client_order_id_swap + ' does not start with swapId' + swap_id_string
1178
1178
  client_order_id_inverse = swap_inverse_order_request['newClientOrderId']
1179
1179
  assert client_order_id_inverse.startswith(swap_id_string), 'binance - swap clientOrderIdInverse: ' + client_order_id_inverse + ' does not start with swapId' + swap_id_string
1180
+ create_orders_request = None
1181
+ try:
1182
+ orders = [{
1183
+ 'symbol': 'BTC/USDT:USDT',
1184
+ 'type': 'limit',
1185
+ 'side': 'sell',
1186
+ 'amount': 1,
1187
+ 'price': 100000,
1188
+ }, {
1189
+ 'symbol': 'BTC/USDT:USDT',
1190
+ 'type': 'market',
1191
+ 'side': 'buy',
1192
+ 'amount': 1,
1193
+ }]
1194
+ exchange.create_orders(orders)
1195
+ except Exception as e:
1196
+ create_orders_request = self.urlencoded_to_dict(exchange.last_request_body)
1197
+ batch_orders = create_orders_request['batchOrders']
1198
+ for i in range(0, len(batch_orders)):
1199
+ current = batch_orders[i]
1200
+ current_client_order_id = current['newClientOrderId']
1201
+ assert current_client_order_id.startswith(swap_id_string), 'binance createOrders - clientOrderId: ' + current_client_order_id + ' does not start with swapId' + swap_id_string
1180
1202
  if not is_sync():
1181
1203
  close(exchange)
1182
1204
  return True
ccxt/tradeogre.py CHANGED
@@ -135,6 +135,7 @@ class tradeogre(Exchange, ImplicitAPI):
135
135
  'ticker/{market}': 1,
136
136
  'history/{market}': 1,
137
137
  'chart/{interval}/{market}/{timestamp}': 1,
138
+ 'chart/{interval}/{market}': 1,
138
139
  },
139
140
  },
140
141
  'private': {
@@ -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
 
@@ -442,6 +443,7 @@ class tradeogre(Exchange, ImplicitAPI):
442
443
  :param int [since]: timestamp in ms of the earliest candle to fetch
443
444
  :param int [limit]: the maximum amount of candles to fetch
444
445
  :param dict [params]: extra parameters specific to the exchange API endpoint
446
+ :param int [params.until]: timestamp of the latest candle in ms
445
447
  :returns int[][]: A list of candles ordered, open, high, low, close, volume
446
448
  """
447
449
  self.load_markets()
@@ -450,11 +452,14 @@ class tradeogre(Exchange, ImplicitAPI):
450
452
  'market': market['id'],
451
453
  'interval': self.safe_string(self.timeframes, timeframe, timeframe),
452
454
  }
453
- if since is None:
454
- raise BadRequest(self.id + ' fetchOHLCV requires a since argument')
455
+ response = None
456
+ until = self.safe_integer(params, 'until')
457
+ if until is not None:
458
+ params = self.omit(params, 'until')
459
+ request['timestamp'] = self.parse_to_int(until / 1000)
460
+ response = self.publicGetChartIntervalMarketTimestamp(self.extend(request, params))
455
461
  else:
456
- request['timestamp'] = since
457
- response = self.publicGetChartIntervalMarketTimestamp(self.extend(request, params))
462
+ response = self.publicGetChartIntervalMarket(self.extend(request, params))
458
463
  #
459
464
  # [
460
465
  # [
@@ -483,9 +488,9 @@ class tradeogre(Exchange, ImplicitAPI):
483
488
  return [
484
489
  self.safe_timestamp(ohlcv, 0),
485
490
  self.safe_number(ohlcv, 1),
491
+ self.safe_number(ohlcv, 2),
486
492
  self.safe_number(ohlcv, 3),
487
493
  self.safe_number(ohlcv, 4),
488
- self.safe_number(ohlcv, 2),
489
494
  self.safe_number(ohlcv, 5),
490
495
  ]
491
496
 
ccxt/whitebit.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.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
+ 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
+ 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 = 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
+ 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
+ self.load_markets()
2926
+ symbols = self.market_symbols(symbols)
2927
+ response = 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
+ 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
+ self.load_markets()
2962
+ market = self.market(symbol)
2963
+ request: dict = {
2964
+ 'symbol': market['id'],
2965
+ }
2966
+ response = 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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ccxt
3
- Version: 4.4.67
3
+ Version: 4.4.69
4
4
  Summary: A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges
5
5
  Home-page: https://ccxt.com
6
6
  Author: Igor Kroitor
@@ -83,7 +83,7 @@ Current feature list:
83
83
  ## Certified Cryptocurrency Exchanges
84
84
 
85
85
 
86
- | logo | id | name | ver | type | certified | pro | discount |
86
+ |logo |id |name |ver |type |certified |pro |discount |
87
87
  |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|-----------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------:|--------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------:|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
88
88
  | [![binance](https://github.com/user-attachments/assets/e9419b93-ccb0-46aa-9bff-c883f096274b)](https://accounts.binance.com/en/register?ref=D7YA7CLY) | binance | [Binance](https://accounts.binance.com/en/register?ref=D7YA7CLY) | [![API Version *](https://img.shields.io/badge/*-lightgray)](https://developers.binance.com/en) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | [![Sign up with Binance using CCXT's referral link for a 10% discount!](https://img.shields.io/static/v1?label=Fee&message=%2d10%25&color=orange)](https://accounts.binance.com/en/register?ref=D7YA7CLY) |
89
89
  | [![binancecoinm](https://github.com/user-attachments/assets/387cfc4e-5f33-48cd-8f5c-cd4854dabf0c)](https://accounts.binance.com/en/register?ref=D7YA7CLY) | binancecoinm | [Binance COIN-M](https://accounts.binance.com/en/register?ref=D7YA7CLY) | [![API Version *](https://img.shields.io/badge/*-lightgray)](https://binance-docs.github.io/apidocs/delivery/en/) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | [![Sign up with Binance COIN-M using CCXT's referral link for a 10% discount!](https://img.shields.io/static/v1?label=Fee&message=%2d10%25&color=orange)](https://accounts.binance.com/en/register?ref=D7YA7CLY) |
@@ -110,7 +110,7 @@ Current feature list:
110
110
 
111
111
  The CCXT library currently supports the following 106 cryptocurrency exchange markets and trading APIs:
112
112
 
113
- | logo | id | name | ver | type | certified | pro |
113
+ |logo |id |name |ver |type |certified |pro |
114
114
  |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------|----------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------:|--------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
115
115
  | [![ace](https://github.com/user-attachments/assets/115f1e4a-0fd0-4b76-85d5-a49ebf64d1c8)](https://ace.io/) | ace | [ACE](https://ace.io/) | [![API Version 2](https://img.shields.io/badge/2-lightgray)](https://github.com/ace-exchange/ace-offical-api-docs) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | | |
116
116
  | [![alpaca](https://github.com/user-attachments/assets/e9476df8-a450-4c3e-ab9a-1a7794219e1b)](https://alpaca.markets) | alpaca | [Alpaca](https://alpaca.markets) | [![API Version *](https://img.shields.io/badge/*-lightgray)](https://alpaca.markets/docs/) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) |
@@ -278,13 +278,13 @@ console.log(version, Object.keys(exchanges));
278
278
 
279
279
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
280
280
 
281
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.4.67/dist/ccxt.browser.min.js
282
- * unpkg: https://unpkg.com/ccxt@4.4.67/dist/ccxt.browser.min.js
281
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.4.69/dist/ccxt.browser.min.js
282
+ * unpkg: https://unpkg.com/ccxt@4.4.69/dist/ccxt.browser.min.js
283
283
 
284
284
  CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
285
285
 
286
286
  ```HTML
287
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.4.67/dist/ccxt.browser.min.js"></script>
287
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.4.69/dist/ccxt.browser.min.js"></script>
288
288
  ```
289
289
 
290
290
  Creates a global `ccxt` object: