Moves slippage transactions off of ndict.

So that the datatype is unique.
This commit is contained in:
Eddie Hebert
2013-01-22 20:55:24 -05:00
parent 649fb10c8e
commit d5a0446f7b
2 changed files with 12 additions and 4 deletions
+1 -1
View File
@@ -549,7 +549,7 @@ class PerformancePeriod(object):
# we want the key to be absent, not just empty
if self.keep_transactions:
transactions = [x.as_dict() for x in self.processed_transactions]
transactions = [x.__dict__ for x in self.processed_transactions]
rval['transactions'] = transactions
return rval
+11 -3
View File
@@ -19,8 +19,6 @@ import math
from functools import partial
from zipline.utils.protocol_utils import ndict
from logbook import Processor
@@ -48,6 +46,16 @@ def transact_partial(slippage, commission):
return partial(transact_stub, slippage, commission)
class Transaction(object):
def __init__(self, initial_values=None):
if initial_values:
self.__dict__ = initial_values
def __getitem__(self, name):
return self.__dict__[name]
def create_transaction(sid, amount, price, dt):
txn = {
@@ -57,7 +65,7 @@ def create_transaction(sid, amount, price, dt):
'price': price,
}
transaction = ndict(txn)
transaction = Transaction(txn)
return transaction