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()
    # 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()
Esempio n. 3
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)