Quantcast

rugarch vs fgarch

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

rugarch vs fgarch

Abhishek Gupta
rugarch is a package that allows you to do Univariate GARCH.
What package should I be using if I want to estimated a multi-factor
univariate GARCH model.

For example:
sp_ret = alpha_0 + alpha1*(market_index_ret) +alpha2*(exchange_rate_return)
+ error
sigma^2 = gamma_0 + gamm1*(error^2_{t-1}) + gamma2*(sigma^2_{t-1})

Thanks.
--
Abhishek

        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

IBrokers : quotes from futures combo and reqIds

omerle
Dear,

1 - Quotes from futures combo

I need quotes from futures combo but I cant find how to find these quotes.
I can place combo orders but I can't find how to get the quotes. For instance, I would
like to have the quotes of the combo between ECO AUG12 (83617918) and ECO NOV12
(87689647).
Do you have any idea ?
Which part of the IB API documentation should I check ?
That's quite important for me !

2 - reqIds

If I understand well reqIds, it doesnt give the next iDs from Interactive Broker but the
last iDs + 1 of the R session or TWS. Sometimes it doesn't work for me because when I
relaunch R or TWS it forgets the real last iDs.
When the iDs count is relaunch ? How can I relaunch it ?


Thanks a lot,

Olivier MERLE

Une messagerie gratuite, garantie à vie et des services en plus, ça vous tente ?
Je crée ma boîte mail www.laposte.net

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: rugarch vs fgarch

alexios
In reply to this post by Abhishek Gupta
You can do this with rugarch (and possibly fGarch) by passing the
external regressors (factors) in the conditional mean equation. The
documentation and vignette should provide enough information to enable
you to figure out how to do this. You can also adopt a 2-stage approach
in which case any GARCH package can do this (by passing the residuals
from a first stage regression).

-Alexios

On 19/07/2012 12:57, Abhishek Gupta wrote:

> rugarch is a package that allows you to do Univariate GARCH.
> What package should I be using if I want to estimated a multi-factor
> univariate GARCH model.
>
> For example:
> sp_ret = alpha_0 + alpha1*(market_index_ret) +alpha2*(exchange_rate_return)
> + error
> sigma^2 = gamma_0 + gamm1*(error^2_{t-1}) + gamma2*(sigma^2_{t-1})
>
> Thanks.
>

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: IBrokers : quotes from futures combo and reqIds

gsee
In reply to this post by omerle
I don't have a complete answer, but I don't think you directly request
a quote for a twsBAG.  You could get a quote for each leg and
calculate it yourself.  Below is an example.  I hope you don't mind if
I use the get_quote function from my twsInstrument package
(https://r-forge.r-project.org/R/?group_id=1113).  I don't know how IB
calculates the BidSize and AskSize of a combo, but you can look at how
I calculated it and see if it makes sense.

[I don't trade subscribe to market data for MATIF, so below I'll make
a combo between SPY and DIA.  Note that the ratio I chose is by no
means a recommendation -- I just picked a number that would make the
spread close to dollar neutral]

require("twsInstrument")
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"
    )
)

## Get a quote for both legs

(tmp <- get_quote(c(bag$comboleg[[1]]$conId, bag$comboleg[[2]]$conId)))
#    BidSize BidPrice AskPrice AskSize   Last LastSize Volume
#SPY     108   137.45   137.46     138 137.45        3 385111
#DIA      25   129.10   129.11      23 129.09        1  10656

data.frame(BidSize=min(c(as.numeric(bag$comboleg[[1]]$ratio) * tmp$BidSize[1],
                   as.numeric(bag$comboleg[[2]]$ratio) * tmp$AskSize[2])),
           BidPrice=as.numeric(bag$comboleg[[1]]$ratio) * tmp$BidPrice[1] -
                    as.numeric(bag$comboleg[[2]]$ratio) * tmp$AskPrice[2],
           AskPrice=as.numeric(bag$comboleg[[1]]$ratio) * tmp$AskPrice[1] -
                    as.numeric(bag$comboleg[[2]]$ratio) * tmp$BidPrice[2],
           AskSize=min(c(as.numeric(bag$comboleg[[1]]$ratio) * tmp$AskSize[1],
                   as.numeric(bag$comboleg[[2]]$ratio) * tmp$BidSize[2])),
           row.names=paste(rownames(tmp), collapse="."))

#        BidSize BidPrice AskPrice AskSize
#SPY.DIA   24.38   0.5934    0.614    26.5

HTH,
Garrett


On Thu, Jul 19, 2012 at 8:18 AM, omerle <[hidden email]> wrote:

