3

Interactive Broker's TWS software has a way of showing trading day information, i.e. if the exchange was closed for this day and if open what the trading hours where. See here: https://www.interactivebrokers.com/en/index.php?f=22063

How do I retrieve this information via the relatively new TWS API?

I could not find it anywhere in the docs.

pashute
  • 3,965
  • 3
  • 38
  • 65
  • reqContractDetails will return a contractDetails object with tradingHours as a field, http://interactivebrokers.github.io/tws-api/classIBApi_1_1ContractDetails.html#a2a6f950c506280e2f2d3904126a3349d . Try some code and see if you need more help. Here's a sample https://stackoverflow.com/a/42868938/2855515 – brian Jan 22 '18 at 14:35
  • Thanks!!! That is it! Could you put that as an answer and I'll accept it? – pashute Jan 24 '18 at 05:49

1 Answers1

3

reqContractDetails(id, contract) will return a contractDetails object with tradingHours as a field.

Here's a sample of using the new API. Just call reqContractDetails instead of market data. There's a EWrapper callback for contractDetailsEnd that will be called when the API is finished sending data as there may be more than one contract.

brian
  • 10,619
  • 4
  • 21
  • 79
  • Is there a way to get the same data but for the past? E.g. for the past 1 month? – Zsolt Safrany Jul 05 '20 at 21:11
  • @ZsoltSafrany Not that I know of. Best to routinely save what you need. I go to investing dot com and scrape the holidays and news events for my own historical calendar. Exchanges also maintain a list of past holidays. Not sure about one off events like 9/11 or Bush sr.'s funeral. – brian Jul 05 '20 at 21:42
  • thanks for the reply. One workaround I found in the meantime with the IB API is to request historical data with bar size being 1 day and duration being X days. This will basically return the last X days where the market was open. – Zsolt Safrany Jul 05 '20 at 23:59