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:
Jean Bredeche
2017-04-24 15:41:20 -04:00
parent b1248cb6d6
commit 1f8e194e09
2 changed files with 40 additions and 1 deletions
+5 -1
View File
@@ -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):