def test_validate(self):
        sessionID = fix.SessionID("FIX.4.2", "SenderCompID", "TargetCompID")

        dictionary = fix.Dictionary()
        try:
            self.object.set(sessionID, dictionary)
            self.assertTrue(0)
        except fix.ConfigError as e:
            self.assertTrue(1)

        dictionary.setString(fix.CONNECTION_TYPE, "badvalue")
        try:
            self.object.set(sessionID, dictionary)
            self.assertTrue(0)
        except fix.ConfigError as e:
            self.assertTrue(1)

        dictionary.setString(fix.CONNECTION_TYPE, "initiator")
        try:
            self.object.set(sessionID, dictionary)
            self.assertTrue(1)
        except fix.ConfigError as e:
            self.assertTrue(0)

        sessionID = fix.SessionID("FIX4.2", "SenderCompID", "TargetCompID")
        try:
            self.object.set(sessionID, dictionary)
            self.assertTrue(0)
        except fix.ConfigError as e:
            self.assertTrue(1)
    def test_validate(self):
        sessionID = fix.SessionID("FIX.4.2", "SenderCompID", "TargetCompID")

        dictionary = fix.Dictionary()
        try:
            self.object.set(sessionID, dictionary)
            self.failUnless(0)
        except fix.ConfigError, e:
            self.failUnless(1)
示例#3
0
 def test_merge(self):
     self.object.setString("FIRSTKEY", "FIRSTVALUE")
     self.object.setString("THIRDKEY", "FIRST")
     second = fix.Dictionary()
     second.setString("SECONDKEY", "SECONDVALUE")
     second.setString("THIRDKEY", "SECOND")
     self.object.merge(second)
     self.failUnless(self.object.getString("FIRSTKEY") == "FIRSTVALUE")
     self.failUnless(self.object.getString("SECONDKEY") == "SECONDVALUE")
     self.failUnless(self.object.getString("THIRDKEY") == "FIRST")
def main():
    sessionID = fix.SessionID('FIX.4.4', SENDERCOMPID, 'PAYMIUM')

    params = fix.Dictionary()
    params.setString('ConnectionType', 'initiator')
    params.setString('StartTime', '00:00:00')
    params.setString('EndTime', '00:00:00')
    params.setString('HeartBtInt', '30')
    params.setString('CheckLatency', 'Y')
    params.setString('SocketConnectHost', '195.154.171.115')
    params.setString('SocketConnectPort', '8359')
    params.setString('DataDictionary', FIX44FILE)
    params.setString('EncryptMethod', '0')

    settings = fix.SessionSettings()
    settings.set(sessionID, params)

    application = MyApplication()
    factory = fix.FileStoreFactory("store")
    acceptor = fix.SocketInitiator(application, factory, settings,
                                   fix.ScreenLogFactory(DEBUG, DEBUG, DEBUG))
    acceptor.start()

    time.sleep(2)

    mdr = fixMsg.MarketDataRequest()
    mdr.setField(fix.MDReqID("MDRQ-%d" % (time.time() * 1000000)))
    # We want the full book here, not just the top
    mdr.setField(fix.MarketDepth(1))
    # We want to get a snapshot and also subscribe to the market depth updates
    mdr.setField(
        fix.SubscriptionRequestType(
            fix.SubscriptionRequestType_SNAPSHOT_PLUS_UPDATES))
    # We'll want only incremental refreshes when new data is available
    mdr.setField(fix.MDUpdateType(fix.MDUpdateType_INCREMENTAL_REFRESH))
    # Specify the currency
    instruments = fixMsg.MarketDataRequest().NoRelatedSym()
    instruments.setField(fix.Symbol("EUR/XBT"))
    mdr.addGroup(instruments)
    # Specify that we'll want the bids and asks
    mdr.setField(fix.NoMDEntryTypes(2))
    group = fixMsg.MarketDataRequest().NoMDEntryTypes()
    group.setField(fix.MDEntryType(fix.MDEntryType_BID))
    group.setField(fix.MDEntryType(fix.MDEntryType_OFFER))
    mdr.addGroup(group)

    fix.Session.sendToTarget(mdr, sessionID)

    while True:
        time.sleep(10)

    acceptor.stop()
 def test_get_sessions(self):
     dictionary = fix.Dictionary()
     dictionary.setString(fix.BEGINSTRING, "FIX.4.4")
     dictionary.setString(fix.START_TIME, "00:00:00")
     dictionary.setString(fix.END_TIME, "00:00:00")
     dictionary.setString(fix.CONNECTION_TYPE, "initiator")
     self.object.set(dictionary)
     sessionids = [fix.SessionID('FIX.4.4', 'SenderA', 'TargetA'), fix.SessionID('FIX.4.4', 'SenderB', 'TargetB')]
     for sessionid in sessionids:
         self.object.set(sessionid, self.object.get())
     sessionids = [str(s) for s in sessionids]
     for sessionid in self.object.getSessions():
         self.assertIn(str(sessionid), sessionids)
