Diagnosing Issues and Troubleshooting with the TWS API (2024)

Table of Contents
Study Notes: Leave a Reply

Duration 7:45

Level Beginner

Ask a Curriculum Question

Take Lesson Quiz

Study Notes:

It is important to remember that the TWS API is an interface or an extension of TWS and IB Gateway. When troubleshooting issues with the Excel samples or other API applications, it is important to check the corresponding TWS functions. The TWS can be used as a reference for the expected behavior of the API application, or to check if a legitimate issue stems from the TWS itself. Additionally, when working with API applications, it is important to monitor error messages and gather diagnostics files and logs. These topics will all be covered in this video.

Example Case

Say you are requesting:

  • Historical data via the Excel DDE sample.
  • In row 12, we are requesting historical 1 day bars for IBKR.
  • The endDateTime is 20200909 23:59:59.

Diagnosing Issues and Troubleshooting with the TWS API (1)

With these parameters, you may assume that the last daily bar returned would have a time stamp of 20200907.

Diagnosing Issues and Troubleshooting with the TWS API (2)

However, the timestamp of the last bar is “20200904”.To check why the response is not what’s expected, we can review the corresponding TWS function. In this case, the API historical bars function corresponds to TWS bar charts.

In our shifted graph, locate the bar with date 202009. Then, let’s count 3 day bars going back starting with 20200909.
In a TWS chart, if we try to count 3 bars at this date, the last bar is also 20200904 and there is no bar for 0907.

Diagnosing Issues and Troubleshooting with the TWS API (3)
You have now confirmed the TWS shows the same results. To take it a step further and see if this is expected TWS behavior, you could check the IBKR trading schedule and found that trading was closed on 0907.

Error messages and Notifications

When an API function does not produce the expected results, the first thing to check for are error messages. Whenever a request is made to TWS by the API, some sort of response is usually expected, whether it is account management, market data, or an error message. Although there can be an issue that causes the TWS to never return a response to the API, it is fairly uncommon.

The API returns error messages via the error callback function. As with most callback functions, each message has a “reqId” or request Id associated with it. This ID will allow you to associate the error with a specific request, whether it be a placed order, a request for market data, etc.

Let’s go back to our first scenario where we were requesting historical data for IBKR via the DDE sample.
Now, let’s intentionally send an incorrect request.

  • Here we will add an “R” to the end of the symbol to make the symbol invalid.
  • No new output page was created, and if we scroll to column Z, there is an error.
  • The error code is 200.
  • This error indicates there is something wrong with our contract, in this case the symbol.
  • An ID number associated with this historical data request and error is listed in column X.
  • To see a list of most error messages and a description of what they indicate, go to the errors documentation page in Github.
  • As a final note, when moving on to build custom API spreadsheets and applications, error messages will be essential as well in order to create a robust program that can respond to different situations.
  • See our documentation on “Considerations for Automated Systems” for further information.

Log files and Diagnostics

  • If you are not able to find the source of an issue by checking the TWS or reviewing the received error messages, the next step is to gather log files and diagnostics for review. Advanced logging must enabled in the API settings.
  • Go to File, Global Configuration,API, Settings.
  • Check the box “create API message log file.” This will create a separate log file, only recording API messages.
  • Then, set the logging level to “Detail.” This will allow the TWS to record detailed API messages in its logs.
  • Also, you may check the box “Include market data in API log file” if you are troubleshooting issues involving market
    data figures.

Diagnosing Issues and Troubleshooting with the TWS API (4)
Now let’s click on Apply and Ok, and advanced API logging is enabled from this point forward.

After an issue occurs, the log files can be reviewed by either the client or an API support representative.

  • A client may view their logs by going to the menu Account, Diagnostics, then choose either the TWS logs or the API logs.
  • Choose a date and export the logs to a directory. Logs are saved as text files.
  • To upload logs for review with an IBKR client services representative, press the keyboard combination Ctrl-Alt-Q in TWS or IB Gateway, or go to the Help menu and Upload Diagnostics.
  • Then in the Upload Diagnostics window, press Submit.
  • The TWS and API logs can be a bit complex, especially the TWS logs.

However, an important concept in the API logs is that a left arrow indicates an outbound message or request being sent from the API to TWS, and a right arrow is a message being returned by TWS to the API.

This covers the major concepts of issue diagnosing and troubleshooting. IBKR support representatives can help with further questions.
Please note that the API can help troubleshoot issues and review log files, however it cannot provide programming assistance or troubleshoot local operating system issues.

The topics discussed here are also documented in our API support page.

Additional Links

Troubleshooting and Support

