fix some formatting issues
This commit is contained in:
parent
5469293e5f
commit
fb7ea169d4
@ -56,6 +56,8 @@ def default_conf():
|
|||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def backtest_conf():
|
def backtest_conf():
|
||||||
return {
|
return {
|
||||||
|
"stake_currency": "BTC",
|
||||||
|
"stake_amount": 0.01,
|
||||||
"minimal_roi": {
|
"minimal_roi": {
|
||||||
"40": 0.0,
|
"40": 0.0,
|
||||||
"30": 0.01,
|
"30": 0.01,
|
||||||
|
@ -59,7 +59,7 @@ def get_timeframe(data: Dict[str, Dict]) -> Tuple[Arrow, Arrow]:
|
|||||||
return arrow.get(min_date), arrow.get(max_date)
|
return arrow.get(min_date), arrow.get(max_date)
|
||||||
|
|
||||||
|
|
||||||
def generate_text_table(data: Dict[str, Dict], results: DataFrame) -> str:
|
def generate_text_table(data: Dict[str, Dict], results: DataFrame, stake_currency) -> str:
|
||||||
"""
|
"""
|
||||||
Generates and returns a text table for the given backtest data and the results dataframe
|
Generates and returns a text table for the given backtest data and the results dataframe
|
||||||
:return: pretty printed table with tabulate as str
|
:return: pretty printed table with tabulate as str
|
||||||
@ -72,7 +72,7 @@ def generate_text_table(data: Dict[str, Dict], results: DataFrame) -> str:
|
|||||||
pair,
|
pair,
|
||||||
len(result.index),
|
len(result.index),
|
||||||
'{:.2f}%'.format(result.profit.mean() * 100.0),
|
'{:.2f}%'.format(result.profit.mean() * 100.0),
|
||||||
'{:.8f}'.format(result.profit.sum()),
|
'{:.08f} {}'.format(result.profit.sum(), stake_currency),
|
||||||
'{:.2f}'.format(result.duration.mean() * 5),
|
'{:.2f}'.format(result.duration.mean() * 5),
|
||||||
])
|
])
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ def generate_text_table(data: Dict[str, Dict], results: DataFrame) -> str:
|
|||||||
'TOTAL',
|
'TOTAL',
|
||||||
len(results.index),
|
len(results.index),
|
||||||
'{:.2f}%'.format(results.profit.mean() * 100.0),
|
'{:.2f}%'.format(results.profit.mean() * 100.0),
|
||||||
'{:.8f}'.format(results.profit.sum()),
|
'{:.08f} {}'.format(results.profit.sum(), stake_currency),
|
||||||
'{:.2f}'.format(results.duration.mean() * 5),
|
'{:.2f}'.format(results.duration.mean() * 5),
|
||||||
])
|
])
|
||||||
return tabulate(tabular_data, headers=headers)
|
return tabulate(tabular_data, headers=headers)
|
||||||
@ -100,7 +100,7 @@ def backtest(backtest_conf, processed, mocker):
|
|||||||
trade = Trade(
|
trade = Trade(
|
||||||
open_rate=row.close,
|
open_rate=row.close,
|
||||||
open_date=row.date,
|
open_date=row.date,
|
||||||
amount=1,
|
amount=backtest_conf['stake_amount'],
|
||||||
fee=exchange.get_fee() * 2
|
fee=exchange.get_fee() * 2
|
||||||
)
|
)
|
||||||
# calculate win/lose forwards from buy point
|
# calculate win/lose forwards from buy point
|
||||||
@ -138,12 +138,17 @@ def test_backtest(backtest_conf, backdata, mocker):
|
|||||||
config = config or backtest_conf
|
config = config or backtest_conf
|
||||||
data = livedata or backdata
|
data = livedata or backdata
|
||||||
|
|
||||||
|
print('Using stake_currency: {} ...\nUsing stake_amount: {} ...'.format(
|
||||||
|
config['stake_currency'], config['stake_amount']
|
||||||
|
))
|
||||||
|
|
||||||
min_date, max_date = get_timeframe(data)
|
min_date, max_date = get_timeframe(data)
|
||||||
print('Measuring data from {} up to {} ...'.format(
|
print('Measuring data from {} up to {} ...'.format(
|
||||||
min_date.isoformat(), max_date.isoformat()
|
min_date.isoformat(), max_date.isoformat()
|
||||||
))
|
))
|
||||||
|
|
||||||
results = backtest(config, preprocess(data), mocker)
|
results = backtest(config, preprocess(data), mocker)
|
||||||
print('====================== BACKTESTING REPORT ======================================\n')
|
print('====================== BACKTESTING REPORT ======================================\n\n'
|
||||||
print(generate_text_table(data, results))
|
'NOTE: This Report doesn\'t respect the limits of max_open_trades, \n'
|
||||||
|
' so the projected values should be taken with a grain of salt.\n')
|
||||||
|
print(generate_text_table(data, results, config['stake_currency']))
|
||||||
|
Loading…
Reference in New Issue
Block a user