示例#6
0
文件: genus.py 项目: edword01/vnpy
    def start(self):
        """"""
        self.register_event()

        # For child app
        child_settings = fix.SessionSettings()
        child_dict = fix.Dictionary()

        child_dict.setString("ConnectionType", "acceptor")
        child_dict.setString("ResetOnLogon", "Y")
        child_dict.setString("FileLogPath", "./genus_log/child")
        child_dict.setString("LogonTimeout", "30")
        child_dict.setString("StartTime", "00:00:00")
        child_dict.setString("EndTime", "00:00:00")
        child_dict.setString("HeartBtInt", "30")
        child_dict.setString("CheckLatency", "N")
        child_dict.setString("UseDataDictionary", "N")
        child_dict.setString("FileStorePath", "./genus_store/child")
        child_dict.setString("ScreenLogShowIncoming", "N")
        child_dict.setString("ScreenLogShowOutgoing", "N")
        child_dict.setString("ScreenLogShowEvents", "N")

        child_dict.setString("SocketAcceptHost", SETTINGS["genus.child_host"])
        child_dict.setString("SocketAcceptPort", SETTINGS["genus.child_port"])

        child_session = fix.SessionID("FIX.4.2",
                                      SETTINGS["genus.child_sender"],
                                      SETTINGS["genus.child_target"])
        child_settings.set(child_session, child_dict)

        child_store_factory = fix.FileStoreFactory(child_settings)
        child_log_factory = fix.ScreenLogFactory(child_settings)

        self.child_app: GenusChildApp = GenusChildApp(self)
        self.child_socket = fix.SocketAcceptor(self.child_app,
                                               child_store_factory,
                                               child_settings,
                                               child_log_factory)
        self.child_socket.start()

        # For parent app
        parent_settings = fix.SessionSettings()
        parent_dict = fix.Dictionary()

        parent_dict.setString("ConnectionType", "initiator")
        parent_dict.setString("ResetOnLogon", "Y")
        parent_dict.setString("FileLogPath", "./genus_log/parent")
        parent_dict.setString("LogonTimeout", "30")
        parent_dict.setString("StartTime", "00:00:00")
        parent_dict.setString("EndTime", "00:00:00")
        parent_dict.setString("HeartBtInt", "30")
        parent_dict.setString("CheckLatency", "N")
        parent_dict.setString("UseDataDictionary", "N")
        parent_dict.setString("FileStorePath", "./genus_store/parent")
        parent_dict.setString("ScreenLogShowIncoming", "N")
        parent_dict.setString("ScreenLogShowOutgoing", "N")
        parent_dict.setString("ScreenLogShowEvents", "N")

        parent_dict.setString("SocketConnectHost",
                              SETTINGS["genus.parent_host"])
        parent_dict.setString("SocketConnectPort",
                              SETTINGS["genus.parent_port"])

        parent_session = fix.SessionID("FIX.4.2",
                                       SETTINGS["genus.parent_sender"],
                                       SETTINGS["genus.parent_target"])
        parent_settings.set(parent_session, parent_dict)

        parent_store_factory = fix.FileStoreFactory(parent_settings)
        parent_log_factory = fix.ScreenLogFactory(parent_settings)

        self.parent_app: GenusParentApp = GenusParentApp(self)
        self.parent_socket = fix.SocketInitiator(self.parent_app,
                                                 parent_store_factory,
                                                 parent_settings,
                                                 parent_log_factory)
        self.parent_socket.start()
示例#7
0
 def setUp(self):
     self.object = fix.Dictionary()