Merge pull request #2019 from freqtrade/small/cleanups
[Minor] Small code cleanups
This commit is contained in:
commit
3ae94520c3
@ -17,7 +17,7 @@ from freqtrade.state import RunMode
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DataProvider(object):
|
||||
class DataProvider():
|
||||
|
||||
def __init__(self, config: dict, exchange: Exchange) -> None:
|
||||
self._config = config
|
||||
@ -81,11 +81,14 @@ class DataProvider(object):
|
||||
# TODO: Implement me
|
||||
pass
|
||||
|
||||
def orderbook(self, pair: str, max: int):
|
||||
def orderbook(self, pair: str, maximum: int):
|
||||
"""
|
||||
return latest orderbook data
|
||||
:param pair: pair to get the data for
|
||||
:param maximum: Maximum number of orderbook entries to query
|
||||
:return: dict including bids/asks with a total of `maximum` entries.
|
||||
"""
|
||||
return self._exchange.get_order_book(pair, max)
|
||||
return self._exchange.get_order_book(pair, maximum)
|
||||
|
||||
@property
|
||||
def runmode(self) -> RunMode:
|
||||
|
@ -217,7 +217,8 @@ class Telegram(RPC):
|
||||
|
||||
"*Open Order:* `{open_order}`" if r['open_order'] else ""
|
||||
]
|
||||
messages.append("\n".join(filter(None, lines)).format(**r))
|
||||
# Filter empty lines using list-comprehension
|
||||
messages.append("\n".join([l for l in lines if l]).format(**r))
|
||||
|
||||
for msg in messages:
|
||||
self._send_msg(msg, bot=bot)
|
||||
|
@ -69,8 +69,8 @@ def test_load_strategy(result):
|
||||
|
||||
|
||||
def test_load_strategy_base64(result):
|
||||
with open("freqtrade/tests/strategy/test_strategy.py", "r") as file:
|
||||
encoded_string = urlsafe_b64encode(file.read().encode("utf-8")).decode("utf-8")
|
||||
with open("freqtrade/tests/strategy/test_strategy.py", "rb") as file:
|
||||
encoded_string = urlsafe_b64encode(file.read()).decode("utf-8")
|
||||
resolver = StrategyResolver({'strategy': 'TestStrategy:{}'.format(encoded_string)})
|
||||
assert 'adx' in resolver.strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
# pragma pylint: disable=protected-access, too-many-lines, invalid-name, too-many-arguments
|
||||
|
||||
import logging
|
||||
import re
|
||||
import time
|
||||
from copy import deepcopy
|
||||
from unittest.mock import MagicMock, PropertyMock
|
||||
@ -1419,8 +1418,7 @@ def test_update_trade_state(mocker, default_conf, limit_buy_order, caplog) -> No
|
||||
# Assert we call handle_trade() if trade is feasible for execution
|
||||
freqtrade.update_trade_state(trade)
|
||||
|
||||
regexp = re.compile('Found open order for.*')
|
||||
assert filter(regexp.match, caplog.record_tuples)
|
||||
assert log_has_re('Found open order for.*', caplog.record_tuples)
|
||||
|
||||
|
||||
def test_update_trade_state_withorderdict(default_conf, trades_for_order, limit_buy_order, mocker):
|
||||
@ -1941,14 +1939,11 @@ def test_check_handle_timedout_exception(default_conf, ticker, mocker, caplog) -
|
||||
)
|
||||
|
||||
Trade.session.add(trade_buy)
|
||||
regexp = re.compile(
|
||||
'Cannot query order for Trade(id=1, pair=ETH/BTC, amount=90.99181073, '
|
||||
'open_rate=0.00001099, open_since=10 hours ago) due to Traceback (most '
|
||||
'recent call last):\n.*'
|
||||
)
|
||||
|
||||
freqtrade.check_handle_timedout()
|
||||
assert filter(regexp.match, caplog.record_tuples)
|
||||
assert log_has_re(r'Cannot query order for Trade\(id=1, pair=ETH/BTC, amount=90.99181073, '
|
||||
r'open_rate=0.00001099, open_since=10 hours ago\) due to Traceback \(most '
|
||||
r'recent call last\):\n.*', caplog.record_tuples)
|
||||
|
||||
|
||||
def test_handle_timedout_limit_buy(mocker, default_conf) -> None:
|
||||
|
@ -23,7 +23,7 @@ def fig_generating_mock(fig, *args, **kwargs):
|
||||
|
||||
|
||||
def find_trace_in_fig_data(data, search_string: str):
|
||||
matches = filter(lambda x: x.name == search_string, data)
|
||||
matches = (d for d in data if d.name == search_string)
|
||||
return next(matches)
|
||||
|
||||
|
||||
|
@ -13,4 +13,4 @@ def test_talib_bollingerbands_near_zero_values():
|
||||
{'close': 0.00000014}
|
||||
])
|
||||
bollinger = ta.BBANDS(inputs, matype=0, timeperiod=2)
|
||||
assert (bollinger['upperband'][3] != bollinger['middleband'][3])
|
||||
assert bollinger['upperband'][3] != bollinger['middleband'][3]
|
||||
|
Loading…
Reference in New Issue
Block a user