bitget 0.0.82__py3-none-any.whl → 0.0.84__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.
bitget/ccxt/__init__.py CHANGED
@@ -26,7 +26,7 @@ sys.modules['ccxt'] = ccxt_module
26
26
 
27
27
  # ----------------------------------------------------------------------------
28
28
 
29
- __version__ = '4.5.0'
29
+ __version__ = '4.5.2'
30
30
 
31
31
  # ----------------------------------------------------------------------------
32
32
 
@@ -8,7 +8,7 @@ sys.modules['ccxt'] = ccxt_module
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
11
- __version__ = '4.5.0'
11
+ __version__ = '4.5.2'
12
12
 
13
13
  # -----------------------------------------------------------------------------
14
14
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # -----------------------------------------------------------------------------
4
4
 
5
- __version__ = '4.5.0'
5
+ __version__ = '4.5.2'
6
6
 
7
7
  # -----------------------------------------------------------------------------
8
8
 
@@ -1917,7 +1917,7 @@ class bitget(Exchange, ImplicitAPI):
1917
1917
  res = self.safe_dict(results, i)
1918
1918
  data = self.safe_list(res, 'data', [])
1919
1919
  firstData = self.safe_dict(data, 0, {})
1920
- isBorrowable = self.safe_string(firstData, 'isBorrowable')
1920
+ isBorrowable = self.safe_bool(firstData, 'isBorrowable')
1921
1921
  if fetchMargins and isBorrowable is not None:
1922
1922
  keysList = list(self.index_by(data, 'symbol').keys())
1923
1923
  self.options['crossMarginPairsData'] = keysList
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.5.0'
7
+ __version__ = '4.5.2'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -2337,6 +2337,12 @@ class Exchange(object):
2337
2337
  # return the first index of the cache that can be applied to the orderbook or -1 if not possible
2338
2338
  return -1
2339
2339
 
2340
+ def arrays_concat(self, arraysOfArrays: List[Any]):
2341
+ result = []
2342
+ for i in range(0, len(arraysOfArrays)):
2343
+ result = self.array_concat(result, arraysOfArrays[i])
2344
+ return result
2345
+
2340
2346
  def find_timeframe(self, timeframe, timeframes=None):
2341
2347
  if timeframes is None:
2342
2348
  timeframes = self.timeframes
bitget/ccxt/bitget.py CHANGED
@@ -1916,7 +1916,7 @@ class bitget(Exchange, ImplicitAPI):
1916
1916
  res = self.safe_dict(results, i)
1917
1917
  data = self.safe_list(res, 'data', [])
1918
1918
  firstData = self.safe_dict(data, 0, {})
1919
- isBorrowable = self.safe_string(firstData, 'isBorrowable')
1919
+ isBorrowable = self.safe_bool(firstData, 'isBorrowable')
1920
1920
  if fetchMargins and isBorrowable is not None:
1921
1921
  keysList = list(self.index_by(data, 'symbol').keys())
1922
1922
  self.options['crossMarginPairsData'] = keysList
@@ -8,7 +8,7 @@ sys.modules['ccxt'] = ccxt_module
8
8
 
9
9
  # ----------------------------------------------------------------------------
10
10
 
11
- __version__ = '4.5.0'
11
+ __version__ = '4.5.2'
12
12
 
13
13
  # ----------------------------------------------------------------------------
14
14
 
bitget/ccxt/pro/bitget.py CHANGED
@@ -54,10 +54,14 @@ class bitget(bitgetAsync):
54
54
  'ws': {
55
55
  'public': 'wss://ws.bitget.com/v2/ws/public',
56
56
  'private': 'wss://ws.bitget.com/v2/ws/private',
57
+ 'utaPublic': 'wss://ws.bitget.com/v3/ws/public',
58
+ 'utaPrivate': 'wss://ws.bitget.com/v3/ws/private',
57
59
  },
58
60
  'demo': {
59
61
  'public': 'wss://wspap.bitget.com/v2/ws/public',
60
62
  'private': 'wss://wspap.bitget.com/v2/ws/private',
63
+ 'utaPublic': 'wss://wspap.bitget.com/v3/ws/public',
64
+ 'utaPrivate': 'wss://wspap.bitget.com/v3/ws/private',
61
65
  },
62
66
  },
63
67
  },
@@ -67,6 +71,7 @@ class bitget(bitgetAsync):
67
71
  # WS timeframes differ from REST timeframes
68
72
  'timeframes': {
69
73
  '1m': '1m',
74
+ '3m': '3m',
70
75
  '5m': '5m',
71
76
  '15m': '15m',
72
77
  '30m': '30m',
@@ -109,7 +114,9 @@ class bitget(bitgetAsync):
109
114
  },
110
115
  })
111
116
 
112
- def get_inst_type(self, market, params={}):
117
+ def get_inst_type(self, market, uta: bool = False, params={}):
118
+ if (uta is None) or not uta:
119
+ uta, params = self.handle_option_and_params(params, 'getInstType', 'uta', False)
113
120
  instType = None
114
121
  if market is None:
115
122
  instType, params = self.handleProductTypeAndParams(None, params)
@@ -120,6 +127,8 @@ class bitget(bitgetAsync):
120
127
  instypeAux = None
121
128
  instypeAux, params = self.handle_option_and_params(params, 'getInstType', 'instType', instType)
122
129
  instType = instypeAux
130
+ if uta:
131
+ instType = instType.lower()
123
132
  return [instType, params]
124
133
 
125
134
  async def watch_ticker(self, symbol: str, params={}) -> Ticker:
@@ -128,9 +137,11 @@ class bitget(bitgetAsync):
128
137
 
129
138
  https://www.bitget.com/api-doc/spot/websocket/public/Tickers-Channel
130
139
  https://www.bitget.com/api-doc/contract/websocket/public/Tickers-Channel
140
+ https://www.bitget.com/api-doc/uta/websocket/public/Tickers-Channel
131
141
 
132
142
  :param str symbol: unified symbol of the market to watch the ticker for
133
143
  :param dict [params]: extra parameters specific to the exchange API endpoint
144
+ :param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
134
145
  :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