> Dear,
>
> 1 - Quotes from futures combo
>
> I need quotes from futures combo but I cant find how to find these quotes.
> I can place combo orders but I can't find how to get the quotes. For instance, I would
> like to have the quotes of the combo between ECO AUG12 (83617918) and ECO NOV12
> (87689647).
> Do you have any idea ?
> Which part of the IB API documentation should I check ?
> That's quite important for me !
>
> 2 - reqIds
>
> If I understand well reqIds, it doesnt give the next iDs from Interactive Broker but the
> last iDs + 1 of the R session or TWS. Sometimes it doesn't work for me because when I
> relaunch R or TWS it forgets the real last iDs.
> When the iDs count is relaunch ? How can I relaunch it ?
>
>
> Thanks a lot,
>
> Olivier MERLE
>
> Une messagerie gratuite, garantie à vie et des services en plus, ça vous tente ?
> Je crée ma boîte mail www.laposte.net
>
> _______________________________________________
> [hidden email] 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.

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: IBrokers : quotes from futures combo and reqIds

Stergios
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.

--
Stergios Marinopoulos


________________________________
From: G See <[hidden email]>
To: omerle <[hidden email]>
Cc: [hidden email]
Sent: Thursday, July 19, 2012 10:37 AM
Subject: Re: [R-SIG-Finance] IBrokers : quotes from futures combo and reqIds

I don't have a complete answer, but I don't think you directly request
a quote for a twsBAG.  You could get a quote for each leg and
calculate it yourself.  Below is an example.  I hope you don't mind if
I use the get_quote function from my twsInstrument package
(https://r-forge.r-project.org/R/?group_id=1113).  I don't know how IB
calculates the BidSize and AskSize of a combo, but you can look at how
I calculated it and see if it makes sense.

[I don't trade subscribe to market data for MATIF, so below I'll make
a combo between SPY and DIA.  Note that the ratio I chose is by no
means a recommendation -- I just picked a number that would make the
spread close to dollar neutral]

require("twsInstrument")
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"
    )
)

## Get a quote for both legs

(tmp <- get_quote(c(bag$comboleg[[1]]$conId, bag$comboleg[[2]]$conId)))
#    BidSize BidPrice AskPrice AskSize   Last LastSize Volume
#SPY     108   137.45   137.46     138 137.45        3 385111
#DIA      25   129.10   129.11      23 129.09        1  10656

data.frame(BidSize=min(c(as.numeric(bag$comboleg[[1]]$ratio) * tmp$BidSize[1],
                   as.numeric(bag$comboleg[[2]]$ratio) * tmp$AskSize[2])),
           BidPrice=as.numeric(bag$comboleg[[1]]$ratio) * tmp$BidPrice[1] -
                    as.numeric(bag$comboleg[[2]]$ratio) * tmp$AskPrice[2],
           AskPrice=as.numeric(bag$comboleg[[1]]$ratio) * tmp$AskPrice[1] -
                    as.numeric(bag$comboleg[[2]]$ratio) * tmp$BidPrice[2],
           AskSize=min(c(as.numeric(bag$comboleg[[1]]$ratio) * tmp$AskSize[1],
                   as.numeric(bag$comboleg[[2]]$ratio) * tmp$BidSize[2])),
           row.names=paste(rownames(tmp), collapse="."))

#        BidSize BidPrice AskPrice AskSize
#SPY.DIA   24.38   0.5934    0.614    26.5

HTH,
Garrett


On Thu, Jul 19, 2012 at 8:18 AM, omerle <[hidden email]> wrote:

> Dear,
>
> 1 - Quotes from futures combo
>
> I need quotes from futures combo but I cant find how to find these quotes.
> I can place combo orders but I can't find how to get the quotes. For instance, I would
> like to have the quotes of the combo between ECO AUG12 (83617918) and ECO NOV12
> (87689647).
> Do you have any idea ?
> Which part of the IB API documentation should I check ?
> That's quite important for me !
>
> 2 - reqIds
>
> If I understand well reqIds, it doesnt give the next iDs from Interactive Broker but the
> last iDs + 1 of the R session or TWS. Sometimes it doesn't work for me because when I
> relaunch R or TWS it forgets the real last iDs.
> When the iDs count is relaunch ? How can I relaunch it ?
>
>
> Thanks a lot,
>
> Olivier MERLE
>
> Une messagerie gratuite, garantie à vie et des services en plus, ça vous tente ?
> Je crée ma boîte mail www.laposte.net
>
> _______________________________________________
> [hidden email] 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.

_______________________________________________
[hidden email] 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.

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: IBrokers : quotes from futures combo and reqIds

