Skip to content

Commit

Permalink
fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
scientes committed Apr 8, 2021
1 parent 156a22a commit c8a63c0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/graph.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import datetime
from time import sleep, time_ns

import ccxt
import ccxt #type: ignore


class PricePath:
Expand All @@ -10,7 +10,7 @@ def __init__(self, exchanges: list = [], gdict: dict = {}, cache: dict = {}):
exchanges = ["binance", "coinbasepro"]
self.gdict = gdict
self.cache = cache
self.priority: dict = {}
self.priority : dict= {}
allpairs = []

for exchange_id in exchanges:
Expand All @@ -29,7 +29,7 @@ def __init__(self, exchanges: list = [], gdict: dict = {}, cache: dict = {}):
)
allpairs = list(set(allpairs))
# print("Total Pairs to check:", len(allpairs))
allpairs.sort(key=lambda x: x[3])
allpairs.sort(key=lambda x: x[3]) #type: ignore
for i in allpairs:
base = i[0]
quote = i[1]
Expand Down
24 changes: 12 additions & 12 deletions src/price_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from time import sleep
from typing import Any, Optional, Union

import ccxt
import ccxt #type: ignore
import requests

import config
Expand Down Expand Up @@ -434,7 +434,7 @@ def get_candles(self, start: int, stop: int, symbol: str, exchange: str) -> list
log.error(
"fetchOHLCV not implemented on exchange, skipping priceloading using ohlcv"
)
return None
return []

def _get_bulk_pair_data_path(
self,
Expand All @@ -443,7 +443,7 @@ def _get_bulk_pair_data_path(
reference_coin: str,
preferredexchange: str = "binance",
) -> list:
def merge_prices(a: list, b: list = None):
def merge_prices(a: list, b: list = []) -> list:
prices = []
if not b:
return a
Expand All @@ -456,12 +456,12 @@ def merge_prices(a: list, b: list = None):
prices.append((i[0], i[1] * factor))
return prices

timestamps = []
timestamppairs = []
timestamps: list = []
timestamppairs: list = []
maxminutes = (
300 # coinbasepro only allows a max of 300 minutes need a better solution
)
timestamps = (op.utc_time for op in operations)
timestamps = (op.utc_time for op in operations) # type: ignore
if not preferredexchange:
preferredexchange = "binance"

Expand Down Expand Up @@ -490,7 +490,7 @@ def merge_prices(a: list, b: list = None):
coin, reference_coin, first, last, preferredexchange=preferredexchange
)
for p in path:
tempdatalis = []
tempdatalis: list = []
printstr = [a[1]["symbol"] for a in p[1]]
log.debug(f"found path over {' -> '.join(printstr)}")
for i in range(len(p[1])):
Expand Down Expand Up @@ -525,7 +525,7 @@ def merge_prices(a: list, b: list = None):
)
)
tempdatalis[i].append(
(operation, min(ts, key=lambda x: x[0])[1][1])
(operation, min(ts, key=lambda x: x[0])[1][1]) # type: ignore
)
else:
tempdatalis = []
Expand All @@ -539,7 +539,7 @@ def merge_prices(a: list, b: list = None):
self.path.change_prio(printstr, 0.2)
break
else:
prices = []
prices: list = []
for d in tempdatalis:
prices = merge_prices(d, prices)
datacomb.extend(prices)
Expand All @@ -549,8 +549,8 @@ def merge_prices(a: list, b: list = None):
return datacomb

def preload_price_data_path(
self, operations: list, coin: str, exchange: str = None
):
self, operations: list, coin: str, exchange: str = ""
) -> None:

reference_coin = config.FIAT
# get pairs used for calculating the price
Expand All @@ -564,7 +564,7 @@ def preload_price_data_path(
self.get_db_path(op.platform), tablename, op.utc_time
)
]
operations_grouped = {}
operations_grouped:dict = {}
if operations_filtered:
for i in operations_filtered:
if i.coin == config.FIAT:
Expand Down

0 comments on commit c8a63c0

Please sign in to comment.