135
146
  """
136
147
  await self.load_markets()
@@ -138,12 +149,16 @@ class bitget(bitgetAsync):
138
149
  symbol = market['symbol']
139
150
  messageHash = 'ticker:' + symbol
140
151
  instType = None
141
- instType, params = self.get_inst_type(market, params)
152
+ uta = None
153
+ uta, params = self.handle_option_and_params(params, 'watchTicker', 'uta', False)
154
+ instType, params = self.get_inst_type(market, uta, params)
142
155
  args: dict = {
143
156
  'instType': instType,
144
- 'channel': 'ticker',
145
- 'instId': market['id'],
146
157
  }
158
+ topicOrChannel = 'topic' if uta else 'channel'
159
+ symbolOrInstId = 'symbol' if uta else 'instId'
160
+ args[topicOrChannel] = 'ticker'
161
+ args[symbolOrInstId] = market['id']
147
162
  return await self.watch_public(messageHash, args, params)
148
163
 
149
164
  async def un_watch_ticker(self, symbol: str, params={}) -> Any:
@@ -166,16 +181,20 @@ class bitget(bitgetAsync):
166
181
 
167
182
  https://www.bitget.com/api-doc/spot/websocket/public/Tickers-Channel
168
183
  https://www.bitget.com/api-doc/contract/websocket/public/Tickers-Channel
184
+ https://www.bitget.com/api-doc/uta/websocket/public/Tickers-Channel
169
185
 
170
186
  :param str[] symbols: unified symbol of the market to watch the tickers for
171
187
  :param dict [params]: extra parameters specific to the exchange API endpoint
188
+ :param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
172
189
  :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
173
190
  """
174
191
  await self.load_markets()
175
192
  symbols = self.market_symbols(symbols, None, False)
176
193
  market = self.market(symbols[0])
177
194
  instType = None
178
- instType, params = self.get_inst_type(market, params)
195
+ uta = None
196
+ uta, params = self.handle_option_and_params(params, 'watchTickers', 'uta', False)
197
+ instType, params = self.get_inst_type(market, uta, params)
179
198
  topics = []
180
199
  messageHashes = []
181
200
  for i in range(0, len(symbols)):
@@ -183,9 +202,11 @@ class bitget(bitgetAsync):
183
202
  marketInner = self.market(symbol)
184
203
  args: dict = {
185
204
  'instType': instType,
186
- 'channel': 'ticker',
187
- 'instId': marketInner['id'],
188
205
  }
206
+ topicOrChannel = 'topic' if uta else 'channel'
207
+ symbolOrInstId = 'symbol' if uta else 'instId'
208
+ args[topicOrChannel] = 'ticker'
209
+ args[symbolOrInstId] = marketInner['id']
189
210
  topics.append(args)
190
211
  messageHashes.append('ticker:' + symbol)
191
212
  tickers = await self.watch_public_multiple(messageHashes, topics, params)
@@ -196,6 +217,8 @@ class bitget(bitgetAsync):
196
217
  return self.filter_by_array(self.tickers, 'symbol', symbols)
197
218
 
198
219
  def handle_ticker(self, client: Client, message):
220
+ #
221
+ # default
199
222
  #
200
223
  # {
201
224
  # "action": "snapshot",
@@ -226,6 +249,29 @@ class bitget(bitgetAsync):
226
249
  # "ts": 1701842994341
227
250
  # }
228
251
  #
252
+ # uta
253
+ #
254
+ # {
255
+ # "action": "snapshot",
256
+ # "arg": {"instType": "spot", topic: "ticker", symbol: "BTCUSDT"},
257
+ # "data": [
258
+ # {
259
+ # "highPrice24h": "120255.61",
260
+ # "lowPrice24h": "116145.88",
261
+ # "openPrice24h": "118919.38",
262
+ # "lastPrice": "119818.83",
263
+ # "turnover24h": "215859996.272276",
264
+ # "volume24h": "1819.756798",
265
+ # "bid1Price": "119811.26",
266
+ # "ask1Price": "119831.18",
267
+ # "bid1Size": "0.008732",
268
+ # "ask1Size": "0.004297",
269
+ # "price24hPcnt": "0.02002"
270
+ # }
271
+ # ],
272
+ # "ts": 1753230479687
273
+ # }
274
+ #
229
275
  self.handle_bid_ask(client, message)
230
276
  ticker = self.parse_ws_ticker(message)
231
277
  symbol = ticker['symbol']
@@ -304,56 +350,85 @@ class bitget(bitgetAsync):
304
350
  # "ts": 1701843962812
305
351
  # }
306
352
  #
353
+ # uta
354
+ #
355
+ # {
356
+ # "action": "snapshot",
357
+ # "arg": {"instType": "spot", topic: "ticker", symbol: "BTCUSDT"},
358
+ # "data": [
359
+ # {
360
+ # "highPrice24h": "120255.61",
361
+ # "lowPrice24h": "116145.88",
362
+ # "openPrice24h": "118919.38",
363
+ # "lastPrice": "119818.83",
364
+ # "turnover24h": "215859996.272276",
365
+ # "volume24h": "1819.756798",
366
+ # "bid1Price": "119811.26",
367
+ # "ask1Price": "119831.18",
368
+ # "bid1Size": "0.008732",
369
+ # "ask1Size": "0.004297",
370
+ # "price24hPcnt": "0.02002"
371
+ # }
372
+ # ],
373
+ # "ts": 1753230479687
374
+ # }
375
+ #
307
376
  arg = self.safe_value(message, 'arg', {})
308
377
  data = self.safe_value(message, 'data', [])
309
378
  ticker = self.safe_value(data, 0, {})
310
- timestamp = self.safe_integer(ticker, 'ts')
311
- instType = self.safe_string(arg, 'instType')
312
- marketType = 'spot' if (instType == 'SPOT') else 'contract'
313
- marketId = self.safe_string(ticker, 'instId')
379
+ utaTimestamp = self.safe_integer(message, 'ts')
380
+ timestamp = self.safe_integer(ticker, 'ts', utaTimestamp)
381
+ instType = self.safe_string_lower(arg, 'instType')
382
+ marketType = 'spot' if (instType == 'spot') else 'contract'
383
+ utaMarketId = self.safe_string(arg, 'symbol')
384
+ marketId = self.safe_string(ticker, 'instId', utaMarketId)
314
385
  market = self.safe_market(marketId, market, None, marketType)