gsee
On Thu, Jul 19, 2012 at 10:09 AM, Stergios Marinopoulos
<[hidden email]> 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

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: IBrokers : quotes from futures combo and reqIds

Stergios
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 <[hidden email]>
To: Stergios Marinopoulos <[hidden email]>
Cc: omerle <[hidden email]>; "[hidden email]" <[hidden email]>
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
<[hidden email]> 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

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: IBrokers : quotes from futures combo and reqIds

soren wilkening
Hi Stergios

I believe it is your ratios. They have to be integers.
your second one is      

ratio = "1.06"

You will have to calculate the most feasible rational approximation to
your beta of

-1.06/1

One solution would be

-21/20   ~   -1.05

So you could set

leg1: ratio = "21"
leg2: ratio = "20"

That should do it.

Cheers

Soren

http://censix.com


On Thu, 19 Jul 2012 08:28:17 -0700 (PDT)
Stergios Marinopoulos <[hidden email]> wrote:

> 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 <[hidden email]>
> To: Stergios Marinopoulos <[hidden email]>
> Cc: omerle <[hidden email]>; "[hidden email]"
> <[hidden email]> 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
> <[hidden email]> 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
>
> _______________________________________________
> [hidden email] 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.



------------------------------------------------------------------
Soren Wilkening

http://censix.com

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: IBrokers : quotes from futures combo and reqIds

