def import_vix_future():
    context = get_default_app_context()
    client = MongoClient('localhost', 27017)

    store = context.provider_mgr.get(DataStore.Mongo)
    store.start(app_context=context)

    ref_data_mgr = context.ref_data_mgr
    ref_data_mgr.start(app_context=context)

    seq_mgr = SequenceManager()
    seq_mgr.start(app_context=context)

    for ex in vix_expiries:
        inst = build_vix_future(ex, seq_mgr)
        ref_data_mgr.add_inst(inst)
    ref_data_mgr.save_all()
def import_vix_future():
    context = get_default_app_context()
    client = MongoClient('localhost', 27017)

    store = context.provider_mgr.get(DataStore.Mongo)
    store.start(app_context=context)

    ref_data_mgr = context.ref_data_mgr
    ref_data_mgr.start(app_context=context)

    seq_mgr = SequenceManager()
    seq_mgr.start(app_context=context)

    for ex in vix_expiries:
        inst = build_vix_future(ex, seq_mgr)
        ref_data_mgr.add_inst(inst)
    ref_data_mgr.save_all()
Example #3
0
    def __init__(self, app_config=None):
        super(ApplicationContext, self).__init__()

        self.startables = []

        self.app_config = app_config if app_config else ApplicationConfig()

        self.clock = self.add_startable(self.__get_clock())
        self.provider_mgr = self.add_startable(ProviderManager())

        self.seq_mgr = self.add_startable(SequenceManager())

        self.inst_data_mgr = self.add_startable(InstrumentDataManager())
        self.ref_data_mgr = self.add_startable(self.__get_ref_data_mgr())

        self.order_mgr = self.add_startable(OrderManager())
        self.acct_mgr = self.add_startable(AccountManager())
        self.portf_mgr = self.add_startable(PortfolioManager())
        self.stg_mgr = self.add_startable(StrategyManager())

        self.event_bus = EventBus()
    # app_config = ApplicationConfig(None, None, None, persistence_config,
    #                                config)
    return ApplicationContext(app_config=app_config)


context = get_default_app_context()
client = MongoClient('localhost', 27017)

store = context.provider_mgr.get(DataStore.Mongo)
store.start(app_context=context)

ref_data_mgr = context.ref_data_mgr
ref_data_mgr.start(app_context=context)

seq_mgr = SequenceManager()
seq_mgr.start(app_context=context)

class SwigIBClientForInstrument(EWrapper):
    '''Callback object passed to TWS, these functions will be called directly
    by TWS.
    '''

    def __init__(self, port=4001, client_id=12):
        super(SwigIBClientForInstrument, self).__init__()

        self.tws = EPosixClientSocket(self)
        self.port = port
        self.client_id = client_id

        self.got_history = Event()
Example #5
0
def test_save_sequences():
    context = get_default_app_context()
    store = context.provider_mgr.get(DataStore.Mongo)
    store.start(app_context=context)

    seq_mgr = SequenceManager()
    seq_mgr.start(app_context=context)

    print seq_mgr.get_next_sequence("order")
    print seq_mgr.get_next_sequence("order")

    print seq_mgr.get_next_sequence("trade")
    print seq_mgr.get_next_sequence("trade")

    seq_mgr.stop()

    seq_mgr = SequenceManager()
    seq_mgr.start(app_context=context)
    # app_config = ApplicationConfig(None, None, None, persistence_config,
    #                                config)
    return ApplicationContext(app_config=app_config)


context = get_default_app_context()
client = MongoClient('localhost', 27017)

store = context.provider_mgr.get(DataStore.Mongo)
store.start(app_context=context)

ref_data_mgr = context.ref_data_mgr
ref_data_mgr.start(app_context=context)

seq_mgr = SequenceManager()
seq_mgr.start(app_context=context)


class SwigIBClientForInstrument(EWrapper):
    '''Callback object passed to TWS, these functions will be called directly
    by TWS.
    '''
    def __init__(self, port=4001, client_id=12):
        super(SwigIBClientForInstrument, self).__init__()

        self.tws = EPosixClientSocket(self)
        self.port = port
        self.client_id = client_id

        self.got_history = Event()
Example #7
0
def test_save_sequences():
    context = get_default_app_context()
    store = context.provider_mgr.get(DataStore.Mongo)
    store.start(app_context=context)

    seq_mgr = SequenceManager()
    seq_mgr.start(app_context=context)

    print seq_mgr.get_next_sequence("order")
    print seq_mgr.get_next_sequence("order")

    print seq_mgr.get_next_sequence("trade")
    print seq_mgr.get_next_sequence("trade")

    seq_mgr.stop()

    seq_mgr = SequenceManager()
    seq_mgr.start(app_context=context)