Beispiel #1
0
import zipline.errors
import zipline.protocol as zp

from zipline.finance.slippage import (VolumeShareSlippage, transact_partial,
                                      check_order_triggers)
from zipline.finance.commission import PerShare
from zipline.utils.protocol_utils import Enum

from zipline.utils.serialization_utils import (VERSION_LABEL)

log = Logger('Blotter')

ORDER_STATUS = Enum(
    'OPEN',
    'FILLED',
    'CANCELLED',
    'REJECTED',
    'HELD',
)


class Blotter(object):
    def __init__(self, take_market=False):
        self.transact = transact_partial(VolumeShareSlippage(), PerShare())
        # these orders are aggregated by sid
        self.open_orders = defaultdict(list)
        # keep a dict of orders by their own id
        self.orders = {}
        # holding orders that have come in since the last
        # event.
        self.new_orders = []
Beispiel #2
0
from zipline import ndict
from zipline.protocol import SIDData, DATASOURCE_TYPE
from zipline.finance.performance import PerformanceTracker
from zipline.gens.utils import hash_args

from zipline.finance.slippage import (VolumeShareSlippage, transact_partial,
                                      check_order_triggers)
from zipline.finance.commission import PerShare
import zipline.utils.math_utils as zp_math

log = Logger('Trade Simulation')

from zipline.utils.protocol_utils import Enum

ORDER_STATUS = Enum('OPEN', 'FILLED')


class Blotter(object):
    def __init__(self):
        self.transact = transact_partial(VolumeShareSlippage(), PerShare())
        # these orders are aggregated by sid
        self.open_orders = defaultdict(list)
        # keep a dict of orders by their own id
        self.orders = {}
        # holding orders that have come in since the last
        # event.
        self.new_orders = []

    def place_order(self, order):
        # initialized filled field.