[R-SIG-Finance] IBrokers reqOpenOrders

me me at censix.com
Mon Feb 13 19:16:12 CET 2012


Sasha

type 'reqOpenOrders' at the R prompt and you will see that the
function enters an infinite 'while (TRUE)' loop where it reads the
responses from the TWS. This uses the default eWrapper object, which
will print the TWS messages using a 'cat' command. If you want to
do some proper processing of the TWS messages, you at least need to:

1. run the while loop only for a finite amount of time, i.e. 1 minute
or so

2. define your own eWrapper object that is able to 'do something' with
the open_order events coming back from the TWS, i.e. 'cat' them to a
file. The 'cat' command accepts a filename as argument, if I am not
mistaken.

S.


On Mon, 13 Feb 2012 17:59:55 +0000
Sash Ali <sashinali79 at hotmail.com> wrote:

> 
> Yes, thank you Soren - I think you were on the right lines. 
> 
> I was using the same TWS object to request live data through
> 
> reqMktData(tws, Contract=assets,
> eventWrapper=eWrapper.MktData.CSV(n.mkts), file=files)
> 
> and I think as a result of this, I was returned the aforementioned
> error.
> 
> Now I declare a separate TWS object through
> 
> tws2 <- twsConnect(clientId=2);
> 
> and use tws2 to place orders through placeOrders(tws2..... ), and
> then request open orders through
> 
> IBrokers::reqOpenOrders(tws2)
> 
> 
> the correct output is returned directly to the console but which then
> hangs..... Only escaping then allows me to use to console again.
> 
> Would you be able to advise of a way to output the data to say a text
> file, such that my R console is not affected ?
> 
> Many thanks again & Kind Regards,
> 
> Sash
> 
> 
> 
> > Date: Mon, 13 Feb 2012 18:09:34 +0100
> > From: me at censix.com
> > To: sashinali79 at hotmail.com
> > CC: r-sig-finance at r-project.org
> > Subject: Re: [R-SIG-Finance] IBrokers reqOpenOrders
> > 
> > I am guessing, but this error looks like it is related to the actual
> > connection you are trying to establish with the TWS. 
> > 
> > I have been using reqOpenOrders() without problems for a
> > while now.
> > 
> > Cheers
> > 
> > Soren
> > 
> > 
> > 
> > On Mon, 13 Feb 2012 12:27:47 +0000
> > Sash Ali <sashinali79 at hotmail.com> wrote:
> > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > Hi folks,
> > > 
> > > I've been using the IBrokers package to automate placing market,
> > > stop, and limit orders into my trading account. However, I have a
> > > number of stop and limit orders that have not been hit and would
> > > like to automate the canceling of these.
> > > 
> > > I am unable to find the required tools in the IBrokers
> > > documentation or on forums. However, I have discovered a brief
> > > mention on this forum on the 'reqOpenOrders' function but I can
> > > find only limited information on how to use it. 
> > > 
> > > I have tried the following,
> > > 
> > > tws <- twsConnect(clientId=1);
> > > IBrokers::reqOpenOrders(tws)
> > > 
> > > However, the output is 
> > > 
> > > Error in e_tick_size(NULL, msg, timestamp, file, symbols, ...) : 
> > >   argument "file" is missing, with no default
> > > 
> > > - which I do not understand.
> > > 
> > > I would be grateful for any help.
> > > 
> > > Sash
> > > 
> > > 
> > >  		 	   		  
> > > 	[[alternative HTML version deleted]]
> > > 
> > > _______________________________________________
> > > R-SIG-Finance at r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > > -- Subscriber-posting only. If you want to post, subscribe first.
> > > -- Also note that this is not the r-help list where general R
> > > questions should go.
> > 
>  		 	   		  
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R
> questions should go.



More information about the R-SIG-Finance mailing list