mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-09 11:50:09 +08:00
BUG: Position cost basis was calculated incorrectly for Futures
For futures, we need to divide the position’s commission by the contract size to get a per-unit commission in order to properly update the position’s cost basis.
This commit is contained in:
@@ -173,7 +173,11 @@ class Position(object):
|
||||
return
|
||||
|
||||
prev_cost = self.cost_basis * self.amount
|
||||
new_cost = prev_cost + cost
|
||||
if isinstance(asset, Future):
|
||||
cost_to_use = cost / asset.multiplier
|
||||
else:
|
||||
cost_to_use = cost
|
||||
new_cost = prev_cost + cost_to_use
|
||||
self.cost_basis = new_cost / self.amount
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
Reference in New Issue
Block a user