필터 지우기
필터 지우기

IB TWS code stuck in for loop

조회 수: 1 (최근 30일)
Benvaulter
Benvaulter 2016년 5월 11일
댓글: terry dylan 2019년 1월 10일
Hey everyone,
I am using the Trading Toolbox to establish a connection to the IB TWS. In general, the API works fine and my code executes my intentions like retrieving real time data and executing orders.
What I would like to do now is executing my code block in a for-loop (to run through multiple strategies), but as soon as I attempt to execute the code in a for loop, the code appears to be stuck in an infinite loop, which I can only break by shutting down Matlab (even CTRL + c, won't do the trick in this case). My command window then rapdily displays IB error msgs like "Cannot unregister ‘xxx'", where xxx is a variety of IB functions such as tickPrice, tickData, etc..
The odd thing is, that when I manually highlight the code and run it (with F9), everything works like a charm. From my research it appears that it has something to do with the way the ib connection is handled. I open the ib connection at the beginning of the for loop (inside of it) and close it and the end of the loop (also inside the loop). I already attempted to pause the execution for 1-2 seconds after the "close"-command to ensure sufficient time for the connection to be properly closed but with no effect.
Can anyone help me out here or has an idea on how to tackle this problem?
Many thanks in advance!
  댓글 수: 1
terry dylan
terry dylan 2019년 1월 10일
i have encountered a similar problem, when connecting to IB, if i disconnect from IB using "clear ib", then the next time i connect to IB, and request data, the code will stuck in a while loop drawnow . The only way then is to re-open Matlab, or re-open TWS
I wonder if you have solved this problem, Please let me know
Best regards
Terry

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by