mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-28 14:29:26 +08:00
fixes for unit tests, back to 50/51 passing.
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
from collections import defaultdict
|
||||
from zipline.transforms.base import BaseTransform
|
||||
|
||||
class Returns(object):
|
||||
"""
|
||||
Class that maintains a dictionary from sids to the event
|
||||
representing the most recent closing price.
|
||||
"""
|
||||
def __init__(self, days == 1):
|
||||
def __init__(self, days = 1):
|
||||
self.days = days
|
||||
self.mapping = defaultdict(self._create)
|
||||
|
||||
|
||||
def update(self, event):
|
||||
"""
|
||||
Update and return the calculated returns for this event's sid.
|
||||
@@ -18,7 +17,7 @@ class Returns(object):
|
||||
return sid_returns
|
||||
|
||||
def _create(self):
|
||||
return ReturnsFromPriorClose(days)
|
||||
return ReturnsFromPriorClose(self.days)
|
||||
|
||||
class ReturnsFromPriorClose(object):
|
||||
"""
|
||||
|
||||
@@ -31,6 +31,8 @@ class TransactionSimulator(object):
|
||||
self.open_orders[sid] = []
|
||||
|
||||
def place_order(self, order):
|
||||
# initialized filled field.
|
||||
order.filled = 0
|
||||
self.open_orders[order.sid].append(order)
|
||||
|
||||
def update(self, event):
|
||||
@@ -39,7 +41,7 @@ class TransactionSimulator(object):
|
||||
if event.type == zp.DATASOURCE_TYPE.TRADE:
|
||||
event.TRANSACTION = self.apply_trade_to_open_orders(event)
|
||||
return event
|
||||
|
||||
|
||||
def simulate_buy_all(self, event):
|
||||
txn = self.create_transaction(
|
||||
event.sid,
|
||||
|
||||
Reference in New Issue
Block a user