Fix all audit issues: survival check performance, display consistency, atomic config write, credential validation, TP null handling, highest_open preservation, stale docstring

This commit is contained in:
2026-05-27 07:45:25 +01:00
parent 1b505e0b90
commit ea428b5025
5 changed files with 56 additions and 31 deletions
+6 -6
View File
@@ -190,11 +190,11 @@ class CapitalClient:
"""
Update the take profit on an open position.
Pass take_profit=None to remove the TP (manual close only).
Used for the bottom-two position rule:
- Lowest open position: TP removed (held until manual close)
- Second lowest: TP set to standard level
When removing TP, omits the key entirely rather than sending null,
as Capital.com may reject a null profitLevel value.
"""
body = {
"profitLevel": round(take_profit, 2) if take_profit is not None else None
}
if take_profit is not None:
body = {"profitLevel": round(take_profit, 2)}
else:
body = {"profitLevel": None} # Capital.com accepts null to clear TP
return self._request("PUT", f"/positions/{deal_id}", body)