Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bmoscon committed Jul 22, 2021
1 parent 47e0015 commit f60e839
Show file tree
Hide file tree
Showing 65 changed files with 31,118 additions and 35,839 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[flake8]
ignore = E501,F405,F403
exclude = tests/*,docs/*,*.md,__init__.py,cryptofeed/exchanges.py,cryptofeed/providers.py
exclude = tests/*,docs/*,*.md,__init__.py,cryptofeed/exchanges.py
2 changes: 1 addition & 1 deletion cryptofeed/exchange/bequant.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _parse_symbol_data(cls, data: dict) -> Tuple[Dict, Dict]:
s = Symbol(base_currency, quote_currency)
ret[s.normalized] = symbol['id']
info['tick_size'][s.normalized] = symbol['tickSize']
info['instrument_type'][s.normalized] = SPOT
info['instrument_type'][s.normalized] = s.type

return ret, info

Expand Down
2 changes: 1 addition & 1 deletion cryptofeed/exchange/bitcoincom.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _parse_symbol_data(cls, data: dict) -> Tuple[Dict, Dict]:
s = Symbol(base_currency, quote_currency)
ret[s.normalized] = symbol['id']
info['tick_size'][s.normalized] = symbol['tickSize']
info['instrument_type'][s.normalized] = SPOT
info['instrument_type'][s.normalized] = s.type

return ret, info

Expand Down
2 changes: 1 addition & 1 deletion cryptofeed/exchange/bitfinex.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _parse_symbol_data(cls, data: list) -> Tuple[Dict, Dict]:

s = Symbol(base, quote)
ret[s.normalized] = "t" + p
info['instrument_type'][s.normalized] = SPOT
info['instrument_type'][s.normalized] = s.type
return ret, info

def __init__(self, symbols=None, channels=None, subscription=None, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion cryptofeed/exchange/bithumb.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _parse_symbol_data(cls, data: dict) -> Tuple[Dict, Dict]:
continue
s = Symbol(base_curr, quote_curr)
ret[s.normalized] = f"{base_curr}_{quote_curr}"
info['instrument_type'][s.normalized] = SPOT
info['instrument_type'][s.normalized] = s.type

return ret, {}

Expand Down
2 changes: 1 addition & 1 deletion cryptofeed/exchange/bitstamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _parse_symbol_data(cls, data: dict) -> Tuple[Dict, Dict]:
s = Symbol(base, quote)
symbol = d['url_symbol']
ret[s.normalized] = symbol
info['instrument_type'][s.normalized] = SPOT
info['instrument_type'][s.normalized] = s.type

return ret, info

Expand Down
2 changes: 1 addition & 1 deletion cryptofeed/exchange/bittrex.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def _parse_symbol_data(cls, data: dict) -> Tuple[Dict, Dict]:
continue
s = Symbol(e['baseCurrencySymbol'], e['quoteCurrencySymbol'])
ret[s.normalized] = e['symbol']
info['instrument_type'][s.normalized] = SPOT
info['instrument_type'][s.normalized] = s.type
return ret, info

def __init__(self, depth=500, candle_interval='1m', **kwargs):
Expand Down
6 changes: 3 additions & 3 deletions cryptofeed/exchange/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ def _parse_symbol_data(cls, data: dict) -> Tuple[Dict, Dict]:
info = {'instrument_type': {}}
ret = {}
for entry in data:
if data['status'] != 'open':
if entry['status'] != 'open':
continue
base, quote = entry['symbol'].split("-")
s = Symbol(base, quote)
ret[s.normalized] = data['symbol']
info['instrument_type'][s.normalized] = SPOT
ret[s.normalized] = entry['symbol']
info['instrument_type'][s.normalized] = s.type
return ret, info

def __init__(self, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion cryptofeed/exchange/gateio.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def _parse_symbol_data(cls, data: dict) -> Tuple[Dict, Dict]:
info = {'instrument_type': {}}

for entry in data:
if data["trade_status"] != "tradable":
if entry["trade_status"] != "tradable":
continue
s = Symbol(entry['base'], entry['quote'])
ret[s.normalized] = entry['id']
Expand Down
2 changes: 1 addition & 1 deletion cryptofeed/exchange/huobi.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _parse_symbol_data(cls, data: dict) -> Tuple[Dict, Dict]:
s = Symbol(base, quote)

ret[s.normalized] = e['symbol']
info['instrument_type'][s.normalized] = SPOT
info['instrument_type'][s.normalized] = s.type
return ret, info

def __init__(self, candle_interval='1m', **kwargs):
Expand Down
5 changes: 2 additions & 3 deletions cryptofeed/exchange/huobi_dm.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async def _book(self, msg: dict, timestamp: float):
'ch':'market.BTC_CW.depth.step0'
}
"""
pair = self.std_symbol_to_exchange_symbol(msg['ch'].split('.')[1])
pair = self.exchange_symbol_to_std_symbol(msg['ch'].split('.')[1])
data = msg['tick']
forced = pair not in self.l2_book

Expand Down Expand Up @@ -106,7 +106,7 @@ async def _trade(self, msg: dict, timestamp: float):
for trade in msg['tick']['data']:
await self.callback(TRADES,
feed=self.id,
symbol=self.std_symbol_to_exchange_symbol(msg['ch'].split('.')[1]),
symbol=self.exchange_symbol_to_std_symbol(msg['ch'].split('.')[1]),
order_id=trade['id'],
side=BUY if trade['direction'] == 'buy' else SELL,
amount=Decimal(trade['amount']),
Expand Down Expand Up @@ -144,7 +144,6 @@ async def subscribe(self, conn: AsyncConnection):
continue
for pair in self.subscription[chan]:
client_id += 1
pair = self.exchange_symbol_to_std_symbol(pair)
await conn.write(json.dumps(
{
"sub": f"market.{pair}.{chan}",
Expand Down
2 changes: 1 addition & 1 deletion cryptofeed/exchange/kraken.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _parse_symbol_data(cls, data: dict) -> Tuple[Dict, Dict]:
s = Symbol(base, quote)

ret[s.normalized] = data['result'][symbol]['wsname']
info['instrument_type'][s.normalized] = SPOT
info['instrument_type'][s.normalized] = s.type
return ret, {}

def __init__(self, candle_interval='1m', max_depth=1000, **kwargs):
Expand Down
1 change: 1 addition & 0 deletions cryptofeed/exchange/kucoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def _parse_symbol_data(cls, data: dict) -> Tuple[Dict, Dict]:
s = Symbol(symbol['baseCurrency'], symbol['quoteCurrency'])
info['tick_size'][s.normalized] = symbol['priceIncrement']
ret[s.normalized] = symbol['symbol']
info['instrument_type'][s.normalized] = s.type
return ret, info

def __init__(self, candle_interval='1m', **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion cryptofeed/exchange/okcoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _parse_symbol_data(cls, data: dict) -> Tuple[Dict, Dict]:
s = Symbol(e['base_currency'], e['quote_currency'])
ret[s.normalized] = e['instrument_id']
info['tick_size'][s.normalized] = e['tick_size']
info['instrument_type'][s.normalized] = SPOT
info['instrument_type'][s.normalized] = s.type
return ret, info

def __init__(self, **kwargs):
Expand Down
7 changes: 4 additions & 3 deletions cryptofeed/exchange/okex.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _parse_symbol_data(cls, data: list) -> Tuple[Dict, Dict]:
otype = PUT if otype == 'P' else CALL
elif stype == SWAP:
base, quote, _ = e['instId'].split("-")
print(base)

s = Symbol(base, quote, expiry_date=expiry, type=stype, option_type=otype, strike_price=strike)
ret[s.normalized] = e['instId']
info['tick_size'][s.normalized] = e['tickSz']
Expand Down Expand Up @@ -168,8 +168,9 @@ def get_channel_symbol_combinations(self):
continue
for symbol in self.subscription[chan]:
d = {}
instrument_type = self.instrument_type(symbol)
if instrument_type != 'swap' and 'funding' in chan:
sym = self.exchange_symbol_to_std_symbol(symbol)
instrument_type = self.instrument_type(sym)
if instrument_type != SWAP and 'funding' in chan:
continue # No funding for spot, futures and options
d.update({"channel": chan, "instId": symbol})
combos.append(d)
Expand Down
2 changes: 1 addition & 1 deletion cryptofeed/exchange/poloniex.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _parse_symbol_data(cls, data: dict) -> Tuple[Dict, Dict]:
quote, base = std.split("_")
s = Symbol(base, quote)
ret[s.normalized] = symbol
info['instrument_type'][s.normalized] = SPOT
info['instrument_type'][s.normalized] = s.type
return ret, info

def __init__(self, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion cryptofeed/exchange/probit.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _parse_symbol_data(cls, data: dict) -> Tuple[Dict, Dict]:
continue
s = Symbol(entry['base_currency_id'], entry['quote_currency_id'])
ret[s.normalized] = entry['id']
info['instrument_type'][s.normalized] = SPOT
info['instrument_type'][s.normalized] = s.type

return ret, info

Expand Down
6 changes: 3 additions & 3 deletions cryptofeed/exchange/upbit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from cryptofeed.symbols import Symbol
import logging
from decimal import Decimal
from typing import Dict, Tuple
Expand All @@ -11,6 +10,7 @@
from cryptofeed.defines import BID, ASK, BUY, L2_BOOK, SELL, SPOT, TICKER, TRADES, UPBIT
from cryptofeed.feed import Feed
from cryptofeed.standards import timestamp_normalize
from cryptofeed.symbols import Symbol


LOG = logging.getLogger('feedhandler')
Expand All @@ -26,10 +26,10 @@ def _parse_symbol_data(cls, data: dict) -> Tuple[Dict, Dict]:
ret = {}
info = {'instrument_type': {}}
for entry in data:
base, quote = entry['market'].split("-")
quote, base = entry['market'].split("-")
s = Symbol(base, quote)
ret[s.normalized] = entry['market']
info['instrument_type'][s.normalized] = SPOT
info['instrument_type'][s.normalized] = s.type
return ret, info

def __init__(self, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion cryptofeed/raw_data_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from collections import defaultdict
import functools
import ast
import json

from yapic import json
from aiofile import AIOFile

from cryptofeed.defines import HUOBI, UPBIT, OKEX, OKCOIN
Expand Down
4 changes: 2 additions & 2 deletions sample_data/BINANCE_FUTURES.0

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions sample_data/BINANCE_FUTURES.http.0.0

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions sample_data/BINANCE_FUTURES.http.4.0

This file was deleted.

Loading

0 comments on commit f60e839

Please sign in to comment.