Esempio n. 1
0
    def __init__(self):

        self.emkt = easymkt.EasyMKT()

        print("Setting up field list...")

        self.emkt.add_field("TICKER")
        self.emkt.add_field("LAST_PRICE")
        self.emkt.add_field("MID")
        self.emkt.add_field("BID")
        self.emkt.add_field("ASK")

        print("Field List: ")

        for f in self.emkt.subscription_fields:
            print("\t" + f)

        print("Setting up security universe...")

        self.emkt.add_security("BBHBEAT Index")
        self.emkt.add_security("VOD LN Equity")
        self.emkt.add_security("IBM US Equity")

        print("Security universe: ")

        for s in self.emkt.securities:
            print("\t" + s.name)

        self.emkt.add_notification_handler(self.process_notification)

        self.emkt.start()
Esempio n. 2
0
    def test_external_request_non_blocking(self):

        raised = False

        try:
            emkt = easymkt.EasyMKT()
            emkt.start()

            req = emkt.create_request("ReferenceDataRequest")

            req.append("securities", "IBM US Equity")

            req.append("fields", "PX_LAST")

            self.pending_result = True

            emkt.send_request(req, self.message_handler)

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

        self.pending_result = True

        while self.pending_result:
            pass

        self.assertFalse(raised)
Esempio n. 3
0
    def test_external_request_blocking(self):

        raised = False

        msg = None

        try:
            emkt = easymkt.EasyMKT()
            emkt.start()

            req = emkt.create_request("ReferenceDataRequest")

            req.append("securities", "IBM US Equity")

            req.append("fields", "PX_LAST")

            msg = emkt.send_request(req)

            pxlast = msg.getElement("securityData").getValue(0).getElement(
                "fieldData").getElement("PX_LAST").getValue()
            print(pxlast)

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

        print(msg)

        self.assertFalse(raised)
Esempio n. 4
0
    def test_start_easymkt_does_not_fail(self):

        raised = False

        try:
            pass
            emkt = easymkt.EasyMKT()
            emkt.add_field("LAST_PRICE")
            sec = emkt.add_security("BBHBEAT Index")
            sec.add_notification_handler(self.process_notification)
            emkt.start()

            time.sleep(5)

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

        self.assertFalse(raised)