pep8 compliance

This commit is contained in:
Jean-Baptiste LE STANG 2018-01-03 11:35:54 +01:00
parent 2d273a8509
commit eb53a796e2
2 changed files with 15 additions and 11 deletions

View File

@ -62,14 +62,14 @@ def generate_text_table(
results.profit_BTC.sum(), results.profit_BTC.sum(),
results.duration.mean() * ticker_interval, results.duration.mean() * ticker_interval,
results.profit.sum(), results.profit.sum(),
results.loss.sum(), results.loss.sum()
]) ])
return tabulate(tabular_data, headers=headers, floatfmt=floatfmt) return tabulate(tabular_data, headers=headers, floatfmt=floatfmt)
def backtest(stake_amount: float, processed: Dict[str, DataFrame], def backtest(stake_amount: float, processed: Dict[str, DataFrame],
max_open_trades: int = 0, realistic: bool = True, sell_profit_only: bool = False, stoploss: int = -1.00, use_sell_signal: bool = False) -> DataFrame: max_open_trades: int = 0, realistic: bool = True, sell_profit_only: bool = False,
stoploss: int = -1.00, use_sell_signal: bool = False) -> DataFrame:
""" """
Implements backtesting functionality Implements backtesting functionality
:param stake_amount: btc amount to use for each trade :param stake_amount: btc amount to use for each trade
@ -118,7 +118,9 @@ def backtest(stake_amount: float, processed: Dict[str, DataFrame],
current_profit_percent = trade.calc_profit_percent(rate=row2.close) current_profit_percent = trade.calc_profit_percent(rate=row2.close)
if (sell_profit_only and current_profit_percent < 0): if (sell_profit_only and current_profit_percent < 0):
continue continue
if min_roi_reached(trade, row2.close, row2.date) or (row2.sell == 1 and use_sell_signal) or current_profit_percent <= stoploss: if min_roi_reached(trade, row2.close, row2.date)
or (row2.sell == 1 and use_sell_signal)
or current_profit_percent <= stoploss:
current_profit_btc = trade.calc_profit(rate=row2.close) current_profit_btc = trade.calc_profit(rate=row2.close)
lock_pair_until = row2.Index lock_pair_until = row2.Index
@ -181,7 +183,9 @@ def start(args):
# Execute backtest and print results # Execute backtest and print results
results = backtest( results = backtest(
config['stake_amount'], preprocessed, max_open_trades, args.realistic_simulation, config.get('experimental',{}).get('sell_profit_only', False), config.get('stoploss'), config.get('experimental',{}).get('use_sell_signal',False) config['stake_amount'], preprocessed, max_open_trades, args.realistic_simulation,
config.get('experimental', {}).get('sell_profit_only', False), config.get('stoploss'),
config.get('experimental', {}).get('use_sell_signal', False)
) )
logger.info( logger.info(
'\n====================== BACKTESTING REPORT ================================\n%s', '\n====================== BACKTESTING REPORT ================================\n%s',