tradesim as generator v. 2.0

This commit is contained in:
scottsanderson
2012-08-03 14:07:05 -04:00
parent d74bc1bbc5
commit ace5d05fab
6 changed files with 229 additions and 137 deletions
+8 -2
View File
@@ -11,8 +11,8 @@ log = logbook.Logger('Transaction Simulator')
class TransactionSimulator(object):
UPDATER = True
def __init__(self, open_orders, style=SIMULATION_STYLE.PARTIAL_VOLUME):
self.open_orders = open_orders
def __init__(self, sid_filter, style=SIMULATION_STYLE.PARTIAL_VOLUME):
self.open_orders = {}
self.txn_count = 0
self.trade_window = datetime.timedelta(seconds=30)
self.orderTTL = datetime.timedelta(days=1)
@@ -27,6 +27,12 @@ class TransactionSimulator(object):
elif style == SIMULATION_STYLE.NOOP:
self.apply_trade_to_open_orders = self.simulate_noop
for sid in sid_filter:
self.open_orders[sid] = []
def place_order(self, order):
self.open_orders[order.sid].append(order)
def update(self, event):
event.TRANSACTION = None
if event.type == zp.DATASOURCE_TYPE.TRADE: