From 4d5457a3631d598967f2e44b0b288ed5ec016287 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Tue, 4 Sep 2012 18:57:01 -0400 Subject: [PATCH] Applies PEP-8 recommendations to `vwap` module. --- zipline/gens/vwap.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/zipline/gens/vwap.py b/zipline/gens/vwap.py index e904d0e0..9d908b46 100644 --- a/zipline/gens/vwap.py +++ b/zipline/gens/vwap.py @@ -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.