Skip to content

Commit

Permalink
TST: Use np.floor to preserve float return, since py3 returns an int
Browse files Browse the repository at this point in the history
  • Loading branch information
richafrank committed Feb 3, 2016
1 parent 670063d commit d986f5b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions zipline/finance/performance/position.py
Expand Up @@ -32,14 +32,12 @@
"""

from __future__ import division
from math import (
copysign,
floor,
)
from math import copysign

from copy import copy

import logbook
import numpy as np
import zipline.protocol as zp

from zipline.utils.serialization_utils import (
Expand Down Expand Up @@ -71,7 +69,8 @@ def earn_dividend(self, dividend):
# stock dividend
if dividend['payment_sid']:
out['payment_sid'] = dividend['payment_sid']
out['share_count'] = floor(self.amount * float(dividend['ratio']))
out['share_count'] = np.floor(self.amount
* float(dividend['ratio']))

# cash dividend
if dividend['net_amount']:
Expand Down Expand Up @@ -106,7 +105,7 @@ def handle_split(self, sid, ratio):
raw_share_count = self.amount / float(ratio)

# e.g., 33
full_share_count = floor(raw_share_count)
full_share_count = np.floor(raw_share_count)

# e.g., 0.333
fractional_share_count = raw_share_count - full_share_count
Expand Down

0 comments on commit d986f5b

Please sign in to comment.