From 2aa038c2a7e3373165a2037d0b20b4f6d17b36d1 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Tue, 18 Jun 2013 11:22:35 -0400 Subject: [PATCH] MAINT: Make usage of absolute`value more clear in slippage. Instead of using copysign with a param of 1, use `abs` to make the code more clear between when slippage is using the absolute value, and when it is creating an amount that uses the order direction. --- zipline/finance/slippage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zipline/finance/slippage.py b/zipline/finance/slippage.py index 5352f8bb..d28cded4 100644 --- a/zipline/finance/slippage.py +++ b/zipline/finance/slippage.py @@ -106,7 +106,7 @@ def create_transaction(event, order, price, amount): # floor the amount to protect against non-whole number orders # TODO: Investigate whether we can add a robust check in blotter # and/or tradesimulation, as well. - amount_magnitude = int(math.copysign(amount, 1)) + amount_magnitude = int(abs(amount)) if amount_magnitude < 1: raise Exception("Transaction magnitude must be at least 1.") @@ -155,7 +155,7 @@ class SlippageModel(object): if txn: txns.append(txn) - self._volume_for_bar += math.copysign(txn.amount, 1) + self._volume_for_bar += abs(txn.amount) return txns