Пример #1
0
def test_update_details():
    t = MixinFixture()
    t.version = 110

    instrument = Instrument(t)
    instrument.symbol = 'AAPL'
    instrument.security_ids = {SecurityIdentifierType.ISIN: 'US0378331005'}

    fut = t.refresh_instrument(instrument)
    assert not fut.done()
    t.assert_message_sent(9, 8, 43, 0, 'AAPL', '', '', 0.0, '', '', '', '', '', '', '', False,
                          'ISIN', 'US0378331005')

    t.dispatch_message(["10", "1", "43",  # CONTRACT_DATA
                        "AAPL", "STK", "", "", "", "NASDAQ", "", "", "", "", "", "",
                        "",
                        "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "0",
                        ""])
    assert not fut.done()
    assert instrument.symbol == 'AAPL'
    assert instrument.exchange == 'NASDAQ'

    t.dispatch_message(["52", "1", "43"]),  # CONTRACT_DATA_END
    assert fut.done()
    assert fut.result() is instrument
Пример #2
0
    def _handle_symbol_samples(self, request_id: RequestId, num_contracts: int, message: IncomingMessage):
        result = []
        for _ in range(num_contracts):
            contract = Instrument(self)

            contract.contract_id = message.read(int)
            contract.symbol = message.read(str)
            contract.security_type = SecurityType(message.read(str))
            contract.primary_exchange = message.read(str)
            contract.currency = message.read(str)

            message.read(typing.List[str])  # derivative_security_types

            result.append(contract)

        self.resolve_future(request_id, result)