Spaces:
Sleeping
Sleeping
File size: 702 Bytes
4b5acd5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | def calculate_risk(ta):
entry = ta["price"]
support = ta["support"]
resistance = ta["resistance"]
risk = round(entry - support, 2)
reward = round(resistance - entry, 2)
rr = round(
reward / risk,
2
) if risk > 0 else 0
stop_loss = round(
support * 0.995,
2
)
take_profit = round(
resistance * 1.005,
2
)
position_size = "SMALL"
if rr >= 3:
position_size = "LARGE"
elif rr >= 2:
position_size = "MEDIUM"
return {
"entry": entry,
"stop_loss": stop_loss,
"take_profit": take_profit,
"rr": rr,
"position_size": position_size
} |