Dinosaur Technology and Trading » Interactive Brokers C# Client

Getting ContractId value?

(3 posts)

  1. ianb
    Member

    Hi Karl,

    Thank you for a great API. I started using the IB JAVA API but as I know very little about JAVA had a tough time with it. Using your API, Visual Studio Express and C# I have made a lot of progress in a much shorter time even as a DOT NET newbie.

    To the point. I'm trying to match contract info between the client events and my application. I wanted the ContractId and wrote the following:

    int EStickerId = 201;
    string expiration = "200809"
    ES = new Contract("ES", "GLOBEX", SecurityType.Future, "USD", expiration);
    client.RequestMarketData(EStickerId, ES, null, false);
    int EScontractId = ES.ContractId;

    expecting to get the ContractId in EScontractId but I get 0. I looked at the definition of Contract.ContractId and don't see it being set. I haven't checked (& don't really want to!) the JAVA API to see if that returns the right value. I have a workaround which gets the ContractId from the client_UpdatePortFolio event using e.Contract.ContractId but I have no guarantee that I will get client_UpdatePortFolio event ...

    Any help in getting the ContractId immediately after client.RequestMarketData would be much appreciated.

    Ian

    Posted 2 months ago #
  2. ianb
    Member

    I found a better workaround - using the symbol instead of the contract ID. It's not as robust but as I my ATS doesn't trade different expirations, that's not a problem :


    int EStickerId = 201;
    string expiration = "200809"
    ES = new Contract("ES", "GLOBEX", SecurityType.Future, "USD", expiration);
    client.RequestMarketData(EStickerId, ES, null, false);
    string ESsymbol = ES.symbol;

    ES.symbol returns the correct data while ES.ContractId returns 0.<br>

    Once again, thanks again for an excellent API.

    Ian

    Posted 2 months ago #
  3. Hey Ian,

    Use

    public void ReqContractDetails(
    Contract contract
    )

    The resulting call back will have the contractId set.

    -Karl

    Posted 1 month ago #

RSS feed for this topic

Reply

You must log in to post.