add typehints and type: ignores

This commit is contained in:
xmatthias 2018-05-31 22:00:46 +02:00
parent cf34b84cf1
commit 3fb1dd02f1
4 changed files with 9 additions and 9 deletions

View File

@ -95,7 +95,7 @@ class Analyze(object):
Return ticker interval to use
:return: Ticker interval value to use
"""
return self.strategy.ticker_interval
return self.strategy.ticker_interval # type: ignore
def analyze_ticker(self, ticker_history: List[Dict]) -> DataFrame:
"""
@ -195,13 +195,13 @@ class Analyze(object):
:return True if bot should sell at current rate
"""
current_profit = trade.calc_profit_percent(current_rate)
if self.strategy.stoploss is not None and current_profit < self.strategy.stoploss:
if self.strategy.stoploss is not None and current_profit < self.strategy.stoploss: # type: ignore
logger.debug('Stop loss hit.')
return True
# Check if time matches and current rate is above threshold
time_diff = (current_time.timestamp() - trade.open_date.timestamp()) / 60
for duration, threshold in self.strategy.minimal_roi.items():
for duration, threshold in self.strategy.minimal_roi.items(): # type: ignore
if time_diff <= duration:
return False
if current_profit > threshold:

View File

@ -290,7 +290,7 @@ def get_ticker_history(pair: str, tick_interval: str, since_ms: Optional[int] =
# chached data was already downloaded
till_time_ms = min(till_time_ms, arrow.utcnow().shift(minutes=-10).timestamp * 1000)
data = []
data: List[Dict[Any, Any]] = []
while not since_ms or since_ms < till_time_ms:
data_part = _API.fetch_ohlcv(pair, timeframe=tick_interval, since=since_ms)

View File

@ -14,7 +14,7 @@ from argparse import Namespace
from functools import reduce
from math import exp
from operator import itemgetter
from typing import Dict, Any, Callable
from typing import Dict, Any, Callable, Optional
import numpy
import talib.abstract as ta
@ -60,7 +60,7 @@ class Hyperopt(Backtesting):
self.expected_max_profit = 3.0
# Configuration and data used by hyperopt
self.processed = None
self.processed: Optional[Dict[str, Any]] = None
# Hyperopt Trials
self.trials_file = os.path.join('user_data', 'hyperopt_trials.pickle')
@ -344,7 +344,7 @@ class Hyperopt(Backtesting):
"""
Return the space to use during Hyperopt
"""
spaces = {}
spaces: Dict = {}
if self.has_space('buy'):
spaces = {**spaces, **Hyperopt.indicator_space()}
if self.has_space('roi'):
@ -503,7 +503,7 @@ class Hyperopt(Backtesting):
)
if self.has_space('buy'):
self.analyze.populate_indicators = Hyperopt.populate_indicators
self.analyze.populate_indicators = Hyperopt.populate_indicators # type: ignore
self.processed = self.tickerdata_to_dataframe(data)
if self.config.get('mongodb'):

View File

@ -101,7 +101,7 @@ class StrategyResolver(object):
# Generate spec based on absolute path
spec = importlib.util.spec_from_file_location('user_data.strategies', module_path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
spec.loader.exec_module(module) # type: ignore
valid_strategies_gen = (
obj for name, obj in inspect.getmembers(module, inspect.isclass)