use date info to calculate trade durations
This commit is contained in:
parent
192521523f
commit
8c7b29734e
@ -33,7 +33,7 @@ def get_timeframe(data: Dict[str, DataFrame]) -> Tuple[arrow.Arrow, arrow.Arrow]
|
|||||||
|
|
||||||
|
|
||||||
def generate_text_table(
|
def generate_text_table(
|
||||||
data: Dict[str, Dict], results: DataFrame, stake_currency, ticker_interval) -> str:
|
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
|
||||||
@ -49,7 +49,7 @@ def generate_text_table(
|
|||||||
len(result.index),
|
len(result.index),
|
||||||
result.profit_percent.mean() * 100.0,
|
result.profit_percent.mean() * 100.0,
|
||||||
result.profit_BTC.sum(),
|
result.profit_BTC.sum(),
|
||||||
result.duration.mean() * ticker_interval,
|
result.duration.mean(),
|
||||||
len(result[result.profit_BTC > 0]),
|
len(result[result.profit_BTC > 0]),
|
||||||
len(result[result.profit_BTC < 0])
|
len(result[result.profit_BTC < 0])
|
||||||
])
|
])
|
||||||
@ -60,7 +60,7 @@ def generate_text_table(
|
|||||||
len(results.index),
|
len(results.index),
|
||||||
results.profit_percent.mean() * 100.0,
|
results.profit_percent.mean() * 100.0,
|
||||||
results.profit_BTC.sum(),
|
results.profit_BTC.sum(),
|
||||||
results.duration.mean() * ticker_interval,
|
results.duration.mean(),
|
||||||
len(results[results.profit_BTC > 0]),
|
len(results[results.profit_BTC > 0]),
|
||||||
len(results[results.profit_BTC < 0])
|
len(results[results.profit_BTC < 0])
|
||||||
])
|
])
|
||||||
@ -91,7 +91,7 @@ def get_sell_trade_entry(pair, row, buy_subset, ticker, trade_count_lock, args):
|
|||||||
return row2, (pair,
|
return row2, (pair,
|
||||||
trade.calc_profit_percent(rate=row2.close),
|
trade.calc_profit_percent(rate=row2.close),
|
||||||
trade.calc_profit(rate=row2.close),
|
trade.calc_profit(rate=row2.close),
|
||||||
row2.Index - row.Index
|
(row2.date - row.date).seconds // 60
|
||||||
), row2.date
|
), row2.date
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -231,5 +231,5 @@ def start(args):
|
|||||||
})
|
})
|
||||||
logger.info(
|
logger.info(
|
||||||
'\n==================================== BACKTESTING REPORT ====================================\n%s', # noqa
|
'\n==================================== BACKTESTING REPORT ====================================\n%s', # noqa
|
||||||
generate_text_table(data, results, config['stake_currency'], strategy.ticker_interval)
|
generate_text_table(data, results, config['stake_currency'])
|
||||||
)
|
)
|
||||||
|
@ -406,7 +406,7 @@ def optimizer(params):
|
|||||||
|
|
||||||
total_profit = results.profit_percent.sum()
|
total_profit = results.profit_percent.sum()
|
||||||
trade_count = len(results.index)
|
trade_count = len(results.index)
|
||||||
trade_duration = results.duration.mean() * 5
|
trade_duration = results.duration.mean()
|
||||||
|
|
||||||
if trade_count == 0 or trade_duration > MAX_ACCEPTED_TRADE_DURATION:
|
if trade_count == 0 or trade_duration > MAX_ACCEPTED_TRADE_DURATION:
|
||||||
print('.', end='')
|
print('.', end='')
|
||||||
|
@ -29,12 +29,12 @@ def test_generate_text_table():
|
|||||||
'loss': [0, 0]
|
'loss': [0, 0]
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
print(generate_text_table({'BTC_ETH': {}}, results, 'BTC', 5))
|
print(generate_text_table({'BTC_ETH': {}}, results, 'BTC'))
|
||||||
assert generate_text_table({'BTC_ETH': {}}, results, 'BTC', 5) == (
|
assert generate_text_table({'BTC_ETH': {}}, results, 'BTC') == (
|
||||||
'pair buy count avg profit % total profit BTC avg duration profit loss\n' # noqa
|
'pair buy count avg profit % total profit BTC avg duration profit loss\n' # noqa
|
||||||
'------- ----------- -------------- ------------------ -------------- -------- ------\n' # noqa
|
'------- ----------- -------------- ------------------ -------------- -------- ------\n' # noqa
|
||||||
'BTC_ETH 2 15.00 0.60000000 100.0 2 0\n' # noqa
|
'BTC_ETH 2 15.00 0.60000000 20.0 2 0\n' # noqa
|
||||||
'TOTAL 2 15.00 0.60000000 100.0 2 0') # noqa
|
'TOTAL 2 15.00 0.60000000 20.0 2 0') # noqa
|
||||||
|
|
||||||
|
|
||||||
def test_get_timeframe(default_strategy):
|
def test_get_timeframe(default_strategy):
|
||||||
|
Loading…
Reference in New Issue
Block a user