Error Handling

Contact Us

Join The Conversation

If you have a general question, it may already be covered in our FAQs. If you have an account-specific question or concern, please reach out to Client Services.

Visit IBKR.comOpen an IBKR Account

2 thoughts on “Diagnosing Issues and Troubleshooting with the TWS API”

  • “A client may view their logs by going to the menu Account, Diagnostics, then choose either the TWS logs or the API logs.”
    This statement is incorrect, Cant see Diagnostics in Account menu at all

    Reply

Leave a Reply

Disclosure: Interactive Brokers

The analysis in this material is provided for information only and is not and should not be construed as an offer to sell or the solicitation of an offer to buy any security. To the extent that this material discusses general market activity, industry or sector trends or other broad-based economic or political conditions, it should not be construed as research or investment advice. To the extent that it includes references to specific securities, commodities, currencies, or other instruments, those references do not constitute a recommendation by IBKR to buy, sell or hold such investments. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circ*mstances and, as necessary, seek professional advice.

The views and opinions expressed herein are those of the author and do not necessarily reflect the views of Interactive Brokers, its affiliates, or its employees.

Disclosure: API Examples Discussed

Throughout the lesson, please keep in mind that the examples discussed are purely for technical demonstration purposes, and do not constitute trading advice. Also, it is important to remember that placing trades in a paper account is recommended before any live trading.

Diagnosing Issues and Troubleshooting with the TWS API (2024)
Top Articles
How To Connect an Alexa Device to WiFi : HelloTech How
Power Outage Map Albany Ny
What Are the Best Cal State Schools? | BestColleges
Immobiliare di Felice| Appartamento | Appartamento in vendita Porto San
1movierulzhd.fun Reviews | scam, legit or safe check | Scamadviser
His Lost Lycan Luna Chapter 5
Jefferson County Ky Pva
Category: Star Wars: Galaxy of Heroes | EA Forums
Katie Boyle Dancer Biography
Rls Elizabeth Nj
Student Rating Of Teaching Umn
Oriellys St James Mn
Wunderground Huntington Beach
Slushy Beer Strain
General Info for Parents
Craigslist Motorcycles Orange County Ca
Saberhealth Time Track
Vanessa West Tripod Jeffrey Dahmer
Check From Po Box 1111 Charlotte Nc 28201
Best Forensic Pathology Careers + Salary Outlook | HealthGrad
WEB.DE Apps zum mailen auf dem SmartPhone, für Ihren Browser und Computer.
10-Day Weather Forecast for Santa Cruz, CA - The Weather Channel | weather.com
360 Tabc Answers
Invitation Homes plans to spend $1 billion buying houses in an already overheated market. Here's its presentation to investors setting out its playbook.
Blue Rain Lubbock
Veracross Login Bishop Lynch
Panolian Batesville Ms Obituaries 2022
Jayah And Kimora Phone Number
Colonial Executive Park - CRE Consultants
Sessional Dates U Of T
Weathervane Broken Monorail
Chelsea Hardie Leaked
Ultra Ball Pixelmon
This Is How We Roll (Remix) - Florida Georgia Line, Jason Derulo, Luke Bryan - NhacCuaTui
Delta Math Login With Google
In hunt for cartel hitmen, Texas Ranger's biggest obstacle may be the border itself (2024)
J&R Cycle Villa Park
Best New England Boarding Schools
October 19 Sunset
拿到绿卡后一亩三分地
M Life Insider
Cpmc Mission Bernal Campus & Orthopedic Institute Photos
התחבר/י או הירשם/הירשמי כדי לראות.
Luciane Buchanan Bio, Wiki, Age, Husband, Net Worth, Actress
Az Unblocked Games: Complete with ease | airSlate SignNow
Backpage New York | massage in New York, New York
Sc Pick 3 Past 30 Days Midday
Research Tome Neltharus
Diccionario De Los Sueños Misabueso
Prologistix Ein Number
North Park Produce Poway Weekly Ad
Access One Ummc
Latest Posts
Article information

Author: Sen. Emmett Berge

Last Updated:

Views: 6262

Rating: 5 / 5 (60 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Sen. Emmett Berge

Birthday: 1993-06-17

Address: 787 Elvis Divide, Port Brice, OH 24507-6802

Phone: +9779049645255

Job: Senior Healthcare Specialist

Hobby: Cycling, Model building, Kitesurfing, Origami, Lapidary, Dance, Basketball

Introduction: My name is Sen. Emmett Berge, I am a funny, vast, charming, courageous, enthusiastic, jolly, famous person who loves writing and wants to share my knowledge and understanding with you.