315
- close = self.safe_string(ticker, 'lastPr')
316
- changeDecimal = self.safe_string(ticker, 'change24h')
317
- change = Precise.string_mul(changeDecimal, '100')
386
+ close = self.safe_string_2(ticker, 'lastPr', 'lastPrice')
387
+ changeDecimal = self.safe_string(ticker, 'change24h', '')
388
+ change = self.safe_string(ticker, 'price24hPcnt', Precise.string_mul(changeDecimal, '100'))
318
389
  return self.safe_ticker({
319
390
  'symbol': market['symbol'],
320
391
  'timestamp': timestamp,
321
392
  'datetime': self.iso8601(timestamp),
322
- 'high': self.safe_string(ticker, 'high24h'),
323
- 'low': self.safe_string(ticker, 'low24h'),
324
- 'bid': self.safe_string(ticker, 'bidPr'),
325
- 'bidVolume': self.safe_string(ticker, 'bidSz'),
326
- 'ask': self.safe_string(ticker, 'askPr'),
327
- 'askVolume': self.safe_string(ticker, 'askSz'),
393
+ 'high': self.safe_string_2(ticker, 'high24h', 'highPrice24h'),
394
+ 'low': self.safe_string_2(ticker, 'low24h', 'lowPrice24h'),
395
+ 'bid': self.safe_string_2(ticker, 'bidPr', 'bid1Price'),
396
+ 'bidVolume': self.safe_string_2(ticker, 'bidSz', 'bid1Size'),
397
+ 'ask': self.safe_string_2(ticker, 'askPr', 'ask1Price'),
398
+ 'askVolume': self.safe_string_2(ticker, 'askSz', 'ask1Size'),
328
399
  'vwap': None,
329
- 'open': self.safe_string(ticker, 'open24h'),
400
+ 'open': self.safe_string_2(ticker, 'open24h', 'openPrice24h'),
330
401
  'close': close,
331
402
  'last': close,
332
403
  'previousClose': None,
333
404
  'change': None,
334
405
  'percentage': change,
335
406
  'average': None,
336
- 'baseVolume': self.safe_string(ticker, 'baseVolume'),
337
- 'quoteVolume': self.safe_string(ticker, 'quoteVolume'),
407
+ 'baseVolume': self.safe_string_2(ticker, 'baseVolume', 'volume24h'),
408
+ 'quoteVolume': self.safe_string_2(ticker, 'quoteVolume', 'turnover24h'),
338
409
  'info': ticker,
339
410
  }, market)
340
411
 
341
412
  async def watch_bids_asks(self, symbols: Strings = None, params={}) -> Tickers:
342
413
  """
414
+ watches best bid & ask for symbols
343
415
 
344
416
  https://www.bitget.com/api-doc/spot/websocket/public/Tickers-Channel
345
417
  https://www.bitget.com/api-doc/contract/websocket/public/Tickers-Channel
418
+ https://www.bitget.com/api-doc/uta/websocket/public/Tickers-Channel
346
419
 
347
- watches best bid & ask for symbols
348
420
  :param str[] symbols: unified symbol of the market to fetch the ticker for
349
421
  :param dict [params]: extra parameters specific to the exchange API endpoint
422
+ :param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
350
423
  :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
351
424
  """
352
425
  await self.load_markets()
353
426
  symbols = self.market_symbols(symbols, None, False)
354
427
  market = self.market(symbols[0])
355
428
  instType = None
356
- instType, params = self.get_inst_type(market, params)
429
+ uta = None
430
+ uta, params = self.handle_option_and_params(params, 'watchBidsAsks', 'uta', False)
431
+ instType, params = self.get_inst_type(market, uta, params)
357
432
  topics = []
358
433
  messageHashes = []
359
434
  for i in range(0, len(symbols)):
@@ -361,9 +436,11 @@ class bitget(bitgetAsync):
361
436
  marketInner = self.market(symbol)
362
437
  args: dict = {
363
438
  'instType': instType,
364
- 'channel': 'ticker',
365
- 'instId': marketInner['id'],
366
439
  }
440
+ topicOrChannel = 'topic' if uta else 'channel'
441
+ symbolOrInstId = 'symbol' if uta else 'instId'
442
+ args[topicOrChannel] = 'ticker'
443
+ args[symbolOrInstId] = marketInner['id']
367
444
  topics.append(args)
368
445
  messageHashes.append('bidask:' + symbol)
369
446
  tickers = await self.watch_public_multiple(messageHashes, topics, params)
@@ -384,19 +461,21 @@ class bitget(bitgetAsync):
384
461
  arg = self.safe_value(message, 'arg', {})
385
462
  data = self.safe_value(message, 'data', [])
386
463
  ticker = self.safe_value(data, 0, {})
387
- timestamp = self.safe_integer(ticker, 'ts')
388
- instType = self.safe_string(arg, 'instType')
389
- marketType = 'spot' if (instType == 'SPOT') else 'contract'
390
- marketId = self.safe_string(ticker, 'instId')
464
+ utaTimestamp = self.safe_integer(message, 'ts')
465
+ timestamp = self.safe_integer(ticker, 'ts', utaTimestamp)
466
+ instType = self.safe_string_lower(arg, 'instType')
467
+ marketType = 'spot' if (instType == 'spot') else 'contract'
468
+ utaMarketId = self.safe_string(arg, 'symbol')
469
+ marketId = self.safe_string(ticker, 'instId', utaMarketId)
391
470
  market = self.safe_market(marketId, market, None, marketType)
