just pass stake_amount instead of the whole config

This commit is contained in:
Janne Sinivirta 2017-12-23 17:26:22 +02:00
parent 24bc3a8390
commit 1058820e1b
3 changed files with 7 additions and 7 deletions

View File

@ -64,7 +64,7 @@ def generate_text_table(
return tabulate(tabular_data, headers=headers)
def backtest(config: Dict, processed: Dict[str, DataFrame],
def backtest(stake_amount: float, processed: Dict[str, DataFrame],
max_open_trades: int = 0, realistic: bool = True) -> DataFrame:
"""
Implements backtesting functionality
@ -98,8 +98,8 @@ def backtest(config: Dict, processed: Dict[str, DataFrame],
trade = Trade(
open_rate=row.close,
open_date=row.date,
stake_amount=config['stake_amount'],
amount=config['stake_amount'] / row.open,
stake_amount=stake_amount,
amount=stake_amount / row.open,
fee=exchange.get_fee()
)
@ -170,7 +170,7 @@ def start(args):
# Execute backtest and print results
results = backtest(
config, preprocess(data), max_open_trades, args.realistic_simulation
config['stake_amount'], preprocess(data), max_open_trades, args.realistic_simulation
)
logger.info(
'\n====================== BACKTESTING REPORT ======================================\n%s',

View File

@ -116,7 +116,7 @@ def optimizer(params):
from freqtrade.optimize import backtesting
backtesting.populate_buy_trend = buy_strategy_generator(params)
results = backtest(OPTIMIZE_CONFIG, PROCESSED)
results = backtest(OPTIMIZE_CONFIG['stake_amount'], PROCESSED)
result = format_results(results)

View File

@ -12,7 +12,7 @@ def test_backtest(default_conf, mocker):
exchange._API = Bittrex({'key': '', 'secret': ''})
data = optimize.load_data(ticker_interval=5, pairs=['BTC_ETH'])
results = backtest(default_conf, optimize.preprocess(data), 10, True)
results = backtest(default_conf['stake_amount'], optimize.preprocess(data), 10, True)
num_results = len(results)
assert num_results > 0
@ -23,7 +23,7 @@ def test_1min_ticker_interval(default_conf, mocker):
# Run a backtesting for an exiting 5min ticker_interval
data = optimize.load_data(ticker_interval=1, pairs=['BTC_UNITEST'])
results = backtest(default_conf, optimize.preprocess(data), 1, True)
results = backtest(default_conf['stake_amount'], optimize.preprocess(data), 1, True)
assert len(results) > 0