Spaces:
Sleeping
Sleeping
Download risk_engine.py from 404chain/Signal_bot: direct link, hf CLI and curl.
- Browser
- Download file 702 Bytes
-
https://huggingface.co/spaces/404chain/Signal_bot/resolve/main/risk_engine.py
- Command line
-
hf download hf://spaces/404chain/Signal_bot/risk_engine.py
-
curl -L -o risk_engine.py https://huggingface.co/spaces/404chain/Signal_bot/resolve/main/risk_engine.py
702 Bytes
| 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 | |
| } |