gsee
:-( I'm afraid it doesn't even work with "1" and "1"

Were you able to get market data for a twsBAG, Soren?

In May, Jeff suggested it doesn't work:
https://stat.ethz.ch/pipermail/r-sig-finance/2012q2/010258.html


On Thu, Jul 19, 2012 at 11:36 AM, me <[hidden email]> wrote:

> Hi Stergios
>
> I believe it is your ratios. They have to be integers.
> your second one is
>
> ratio = "1.06"
>
> You will have to calculate the most feasible rational approximation to
> your beta of
>
> -1.06/1
>
> One solution would be
>
> -21/20   ~   -1.05
>
> So you could set
>
> leg1: ratio = "21"
> leg2: ratio = "20"
>
> That should do it.
>
> Cheers
>
> Soren
>
> http://censix.com
>
>
> On Thu, 19 Jul 2012 08:28:17 -0700 (PDT)
> Stergios Marinopoulos <[hidden email]> wrote:
>
>> 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 <[hidden email]>
>> To: Stergios Marinopoulos <[hidden email]>
>> Cc: omerle <[hidden email]>; "[hidden email]"
>> <[hidden email]> 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
>> <[hidden email]> 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
>>
>> _______________________________________________
>> [hidden email] 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.
>
>
>
> ------------------------------------------------------------------
> Soren Wilkening
>
> http://censix.com

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: IBrokers : quotes from futures combo and reqIds

Stergios
In reply to this post by Stergios
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 <[hidden email]>
To: G See <[hidden email]>
Cc: "[hidden email]" <[hidden email]>
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 <[hidden email]>
To: Stergios Marinopoulos <[hidden email]>
Cc: omerle <[hidden email]>; "[hidden email]" <[hidden email]>
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
<[hidden email]> 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

_______________________________________________
[hidden email] 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.


_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: IBrokers : quotes from futures combo and reqIds

Jeffrey Ryan-2
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
<[hidden email]> 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 <[hidden email]>
> To: G See <[hidden email]>
> Cc: "[hidden email]" <[hidden email]>
> 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 <[hidden email]>
> To: Stergios Marinopoulos <[hidden email]>
> Cc: omerle <[hidden email]>; "[hidden email]" <[hidden email]>
> 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
> <[hidden email]> 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
>
> _______________________________________________
> [hidden email] 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.
>
>
> _______________________________________________
> [hidden email] 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
[hidden email]

www.lemnica.com
www.esotericR.com

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: IBrokers : quotes from futures combo and reqIds

Jeffrey Ryan-2
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 <[hidden email]> 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
> <[hidden email]> 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 <[hidden email]>
>> To: G See <[hidden email]>
>> Cc: "[hidden email]" <[hidden email]>
>> 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 <[hidden email]>
>> To: Stergios Marinopoulos <[hidden email]>
>> Cc: omerle <[hidden email]>; "[hidden email]" <[hidden email]>
>> 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
>> <[hidden email]> 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
>>
>> _______________________________________________
>> [hidden email] 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.
>>
>>
>> _______________________________________________
>> [hidden email] 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
> [hidden email]
>
> www.lemnica.com
> www.esotericR.com



--
Jeffrey Ryan
[hidden email]

www.lemnica.com
www.esotericR.com

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: IBrokers : quotes from futures combo and reqIds

Jeffrey Ryan-2
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 <[hidden email]> 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 <[hidden email]> 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
>> <[hidden email]> 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 <[hidden email]>
>>> To: G See <[hidden email]>
>>> Cc: "[hidden email]" <[hidden email]>
>>> 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 <[hidden email]>
>>> To: Stergios Marinopoulos <[hidden email]>
>>> Cc: omerle <[hidden email]>; "[hidden email]" <[hidden email]>
>>> 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
>>> <[hidden email]> 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
>>>
>>> _______________________________________________
>>> [hidden email] 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.
>>>
>>>
>>> _______________________________________________
>>> [hidden email] 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
>> [hidden email]
>>
>> www.lemnica.com
>> www.esotericR.com
>
>
>
> --
> Jeffrey Ryan
> [hidden email]
>
> www.lemnica.com
> www.esotericR.com



--
Jeffrey Ryan
[hidden email]

www.lemnica.com
www.esotericR.com

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: IBrokers : quotes from futures combo and reqIds

omerle
In reply to this post by omerle
Thanks a lof for your kind answers ! I am again amazed by the R community.

I might have under explain my problem.

1 - My original question :

"I need quotes from futures combo but I cant find how to find these quotes. I can place
combo orders but I can't find how to get the quotes. For instance, I would like to have
the quotes of the combo between ECO AUG12 (83617918) and ECO NOV12 (87689647). Do you
have any idea ? Which part of the IB API documentation should I check ? That's quite
important for me !"

2 - Additional elements :

=> In most futures market, combo orders/quotes are another market not only the
combinaison of the two markets underlyings.

For instance :
ECO AUG12 (83617918)
Bid - Ask
100 - 102
ECO NOV12 (87689647)
Bid - Ask
104 - 105

The implied combo Bid-Ask market would be :
Bid - Ask
2 - 5

The combo market could be anything inside this implied B/A (because people place order
inside the combo market). For instance, I could have :
Bid - Ask
2.5 - 3

3 - What I can currently do :

Using twsContract and the parameter comboleg to send a combo order inside the combo
market.
I think that if IB implemented orders in the combo market the API could also do the work
to retrieve the data.

4 - What I would like to do :

Get the quotes of the combo market.

5 - What I tried :

I tried to put my twsContract (which was used in placeOrder) in reqMktData but I didn't
get any data.

PS : To [hidden email]

When you said it works in Java you mean for quotes from the combo market ? or just
implied quotes ?


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: "[hidden email]"
>>>> 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 ; "[hidden email]"
>>>> 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
>>>>
>>>> _______________________________________________
>>>> [hidden email] 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.
>>>>
>>>>
>>>> _______________________________________________
>>>> [hidden email] 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
>>> [hidden email]
>>>
>>> www.lemnica.com
>>> www.esotericR.com
>>
>>
>>
>> --
>> Jeffrey Ryan
>> [hidden email]
>>
>> 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

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: IBrokers : quotes from futures combo and reqIds

Stergios


> PS : To [hidden email]
>  
>  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: "[hidden email]"
>>>> 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 ; "[hidden email]"
>>>> 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
>>>>
>>>> _______________________________________________
>>>> [hidden email] 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.
>>>>
>>>>
>>>> _______________________________________________
>>>> [hidden email] 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
>>> [hidden email]
>>>
>>> www.lemnica.com
>>> www.esotericR.com
>>
>>
>>
>> --
>> Jeffrey Ryan
>> [hidden email]
>>
>> 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

_______________________________________________
[hidden email] 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.
_______________________________________________
[hidden email] 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.

Example9.java (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: IBrokers : quotes from futures combo and reqIds

Jeffrey Ryan
Thanks for passing a working Java example.  I'll use this to
test/adjust the code in IBrokers so it will do the same.

Best,
Jeff


On Sun, Jul 29, 2012 at 2:06 PM, Stergios Marinopoulos
<[hidden email]> wrote:

>
>
>> PS : To [hidden email]
>>
>>  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: "[hidden email]"
>>>>> 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 ; "[hidden email]"
>>>>> 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
>>>>>
>>>>> _______________________________________________
>>>>> [hidden email] 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.
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> [hidden email] 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
>>>> [hidden email]
>>>>
>>>> www.lemnica.com
>>>> www.esotericR.com
>>>
>>>
>>>
>>> --
>>> Jeffrey Ryan
>>> [hidden email]
>>>
>>> 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
>
> _______________________________________________
> [hidden email] 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.
>
> _______________________________________________
> [hidden email] 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
[hidden email]

www.lemnica.com

_______________________________________________
[hidden email] 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.
Loading...