I am a beginning trader who is just using iBrokers package of R for algorithm trading.
My goal is to let R implement a strategy instantly when I get the right signal(market price).
But now I am stuck at the point that when I call function "reqMktData" to receive real-time data, I found R will not stop unless I manually stop it or I ask the function to return snapshot data.
Even though I may be able to write a while loop to get real-time data for the latter case, I found it very slow compared to what I want it to be (each call of reqMktData will take a few seconds).
I was wondering if anyone could provide some hints to achieve my goal. Or can anyone provide a working example of a loop that collects real time data through the IBrokers package and allows trading logic to be executed? I have spent a few days searching for solutions on internet and found nothing. Hope this is not a bad question. Thank you!