just pass stake_amount instead of the whole config
This commit is contained in:
parent
24bc3a8390
commit
1058820e1b
@ -64,7 +64,7 @@ def generate_text_table(
|
|||||||
return tabulate(tabular_data, headers=headers)
|
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:
|
max_open_trades: int = 0, realistic: bool = True) -> DataFrame:
|
||||||
"""
|
"""
|
||||||
Implements backtesting functionality
|
Implements backtesting functionality
|
||||||
@ -98,8 +98,8 @@ def backtest(config: Dict, processed: Dict[str, DataFrame],
|
|||||||
trade = Trade(
|
trade = Trade(
|
||||||
open_rate=row.close,
|
open_rate=row.close,
|
||||||
open_date=row.date,
|
open_date=row.date,
|
||||||
stake_amount=config['stake_amount'],
|
stake_amount=stake_amount,
|
||||||
amount=config['stake_amount'] / row.open,
|
amount=stake_amount / row.open,
|
||||||
fee=exchange.get_fee()
|
fee=exchange.get_fee()
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ def start(args):
|
|||||||
|
|
||||||
# Execute backtest and print results
|
# Execute backtest and print results
|
||||||
results = backtest(
|
results = backtest(
|
||||||
config, preprocess(data), max_open_trades, args.realistic_simulation
|
config['stake_amount'], preprocess(data), max_open_trades, args.realistic_simulation
|
||||||
)
|
)
|
||||||
logger.info(
|
logger.info(
|
||||||
'\n====================== BACKTESTING REPORT ======================================\n%s',
|
'\n====================== BACKTESTING REPORT ======================================\n%s',
|
||||||
|
@ -116,7 +116,7 @@ def optimizer(params):
|
|||||||
from freqtrade.optimize import backtesting
|
from freqtrade.optimize import backtesting
|
||||||
backtesting.populate_buy_trend = buy_strategy_generator(params)
|
backtesting.populate_buy_trend = buy_strategy_generator(params)
|
||||||
|
|
||||||
results = backtest(OPTIMIZE_CONFIG, PROCESSED)
|
results = backtest(OPTIMIZE_CONFIG['stake_amount'], PROCESSED)
|
||||||
|
|
||||||
result = format_results(results)
|
result = format_results(results)
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ def test_backtest(default_conf, mocker):
|
|||||||
exchange._API = Bittrex({'key': '', 'secret': ''})
|
exchange._API = Bittrex({'key': '', 'secret': ''})
|
||||||
|
|
||||||
data = optimize.load_data(ticker_interval=5, pairs=['BTC_ETH'])
|
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)
|
num_results = len(results)
|
||||||
assert num_results > 0
|
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
|
# Run a backtesting for an exiting 5min ticker_interval
|
||||||
data = optimize.load_data(ticker_interval=1, pairs=['BTC_UNITEST'])
|
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
|
assert len(results) > 0
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user