392
471
  return self.safe_ticker({
393
472
  'symbol': market['symbol'],
394
473
  'timestamp': timestamp,
395
474
  'datetime': self.iso8601(timestamp),
396
- 'ask': self.safe_string(ticker, 'askPr'),
397
- 'askVolume': self.safe_string(ticker, 'askSz'),
398
- 'bid': self.safe_string(ticker, 'bidPr'),
399
- 'bidVolume': self.safe_string(ticker, 'bidSz'),
475
+ 'ask': self.safe_string_2(ticker, 'askPr', 'ask1Price'),
476
+ 'askVolume': self.safe_string_2(ticker, 'askSz', 'ask1Size'),
477
+ 'bid': self.safe_string_2(ticker, 'bidPr', 'bid1Price'),
478
+ 'bidVolume': self.safe_string_2(ticker, 'bidSz', 'bid1Size'),
400
479
  'info': ticker,
401
480
  }, market)
402
481
 
@@ -406,12 +485,14 @@ class bitget(bitgetAsync):
406
485
 
407
486
  https://www.bitget.com/api-doc/spot/websocket/public/Candlesticks-Channel
408
487
  https://www.bitget.com/api-doc/contract/websocket/public/Candlesticks-Channel
488
+ https://www.bitget.com/api-doc/uta/websocket/public/Candlesticks-Channel
409
489
 
410
490
  :param str symbol: unified symbol of the market to fetch OHLCV data for
411
491
  :param str timeframe: the length of time each candle represents
412
492
  :param int [since]: timestamp in ms of the earliest candle to fetch
413
493
  :param int [limit]: the maximum amount of candles to fetch
414
494
  :param dict [params]: extra parameters specific to the exchange API endpoint
495
+ :param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
415
496
  :returns int[][]: A list of candles ordered, open, high, low, close, volume
416
497
  """
417
498
  await self.load_markets()
@@ -419,14 +500,24 @@ class bitget(bitgetAsync):
419
500
  symbol = market['symbol']
420
501
  timeframes = self.safe_value(self.options, 'timeframes')
421
502
  interval = self.safe_string(timeframes, timeframe)
422
- messageHash = 'candles:' + timeframe + ':' + symbol
503
+ messageHash = None
423
504
  instType = None
424
- instType, params = self.get_inst_type(market, params)
505
+ uta = None
506
+ uta, params = self.handle_option_and_params(params, 'watchOHLCV', 'uta', False)
507
+ instType, params = self.get_inst_type(market, uta, params)
425
508
  args: dict = {
426
509
  'instType': instType,
427
- 'channel': 'candle' + interval,
428
- 'instId': market['id'],
429
510
  }
511
+ if uta:
512
+ args['topic'] = 'kline'
513
+ args['symbol'] = market['id']
514
+ args['interval'] = interval
515
+ params['uta'] = True
516
+ messageHash = 'kline:' + symbol
517
+ else:
518
+ args['channel'] = 'candle' + interval
519
+ args['instId'] = market['id']
520
+ messageHash = 'candles:' + timeframe + ':' + symbol
430
521
  ohlcv = await self.watch_public(messageHash, args, params)
431
522
  if self.newUpdates:
432
523
  limit = ohlcv.getLimit(symbol, limit)
@@ -438,17 +529,43 @@ class bitget(bitgetAsync):
438
529
 
439
530
  https://www.bitget.com/api-doc/spot/websocket/public/Candlesticks-Channel
440
531
  https://www.bitget.com/api-doc/contract/websocket/public/Candlesticks-Channel
532
+ https://www.bitget.com/api-doc/uta/websocket/public/Candlesticks-Channel
441
533
 
442
534
  :param str symbol: unified symbol of the market to unwatch the ohlcv for
443
535
  :param str [timeframe]: the period for the ratio, default is 1 minute
444
536
  :param dict [params]: extra parameters specific to the exchange API endpoint
537
+ :param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
445
538
  :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
446
539
  """
447
540
  await self.load_markets()
448
541
  timeframes = self.safe_dict(self.options, 'timeframes')
449
542
  interval = self.safe_string(timeframes, timeframe)
450
- channel = 'candle' + interval
451
- return await self.un_watch_channel(symbol, channel, 'candles:' + timeframe, params)
543
+ channel = None
544
+ market = None
545
+ if symbol is not None:
546
+ market = self.market(symbol)
547
+ instType = None
548
+ messageHash = None
549
+ uta = None
550
+ uta, params = self.handle_option_and_params(params, 'unWatchOHLCV', 'uta', False)
551
+ instType, params = self.get_inst_type(market, uta, params)
552
+ args: dict = {
553
+ 'instType': instType,
554
+ }
555
+ if uta:
556
+ channel = 'kline'
557
+ args['topic'] = channel
558
+ args['symbol'] = market['id']
559
+ args['interval'] = interval
560
+ params['uta'] = True
561
+ params['interval'] = interval
562
+ messageHash = channel + symbol
563
+ else:
564
+ channel = 'candle' + interval
565
+ args['channel'] = channel
566
+ args['instId'] = market['id']
567
+ messageHash = 'candles:' + interval
568
+ return await self.un_watch_channel(symbol, channel, messageHash, params)
452
569
 
453
570
  def handle_ohlcv(self, client: Client, message):
454
571
  #
@@ -484,15 +601,45 @@ class bitget(bitgetAsync):
484
601
  # "ts": 1701901610417
485
602
  # }
486
603
  #
604
+ # uta
605
+ #
606
+ # {
607
+ # "action": "snapshot",
608
+ # "arg": {
609
+ # "instType": "usdt-futures",
610
+ # "topic": "kline",
611
+ # "symbol": "BTCUSDT",
612
+ # "interval": "1m"
613
+ # },
614
+ # "data": [
615
+ # {
616
+ # "start": "1755564480000",
617
+ # "open": "116286",
618
+ # "close": "116256.2",
619
+ # "high": "116310.2",
620
+ # "low": "116232.8",
621
+ # "volume": "39.7062",
622
+ # "turnover": "4616746.46654"
623
+ # },
624
+ # ],
625
+ # "ts": 1755594421877
626
+ # }
627
+ #
487
628
  arg = self.safe_value(message, 'arg', {})
488
- instType = self.safe_string(arg, 'instType')
489
- marketType = 'spot' if (instType == 'SPOT') else 'contract'
490
- marketId = self.safe_string(arg, 'instId')
629
+ instType = self.safe_string_lower(arg, 'instType')
630
+ marketType = 'spot' if (instType == 'spot') else 'contract'
631
+ marketId = self.safe_string_2(arg, 'instId', 'symbol')
491
632
  market = self.safe_market(marketId, None, None, marketType)
492
633
  symbol = market['symbol']
493
634
  self.ohlcvs[symbol] = self.safe_value(self.ohlcvs, symbol, {})
494
- channel = self.safe_string(arg, 'channel')
495
- interval = channel.replace('candle', '')
635
+ channel = self.safe_string_2(arg, 'channel', 'topic')
636
+ interval = self.safe_string(arg, 'interval')
637
+ isUta = None
638
+ if interval is None:
639
+ isUta = False
640
+ interval = channel.replace('candle', '')
641
+ else:
642
+ isUta = True
496
643
  timeframes = self.safe_value(self.options, 'timeframes')
497
644
  timeframe = self.find_timeframe(interval, timeframes)
498
645
  stored = self.safe_value(self.ohlcvs[symbol], timeframe)
@@ -504,7 +651,11 @@ class bitget(bitgetAsync):
504
651
  for i in range(0, len(data)):
505
652
  parsed = self.parse_ws_ohlcv(data[i], market)
506
653
  stored.append(parsed)
507
- messageHash = 'candles:' + timeframe + ':' + symbol
654
+ messageHash = None
655
+ if isUta:
656
+ messageHash = 'kline:' + symbol
657
+ else:
658
+ messageHash = 'candles:' + timeframe + ':' + symbol
508
659
  client.resolve(stored, messageHash)
509
660
 
510
661
  def parse_ws_ohlcv(self, ohlcv, market=None) -> list:
@@ -520,14 +671,26 @@ class bitget(bitgetAsync):
520
671
  # "437404.105512" # USDT volume
521
672
  # ]
522
673
  #
674
+ # uta
675
+ #
676
+ # {
677
+ # "start": "1755564480000",
678
+ # "open": "116286",
679
+ # "close": "116256.2",
680
+ # "high": "116310.2",
681
+ # "low": "116232.8",
682
+ # "volume": "39.7062",
683
+ # "turnover": "4616746.46654"
684
+ # }
685
+ #
523
686
  volumeIndex = 6 if (market['inverse']) else 5
524
687
  return [
525
- self.safe_integer(ohlcv, 0),
526
- self.safe_number(ohlcv, 1),
527
- self.safe_number(ohlcv, 2),
528
- self.safe_number(ohlcv, 3),
529
- self.safe_number(ohlcv, 4),
530
- self.safe_number(ohlcv, volumeIndex),
688
+ self.safe_integer_2(ohlcv, 'start', 0),
689
+ self.safe_number_2(ohlcv, 'open', 1),
690
+ self.safe_number_2(ohlcv, 'high', 2),
691
+ self.safe_number_2(ohlcv, 'low', 3),
692
+ self.safe_number_2(ohlcv, 'close', 4),
693
+ self.safe_number_2(ohlcv, 'volume', volumeIndex),
531
694
  ]
532
695
 
533
696
  async def watch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
@@ -569,12 +732,21 @@ class bitget(bitgetAsync):
569
732
  market = self.market(symbol)
570
733
  messageHash = 'unsubscribe:' + messageHashTopic + ':' + market['symbol']
571
734
  instType = None
572
- instType, params = self.get_inst_type(market, params)
735
+ uta = None
736
+ uta, params = self.handle_option_and_params(params, 'unWatchChannel', 'uta', False)
737
+ instType, params = self.get_inst_type(market, uta, params)
573
738
  args: dict = {
574
739
  'instType': instType,
575
- 'channel': channel,
576
- 'instId': market['id'],
577
740
  }
741
+ if uta:
742
+ args['topic'] = channel
743
+ args['symbol'] = market['id']
744
+ args['interval'] = self.safe_string(params, 'interval', '1m')
745
+ params['uta'] = True
746
+ params = self.omit(params, 'interval')
747
+ else:
748
+ args['channel'] = channel
749
+ args['instId'] = market['id']
578
750
  return await self.un_watch_public(messageHash, args, params)
579
751
 
580
752
  async def watch_order_book_for_symbols(self, symbols: List[str], limit: Int = None, params={}) -> OrderBook:
@@ -602,7 +774,7 @@ class bitget(bitgetAsync):
602
774
  symbol = symbols[i]
603
775
  market = self.market(symbol)
604
776
  instType = None
