switch current transforms over to the new metaclass

This commit is contained in:
scottsanderson
2012-08-28 14:25:17 -04:00
committed by Eddie Hebert
parent c0694827d6
commit 71839522cf
5 changed files with 14 additions and 10 deletions
+4 -7
View File
@@ -153,8 +153,7 @@ class FinanceTransformsTestCase(TestCase):
def test_vwap(self):
vwap = StatefulTransform(
VWAP,
vwap = VWAP(
market_aware = False,
delta = timedelta(days = 2)
)
@@ -177,7 +176,7 @@ class FinanceTransformsTestCase(TestCase):
def test_returns(self):
# Daily returns.
returns = StatefulTransform(Returns, 1)
returns = Returns(1)
transformed = list(returns.transform(self.source))
tnfm_vals = [message.tnfm_value for message in transformed]
@@ -218,8 +217,7 @@ class FinanceTransformsTestCase(TestCase):
def test_moving_average(self):
mavg = StatefulTransform(
MovingAverage,
mavg = MovingAverage(
market_aware = False,
fields = ['price', 'volume'],
delta = timedelta(days = 2),
@@ -260,8 +258,7 @@ class FinanceTransformsTestCase(TestCase):
self.trading_environment
)
stddev = StatefulTransform(
MovingStandardDev,
stddev = MovingStandardDev(
market_aware = False,
delta = timedelta(minutes = 150),
)
+2 -1
View File
@@ -3,7 +3,7 @@ from datetime import datetime, timedelta
from collections import defaultdict
from zipline import ndict
from zipline.gens.transform import EventWindow
from zipline.gens.transform import EventWindow, TransformMeta
class MovingAverage(object):
"""
@@ -12,6 +12,7 @@ class MovingAverage(object):
averages over any number of distinct fields (For example, we can
maintain a sid's average volume as well as its average price.)
"""
__metaclass__ = TransformMeta
def __init__(self, fields, market_aware, days = None, delta = None):
+3
View File
@@ -1,3 +1,4 @@
from zipline.gens.transform import TransformMeta
from collections import defaultdict, deque
class Returns(object):
@@ -5,6 +6,8 @@ class Returns(object):
Class that maintains a dictionary from sids to the sid's
closing price N trading days ago.
"""
__metaclass__ = TransformMeta
def __init__(self, days):
self.days = days
self.mapping = defaultdict(self._create)
+2 -1
View File
@@ -4,7 +4,7 @@ from collections import defaultdict
from math import sqrt
from zipline import ndict
from zipline.gens.transform import EventWindow
from zipline.gens.transform import EventWindow, TransformMeta
class MovingStandardDev(object):
"""
@@ -13,6 +13,7 @@ class MovingStandardDev(object):
standard deviation of all events falling within the specified
window.
"""
__metaclass__ = TransformMeta
def __init__(self, market_aware, days = None, delta = None):
+3 -1
View File
@@ -3,12 +3,14 @@ from datetime import datetime, timedelta
from collections import defaultdict
from zipline import ndict
from zipline.gens.transform import EventWindow
from zipline.gens.transform import EventWindow, TransformMeta
class VWAP(object):
"""
Class that maintains a dictionary from sids to VWAPEventWindows.
"""
__metaclass__ = TransformMeta
def __init__(self, market_aware, delta=None, days=None):
self.market_aware = market_aware