mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 02:12:01 +00:00
Implement division/0 checks for win and loss columns in edge
closes #3839
This commit is contained in:
parent
d1db847612
commit
f676156ec7
|
@ -310,8 +310,10 @@ class Edge:
|
|||
|
||||
# Calculating number of losing trades, average win and average loss
|
||||
df['nb_loss_trades'] = df['nb_trades'] - df['nb_win_trades']
|
||||
df['average_win'] = df['profit_sum'] / df['nb_win_trades']
|
||||
df['average_loss'] = df['loss_sum'] / df['nb_loss_trades']
|
||||
df['average_win'] = np.where(df['nb_win_trades'] == 0, 0.0,
|
||||
df['profit_sum'] / df['nb_win_trades'])
|
||||
df['average_loss'] = np.where(df['nb_loss_trades'] == 0, 0.0,
|
||||
df['loss_sum'] / df['nb_loss_trades'])
|
||||
|
||||
# Win rate = number of profitable trades / number of trades
|
||||
df['winrate'] = df['nb_win_trades'] / df['nb_trades']
|
||||
|
|
Loading…
Reference in New Issue
Block a user