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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user