Skip to content

Commit

Permalink
fixed some mypy bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
scientes committed Apr 8, 2021
1 parent fd232e9 commit 5278f0d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
9 changes: 2 additions & 7 deletions src/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@


class PricePath:
def __init__(self, exchanges: list = None, gdict: dict = None, cache: dict = None):
if not gdict:
gdict = {}
if not cache:
cache = {}
def __init__(self, exchanges: list = [], gdict: dict = {}, cache: dict = {}):
if not exchanges:
exchanges = ["binance", "coinbasepro"]
self.gdict = gdict
self.cache = cache
self.priority = {}
self.priority : dict= {}
allpairs = []

for exchange_id in exchanges:
Expand Down Expand Up @@ -249,7 +245,6 @@ def get_active_timeframe(path, starttimestamp=0, stoptimestamp=-1):

if __name__ == "__main__":
g = PricePath()
allpairs = []
start = "IOTA"
to = "EUR"
preferredexchange = "binance"
Expand Down
11 changes: 4 additions & 7 deletions src/price_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ class PriceData:
def __init__(self):
self.path = PricePath()

def __init__(self):
self.path = PricePath()

def get_db_path(self, platform: str) -> Path:
return Path(config.DATA_PATH, f"{platform}.db")

Expand Down Expand Up @@ -426,13 +423,13 @@ def get_cost(

def get_candles(self, start: int, stop: int, symbol: str, exchange: str) -> list:
exchange_class = getattr(ccxt, exchange)
exchange = exchange_class()
if exchange.has["fetchOHLCV"]:
sleep(exchange.rateLimit / 1000) # time.sleep wants seconds
exchange_obj = exchange_class()
if exchange_obj.has["fetchOHLCV"]:
sleep(exchange_obj.rateLimit / 1000) # time.sleep wants seconds
# get 2min before and after range
startval = start - 1000 * 60 * 2
rang = max(int((stop - start) / 1000 / 60) + 2, 1)
return exchange.fetch_ohlcv(symbol, "1m", startval, rang)
return list(exchange_obj.fetch_ohlcv(symbol, "1m", startval, rang))
else:
log.error(
"fetchOHLCV not implemented on exchange, skipping priceloading using ohlcv"
Expand Down

0 comments on commit 5278f0d

Please sign in to comment.