calculating expectancy and sort pairs accordingly instead of delta
This commit is contained in:
parent
a806dd45f2
commit
e8716f16ad
@ -355,20 +355,23 @@ class Edge():
|
|||||||
return x
|
return x
|
||||||
##############################
|
##############################
|
||||||
|
|
||||||
# The difference between risk reward ratio and required risk reward
|
# Expectancy
|
||||||
# We use it as an indicator to find the most interesting pair to trade
|
# Tells you the interest percentage you should hope
|
||||||
def delta(x):
|
# E.x. if expectancy is 0.35, on $1 trade you should expect a target of $1.35
|
||||||
x = (abs(1/ ((x[x < 0].sum() / x[x < 0].count()) / (x[x > 0].sum() / x[x > 0].count())))) - (1/(x[x > 0].count()/x.count()) -1)
|
def expectancy(x):
|
||||||
|
average_win = float(x[x > 0].sum() / x[x > 0].count())
|
||||||
|
average_loss = float(abs(x[x < 0].sum() / x[x < 0].count()))
|
||||||
|
winrate = float(x[x > 0].count()/x.count())
|
||||||
|
x = ((1 + average_win/average_loss) * winrate) - 1
|
||||||
return x
|
return x
|
||||||
##############################
|
##############################
|
||||||
|
|
||||||
|
|
||||||
final = results.groupby(['pair', 'stoploss'])['profit_abs'].\
|
final = results.groupby(['pair', 'stoploss'])['profit_abs'].\
|
||||||
agg([winrate, risk_reward_ratio, required_risk_reward, delta]).\
|
agg([winrate, risk_reward_ratio, required_risk_reward, expectancy]).\
|
||||||
reset_index().sort_values(by=['delta', 'stoploss'], ascending=False)\
|
reset_index().sort_values(by=['expectancy', 'stoploss'], ascending=False)\
|
||||||
.groupby('pair').first().sort_values(by=['delta'], ascending=False)
|
.groupby('pair').first().sort_values(by=['expectancy'], ascending=False)
|
||||||
|
|
||||||
# Returning an array of pairs in order of "delta"
|
# Returning an array of pairs in order of "expectancy"
|
||||||
return final.reset_index().values
|
return final.reset_index().values
|
||||||
|
|
||||||
def backslap_pair(self, ticker_data, pair, stoploss):
|
def backslap_pair(self, ticker_data, pair, stoploss):
|
||||||
|
Loading…
Reference in New Issue
Block a user