Keyboard Shortcuts
Likes
Search
guide to using tws api logs??
Hi all having some problems with my code. I want to qualify the Contracts on the SPX ( about 48) and it's not returning. I tried using the repl but nothing happens it just hangs. I tried leaving it for 30 minutes no luck. So I decided to look at the logs to see what is going on. I can download, decrypt and look at the api logs but they seem to be too poorly formatted to be correct. I am seeing a lot of sequences like this one
which looks like accounting information and not api centric. and nothing, that I can see, pertinent to my call. In the repl I see ( last few cells )
but in the log I see
So I can't tell if this is corruption ( denoted by ) or something else like a failed decryption. What I would like to see is just the api traffic and not the accounting information. I thought I specified just the api when I saved and decrypted the file from TWS desktop. Is there a guide for analyzing the logs? A youtube video would be excellent. |
I hit send too quickly, sorry. The api log level is "DETAIL" and I did read the docs
so the first line below makes sense to me BUT the next line ( from the actual log segment above) makes no sense to me.
|
A YouTube video? Really? How about some popcorn and soda with that movie? What you are looking at are the raw messages your client sends to TWS/IBGW through the socket each time it calls a request method ("<-") and the responses from TWS/IBGW to your client that eventually become callbacks ("->"). You can find the source code for the message sender (the code in your client that converts your request calls into messages) and the decoder (that parses TWS/IBGW responses and makes the callbacks) in your TWS API installation for the programming language of your choice. Reading that source code also shows you how each message is structured. Each message starts with a binary 4 byte message length field. They are generally not printable characters and may show up as "bird dropping" or other funny characters in the log and have nothing to do with corruption. The second field in each message is the message id code that identifies what the message is about. It looks like you use Python (judging from a similar post you made in the ib_insync group) so that you can find the definition of the message id code in the IN and OUT classes that are defined in message.py:
The account related information you see are code 73 ACCOUNT_UPDATE_MULTI responses from TWS/IBGW () and are indeed part of the API operation between your client and TWS/IBGW. There can be any number of things going on, but what jumps at me is that you SMART route your SPX option market data requests. I don't have too much practical experience with SPX options, but there may just not be a lot of market data available through that route. One of the options users may want to comment here. I'd try contracts in your calls that route directly to the exchange where SPX options are traded and monitor in TWS that there is activity for those options. Happy debugging. ´³¨¹°ù²µ±ð²Ô On Wed, Aug 30, 2023 at 04:40 PM, comicpilsen wrote:
message.py IN and OUT classes <- IN (as seen from TWS) -> OUT |
I am a huge fan of youtube videos when it comes to this kind of thing but I get your point. I did find this and will be following up with IB when I meet up with them next month. I read through the docs that IB produce but I didn't see anything that leapt out at me regarding the source code. Thanks for pointing that out. I am using python for this. As I said in my follow up post I found the layout of the log and will run the test tomorrow using it, to me it reads that the message format differs from your version
Perhaps I am reading BOTH incorrectly. Thank you for taking the time to give me more information. I wanted to match my call to qualify contracts to the api log as it "seemed" simple. Decrypt the log to a text file and search for the relevant client call using the IB doc message layout. I'll take a quick look at EClientSocket tomorrow to see where I went wrong. Ewald ( ib_insync) has coded up an EXCELLENT notebook that I was using to test out jupyter lab and that's how I dug myself into this. Normally I would be using pluto and julia but I was too lazy to add in the julia kernel. Ho hum. Thanks again for the WONDERFUL analysis.You are doing a marvelous job. |
Well, you are reading (outdated) documentation for TWS logs (as in Help->Troubleshooting->Diagnostics->TWSLogs) but you have posted API logs (as in Help->Troubleshooting->Diagnostics->APILogs). They are very different. I was commenting on the APILogs you had posted that your documentation link does not cover. The best documentation for APILogs is, still, the API source code. ´³¨¹°ù²µ±ð²Ô On Wed, Aug 30, 2023 at 06:51 PM, comicpilsen wrote:
|
I know. But when you click the "Copyrights and Trademarks" link in the bottom left of that page you will find that the page is based on "TWS Javahelp version 008, March 2, 2007" hence my comment that the page is outdated. Everything was a little different 16 years ago and what they called "API Logging" then has some vague resemblance to what you'll find in TWSLog today: From my TWSLog from today: [JTS-EServerSocket-326] - [0:173:173:1:0:0:0:DET] ReqNewsBulletins(12)::[version=1,downloadDaysMsgs=true]
[JTS-EServerSocket-326] - [0:173:173:1:0:0:0:DET] ReqAcctData(6)::[version=2,ID=2147483647,acctCode=null,accountRequestType=START_UPDATE]
[JTS-EServerSocket-326] - [0:173:173:1:0:0:0:DET] [2;1;null]
[JTS-EServerSocket-326] - [0:173:173:1:0:0:0:DET] ReqAllOpenOrders(16)::[version=1]
[JTS-EServerSocket-326] - [0:173:173:1:0:0:0:DET] ReqAutoOpenOrders(15)::[version=1,autoOpenOrders=false] So forget about that ancient artifact. And before you spend a lot of time on log debugging, give direct routing to the SPX options exchange a try. Should not take you more than a few seconds. ´³¨¹°ù²µ±ð²Ô PS. A couple more hints that the page you are reading has little to do with reality is that it says "it logs certain information to its 'log.txt' log file," Try to find that one. And the page documents only 14 Request identifiers and 14 Response identifiers. In TWS API 10.24, the highest Request identifier is REQ_USER_INFO = 104 and the highest Response identifier is USER_INFO = 107. On Wed, Aug 30, 2023 at 08:23 PM, comicpilsen wrote:
|
so the upshot of this is that IB's documentation is in the code. Interesting, certainly something to raise with the great and good from Stamford next month. Ironically I'll be in 141 W. Jackson on Friday so I'll see what they have to offer. To be honest I am REALLY enjoying using ewald's ib_insync for python. He has an excellent way of documentation and it's a real pleasure to use jupyter labs with his code now that it's got an integrated debugger. I'm fine with spending a couple of hours on this as it's fun. Now you have pointed me at the code documentation I can have a little relax. This seems like a simple protocol and the asynch side looks pretty straightforward. Might be nice to just take a peek with wireshark to see how interesting IB's encryption is. Thanks again for your REALLY helpful observations. |