fixed allocation issue

This commit is contained in:
fawce
2012-05-10 13:51:02 -04:00
parent 602f70d0fe
commit 81de47774f
4 changed files with 12 additions and 2 deletions
+3
View File
@@ -15,6 +15,9 @@ class MovingAverageTransform(BaseTransform):
cur.update(event)
self.state['value'] = cur.average
return self.state
def create_vwap(self):
return DailyVWAP(self.daycount)
class MovingAverage(object):
+5 -2
View File
@@ -9,18 +9,21 @@ class VWAPTransform(BaseTransform):
def init(self, daycount=3):
self.daycount = daycount
self.by_sid = defaultdict(DailyVWAP)
self.by_sid = defaultdict(self.create_vwap)
def transform(self, event):
cur = self.by_sid(event.sid)
cur.update(event)
self.state['value'] = cur.vwap
return self.state
def create_vwap(self):
return DailyVWAP(self.daycount)
class DailyVWAP:
"""A class that tracks the volume weighted average price
based on tick updates."""
def __init__(self, daycount=3):
def __init__(self, daycount):
self.window = EventWindow(daycount)
self.flux = 0.0
self.volume = 0
+2
View File
@@ -143,6 +143,8 @@ class SimulatedTrading(object):
sockets[7],
logging = qutil.LOGGER
)
self.con.cancel_socket = self.allocator.lease(1)[0]
# TODO: Not freeform
self.con.manage(
+2
View File
@@ -17,6 +17,8 @@ class ZiplineWithTransformsTestCase(TestCase):
leased_sockets = defaultdict(list)
def setUp(self):
# skip ahead 100 spots
allocator.lease(100)
qutil.configure_logging()
self.trading_environment = factory.create_trading_environment()
self.zipline_test_config = {