[prev in list] [next in list] [prev in thread] [next in thread]
List: r-sig-finance
Subject: Re: [R-SIG-Finance] IBrokers R package: issue with class twsconn (R)
From: Jeffrey Ryan <jeffrey.ryan () lemnica ! com>
Date: 2011-03-25 18:18:33
Message-ID: AANLkTi=8sHdr=nbDkUjy3CO=7pu-_WgnE2cWDJM1h=aR () mail ! gmail ! com
[Download RAW message or body]
Hi Johnny,
Not a fan of S4 or Stack Overflow, so thanks for posting here!
The issue is S3 in S4. This should work:
setOldClass("twsconn") # this is what you are missing
setClass( "MktAsset",
representation( IB.id = "character",
asset.type = "factor",
ccy = "factor",
IB.conn = "twsconn") )
# [1] "MktAsset"
a <- new("MktAsset")
ibg <- ibgConnect() # connect to IB Gateway
a@IB.conn <- ibg
a
An object of class "MktAsset"
Slot "IB.id":
character(0)
Slot "asset.type":
factor(0)
Levels:
Slot "ccy":
factor(0)
Levels:
Slot "IB.conn":
<twsConnection,1 @ 20110325 13:15:22 CST, nextId=1>
If you're able to come to R/Finance in Chicago next month
www.RinFinance.com, I'll be doing a two-hour workshop on Friday
morning regarding IBrokers (and algorithmic trading in general with R)
that would be of interest I suspect.
Best,
Jeff
On Fri, Mar 25, 2011 at 12:40 PM, Johnny Paulo <johnny.jp.22@gmail.com> wrote:
> Hello,
>
> At the moment, I am switching from Python to R and I am trying to write some
> simple code to price a portfolio, using Jeff Ryan's Ibrokers package. I
> would like to have a field of class twsconn in one of my objects
>
> setClass( "MktAsset",
> representation( IB.id = "character",
> asset.type = "factor",
> ccy = "factor",
> IB.conn = "twsconn") )
>
> but the system does not seem happy about it
>
> Msg is
>
> In .completeClassSlots(ClassDef, where) : undefined slot classes in
> definition of "MktAsset": IB.connection(class "twsconn")
>
> but when I ask the class of tws (initialized with tws <- twsConnect(), it
> returns
>
> [1] "twsconn" "environment"
>
> I tried to go through the code to check for the existence of a class twsconn
> but, I found nothing.
>
> Can someone help?
>
> Thanks a lot
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance@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@lemnica.com
www.lemnica.com
R/Finance 2011 April 29th and 30th in Chicago | www.RinFinance.com
_______________________________________________
R-SIG-Finance@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.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic