[R-SIG-Finance] IBrokers : quotes from futures combo and reqIds
Stergios Marinopoulos
stergios_marinopoulos at yahoo.com
Sun Jul 29 21:06:13 CEST 2012
> PS : To stergios_marinopoulos at yahoo.com
>
> When you said it works in Java you mean for quotes from the combo market ? or just
> implied quotes ?
reqMktData() when given a BAG contract returns the spreads on the bid and the ask. It also returns some size information, which I assume is the spread on the sizes when the spread on the bid/ask changes, although I am not sure about this aspect.
Attached is a short working example in Java based on the "ExampleBase" series of examples included in the IB API source code. Just replace the hard-coded IP address to one wihch works for you. This example creates an ES calendar spread, and then calls reqMktData() on the BAG contract; the rest of the program simply prints the bid/ask spread to stdout.
sm
--
Stergios Marinopoulos
Thanks,
Olivier
> I've added in support for sending a BAG contract, though I haven't
> figured out the proper params to verify all the messages are being
> sent correctly; i.e. still failing, just now for less obvious causes
> ;-)
>
> At rev 156 on googlecode
>
> HTH
> Jeff
>
> On Thu, Jul 19, 2012 at 1:41 PM, Jeffrey Ryan wrote:
>> Further investigation leads me to think this is just not supported as
>> of yet. I'll have to see how the API handles this for market data,
>> and add it into IBrokers.
>>
>> At present, the contract is simply getting sent as a BAG, with no
>> further effort to pass along the comboLegs themselves. I don't know
>> technically where it is failing yet, but at this point I can see it
>> simply can't succeed as is. I will fix.
>>
>> Thanks,
>> Jeff
>>
>> On Thu, Jul 19, 2012 at 12:57 PM, Jeffrey Ryan wrote:
>>> Version mismatches from IB/etc may be the cause here, though I am out
>>> of the office this week so am not able to try to debug.
>>>
>>> Make sure you are running the latest of all (including the googlecode
>>> version of IBrokers - which you must build from source at this point).
>>> If not, it will be a little difficult to narrow down where the
>>> problem is.
>>>
>>> Thanks,
>>> Jeff
>>>
>>> On Thu, Jul 19, 2012 at 12:21 PM, Stergios Marinopoulos
>>> wrote:
>>>> I think see the problem. Looking at the TWS error log, I can see that IBrokers
reqMkData() is requesting the following generic tick types by default:
"100,101,104,106,165,221,225,236", (and this is documented in IBroker's reqMktData()
DOH!!!) where
>>>>
>>>> 100: Option Volume
>>>> 101: Option Open Interest 104: Historical Volatility 106: Option Implied Volatility
165: Miscellaneous Stats 221: Mark Price225: Auction values236: Shortable
>>>>
>>>> Those tick types do not make sense for this BAG contract. The only thing that makes
sense for this BAG contract is the spreads between bid, ask, or last. So when you call
reqMktData() set tickGenerics="". But when I try it, however, nothing seems to be
happen.
>>>>
>>>> I believe the eventWrapper argument or the CALLBACK argument to reqMktData() needs
to be used in order to receive the (Java equivalent) tickPrice() events. Maybe someone
with experience with those arguments can chime in.
>>>>
>>>> --
>>>> Stergios Marinopoulos
>>>>
>>>>
>>>>
>>>>
>>>> ----- Original Message -----
>>>> From: Stergios Marinopoulos
>>>> To: G See
>>>> Cc: "r-sig-finance at r-project.org"
>>>> Sent: Thursday, July 19, 2012 11:28 AM
>>>> Subject: Re: [R-SIG-Finance] IBrokers : quotes from futures combo and reqIds
>>>>
>>>> I took Garrett's example and tried to get it working using IBrokers. It's starts
writing data to a file as expected, but then the error below is produced and quote data
is no longer written to the file.
>>>>
>>>> 2 1 320 Error reading request:-'wc' : cause - Unable format field -
>>>>
>>>>
>>>>
>>>>
>>>> Here's the code:
>>>>
>>>> library(IBrokers) ;
>>>> tws <- twsConnect(1)
>>>> bag <- twsBAG(
>>>> twsComboLeg(
>>>> conId = "756733", #conId("SPY"),
>>>> ratio = "1",
>>>> action = "BUY",
>>>> exchange = "SMART"
>>>> ) ,
>>>> twsComboLeg(
>>>> conId = "73128548", #conId("DIA"),
>>>> ratio = "1.06",
>>>> action = "SELL",
>>>> exchange = "SMART"
>>>> )
>>>> )
>>>> bag.csv <- file("~/bag.csv", open="w")
>>>> reqMktData(tws, bag,
>>>> eventWrapper=eWrapper.MktData.CSV(1),
>>>> file=bag.csv)
>>>>
>>>>
>>>> --
>>>> Stergios Marinopoulos
>>>>
>>>>
>>>> ----- Original Message -----
>>>> From: G See
>>>> To: Stergios Marinopoulos
>>>> Cc: omerle ; "r-sig-finance at r-project.org"
>>>> Sent: Thursday, July 19, 2012 11:11 AM
>>>> Subject: Re: [R-SIG-Finance] IBrokers : quotes from futures combo and reqIds
>>>>
>>>> On Thu, Jul 19, 2012 at 10:09 AM, Stergios Marinopoulos
>>>> wrote:
>>>>> In Java, if you create a proper BAG Contract you can use it with reqMktData() or
>>>>> reqHistoricalData(). I imagine the same holds true in R as well. (I can send Java
examples if interested.)
>>>>>
>>>>> Try using IBrokers twsBAG() function to create a combo contract, and use the
returned object as the contract to IBrokers's equivalent of reqMktData() and data should
start streaming.
>>>>>
>>>>
>>>> I'm unable to get that to work. If anyone else can get it to work,
>>>> please share your secret.
>>>>
>>>> Thanks,
>>>> Garrett
>>>>
>>>> _______________________________________________
>>>> 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.
>>>>
>>>>
>>>> _______________________________________________
>>>> 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.
>>>
>>>
>>>
>>> --
>>> Jeffrey Ryan
>>> jeffrey.ryan at lemnica.com
>>>
>>> www.lemnica.com
>>> www.esotericR.com
>>
>>
>>
>> --
>> Jeffrey Ryan
>> jeffrey.ryan at lemnica.com
>>
>> www.lemnica.com
>> www.esotericR.com
>
>
>
Une messagerie gratuite, garantie à vie et des services en plus, ça vous tente ?
Je crée ma boîte mail www.laposte.net
_______________________________________________
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.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Example9.java
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20120729/a38fcb29/attachment.pl>
More information about the R-SIG-Finance
mailing list