mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-10 05:53:07 +08:00
TST: Use np.floor to preserve float return, since py3 returns an int
This commit is contained in:
@@ -32,14 +32,12 @@ Position Tracking
|
||||
"""
|
||||
|
||||
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 (
|
||||
@@ -71,7 +69,8 @@ class Position(object):
|
||||
# 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']:
|
||||
@@ -106,7 +105,7 @@ class Position(object):
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user