fix pep8 warnings
This commit is contained in:
parent
f6d85e021f
commit
95fe0f4dec
@ -60,7 +60,10 @@ def _process(dynamic_whitelist: Optional[int] = 0) -> bool:
|
||||
try:
|
||||
# Refresh whitelist based on wallet maintenance
|
||||
refresh_whitelist(
|
||||
gen_pair_whitelist(_CONF['stake_currency'], topn = dynamic_whitelist) if dynamic_whitelist else None
|
||||
gen_pair_whitelist(
|
||||
_CONF['stake_currency'],
|
||||
topn=dynamic_whitelist
|
||||
) if dynamic_whitelist else None
|
||||
)
|
||||
# Query trades from persistence layer
|
||||
trades = Trade.query.filter(Trade.is_open.is_(True)).all()
|
||||
@ -329,7 +332,9 @@ def main() -> None:
|
||||
if args.dry_run_db:
|
||||
if _CONF.get('dry_run', False):
|
||||
_CONF.update({'dry_run_db': True})
|
||||
logger.info('Dry_run will use the DB file: "tradesv3.dry_run.sqlite". (--dry_run_db detected)')
|
||||
logger.info(
|
||||
'Dry_run will use the DB file: "tradesv3.dry_run.sqlite". (--dry_run_db detected)'
|
||||
)
|
||||
else:
|
||||
logger.info('Dry run is disabled. (--dry_run_db ignored)')
|
||||
|
||||
|
@ -112,7 +112,7 @@ def parse_args(args: List[str]):
|
||||
)
|
||||
parser.add_argument(
|
||||
'--dynamic-whitelist',
|
||||
help='dynamically generate and update whitelist based on 24h BaseVolume (Default 20 currencies)',
|
||||
help='dynamically generate and update whitelist based on 24h BaseVolume (Default 20 currencies)', # noqa
|
||||
dest='dynamic_whitelist',
|
||||
const=20,
|
||||
type=int,
|
||||
@ -122,7 +122,7 @@ def parse_args(args: List[str]):
|
||||
parser.add_argument(
|
||||
'--dry-run-db',
|
||||
help='Force dry run to use a local DB "tradesv3.dry_run.sqlite" instead of memory DB. Work only if dry_run is \
|
||||
enabled.',
|
||||
enabled.', # noqa
|
||||
action='store_true',
|
||||
dest='dry_run_db',
|
||||
)
|
||||
|
@ -35,7 +35,8 @@ def get_timeframe(data: Dict[str, Dict]) -> Tuple[arrow.Arrow, arrow.Arrow]:
|
||||
return arrow.get(min_date), arrow.get(max_date)
|
||||
|
||||
|
||||
def generate_text_table(data: Dict[str, Dict], results: DataFrame, stake_currency, ticker_interval) -> str:
|
||||
def generate_text_table(
|
||||
data: Dict[str, Dict], results: DataFrame, stake_currency, ticker_interval) -> str:
|
||||
"""
|
||||
Generates and returns a text table for the given backtest data and the results dataframe
|
||||
:return: pretty printed table with tabulate as str
|
||||
|
@ -49,7 +49,7 @@ OPTIMIZE_CONFIG = {
|
||||
}
|
||||
|
||||
# Monkey patch config
|
||||
from freqtrade import main
|
||||
from freqtrade import main # noqa
|
||||
main._CONF = OPTIMIZE_CONFIG
|
||||
|
||||
|
||||
@ -102,6 +102,7 @@ SPACE = {
|
||||
]),
|
||||
}
|
||||
|
||||
|
||||
def log_results(results):
|
||||
"if results is better than _TO_BEAT show it"
|
||||
|
||||
@ -118,6 +119,7 @@ def log_results(results):
|
||||
print('.', end='')
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
def optimizer(params):
|
||||
global _CURRENT_TRIES
|
||||
|
||||
@ -148,7 +150,7 @@ def optimizer(params):
|
||||
'result': result,
|
||||
'results': results
|
||||
}
|
||||
|
||||
|
||||
# logger.info('{:5d}/{}: {}'.format(_CURRENT_TRIES, TOTAL_TRIES, result))
|
||||
log_results(result_data)
|
||||
|
||||
|
@ -93,7 +93,7 @@ def authorized_only(command_handler: Callable[[Bot, Update], None]) -> Callable[
|
||||
:return: decorated function
|
||||
"""
|
||||
def wrapper(*args, **kwargs):
|
||||
bot, update = kwargs.get('bot') or args[0], kwargs.get('update') or args[1]
|
||||
update = kwargs.get('update') or args[1]
|
||||
|
||||
# Reject unauthorized messages
|
||||
chat_id = int(_CONF['telegram']['chat_id'])
|
||||
@ -551,7 +551,10 @@ def send_msg(msg: str, bot: Bot = None, parse_mode: ParseMode = ParseMode.MARKDO
|
||||
|
||||
try:
|
||||
try:
|
||||
bot.send_message(_CONF['telegram']['chat_id'], msg, parse_mode=parse_mode, reply_markup=reply_markup)
|
||||
bot.send_message(
|
||||
_CONF['telegram']['chat_id'], msg,
|
||||
parse_mode=parse_mode, reply_markup=reply_markup
|
||||
)
|
||||
except NetworkError as network_err:
|
||||
# Sometimes the telegram server resets the current connection,
|
||||
# if this is the case we send the message again.
|
||||
@ -559,6 +562,9 @@ def send_msg(msg: str, bot: Bot = None, parse_mode: ParseMode = ParseMode.MARKDO
|
||||
'Got Telegram NetworkError: %s! Trying one more time.',
|
||||
network_err.message
|
||||
)
|
||||
bot.send_message(_CONF['telegram']['chat_id'], msg, parse_mode=parse_mode, reply_markup=reply_markup)
|
||||
bot.send_message(
|
||||
_CONF['telegram']['chat_id'], msg,
|
||||
parse_mode=parse_mode, reply_markup=reply_markup
|
||||
)
|
||||
except TelegramError as telegram_err:
|
||||
logger.warning('Got TelegramError: %s! Giving up on that message.', telegram_err.message)
|
||||
|
@ -137,7 +137,9 @@ def test_create_trade_minimal_amount(default_conf, ticker, mocker):
|
||||
mocker.patch.dict('freqtrade.main._CONF', default_conf)
|
||||
mocker.patch.multiple('freqtrade.rpc', init=MagicMock(), send_msg=MagicMock())
|
||||
mocker.patch('freqtrade.main.get_signal', side_effect=lambda s, t: True)
|
||||
buy_mock = mocker.patch('freqtrade.main.exchange.buy', MagicMock(return_value='mocked_limit_buy'))
|
||||
buy_mock = mocker.patch(
|
||||
'freqtrade.main.exchange.buy', MagicMock(return_value='mocked_limit_buy')
|
||||
)
|
||||
mocker.patch.multiple('freqtrade.main.exchange',
|
||||
validate_pairs=MagicMock(),
|
||||
get_ticker=ticker)
|
||||
|
@ -60,11 +60,13 @@ def test_parse_args_dynamic_whitelist():
|
||||
assert args is not None
|
||||
assert args.dynamic_whitelist is 20
|
||||
|
||||
|
||||
def test_parse_args_dynamic_whitelist_10():
|
||||
args = parse_args(['--dynamic-whitelist', '10'])
|
||||
assert args is not None
|
||||
assert args.dynamic_whitelist is 10
|
||||
|
||||
|
||||
def test_parse_args_dynamic_whitelist_invalid_values():
|
||||
with pytest.raises(SystemExit, match=r'2'):
|
||||
parse_args(['--dynamic-whitelist', 'abc'])
|
||||
|
@ -7,6 +7,7 @@ from freqtrade.optimize.backtesting import backtest
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def test_backtest(default_conf, mocker):
|
||||
mocker.patch.dict('freqtrade.main._CONF', default_conf)
|
||||
exchange._API = Bittrex({'key': '', 'secret': ''})
|
||||
|
@ -341,6 +341,7 @@ def test_performance_handle(
|
||||
assert 'Performance' in msg_mock.call_args_list[0][0][0]
|
||||
assert '<code>BTC_ETH\t10.05%</code>' in msg_mock.call_args_list[0][0][0]
|
||||
|
||||
|
||||
def test_daily_handle(
|
||||
default_conf, update, ticker, limit_buy_order, limit_sell_order, mocker):
|
||||
mocker.patch.dict('freqtrade.main._CONF', default_conf)
|
||||
@ -355,7 +356,7 @@ def test_daily_handle(
|
||||
validate_pairs=MagicMock(),
|
||||
get_ticker=ticker)
|
||||
init(default_conf, create_engine('sqlite://'))
|
||||
|
||||
|
||||
# Create some test data
|
||||
create_trade(15.0)
|
||||
trade = Trade.query.first()
|
||||
@ -370,22 +371,22 @@ def test_daily_handle(
|
||||
trade.close_date = datetime.utcnow()
|
||||
trade.is_open = False
|
||||
|
||||
#try valid data
|
||||
# try valid data
|
||||
update.message.text = '/daily 7'
|
||||
_daily(bot=MagicMock(), update=update)
|
||||
assert msg_mock.call_count == 1
|
||||
assert 'Daily' in msg_mock.call_args_list[0][0][0]
|
||||
assert str(date.today()) + ' 1.50701325 BTC' in msg_mock.call_args_list[0][0][0]
|
||||
|
||||
#try invalid data
|
||||
|
||||
# try invalid data
|
||||
msg_mock.reset_mock()
|
||||
update_state(State.RUNNING)
|
||||
update.message.text = '/daily -2'
|
||||
_daily(bot=MagicMock(), update=update)
|
||||
assert msg_mock.call_count == 1
|
||||
assert 'must be an integer greater than 0' in msg_mock.call_args_list[0][0][0]
|
||||
|
||||
|
||||
assert 'must be an integer greater than 0' in msg_mock.call_args_list[0][0][0]
|
||||
|
||||
|
||||
def test_count_handle(default_conf, update, ticker, mocker):
|
||||
mocker.patch.dict('freqtrade.main._CONF', default_conf)
|
||||
mocker.patch('freqtrade.main.get_signal', side_effect=lambda s, t: True)
|
||||
|
Loading…
Reference in New Issue
Block a user