From 9cb9831c087bbe40e70b2965819c672196519400 Mon Sep 17 00:00:00 2001 From: Thomas Wiecki Date: Mon, 25 Nov 2013 11:28:27 -0500 Subject: [PATCH] STY: Prepend order_ to all target methods. --- zipline/algorithm.py | 6 +++--- zipline/test_algorithms.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/zipline/algorithm.py b/zipline/algorithm.py index bdc304e1..653f2a66 100644 --- a/zipline/algorithm.py +++ b/zipline/algorithm.py @@ -469,7 +469,7 @@ class TradingAlgorithm(object): value = self.portfolio.portfolio_value * percent return self.order_value(sid, value, limit_price, stop_price) - def target(self, sid, target, limit_price=None, stop_price=None): + def order_target(self, sid, target, limit_price=None, stop_price=None): """ Place an order to adjust a position to a target number of shares. If the position doesn't already exist, this is equivalent to placing a new @@ -484,7 +484,7 @@ class TradingAlgorithm(object): else: return self.order(sid, target, limit_price, stop_price) - def target_value(self, sid, target, limit_price=None, stop_price=None): + def order_target_value(self, sid, target, limit_price=None, stop_price=None): """ Place an order to adjust a position to a target value. If the position doesn't already exist, this is equivalent to placing a new @@ -501,7 +501,7 @@ class TradingAlgorithm(object): else: return self.order_value(sid, target, limit_price, stop_price) - def target_percent(self, sid, target, limit_price=None, stop_price=None): + def order_target_percent(self, sid, target, limit_price=None, stop_price=None): """ Place an order to adjust a position to a target percent of the current portfolio value. If the position doesn't already exist, this is diff --git a/zipline/test_algorithms.py b/zipline/test_algorithms.py index 88985f94..3500f7b1 100644 --- a/zipline/test_algorithms.py +++ b/zipline/test_algorithms.py @@ -283,7 +283,7 @@ class TestTargetAlgorithm(TradingAlgorithm): assert self.portfolio.positions[0]['last_sale_price'] == \ data[0].price, "Orders not filled at current price." self.target_shares = np.random.randint(1, 30) - self.target(0, self.target_shares) + self.order_target(0, self.target_shares) class TestOrderPercentAlgorithm(TradingAlgorithm): @@ -325,7 +325,7 @@ class TestTargetPercentAlgorithm(TradingAlgorithm): assert self.portfolio.positions[0]['last_sale_price'] == \ data[0].price, "Orders not filled at current price." self.sale_price = data[0].price - self.target_percent(0, .002) + self.order_target_percent(0, .002) class TestTargetValueAlgorithm(TradingAlgorithm): @@ -346,7 +346,7 @@ class TestTargetValueAlgorithm(TradingAlgorithm): assert self.portfolio.positions[0]['last_sale_price'] == \ data[0].price, "Orders not filled at current price." - self.target_value(0, 20) + self.order_target_value(0, 20) self.target_shares = np.round(20 / data[0].price)