Applies PEP-8 recommendations to vwap module.

This commit is contained in:
Eddie Hebert
2012-09-04 18:57:01 -04:00
parent 5bd57d148c
commit 4d5457a363
+8 -6
View File
@@ -3,6 +3,7 @@ from collections import defaultdict
from zipline.gens.transform import EventWindow, TransformMeta
class VWAP(object):
"""
Class that maintains a dictionary from sids to VWAPEventWindows.
@@ -14,7 +15,7 @@ class VWAP(object):
self.market_aware = market_aware
self.delta = delta
self.days = days
# Market-aware mode only works with full-day windows.
if self.market_aware:
assert self.days and not self.delta,\
@@ -28,13 +29,13 @@ class VWAP(object):
# No way to pass arguments to the defaultdict factory, so we
# need to define a method to generate the correct EventWindows.
self.sid_windows = defaultdict(self.create_window)
def create_window(self):
"""Factory method for self.sid_windows."""
return VWAPEventWindow(
self.market_aware,
days = self.days,
delta = self.delta
self.market_aware,
days=self.days,
delta=self.delta
)
def update(self, event):
@@ -48,6 +49,7 @@ class VWAP(object):
window.update(event)
return window.get_vwap()
class VWAPEventWindow(EventWindow):
"""
Iteratively maintains a vwap for a single sid over a given
@@ -69,7 +71,7 @@ class VWAPEventWindow(EventWindow):
def handle_remove(self, event):
self.flux -= event.volume * event.price
self.totalvolume -= event.volume
def get_vwap(self):
"""
Return the calculated vwap for this sid.