From 9fef46632341c5e8c0ee11ebc36908f5d9b4c1b2 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Wed, 10 Oct 2012 15:51:15 -0400 Subject: [PATCH] Uses `min` function in place of taking the minimum with an if statement. --- zipline/finance/slippage.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/zipline/finance/slippage.py b/zipline/finance/slippage.py index 4a89732d..b7deed39 100644 --- a/zipline/finance/slippage.py +++ b/zipline/finance/slippage.py @@ -94,9 +94,8 @@ class VolumeShareSlippage(object): desired_order = total_order + open_amount - volume_share = direction * (desired_order) / event.volume - if volume_share > self.volume_limit: - volume_share = self.volume_limit + volume_share = min(direction * (desired_order) / event.volume, + self.volume_limit) simulated_amount = int(volume_share * event.volume * direction) simulated_impact = (volume_share) ** 2 \ * self.price_impact * direction * event.price