TWS API historical data retrieval after corporate actions

Discussion in 'Interactive Brokers' started by lime, Oct 11, 2024.

  1. lime

    lime

    I have been using the API to retrieve historical intraday data, but am bumping into a wall when the names have done corporate actions mostly splits.

    I cannot get data for (showing no contract):

    - LRCX prior to Oct 3. It did a 10:1 split effective Oct 3.
    - BLK prior to Oct 1. BlackRock completed merger with Global Infrastructure Partners but ticker remained BLK.

    How shall I do it?
     
  2. In the two examples you mention did the stock ticker remain unchanged. However, as it was a material change IB assigned a new so-called conid to each of them.
    For CLRX it changed from 271308 to 732440574
    For BLK it changed from 5049 to 729193719

    IB has a search engine where you can find details about the instruments (stocks, ETFs, futures, etc): https://misc.interactivebrokers.com/cstools/contract_info/v3.10/index.php
     
    lime likes this.
  3. lime

    lime

    Where do you see the old (pre action) conid?
     
  4. In my own database. I happen to have those two tickers on a list of which I am downloading daily data. When updating that list I don't overwrite the old entry, but add a new entry. That's why I still know what those old conid's were.
     
    lime likes this.
  5. lime

    lime

    How shall one download data prior to the corporate actions (change of conid) then?

    I use below to set contract for requesting data, which now will be set to the new conid so doesn’t exist prior to the stock split.

    Contract contract = new Contract();
    contract.Symbol = "LRCX”;
    contract.SecType = "STK";
    contract.Currency = "USD";
    contract.Exchange = "SMART”;
     
  6. I am not sure whether IB retains the historical data of a conid after they have changed that. IB don't consider themselves to be a data vendor, so they might delete old contracts that don't exist anymore.

    It is possible though to specify the conid of the contract for which you want historical data. Use: contract.Conid = xxxx. Then request historical data for that contract. As the conid (conid = contract identifier) is a unique parameter you wouldn't need to add many more parameters to define the contract. You could try to use this for the old conid's and see whether IB still has the data available for you.
     
    lime and MoreLeverage like this.
  7. lime

    lime

    It is just a stock split.
    But again how can I search for the old conid?
     
  8. You can't.
     
  9. lime

    lime

    I find that overly complicated. Just a company doing stock splits. Why should that cause a break in the data retrieval