mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-15 12:15:22 +08:00
Applies PEP-8 recommendations. White space tweaking.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
from zipline.gens.transform import TransformMeta
|
from zipline.gens.transform import TransformMeta
|
||||||
from collections import defaultdict, deque
|
from collections import defaultdict, deque
|
||||||
|
|
||||||
|
|
||||||
class Returns(object):
|
class Returns(object):
|
||||||
"""
|
"""
|
||||||
Class that maintains a dictionary from sids to the sid's
|
Class that maintains a dictionary from sids to the sid's
|
||||||
@@ -16,8 +17,8 @@ class Returns(object):
|
|||||||
"""
|
"""
|
||||||
Update and return the calculated returns for this event's sid.
|
Update and return the calculated returns for this event's sid.
|
||||||
"""
|
"""
|
||||||
assert event.has_key('dt')
|
assert 'dt' in event
|
||||||
assert event.has_key('price')
|
assert 'price' in event
|
||||||
tracker = self.mapping[event.sid]
|
tracker = self.mapping[event.sid]
|
||||||
tracker.update(event)
|
tracker.update(event)
|
||||||
|
|
||||||
@@ -26,6 +27,7 @@ class Returns(object):
|
|||||||
def _create(self):
|
def _create(self):
|
||||||
return ReturnsFromPriorClose(self.days)
|
return ReturnsFromPriorClose(self.days)
|
||||||
|
|
||||||
|
|
||||||
class ReturnsFromPriorClose(object):
|
class ReturnsFromPriorClose(object):
|
||||||
"""
|
"""
|
||||||
Records the last N closing events for a given security as well as the
|
Records the last N closing events for a given security as well as the
|
||||||
@@ -72,6 +74,5 @@ class ReturnsFromPriorClose(object):
|
|||||||
change = event.price - last_close
|
change = event.price - last_close
|
||||||
self.returns = change / last_close
|
self.returns = change / last_close
|
||||||
|
|
||||||
|
|
||||||
# the current event is now the last_event
|
# the current event is now the last_event
|
||||||
self.last_event = event
|
self.last_event = event
|
||||||
|
|||||||
Reference in New Issue
Block a user