From f7b4df4a091b5132250e8c0846984342d86b2c03 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Tue, 12 Mar 2013 19:14:02 -0400 Subject: [PATCH] MAINT: Uses copysign to extract direction of order. Instead of using division of the amount by itself to extract the direction, uses math's copysign. Should be almost functionally equivalent, but copysign won't have a possible floating point error leading the direction to not be exactly 1. --- zipline/finance/slippage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zipline/finance/slippage.py b/zipline/finance/slippage.py index ec9147d9..61e1a72b 100644 --- a/zipline/finance/slippage.py +++ b/zipline/finance/slippage.py @@ -108,7 +108,7 @@ class VolumeShareSlippage(object): open_amount = order.amount - order.filled if(open_amount != 0): - direction = open_amount / math.fabs(open_amount) + direction = math.copysign(1, open_amount) else: direction = 1