Matlab Interactive Brokers Connection Response

1 view (last 30 days)
Here's what I'm trying to achieve
Main Function
# Connect to Interactive Brokers TWS
# Verify that connection has been established
# If connection established, draw gui
end Main Function
Here's a basic code I have for this in Matlab
function main
ib = ibtws('', 7496); %Connect
while ~exist('ibBultInErrMsg', 'var') %Check for response
pause(0.1)
end
drawGUI(); %If you've made it this far, then draw the gui
end
Here's the problem: the variable ibBuiltInErrMsg is only created once the main function is done running. (Matlab automatically creates this variable, and puts it in the same 'workspace' as the variable ib) I am trying to check within the Main Function if the variable ibBuiltInErrMsg does in fact exist. I am doing this as a form of connection verification since the object ib is constructed by Matlab in such a way that it does not provide a 'confirmation' flag for connection.
Essentially from my understanding is that Matlab does not block execution of the main thread to receive 'asynchronous' responses from external software.
Is there a workaround or will I have to use a more powerful language?
Thanks.

Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!