From d475766c63a335409f3786f78f71f2a31ad53d00 Mon Sep 17 00:00:00 2001 From: Matti Hanninen Date: Fri, 14 Jun 2013 13:13:36 +0300 Subject: [PATCH 1/2] DOC: Fix docstring for TradingAlgorithm Fix the example given in the class docstring as the original didn't work on REPL. --- zipline/algorithm.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zipline/algorithm.py b/zipline/algorithm.py index 72a9365f..02d0b3cc 100644 --- a/zipline/algorithm.py +++ b/zipline/algorithm.py @@ -63,10 +63,11 @@ class TradingAlgorithm(object): A new algorithm could look like this: ``` class MyAlgo(TradingAlgorithm): - def initialize(amount): + def initialize(self, sids, amount): + self.sids = sids self.amount = amount - def handle_data(data): + def handle_data(self, data): sid = self.sids[0] self.order(sid, amount) ``` From 43d375700469be3ff50235ce441fb9fb40a8c891 Mon Sep 17 00:00:00 2001 From: Matti Hanninen Date: Fri, 14 Jun 2013 14:17:16 +0300 Subject: [PATCH 2/2] DOC: Fix docstring for TradingAlgorithm Get the amount from the algorithm object instead of referring to a (undefined) global. --- zipline/algorithm.py | 1 + 1 file changed, 1 insertion(+) diff --git a/zipline/algorithm.py b/zipline/algorithm.py index 02d0b3cc..4a89df59 100644 --- a/zipline/algorithm.py +++ b/zipline/algorithm.py @@ -69,6 +69,7 @@ class TradingAlgorithm(object): def handle_data(self, data): sid = self.sids[0] + amount = self.amount self.order(sid, amount) ``` To then to run this algorithm: