Exemple #1
0
    def test_external_request_blocking(self):

        raised = False

        try:
            emsx = easymsx.EasyMSX()
            emsx.start()

            req = emsx.create_request("CreateOrder")

            req.set("EMSX_TICKER", "IBM US Equity")
            req.set("EMSX_AMOUNT", 1000)
            req.set("EMSX_ORDER_TYPE", "MKT")
            req.set("EMSX_TIF", "DAY")
            req.set("EMSX_HAND_INSTRUCTION", "ANY")
            req.set("EMSX_SIDE", "BUY")

            msg = emsx.send_request(req)

            if msg.messageType() == "ErrorInfo":
                raised = True

        except BaseException as e:
            print("Error: " + str(e))
            raised = True

        print(msg)

        self.assertFalse(raised)
Exemple #2
0
    def test_external_request_non_blocking(self):

        raised = False

        try:
            emsx = easymsx.EasyMSX()
            emsx.start()

            req = emsx.create_request("CreateOrder")

            req.set("EMSX_TICKER", "IBM US Equity")
            req.set("EMSX_AMOUNT", 1000)
            req.set("EMSX_ORDER_TYPE", "MKT")
            req.set("EMSX_TIF", "DAY")
            req.set("EMSX_HAND_INSTRUCTION", "ANY")
            req.set("EMSX_SIDE", "BUY")

            self.pending_result = True

            emsx.send_request(req, self.message_handler)

        except BaseException as e:
            print("Error: " + str(e))
            raised = True

        while self.pending_result:
            pass

        self.assertFalse(raised)
Exemple #3
0
    def test_start_easymsx_does_not_fail(self):

        raised = False

        try:
            emsx = easymsx.EasyMSX()
            emsx.orders.add_notification_handler(self.process_notification)
            emsx.routes.add_notification_handler(self.process_notification)

            emsx.start()

        except BaseException as e:
            print("Error: " + str(e))
            raised = True

        self.assertFalse(raised)
Exemple #4
0
    def __init__(self):
        
        print("Initializing EasyMSX...")
        self.emsx = easymsx.EasyMSX()
        print("...done initializing.\n")
        
        print("Teams: ")
        for t in self.emsx.teams:
            print("\t"+t.name)

        print("\nBrokers: ")
        for b in self.emsx.brokers:
            print("\t"+b.name)

        self.emsx.orders.add_notification_handler(self.process_order_notification)
        self.emsx.routes.add_notification_handler(self.process_route_notification)
        
        self.emsx.start()