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:
Eddie Hebert
2013-04-09 11:44:16 -04:00
parent 90fa2a8a4e
commit da9d599afd
+3 -1
View File
@@ -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):
"""