Skip to content

Commit

Permalink
Code for position size/value adjustment was simplified in CorporateAc…
Browse files Browse the repository at this point in the history
…tion class.
  • Loading branch information
titov-vv committed May 22, 2024
1 parent 704ac37 commit a2f6e42
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions jal/db/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1209,16 +1209,8 @@ def processLedger(self, ledger):
ledger.appendTransaction(self, BookAccount.Incomes, -qty, category=PredefinedCategory.Interest, peer=self._broker)
else:
for trade in closed_trades:
if self._asset.id() == asset.id():
if self._subtype == CorporateAction.Split:
adj_coef = (self._qty / qty, qty / self._qty) # Price and quantity 1:N adjustment for split
elif self._subtype == CorporateAction.SpinOff or self._subtype == CorporateAction.Merger:
adj_coef = (share, Decimal('1')) # Cost basis adjustment according to corporate action data
else:
assert False, f"Unexpected corporate action type {self._subtype}"
else:
adj_coef = (share * self._qty / qty, qty / self._qty)
self._account.open_trade(trade, asset, modified_by=self, adjustment=adj_coef)
cost_size_adjustment = (share * self._qty / qty, qty / self._qty)
self._account.open_trade(trade, asset, modified_by=self, adjustment=cost_size_adjustment)
ledger.appendTransaction(self, BookAccount.Assets, qty, asset_id=asset.id(), value=value)

# ----------------------------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit a2f6e42

Please sign in to comment.