Fixed argument threading for transforms.

This commit is contained in:
Stephen Diehl
2012-05-17 16:46:34 -04:00
parent abe906e90e
commit 9229e4193d
4 changed files with 16 additions and 16 deletions
+11 -11
View File
@@ -50,6 +50,17 @@ class Merge(Aggregate):
# Data Flow
# ---------
def append(self, event):
"""
:param event: a ndict with one entry. key is the name of the
transform, value is the transformed value.
Add an event to the buffer for the source specified by
source_id.
"""
self.data_buffer[event.keys()[0]].append(event)
self.received_count += 1
def next(self):
"""Get the next merged message from the feed buffer."""
if not (self.is_full() or self.draining):
@@ -67,14 +78,3 @@ class Merge(Aggregate):
cur = events.pop(0)
result.merge(cur)
return result
def append(self, event):
"""
:param event: a ndict with one entry. key is the name of the
transform, value is the transformed value.
Add an event to the buffer for the source specified by
source_id.
"""
self.data_buffer[event.keys()[0]].append(event)
self.received_count += 1
+1 -1
View File
@@ -5,7 +5,7 @@ from zipline.transforms.base import BaseTransform
class MovingAverageTransform(BaseTransform):
def init(self, daycount=3):
def init(self, name, daycount=3):
self.daycount = daycount
self.by_sid = defaultdict(self._create)
+1 -1
View File
@@ -3,7 +3,7 @@ from zipline.transforms.base import BaseTransform
class ReturnsTransform(BaseTransform):
def init(self):
def init(self, name):
self.by_sid = defaultdict(self._create)
def transform(self, event):
+3 -3
View File
@@ -6,7 +6,7 @@ from zipline.finance.movingaverage import EventWindow
class VWAPTransform(BaseTransform):
def init(self, daycount=3):
def init(self, name, daycount=3):
self.daycount = daycount
self.by_sid = defaultdict(self.create_vwap)
@@ -19,12 +19,12 @@ class VWAPTransform(BaseTransform):
def create_vwap(self):
return DailyVWAP(self.daycount)
class DailyVWAP:
class DailyVWAP(object):
"""
A class that tracks the volume weighted average price based on tick
updates.
"""
def __init__(self, daycount):
def init(self, name, daycount=3):
self.window = EventWindow(daycount)
self.flux = 0.0
self.volume = 0