605
- instType, params = self.get_inst_type(market, params)
777
+ instType, params = self.get_inst_type(market, False, params)
606
778
  args: dict = {
607
779
  'instType': instType,
608
780
  'channel': channel,
@@ -760,7 +932,7 @@ class bitget(bitgetAsync):
760
932
  symbol = symbols[i]
761
933
  market = self.market(symbol)
762
934
  instType = None
763
- instType, params = self.get_inst_type(market, params)
935
+ instType, params = self.get_inst_type(market, False, params)
764
936
  args: dict = {
765
937
  'instType': instType,
766
938
  'channel': 'trade',
@@ -944,7 +1116,7 @@ class bitget(bitgetAsync):
944
1116
  symbols = self.market_symbols(symbols)
945
1117
  if not self.is_empty(symbols):
946
1118
  market = self.get_market_from_symbols(symbols)
947
- instType, params = self.get_inst_type(market, params)
1119
+ instType, params = self.get_inst_type(market, False, params)
948
1120
  messageHash = instType + ':positions' + messageHash
949
1121
  args: dict = {
950
1122
  'instType': instType,
@@ -1139,7 +1311,7 @@ class bitget(bitgetAsync):
1139
1311
  if market is None and type == 'spot':
1140
1312
  instType = 'SPOT'
1141
1313
  else:
1142
- instType, params = self.get_inst_type(market, params)
1314
+ instType, params = self.get_inst_type(market, False, params)
1143
1315
  if type == 'spot' and (symbol is not None):
1144
1316
  subscriptionHash = subscriptionHash + ':' + symbol
1145
1317
  if isTrigger:
@@ -1490,7 +1662,7 @@ class bitget(bitgetAsync):
1490
1662
  if market is None and type == 'spot':
1491
1663
  instType = 'spot'
1492
1664
  else:
1493
- instType, params = self.get_inst_type(market, params)
1665
+ instType, params = self.get_inst_type(market, False, params)
1494
1666
  subscriptionHash = 'fill:' + instType
1495
1667
  args: dict = {
1496
1668
  'instType': instType,
@@ -1711,12 +1883,21 @@ class bitget(bitgetAsync):
1711
1883
  client.resolve(self.balance, messageHash)
1712
1884
 
1713
1885
  async def watch_public(self, messageHash, args, params={}):
1714
- url = self.urls['api']['ws']['public']
1886
+ uta = None
1887
+ url = None
1888
+ uta, params = self.handle_option_and_params(params, 'watchPublic', 'uta', False)
1889
+ if uta:
1890
+ url = self.urls['api']['ws']['utaPublic']
1891
+ else:
1892
+ url = self.urls['api']['ws']['public']
1715
1893
  sandboxMode = self.safe_bool_2(self.options, 'sandboxMode', 'sandbox', False)
1716
1894
  if sandboxMode:
1717
1895
  instType = self.safe_string(args, 'instType')
1718
1896
  if (instType != 'SCOIN-FUTURES') and (instType != 'SUSDT-FUTURES') and (instType != 'SUSDC-FUTURES'):
1719
- url = self.urls['api']['demo']['public']
1897
+ if uta:
1898
+ url = self.urls['api']['demo']['utaPublic']
1899
+ else:
1900
+ url = self.urls['api']['demo']['public']
1720
1901
  request: dict = {
1721
1902
  'op': 'subscribe',
1722
1903
  'args': [args],
@@ -1725,12 +1906,21 @@ class bitget(bitgetAsync):
1725
1906
  return await self.watch(url, messageHash, message, messageHash)
1726
1907
 
1727
1908
  async def un_watch_public(self, messageHash, args, params={}):
1728
- url = self.urls['api']['ws']['public']
1909
+ uta = None
1910
+ url = None
1911
+ uta, params = self.handle_option_and_params(params, 'unWatchPublic', 'uta', False)
1912
+ if uta:
1913
+ url = self.urls['api']['ws']['utaPublic']
1914
+ else:
1915
+ url = self.urls['api']['ws']['public']
1729
1916
  sandboxMode = self.safe_bool_2(self.options, 'sandboxMode', 'sandbox', False)
1730
1917
  if sandboxMode:
1731
1918
  instType = self.safe_string(args, 'instType')
1732
1919
  if (instType != 'SCOIN-FUTURES') and (instType != 'SUSDT-FUTURES') and (instType != 'SUSDC-FUTURES'):
1733
- url = self.urls['api']['demo']['public']
1920
+ if uta:
1921
+ url = self.urls['api']['demo']['utaPublic']
1922
+ else:
1923
+ url = self.urls['api']['demo']['public']
1734
1924
  request: dict = {
1735
1925
  'op': 'unsubscribe',
1736
1926
  'args': [args],
@@ -1739,13 +1929,22 @@ class bitget(bitgetAsync):
1739
1929
  return await self.watch(url, messageHash, message, messageHash)
1740
1930
 
1741
1931
  async def watch_public_multiple(self, messageHashes, argsArray, params={}):
1742
- url = self.urls['api']['ws']['public']
1932
+ uta = None
1933
+ url = None
1934
+ uta, params = self.handle_option_and_params(params, 'watchPublicMultiple', 'uta', False)
1935
+ if uta:
1936
+ url = self.urls['api']['ws']['utaPublic']
1937
+ else:
1938
+ url = self.urls['api']['ws']['public']
1743
1939
  sandboxMode = self.safe_bool_2(self.options, 'sandboxMode', 'sandbox', False)
1744
1940
  if sandboxMode:
1745
1941
  argsArrayFirst = self.safe_dict(argsArray, 0, {})
1746
1942
  instType = self.safe_string(argsArrayFirst, 'instType')
1747
1943
  if (instType != 'SCOIN-FUTURES') and (instType != 'SUSDT-FUTURES') and (instType != 'SUSDC-FUTURES'):
1748
- url = self.urls['api']['demo']['public']
1944
+ if uta:
1945
+ url = self.urls['api']['demo']['utaPublic']
1946
+ else:
1947
+ url = self.urls['api']['demo']['public']
1749
1948
  request: dict = {
1750
1949
  'op': 'subscribe',
1751
1950
  'args': argsArray,
@@ -1874,6 +2073,41 @@ class bitget(bitgetAsync):
1874
2073
  # ]
1875
2074
  # }
1876
2075
  #
2076
+ # uta
2077
+ #
2078
+ # {
2079
+ # "action": "snapshot",
2080
+ # "arg": {"instType": "spot", topic: "ticker", symbol: "BTCUSDT"},
2081
+ # "data": [
2082
+ # {
2083
+ # "highPrice24h": "120255.61",
2084
+ # "lowPrice24h": "116145.88",
2085
+ # "openPrice24h": "118919.38",
2086
+ # "lastPrice": "119818.83",
2087
+ # "turnover24h": "215859996.272276",
2088
+ # "volume24h": "1819.756798",
2089
+ # "bid1Price": "119811.26",
2090
+ # "ask1Price": "119831.18",
2091
+ # "bid1Size": "0.008732",
2092
+ # "ask1Size": "0.004297",
2093
+ # "price24hPcnt": "0.02002"
2094
+ # }
2095
+ # ],
2096
+ # "ts": 1753230479687
2097
+ # }
2098
+ #
2099
+ # unsubscribe
2100
+ #
2101
+ # {
2102
+ # "event": "unsubscribe",
2103
+ # "arg": {
2104
+ # "instType": "spot",
2105
+ # "topic": "kline",
2106
+ # "symbol": "BTCUSDT",
2107
+ # "interval": "1m"
2108
+ # }
2109
+ # }
2110
+ #
1877
2111
  if self.handle_error_message(client, message):
1878
2112
  return
1879
2113
  content = self.safe_string(message, 'message')
@@ -1906,9 +2140,10 @@ class bitget(bitgetAsync):
1906
2140
  'positions': self.handle_positions,
1907
2141
  'account-isolated': self.handle_balance,
1908
2142
  'account-crossed': self.handle_balance,
2143
+ 'kline': self.handle_ohlcv,
1909
2144
  }
1910
2145
  arg = self.safe_value(message, 'arg', {})
1911
- topic = self.safe_value(arg, 'channel', '')
2146
+ topic = self.safe_value_2(arg, 'channel', 'topic', '')
1912
2147
  method = self.safe_value(methods, topic)
1913
2148
  if method is not None:
1914
2149
  method(client, message)
@@ -1984,7 +2219,7 @@ class bitget(bitgetAsync):
1984
2219
  arg = self.safe_dict(message, 'arg', {})
1985
2220
  instType = self.safe_string_lower(arg, 'instType')
1986
2221
  type = 'spot' if (instType == 'spot') else 'contract'
1987
- instId = self.safe_string(arg, 'instId')
2222
+ instId = self.safe_string_2(arg, 'instId', 'symbol')
1988
2223
  market = self.safe_market(instId, None, None, type)
1989
2224
  symbol = market['symbol']
1990
2225
  messageHash = 'unsubscribe:ticker:' + market['symbol']
@@ -2003,18 +2238,34 @@ class bitget(bitgetAsync):
2003
2238
  #
2004
2239
  # {"event":"unsubscribe","arg":{"instType":"SPOT","channel":"candle1m","instId":"BTCUSDT"}}
2005
2240
  #
2241
+ # UTA
2242
+ #
2243
+ # {"event":"unsubscribe","arg":{"instType":"spot","topic":"kline","symbol":"BTCUSDT","interval":"1m"}}
2244
+ #
2006
2245
  arg = self.safe_dict(message, 'arg', {})
2007
2246
  instType = self.safe_string_lower(arg, 'instType')
2008
2247
  type = 'spot' if (instType == 'spot') else 'contract'
2009
- instId = self.safe_string(arg, 'instId')
2010
- channel = self.safe_string(arg, 'channel')
2011
- interval = channel.replace('candle', '')
2248
+ instId = self.safe_string_2(arg, 'instId', 'symbol')
2249
+ channel = self.safe_string_2(arg, 'channel', 'topic')
2250
+ interval = self.safe_string(arg, 'interval')
2251
+ isUta = None
2252
+ if interval is None:
2253
+ isUta = False
2254
+ interval = channel.replace('candle', '')
2255
+ else:
2256
+ isUta = True
2012
2257
  timeframes = self.safe_value(self.options, 'timeframes')
2013
2258
  timeframe = self.find_timeframe(interval, timeframes)
2014
2259
  market = self.safe_market(instId, None, None, type)
2015
2260
  symbol = market['symbol']
2016
- messageHash = 'unsubscribe:candles:' + timeframe + ':' + market['symbol']
2017
- subMessageHash = 'candles:' + timeframe + ':' + symbol
2261
+ messageHash = None
2262
+ subMessageHash = None
2263
+ if isUta:
2264
+ messageHash = 'unsubscribe:kline:' + symbol
2265
+ subMessageHash = 'kline:' + symbol
2266
+ else:
2267
+ messageHash = 'unsubscribe:candles:' + timeframe + ':' + symbol
2268
+ subMessageHash = 'candles:' + timeframe + ':' + symbol
2018
2269
  if symbol in self.ohlcvs:
2019
2270
  if timeframe in self.ohlcvs[symbol]:
2020
2271
  del self.ohlcvs[symbol][timeframe]
@@ -2045,7 +2296,7 @@ class bitget(bitgetAsync):
2045
2296
  argsList = [self.safe_dict(message, 'arg', {})]
2046
2297
  for i in range(0, len(argsList)):
2047
2298
  arg = argsList[i]
2048
- channel = self.safe_string(arg, 'channel')
2299
+ channel = self.safe_string_2(arg, 'channel', 'topic')
2049
2300
  if channel == 'books':
2050
2301
  # for now only unWatchOrderBook is supporteod
2051
2302
  self.handle_order_book_un_subscription(client, message)
@@ -2055,4 +2306,6 @@ class bitget(bitgetAsync):
2055
2306
  self.handle_ticker_un_subscription(client, message)
2056
2307
  elif channel.startswith('candle'):
2057
2308
  self.handle_ohlcv_un_subscription(client, message)
2309
+ elif channel.startswith('kline'):
2310
+ self.handle_ohlcv_un_subscription(client, message)
2058
2311
  return message
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bitget
3
- Version: 0.0.82
3
+ Version: 0.0.84
4
4
  Summary: bitget crypto exchange api client
5
5
  Project-URL: Homepage, https://github.com/ccxt/ccxt
6
6
  Project-URL: Issues, https://github.com/ccxt/ccxt
@@ -780,7 +780,7 @@ You can also construct custom requests to available "implicit" endpoints
780
780
  ### WS Unified
781
781
 
782
782
  - `describe(self)`
783
- - `get_inst_type(self, market, params={})`
783
+ - `get_inst_type(self, market, uta: bool = False, params={})`
784
784
  - `watch_ticker(self, symbol: str, params={})`
785
785
  - `un_watch_ticker(self, symbol: str, params={})`
786
786
  - `watch_tickers(self, symbols: Strings = None, params={})`
@@ -1,11 +1,11 @@
1
1
  bitget/__init__.py,sha256=D5tG1_AjwXjMim3CPnCuWSheOXtq4vlSwVCS5ZG1bMQ,246
2
- bitget/ccxt/__init__.py,sha256=I9PUCJLUniiXrLxS2zqRjoHM6RuK2Ui31t33ItokWf8,6130
3
- bitget/ccxt/bitget.py,sha256=btIwpfkEJ1nXEMKHVxd1hykPMyivAwPj-ym2N_LdzlM,518995
2
+ bitget/ccxt/__init__.py,sha256=bhjUppzTIV1pAkFw4voNhDr2x1V1H1U5FYk6GlRJqj4,6130
3
+ bitget/ccxt/bitget.py,sha256=v7U-p48XIejR2OEV3xCBV4KkuifaJYqkhKILiWrxQas,518993
4
4
  bitget/ccxt/abstract/bitget.py,sha256=U3sRAK3oQJt2ujn-S0ci05HnOIHEad7CJvpDeTQfrYY,101038
5
- bitget/ccxt/async_support/__init__.py,sha256=ofKj3am3krc6247yqh0cRg5dGJR4lwg_tlZkcqWXXxg,4863
6
- bitget/ccxt/async_support/bitget.py,sha256=5LkBlqAw2FAK_qGza5hsVf0U0Hycxd6I4_SURsoJM74,521002
5
+ bitget/ccxt/async_support/__init__.py,sha256=OrWNftRHccFCGxS1-vfed7yaul7GAyr3Yz5tvCkqbD0,4863
6
+ bitget/ccxt/async_support/bitget.py,sha256=nxjRW9dJ5H7HHp-p9yf_ciwpKkXxK0IQY_ERTktNTXE,521000
7
7
  bitget/ccxt/async_support/base/__init__.py,sha256=aVYSsFi--b4InRs9zDN_wtCpj8odosAB726JdUHavrk,67
8
- bitget/ccxt/async_support/base/exchange.py,sha256=YMd_vhLNV7Ay-PhgjeEmksr2-wUhQk6TSj_gsaJhLYg,121268
8
+ bitget/ccxt/async_support/base/exchange.py,sha256=f8NMSn7dvE2ZuL71iRKyinVbyafvacm5Zj4WcQ4TWck,121268
9
9
  bitget/ccxt/async_support/base/throttler.py,sha256=tvDVcdRUVYi8fZRlEcnqtgzcgB_KMUMRs5Pu8tuU-tU,1847
10
10
  bitget/ccxt/async_support/base/ws/__init__.py,sha256=uockzpLuwntKGZbs5EOWFe-Zg-k6Cj7GhNJLc_RX0so,1791
11
11
  bitget/ccxt/async_support/base/ws/cache.py,sha256=xf2VOtfUwloxSlIQ39M1RGZHWQzyS9IGhB5NX6cDcAc,8370
@@ -17,11 +17,11 @@ bitget/ccxt/async_support/base/ws/order_book_side.py,sha256=GhnGUt78pJ-AYL_Dq9pr
17
17
  bitget/ccxt/base/__init__.py,sha256=eTx1OE3HJjspFUQjGm6LBhaQiMKJnXjkdP-JUXknyQ0,1320
18
18
  bitget/ccxt/base/decimal_to_precision.py,sha256=3XI30u9YudHbTA438397u5rkdlXa3atxwZEfUus3C4k,6803
19
19
  bitget/ccxt/base/errors.py,sha256=OGhWNvNtRlJOzFx-n1x3ZjTnaPpfWH0Vc0xACS-MeDw,5012
20
- bitget/ccxt/base/exchange.py,sha256=W1B4s4X8fIXF9lvAte_LmBb8FYHtFF0qATcJgBfXEYA,334124
20
+ bitget/ccxt/base/exchange.py,sha256=wXcblsdBqxUWtSbKu1hDTey2mOUhXe05MT7b91Mztno,334337
21
21
  bitget/ccxt/base/precise.py,sha256=koce64Yrp6vFbGijJtUt-QQ6XhJgeGTCksZ871FPp_A,8886
22
22
  bitget/ccxt/base/types.py,sha256=Gvbogh9i7pPH7Z18xesYeDPribqqwq8uKpOv-YODFBs,11505
23
- bitget/ccxt/pro/__init__.py,sha256=8n9Kb_Y5ZxS938L_8sGb2ldWUL5Z4Clx1D0Tp3RYYLs,4177
24
- bitget/ccxt/pro/bitget.py,sha256=t0wi3SrGCpHBz3jT8wLpD5bRnZhSe2PCdpFfEn2f-9w,90386
23
+ bitget/ccxt/pro/__init__.py,sha256=aclE2S1jDsTNzAhGI_S75WZVCYLRnRO5helH8RmJuqk,4177
24
+ bitget/ccxt/pro/bitget.py,sha256=p4XPcaqmc581alL-UoX08RMgGQYN6Zz0nRoUaP1qmKM,101076
25
25
  bitget/ccxt/static_dependencies/README.md,sha256=3TCvhhn09_Cqf9BDDpao1V7EfKHDpQ6k9oWRsLFixpU,18
26
26
  bitget/ccxt/static_dependencies/__init__.py,sha256=tzFje8cloqmiIE6kola3EaYC0SnD1izWnri69hzHsSw,168
27
27
  bitget/ccxt/static_dependencies/ecdsa/__init__.py,sha256=Xaj0G79BLtBt2YZcOOMV8qOlQZ7fIJznNiHhiEEZfQA,594
@@ -281,6 +281,6 @@ bitget/ccxt/static_dependencies/toolz/curried/exceptions.py,sha256=gKFOHDIayAWnX
281
281
  bitget/ccxt/static_dependencies/toolz/curried/operator.py,sha256=ML92mknkAwzBl2NCm-4werSUmJEtSHNY9NSzhseNM9s,525
282
282
  bitget/ccxt/static_dependencies/typing_inspect/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
283
283
  bitget/ccxt/static_dependencies/typing_inspect/typing_inspect.py,sha256=5gIWomLPfuDpgd3gX1GlnX0MuXM3VorR4j2W2qXORiQ,28269
284
- bitget-0.0.82.dist-info/METADATA,sha256=_Bl1m9wpYuhgV_4s8mxEtxv49hNZI6eAxW70ahwbKvY,44855
285
- bitget-0.0.82.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
286
- bitget-0.0.82.dist-info/RECORD,,
284
+ bitget-0.0.84.dist-info/METADATA,sha256=T2WyP5f7a_Zf3IPcpO44AuB6LgTSIuDF29xa4WH4jZs,44874
285
+ bitget-0.0.84.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
286
+ bitget-0.0.84.dist-info/RECORD,,