ccxt 4.4.64__py2.py3-none-any.whl → 4.4.67__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/__init__.py +5 -3
- ccxt/abstract/cryptomus.py +20 -0
- ccxt/abstract/derive.py +117 -0
- ccxt/abstract/tradeogre.py +1 -0
- ccxt/abstract/whitebit.py +16 -0
- ccxt/async_support/__init__.py +5 -3
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/binance.py +5 -3
- ccxt/async_support/bitget.py +22 -12
- ccxt/async_support/bitrue.py +5 -2
- ccxt/async_support/cryptocom.py +2 -0
- ccxt/async_support/cryptomus.py +1041 -0
- ccxt/async_support/derive.py +2530 -0
- ccxt/async_support/gate.py +5 -1
- ccxt/async_support/htx.py +19 -5
- ccxt/async_support/hyperliquid.py +108 -68
- ccxt/async_support/paradex.py +51 -12
- ccxt/async_support/tradeogre.py +131 -13
- ccxt/async_support/whitebit.py +276 -2
- ccxt/base/errors.py +0 -6
- ccxt/base/exchange.py +8 -1
- ccxt/binance.py +5 -3
- ccxt/bitget.py +22 -12
- ccxt/bitrue.py +5 -2
- ccxt/cryptocom.py +2 -0
- ccxt/cryptomus.py +1041 -0
- ccxt/derive.py +2529 -0
- ccxt/gate.py +5 -1
- ccxt/htx.py +19 -5
- ccxt/hyperliquid.py +108 -68
- ccxt/paradex.py +51 -12
- ccxt/pro/__init__.py +3 -3
- ccxt/pro/bybit.py +3 -2
- ccxt/pro/derive.py +704 -0
- ccxt/pro/gate.py +5 -2
- ccxt/pro/hyperliquid.py +3 -3
- ccxt/test/tests_async.py +36 -3
- ccxt/test/tests_sync.py +36 -3
- ccxt/tradeogre.py +131 -13
- ccxt/whitebit.py +276 -2
- {ccxt-4.4.64.dist-info → ccxt-4.4.67.dist-info}/METADATA +14 -10
- {ccxt-4.4.64.dist-info → ccxt-4.4.67.dist-info}/RECORD +45 -42
- ccxt/abstract/currencycom.py +0 -68
- ccxt/async_support/currencycom.py +0 -2070
- ccxt/currencycom.py +0 -2070
- ccxt/pro/currencycom.py +0 -536
- {ccxt-4.4.64.dist-info → ccxt-4.4.67.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.64.dist-info → ccxt-4.4.67.dist-info}/WHEEL +0 -0
- {ccxt-4.4.64.dist-info → ccxt-4.4.67.dist-info}/top_level.txt +0 -0
ccxt/pro/currencycom.py
DELETED
@@ -1,536 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
# PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
4
|
-
# https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
5
|
-
|
6
|
-
import ccxt.async_support
|
7
|
-
from ccxt.async_support.base.ws.cache import ArrayCache, ArrayCacheByTimestamp
|
8
|
-
import hashlib
|
9
|
-
from ccxt.base.types import Any, Balances, Int, OrderBook, Ticker, Trade
|
10
|
-
from ccxt.async_support.base.ws.client import Client
|
11
|
-
from typing import List
|
12
|
-
from ccxt.base.precise import Precise
|
13
|
-
|
14
|
-
|
15
|
-
class currencycom(ccxt.async_support.currencycom):
|
16
|
-
|
17
|
-
def describe(self) -> Any:
|
18
|
-
return self.deep_extend(super(currencycom, self).describe(), {
|
19
|
-
'has': {
|
20
|
-
'ws': True,
|
21
|
-
'watchBalance': True,
|
22
|
-
'watchTicker': True,
|
23
|
-
'watchTickers': False, # for now
|
24
|
-
'watchTrades': True,
|
25
|
-
'watchOrderBook': True,
|
26
|
-
# 'watchStatus': True,
|
27
|
-
# 'watchHeartbeat': True,
|
28
|
-
'watchOHLCV': True,
|
29
|
-
},
|
30
|
-
'urls': {
|
31
|
-
'api': {
|
32
|
-
'ws': 'wss://api-adapter.backend.currency.com/connect',
|
33
|
-
},
|
34
|
-
},
|
35
|
-
'options': {
|
36
|
-
'tradesLimit': 1000,
|
37
|
-
'OHLCVLimit': 1000,
|
38
|
-
# WS timeframes differ from REST timeframes
|
39
|
-
'timeframes': {
|
40
|
-
'1m': 'M1',
|
41
|
-
'3m': 'M3',
|
42
|
-
'5m': 'M5',
|
43
|
-
'15m': 'M15',
|
44
|
-
'30m': 'M30',
|
45
|
-
'1h': 'H1',
|
46
|
-
'4h': 'H4',
|
47
|
-
'1d': 'D1',
|
48
|
-
'1w': 'W1',
|
49
|
-
},
|
50
|
-
},
|
51
|
-
'streaming': {
|
52
|
-
# okex does not support built-in ws protocol-level ping-pong
|
53
|
-
# instead it requires a custom text-based ping-pong
|
54
|
-
'ping': self.ping,
|
55
|
-
'keepAlive': 20000,
|
56
|
-
},
|
57
|
-
})
|
58
|
-
|
59
|
-
def ping(self, client: Client):
|
60
|
-
# custom ping-pong
|
61
|
-
requestId = str(self.request_id())
|
62
|
-
return {
|
63
|
-
'destination': 'ping',
|
64
|
-
'correlationId': requestId,
|
65
|
-
'payload': {},
|
66
|
-
}
|
67
|
-
|
68
|
-
def handle_pong(self, client: Client, message):
|
69
|
-
client.lastPong = self.milliseconds()
|
70
|
-
return message
|
71
|
-
|
72
|
-
def handle_balance(self, client: Client, message, subscription):
|
73
|
-
#
|
74
|
-
# {
|
75
|
-
# "status": "OK",
|
76
|
-
# "correlationId": "1",
|
77
|
-
# "payload": {
|
78
|
-
# "makerCommission": 0.2,
|
79
|
-
# "takerCommission": 0.2,
|
80
|
-
# "buyerCommission": 0.2,
|
81
|
-
# "sellerCommission": 0.2,
|
82
|
-
# "canTrade": True,
|
83
|
-
# "canWithdraw": True,
|
84
|
-
# "canDeposit": True,
|
85
|
-
# "updateTime": 1596742699,
|
86
|
-
# "balances": [
|
87
|
-
# {
|
88
|
-
# "accountId": 5470306579272968,
|
89
|
-
# "collateralCurrency": True,
|
90
|
-
# "asset": "ETH",
|
91
|
-
# "free": 0,
|
92
|
-
# "locked": 0,
|
93
|
-
# "default": False
|
94
|
-
# },
|
95
|
-
# {
|
96
|
-
# "accountId": 5470310874305732,
|
97
|
-
# "collateralCurrency": True,
|
98
|
-
# "asset": "USD",
|
99
|
-
# "free": 47.82576736,
|
100
|
-
# "locked": 1.187925,
|
101
|
-
# "default": True
|
102
|
-
# },
|
103
|
-
# ]
|
104
|
-
# }
|
105
|
-
# }
|
106
|
-
#
|
107
|
-
payload = self.safe_value(message, 'payload')
|
108
|
-
balance = self.parse_balance(payload)
|
109
|
-
self.balance = self.extend(self.balance, balance)
|
110
|
-
messageHash = self.safe_string(subscription, 'messageHash')
|
111
|
-
client.resolve(self.balance, messageHash)
|
112
|
-
if messageHash in client.subscriptions:
|
113
|
-
del client.subscriptions[messageHash]
|
114
|
-
|
115
|
-
def handle_ticker(self, client: Client, message, subscription):
|
116
|
-
#
|
117
|
-
# {
|
118
|
-
# "status": "OK",
|
119
|
-
# "correlationId": "1",
|
120
|
-
# "payload": {
|
121
|
-
# "tickers": [
|
122
|
-
# {
|
123
|
-
# "symbol": "BTC/USD_LEVERAGE",
|
124
|
-
# "priceChange": "484.05",
|
125
|
-
# "priceChangePercent": "4.14",
|
126
|
-
# "weightedAvgPrice": "11682.83",
|
127
|
-
# "prevClosePrice": "11197.70",
|
128
|
-
# "lastPrice": "11682.80",
|
129
|
-
# "lastQty": "0.25",
|
130
|
-
# "bidPrice": "11682.80",
|
131
|
-
# "askPrice": "11682.85",
|
132
|
-
# "openPrice": "11197.70",
|
133
|
-
# "highPrice": "11734.05",
|
134
|
-
# "lowPrice": "11080.95",
|
135
|
-
# "volume": "299.133",
|
136
|
-
# "quoteVolume": "3488040.3465",
|
137
|
-
# "openTime": 1596585600000,
|
138
|
-
# "closeTime": 1596654452674
|
139
|
-
# }
|
140
|
-
# ]
|
141
|
-
# }
|
142
|
-
# }
|
143
|
-
#
|
144
|
-
destination = '/api/v1/ticker/24hr'
|
145
|
-
payload = self.safe_value(message, 'payload')
|
146
|
-
tickers = self.safe_value(payload, 'tickers', [])
|
147
|
-
for i in range(0, len(tickers)):
|
148
|
-
ticker = self.parse_ticker(tickers[i])
|
149
|
-
symbol = ticker['symbol']
|
150
|
-
self.tickers[symbol] = ticker
|
151
|
-
messageHash = destination + ':' + symbol
|
152
|
-
client.resolve(ticker, messageHash)
|
153
|
-
if messageHash in client.subscriptions:
|
154
|
-
del client.subscriptions[messageHash]
|
155
|
-
|
156
|
-
def handle_trade(self, trade, market=None):
|
157
|
-
#
|
158
|
-
# {
|
159
|
-
# "price": 11668.55,
|
160
|
-
# "size": 0.001,
|
161
|
-
# "id": 1600300736,
|
162
|
-
# "ts": 1596653426822,
|
163
|
-
# "symbol": "BTC/USD_LEVERAGE",
|
164
|
-
# "orderId": "00a02503-0079-54c4-0000-00004020163c",
|
165
|
-
# "clientOrderId": "00a02503-0079-54c4-0000-482f0000754f",
|
166
|
-
# "buyer": False
|
167
|
-
# }
|
168
|
-
#
|
169
|
-
marketId = self.safe_string(trade, 'symbol')
|
170
|
-
symbol = self.safe_symbol(marketId, None, '/')
|
171
|
-
timestamp = self.safe_integer(trade, 'ts')
|
172
|
-
priceString = self.safe_string(trade, 'price')
|
173
|
-
amountString = self.safe_string(trade, 'size')
|
174
|
-
cost = self.parse_number(Precise.string_mul(priceString, amountString))
|
175
|
-
price = self.parse_number(priceString)
|
176
|
-
amount = self.parse_number(amountString)
|
177
|
-
id = self.safe_string(trade, 'id')
|
178
|
-
orderId = self.safe_string(trade, 'orderId')
|
179
|
-
buyer = self.safe_value(trade, 'buyer')
|
180
|
-
side = 'buy' if buyer else 'sell'
|
181
|
-
return {
|
182
|
-
'info': trade,
|
183
|
-
'timestamp': timestamp,
|
184
|
-
'datetime': self.iso8601(timestamp),
|
185
|
-
'symbol': symbol,
|
186
|
-
'id': id,
|
187
|
-
'order': orderId,
|
188
|
-
'type': None,
|
189
|
-
'takerOrMaker': None,
|
190
|
-
'side': side,
|
191
|
-
'price': price,
|
192
|
-
'amount': amount,
|
193
|
-
'cost': cost,
|
194
|
-
'fee': None,
|
195
|
-
}
|
196
|
-
|
197
|
-
def handle_trades(self, client: Client, message):
|
198
|
-
#
|
199
|
-
# {
|
200
|
-
# "status": "OK",
|
201
|
-
# "destination": "internal.trade",
|
202
|
-
# "payload": {
|
203
|
-
# "price": 11668.55,
|
204
|
-
# "size": 0.001,
|
205
|
-
# "id": 1600300736,
|
206
|
-
# "ts": 1596653426822,
|
207
|
-
# "symbol": "BTC/USD_LEVERAGE",
|
208
|
-
# "orderId": "00a02503-0079-54c4-0000-00004020163c",
|
209
|
-
# "clientOrderId": "00a02503-0079-54c4-0000-482f0000754f",
|
210
|
-
# "buyer": False
|
211
|
-
# }
|
212
|
-
# }
|
213
|
-
#
|
214
|
-
payload = self.safe_value(message, 'payload')
|
215
|
-
parsed = self.handle_trade(payload)
|
216
|
-
symbol = parsed['symbol']
|
217
|
-
# destination = self.safe_string(message, 'destination')
|
218
|
-
destination = 'trades.subscribe'
|
219
|
-
messageHash = destination + ':' + symbol
|
220
|
-
stored = self.safe_value(self.trades, symbol)
|
221
|
-
if stored is None:
|
222
|
-
limit = self.safe_integer(self.options, 'tradesLimit', 1000)
|
223
|
-
stored = ArrayCache(limit)
|
224
|
-
self.trades[symbol] = stored
|
225
|
-
stored.append(parsed)
|
226
|
-
client.resolve(stored, messageHash)
|
227
|
-
|
228
|
-
def find_timeframe(self, timeframe, defaultTimeframes=None):
|
229
|
-
timeframes = self.safe_value(self.options, 'timeframes', defaultTimeframes)
|
230
|
-
keys = list(timeframes.keys())
|
231
|
-
for i in range(0, len(keys)):
|
232
|
-
key = keys[i]
|
233
|
-
if timeframes[key] == timeframe:
|
234
|
-
return key
|
235
|
-
return None
|
236
|
-
|
237
|
-
def handle_ohlcv(self, client: Client, message):
|
238
|
-
#
|
239
|
-
# {
|
240
|
-
# "status": "OK",
|
241
|
-
# "destination": "ohlc.event",
|
242
|
-
# "payload": {
|
243
|
-
# "interval": "M1",
|
244
|
-
# "symbol": "BTC/USD_LEVERAGE",
|
245
|
-
# "t": 1596650940000,
|
246
|
-
# "h": 11670.05,
|
247
|
-
# "l": 11658.1,
|
248
|
-
# "o": 11668.55,
|
249
|
-
# "c": 11666.05
|
250
|
-
# }
|
251
|
-
# }
|
252
|
-
#
|
253
|
-
# destination = self.safe_string(message, 'destination')
|
254
|
-
destination = 'OHLCMarketData.subscribe'
|
255
|
-
payload = self.safe_value(message, 'payload', {})
|
256
|
-
interval = self.safe_string(payload, 'interval')
|
257
|
-
timeframe = self.find_timeframe(interval)
|
258
|
-
marketId = self.safe_string(payload, 'symbol')
|
259
|
-
market = self.safe_market(marketId)
|
260
|
-
symbol = market['symbol']
|
261
|
-
messageHash = destination + ':' + timeframe + ':' + symbol
|
262
|
-
result = [
|
263
|
-
self.safe_integer(payload, 't'),
|
264
|
-
self.safe_number(payload, 'o'),
|
265
|
-
self.safe_number(payload, 'h'),
|
266
|
-
self.safe_number(payload, 'l'),
|
267
|
-
self.safe_number(payload, 'c'),
|
268
|
-
None, # no volume v in OHLCV
|
269
|
-
]
|
270
|
-
self.ohlcvs[symbol] = self.safe_value(self.ohlcvs, symbol, {})
|
271
|
-
stored = self.safe_value(self.ohlcvs[symbol], timeframe)
|
272
|
-
if stored is None:
|
273
|
-
limit = self.safe_integer(self.options, 'OHLCVLimit', 1000)
|
274
|
-
stored = ArrayCacheByTimestamp(limit)
|
275
|
-
self.ohlcvs[symbol][timeframe] = stored
|
276
|
-
stored.append(result)
|
277
|
-
client.resolve(stored, messageHash)
|
278
|
-
|
279
|
-
def request_id(self):
|
280
|
-
reqid = self.sum(self.safe_integer(self.options, 'correlationId', 0), 1)
|
281
|
-
self.options['correlationId'] = reqid
|
282
|
-
return reqid
|
283
|
-
|
284
|
-
async def watch_public(self, destination, symbol, params={}):
|
285
|
-
await self.load_markets()
|
286
|
-
market = self.market(symbol)
|
287
|
-
symbol = market['symbol']
|
288
|
-
messageHash = destination + ':' + symbol
|
289
|
-
url = self.urls['api']['ws']
|
290
|
-
requestId = str(self.request_id())
|
291
|
-
request = self.deep_extend({
|
292
|
-
'destination': destination,
|
293
|
-
'correlationId': requestId,
|
294
|
-
'payload': {
|
295
|
-
'symbols': [market['id']],
|
296
|
-
},
|
297
|
-
}, params)
|
298
|
-
subscription = self.extend(request, {
|
299
|
-
'messageHash': messageHash,
|
300
|
-
'symbol': symbol,
|
301
|
-
})
|
302
|
-
return await self.watch(url, messageHash, request, messageHash, subscription)
|
303
|
-
|
304
|
-
async def watch_private(self, destination, params={}):
|
305
|
-
await self.load_markets()
|
306
|
-
messageHash = '/api/v1/account'
|
307
|
-
url = self.urls['api']['ws']
|
308
|
-
requestId = str(self.request_id())
|
309
|
-
payload: dict = {
|
310
|
-
'timestamp': self.milliseconds(),
|
311
|
-
'apiKey': self.apiKey,
|
312
|
-
}
|
313
|
-
auth = self.urlencode(self.keysort(payload))
|
314
|
-
request = self.deep_extend({
|
315
|
-
'destination': destination,
|
316
|
-
'correlationId': requestId,
|
317
|
-
'payload': payload,
|
318
|
-
}, params)
|
319
|
-
request['payload']['signature'] = self.hmac(self.encode(auth), self.encode(self.secret), hashlib.sha256)
|
320
|
-
subscription = self.extend(request, {
|
321
|
-
'messageHash': messageHash,
|
322
|
-
})
|
323
|
-
return await self.watch(url, messageHash, request, messageHash, subscription)
|
324
|
-
|
325
|
-
async def watch_balance(self, params={}) -> Balances:
|
326
|
-
"""
|
327
|
-
watch balance and get the amount of funds available for trading or funds locked in orders
|
328
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
329
|
-
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
|
330
|
-
"""
|
331
|
-
await self.load_markets()
|
332
|
-
return await self.watch_private('/api/v1/account', params)
|
333
|
-
|
334
|
-
async def watch_ticker(self, symbol: str, params={}) -> Ticker:
|
335
|
-
"""
|
336
|
-
watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
337
|
-
:param str symbol: unified symbol of the market to fetch the ticker for
|
338
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
339
|
-
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
340
|
-
"""
|
341
|
-
await self.load_markets()
|
342
|
-
market = self.market(symbol)
|
343
|
-
symbol = market['symbol']
|
344
|
-
destination = '/api/v1/ticker/24hr'
|
345
|
-
messageHash = destination + ':' + symbol
|
346
|
-
url = self.urls['api']['ws']
|
347
|
-
requestId = str(self.request_id())
|
348
|
-
request = self.deep_extend({
|
349
|
-
'destination': destination,
|
350
|
-
'correlationId': requestId,
|
351
|
-
'payload': {
|
352
|
-
'symbol': market['id'],
|
353
|
-
},
|
354
|
-
}, params)
|
355
|
-
subscription = self.extend(request, {
|
356
|
-
'messageHash': messageHash,
|
357
|
-
'symbol': symbol,
|
358
|
-
})
|
359
|
-
return await self.watch(url, messageHash, request, messageHash, subscription)
|
360
|
-
|
361
|
-
async def watch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
362
|
-
"""
|
363
|
-
get the list of most recent trades for a particular symbol
|
364
|
-
:param str symbol: unified symbol of the market to fetch trades for
|
365
|
-
:param int [since]: timestamp in ms of the earliest trade to fetch
|
366
|
-
:param int [limit]: the maximum amount of trades to fetch
|
367
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
368
|
-
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
|
369
|
-
"""
|
370
|
-
await self.load_markets()
|
371
|
-
symbol = self.symbol(symbol)
|
372
|
-
trades = await self.watch_public('trades.subscribe', symbol, params)
|
373
|
-
if self.newUpdates:
|
374
|
-
limit = trades.getLimit(symbol, limit)
|
375
|
-
return self.filter_by_since_limit(trades, since, limit, 'timestamp', True)
|
376
|
-
|
377
|
-
async def watch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
|
378
|
-
"""
|
379
|
-
watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
|
380
|
-
:param str symbol: unified symbol of the market to fetch the order book for
|
381
|
-
:param int [limit]: the maximum amount of order book entries to return
|
382
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
383
|
-
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
|
384
|
-
"""
|
385
|
-
await self.load_markets()
|
386
|
-
symbol = self.symbol(symbol)
|
387
|
-
orderbook = await self.watch_public('depthMarketData.subscribe', symbol, params)
|
388
|
-
return orderbook.limit()
|
389
|
-
|
390
|
-
async def watch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
|
391
|
-
"""
|
392
|
-
watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
393
|
-
:param str symbol: unified symbol of the market to fetch OHLCV data for
|
394
|
-
:param str timeframe: the length of time each candle represents
|
395
|
-
:param int [since]: timestamp in ms of the earliest candle to fetch
|
396
|
-
:param int [limit]: the maximum amount of candles to fetch
|
397
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
398
|
-
:returns int[][]: A list of candles ordered, open, high, low, close, volume
|
399
|
-
"""
|
400
|
-
await self.load_markets()
|
401
|
-
symbol = self.symbol(symbol)
|
402
|
-
destination = 'OHLCMarketData.subscribe'
|
403
|
-
messageHash = destination + ':' + timeframe
|
404
|
-
timeframes = self.safe_value(self.options, 'timeframes')
|
405
|
-
request: dict = {
|
406
|
-
'destination': destination,
|
407
|
-
'payload': {
|
408
|
-
'intervals': [
|
409
|
-
timeframes[timeframe],
|
410
|
-
],
|
411
|
-
},
|
412
|
-
}
|
413
|
-
ohlcv = await self.watch_public(messageHash, symbol, self.extend(request, params))
|
414
|
-
if self.newUpdates:
|
415
|
-
limit = ohlcv.getLimit(symbol, limit)
|
416
|
-
return self.filter_by_since_limit(ohlcv, since, limit, 0, True)
|
417
|
-
|
418
|
-
def handle_deltas(self, bookside, deltas):
|
419
|
-
prices = list(deltas.keys())
|
420
|
-
for i in range(0, len(prices)):
|
421
|
-
price = prices[i]
|
422
|
-
amount = deltas[price]
|
423
|
-
bookside.store(float(price), float(amount))
|
424
|
-
|
425
|
-
def handle_order_book(self, client: Client, message):
|
426
|
-
#
|
427
|
-
# {
|
428
|
-
# "status": "OK",
|
429
|
-
# "destination": "marketdepth.event",
|
430
|
-
# "payload": {
|
431
|
-
# "data": "{"ts":1596235401337,"bid":{"11366.85":0.2500,"11366.1":5.0000,"11365.6":0.5000,"11363.0":2.0000},"ofr":{"11366.9":0.2500,"11367.65":5.0000,"11368.15":0.5000}}",
|
432
|
-
# "symbol": "BTC/USD_LEVERAGE"
|
433
|
-
# }
|
434
|
-
# }
|
435
|
-
#
|
436
|
-
payload = self.safe_value(message, 'payload', {})
|
437
|
-
data = self.safe_value(payload, 'data', {})
|
438
|
-
marketId = self.safe_string(payload, 'symbol')
|
439
|
-
symbol = self.safe_symbol(marketId, None, '/')
|
440
|
-
# destination = self.safe_string(message, 'destination')
|
441
|
-
destination = 'depthMarketData.subscribe'
|
442
|
-
messageHash = destination + ':' + symbol
|
443
|
-
timestamp = self.safe_integer(data, 'ts')
|
444
|
-
# orderbook = self.safe_value(self.orderbooks, symbol)
|
445
|
-
if not (symbol in self.orderbooks):
|
446
|
-
self.orderbooks[symbol] = self.order_book()
|
447
|
-
orderbook = self.orderbooks[symbol]
|
448
|
-
orderbook.reset({
|
449
|
-
'symbol': symbol,
|
450
|
-
'timestamp': timestamp,
|
451
|
-
'datetime': self.iso8601(timestamp),
|
452
|
-
})
|
453
|
-
bids = self.safe_dict(data, 'bid', {})
|
454
|
-
asks = self.safe_dict(data, 'ofr', {})
|
455
|
-
self.handle_deltas(orderbook['bids'], bids)
|
456
|
-
self.handle_deltas(orderbook['asks'], asks)
|
457
|
-
self.orderbooks[symbol] = orderbook
|
458
|
-
client.resolve(orderbook, messageHash)
|
459
|
-
|
460
|
-
def handle_message(self, client: Client, message):
|
461
|
-
#
|
462
|
-
# {
|
463
|
-
# "status": "OK",
|
464
|
-
# "correlationId": "1",
|
465
|
-
# "payload": {
|
466
|
-
# "tickers": [
|
467
|
-
# {
|
468
|
-
# "symbol": "1COV",
|
469
|
-
# "priceChange": "-0.29",
|
470
|
-
# "priceChangePercent": "-0.80",
|
471
|
-
# "prevClosePrice": "36.33",
|
472
|
-
# "lastPrice": "36.04",
|
473
|
-
# "openPrice": "36.33",
|
474
|
-
# "highPrice": "36.46",
|
475
|
-
# "lowPrice": "35.88",
|
476
|
-
# "openTime": 1595548800000,
|
477
|
-
# "closeTime": 1595795305401
|
478
|
-
# }
|
479
|
-
# ]
|
480
|
-
# }
|
481
|
-
# }
|
482
|
-
#
|
483
|
-
# {
|
484
|
-
# "status": "OK",
|
485
|
-
# "destination": "marketdepth.event",
|
486
|
-
# "payload": {
|
487
|
-
# "data": "{"ts":1596235401337,"bid":{"11366.85":0.2500,"11366.1":5.0000,"11365.6":0.5000,"11363.0":2.0000},"ofr":{"11366.9":0.2500,"11367.65":5.0000,"11368.15":0.5000}}",
|
488
|
-
# "symbol": "BTC/USD_LEVERAGE"
|
489
|
-
# }
|
490
|
-
# }
|
491
|
-
#
|
492
|
-
# {
|
493
|
-
# "status": "OK",
|
494
|
-
# "destination": "internal.trade",
|
495
|
-
# "payload": {
|
496
|
-
# "price": 11634.75,
|
497
|
-
# "size": 0.001,
|
498
|
-
# "id": 1605492357,
|
499
|
-
# "ts": 1596263802399,
|
500
|
-
# "instrumentId": 45076691096786110,
|
501
|
-
# "orderId": "00a02503-0079-54c4-0000-0000401fff51",
|
502
|
-
# "clientOrderId": "00a02503-0079-54c4-0000-482b00002f17",
|
503
|
-
# "buyer": False
|
504
|
-
# }
|
505
|
-
# }
|
506
|
-
#
|
507
|
-
requestId = self.safe_string(message, 'correlationId')
|
508
|
-
if requestId is not None:
|
509
|
-
subscriptionsById = self.index_by(client.subscriptions, 'correlationId')
|
510
|
-
status = self.safe_string(message, 'status')
|
511
|
-
subscription = self.safe_value(subscriptionsById, requestId)
|
512
|
-
if subscription is not None:
|
513
|
-
if status == 'OK':
|
514
|
-
subscriptionDestination = self.safe_string(subscription, 'destination')
|
515
|
-
if subscriptionDestination is not None:
|
516
|
-
methods: dict = {
|
517
|
-
'/api/v1/ticker/24hr': self.handle_ticker,
|
518
|
-
'/api/v1/account': self.handle_balance,
|
519
|
-
}
|
520
|
-
method = self.safe_value(methods, subscriptionDestination)
|
521
|
-
if method is None:
|
522
|
-
return
|
523
|
-
else:
|
524
|
-
method(client, message, subscription)
|
525
|
-
return
|
526
|
-
destination = self.safe_string(message, 'destination')
|
527
|
-
if destination is not None:
|
528
|
-
methods: dict = {
|
529
|
-
'marketdepth.event': self.handle_order_book,
|
530
|
-
'internal.trade': self.handle_trades,
|
531
|
-
'ohlc.event': self.handle_ohlcv,
|
532
|
-
'ping': self.handle_pong,
|
533
|
-
}
|
534
|
-
method = self.safe_value(methods, destination)
|
535
|
-
if method is not None:
|
536
|
-
method(client, message)
|
File without changes
|
File without changes
|
File without changes
|