Skip to content

Commit db43ea3

Browse files
committed
Cleanup + bypass combos on deribit while support is added
1 parent 43b6fba commit db43ea3

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

cryptofeed/defines.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@
123123
FUTURES = 'futures'
124124
PERPETUAL = 'perpetual'
125125
OPTION = 'option'
126+
OPTION_COMBO = 'option_combo'
127+
FUTURE_COMBO = 'future_combo'
126128
SPOT = 'spot'
127129
CALL = 'call'
128130
PUT = 'put'

cryptofeed/exchanges/bittrex.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ async def candle(self, msg: dict, timestamp: float):
242242
raw=msg
243243
)
244244
await self.callback(CANDLES, c, timestamp)
245-
245+
246246
async def order(self, msg: dict, timestamp: float):
247247
"""
248248
example message:
@@ -270,7 +270,7 @@ async def order(self, msg: dict, timestamp: float):
270270
status = order['status']
271271
if status == 'new':
272272
status = SUBMITTING
273-
# There was no obsevation made, that there are more than "OPEN" and "CLOSED". Needs Support clarification with BITTREX.
273+
# There was no observation made, that there are more than "OPEN" and "CLOSED". Needs Support clarification with BITTREX.
274274
elif status == 'OPEN':
275275
status = OPEN
276276
elif status == 'CLOSED':
@@ -286,11 +286,11 @@ async def order(self, msg: dict, timestamp: float):
286286
status,
287287
LIMIT if order['type'].lower() == 'limit' else MARKET,
288288
Decimal(order['limit']) if 'limit' in order else None,
289-
Decimal(order['fillQuantity']), # the filled Size
290-
remainingSize, # the remaining Size
289+
Decimal(order['fillQuantity']), # the filled Size
290+
remainingSize, # the remaining Size
291291
timestamp=str(order['createdAt']),
292-
client_order_id= order['clientOrderId'] if 'clientOrderId' in order else None,
293-
#account=self.subaccount,
292+
client_order_id=order['clientOrderId'] if 'clientOrderId' in order else None,
293+
# account=self.subaccount,
294294
raw=msg
295295
)
296296
await self.callback(ORDER_INFO, oi, timestamp)
@@ -351,9 +351,9 @@ async def message_handler(self, msg: str, conn, timestamp: float):
351351
data = json.loads(zlib.decompress(base64.b64decode(message), -zlib.MAX_WBITS).decode(), parse_float=Decimal)
352352
await self.balance(data, timestamp)
353353
elif update['M'] == 'authenticationExpiring':
354-
#WARNING : BITTREX: Invalid message type {'C': 'd-942EDED9-B,0|Bjh,1|Bji,3|Bjj,0|Bjk,0', 'M': [{'H': 'C3', 'M': 'authenticationExpiring', 'A': []}]}
354+
# WARNING : BITTREX: Invalid message type {'C': 'd-942EDED9-B,0|Bjh,1|Bji,3|Bjj,0|Bjk,0', 'M': [{'H': 'C3', 'M': 'authenticationExpiring', 'A': []}]}
355355
LOG.debug("%s: private subscription authentication expired. %s", self.id, msg)
356-
else:
356+
else:
357357
LOG.warning("%s: Invalid message type %s", self.id, msg)
358358
elif 'E' in msg:
359359
LOG.error("%s: Error from exchange %s", self.id, msg)
@@ -364,7 +364,7 @@ async def generate_token(self, conn: AsyncConnection):
364364
content = timestamp + random_content
365365
signed_content = hmac.new(self.key_secret.encode(), content.encode(), hashlib.sha512).hexdigest()
366366

367-
msg = {'A': [self.key_id, timestamp, random_content, signed_content], 'H': 'c3', 'I': 0, 'M': 'Authenticate'}
367+
msg = {'A': [self.key_id, timestamp, random_content, signed_content], 'H': 'c3', 'I': 0, 'M': 'Authenticate'}
368368
# There is only subacounts on BITTREX for institutional customers.
369369
# if self.subaccount:
370370
# msg['args']['subaccount'] = self.subaccount
@@ -373,7 +373,7 @@ async def generate_token(self, conn: AsyncConnection):
373373
async def authenticate(self, conn: AsyncConnection):
374374
if self.requires_authentication:
375375
await self.generate_token(conn)
376-
376+
377377
async def subscribe(self, conn: AsyncConnection):
378378
self.__reset()
379379
# H: Hub, M: Message, A: Args, I: Internal ID
@@ -384,12 +384,12 @@ async def subscribe(self, conn: AsyncConnection):
384384
channel = self.exchange_channel_to_std(chan)
385385
i = 1
386386
# If we subscribe to ORDER_INFO, then that is registered for all symbols in our account.
387-
##if channel in (ORDER_INFO, BALANCES):
387+
# if channel in (ORDER_INFO, BALANCES):
388388
if self.is_authenticated_channel(self.exchange_channel_to_std(chan)):
389-
msg = {'A': ([chan],) , 'H': 'c3', 'I': i, 'M': 'Subscribe'}
389+
msg = {'A': ([chan],), 'H': 'c3', 'I': i, 'M': 'Subscribe'}
390390
await conn.write(json.dumps(msg))
391391
i += 1
392-
else:
392+
else:
393393
for symbol in self.subscription[chan]:
394394
if channel == L2_BOOK:
395395
msg = {'A': ([chan.format(symbol, self.__depth())],), 'H': 'c3', 'I': i, 'M': 'Subscribe'}
@@ -406,9 +406,8 @@ async def subscribe(self, conn: AsyncConnection):
406406
interval = 'HOUR_1'
407407
elif self.candle_interval == '1d':
408408
interval = 'DAY_1'
409-
msg = {'A': ([chan.format(symbol, interval)],), 'H': 'c3', 'I': i, 'M': 'Subscribe'}
409+
msg = {'A': ([chan.format(symbol, interval)],), 'H': 'c3', 'I': i, 'M': 'Subscribe'}
410410
else:
411411
LOG.error("%s: invalid subscription for channel %s", channel)
412412
await conn.write(json.dumps(msg))
413413
i += 1
414-

cryptofeed/exchanges/deribit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ def _parse_symbol_data(cls, data: list) -> Tuple[Dict, Dict]:
6161
quote = e['quote_currency']
6262
stype = e['kind'] if e['settlement_period'] != 'perpetual' else PERPETUAL
6363
otype = e.get('option_type')
64+
if stype in ('option_combo', 'future_combo'):
65+
continue
6466
strike_price = e.get('strike')
6567
strike_price = int(strike_price) if strike_price else None
6668
expiry = e['expiration_timestamp'] / 1000

0 commit comments

Comments
 (0)