mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-30 21:09:25 +08:00
BUG: Fix floored results in trade commission calculations.
When the cost basis was set to an integer the division in the calculation would floor down to the nearest integer. Ensuring that the number is a float during PerTrade's init will ensure that the calculation doesn't use integer division. Do the conversion to float in init rather than calculate, so that calling the builtin `float` is not added to any inner loops.
This commit is contained in:
@@ -48,7 +48,9 @@ class PerTrade(object):
|
||||
share count. $5.00 per trade is fairly typical of
|
||||
discount brokers.
|
||||
"""
|
||||
self.cost = cost
|
||||
# Cost needs to be floating point so that calculation using division
|
||||
# logic does not floor to an integer.
|
||||
self.cost = float(cost)
|
||||
|
||||
def calculate(self, transaction):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user