softwarespartan / IB4m

Interactive Brokers API for Matlab
GNU General Public License v2.0
62 stars 21 forks source link

Strang behaviour reqAccountSummary #145

Closed Despair2000 closed 2 years ago

Despair2000 commented 2 years ago

So far I have been using reqAccountUpdates which always worked fine. I send the request once in the beginning of my program and receive updates every 3 minutes all day like it should.

Now I had the idea to switch to reqAccountSummary instead because there one can choose the fields which are send and I'm only interested in a few and don't need most of them (with reqAccountUpdates you always get all fields). Sadly after I send the request I receive the requested fields only once or this is what I first thought. I have a fifo buffer to catch the account-events and check this buffer frequently if an update has dropped in (isEmpty). If there is something in the buffer my program processes the data and clears the buffer and waits for the next time something shows up in the buffer. This worked great with reqAccountUpdates. With reqAccountSummary isEmpty shows something in the buffer only directly after the request, there never comes an update. And now it gets funny. When I noticed that there are no updates I breaked my program into debug mode and checked (isEmpty) and the buffer was empty. Then I reissued reqAccountUpdates and instantly something popped up in the buffer. I traced through the code and after I executed collection2cell I was really confused. There were over 400 events in the buffer! And it gets even better, the buffer has a size of 32! This seems odd. 1.) Why is isEmpty returning 0 when there are plenty of events in the buffer and 2.) How can there be so many events? This FIFO buffers should throw out the oldest event when the size is exceeded and in this way never contain more events than their size (in my case 32). I tried this many times. Always the same. The longer I wait the more events are in the buffer but I always have to reissue the request to make isEmpty show.

This issue is no big problem for me. I can continue using reqAccountUpdates but I wanted to report it anyway.