1
This commit is contained in:
1 parent
3ae4e18211
commit
730adb3ff2
9 files changed
+206
-33
No files matched your search
@@ -143,6 +143,9 @@ class Position:
|
||||
features: dict = field(default_factory=dict)
|
||||
uid: int = 0 # unique per ledger, so one of several open positions can be closed by hand
|
||||
margin: float = 0.0 # fixed at entry; changing leverage later must not release collateral
|
||||
close_decision_time: float = 0.0
|
||||
close_decision_price: float = 0.0
|
||||
close_reason: str = ""
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -406,6 +409,9 @@ class Ledger:
|
||||
self.balance, self._unrealized = old_balance, old_unrealized
|
||||
self._position_marks[pos.uid] = previous_mark
|
||||
return None
|
||||
pos.close_decision_time = now
|
||||
pos.close_decision_price = price
|
||||
pos.close_reason = reason
|
||||
for hook in self.hooks:
|
||||
hook("close", pos)
|
||||
if self.trades_path:
|
||||
|
||||
Reference in new issue
Block a user