Thanks Charlie.  A patch has been committed in revision 777

note that in your example you did not include the "env" argument in your
call to updatePortf.

> library(quantmod)
> library(blotter)
> .Symbols = new.env()
> getSymbols(c("SPY","QQQ"),env=.Symbols)
<environment: 0xa83ad8>
> currency("USD")
[1] "USD"
> stock(c("SPY","QQQ"),"USD")
[1] "SPY" "QQQ"
> initPortf("default",c("SPY","QQQ"))
[1] "default"
>
addTxn("default",Symbol="SPY",TxnDate="2011-09-12",TxnQty=100,TxnPrice=115.50)
[1] "2011-09-12 SPY 100 @ 115.5"
>
addTxn("default",Symbol="QQQ",TxnDate="2011-09-12",TxnQty=100,TxnPrice=54.01)
[1] "2011-09-12 QQQ 100 @ 54.01"
> updatePortf("default",Symbols=c("SPY","QQQ"),env=.Symbols)
[1] "default"
>

Garrett

On Tue, Sep 13, 2011 at 8:16 AM, Charlie Friedemann <cfriedem@gmail.com>wrote:

> Here's an example:
>
> library(quantmod)
> library(blotter)
>
> .Symbols = new.env()
> getSymbols("SPY",env=.Symbols)
> getSymbols("QQQ",env=.Symbols)
>
> currency("USD")
> stock("SPY",currency="USD")
> stock("QQQ",currency="USD")
>
> initPortf("default",c("SPY","QQQ"))
>
> addTxn("default",Symbol="SPY",TxnDate="2011-09-12",TxnQty=100,TxnPrice=115.50)
>
> addTxn("default",Symbol="QQQ",TxnDate="2011-09-12",TxnQty=100,TxnPrice=54.01)
>
> Using the Symbols argument does not work, the use of .GlobalEnv is
> hardcoded:
>
> updatePortf("default",Symbols=c("SPY","QQQ"))
> Error in get(Symbol, envir = as.environment(.GlobalEnv)) :
>   object 'SPY' not found
>
> One can use get to pull the price data and pass that via Prices, but that's
> slightly clunky:
>
>
> updatePortf("default",Prices=merge(get("SPY",.Symbols),get("QQQ",.Symbols)))
> [1] "default"
>
> If one could pass an env variable to the updatePortf call so that the
> internal call to .updatePosPL will use that environment that would be ideal.
>
> I hope that helps.
>
> On Sep 13, 2011, at 8:28 AM, G See wrote:
>
> You're chances of getting a patch would go up dramatically if you provided
> a reproducible example ;-)
> On Sep 12, 2011 11:32 PM, "Charlie Friedemann" <cfriedem@gmail.com> wrote:
> > I can't believe I missed the Prices argument, passing a merged xts
> > object of all the prices I cared about via worked like a charm.
> >
> > I suppose it would be slightly less effort if there was an env
> > argument to both functions, so if it's possible that could make it
> > into a future release I'd be grateful. Thanks!
> >
> > Charlie
> >
> > On Sep 12, 2011, at 7:53 PM, G See wrote:
> >
> >>
> >> the internal function .updatePosPL has these lines in it:
> >>
> >> if(is.null(Prices)){
> >> prices=getPrice(get(Symbol,
> >> envir=as.environment(.GlobalEnv)),...=...)
> >> } else {
> >> prices=Prices
> >> }
> >>
> >> So, as it is written, you cannot pass an environment to it.
> >> However, you could utilize the "Prices" argument in your call to
> >> updatePortf which would then pass those Prices into .updatePosPL
> >>
> >> It would not be diffucult for us to add an "env" argument to both
> >> functions.
> >>
> >> -Garrett
> >>
> >>
> >>
> >> On Mon, Sep 12, 2011 at 6:42 PM, Brian G. Peterson <brian@braverock.com
> >> > wrote:
> >> passing env='whateverEnvIuse" or env=.wheteverenvIuse doesn't work?
> >>
> >> Please provide a reproducible example, per the posting guide.
> >>
> >> - Brian
> >>
> >> On Mon, 2011-09-12 at 19:22 -0400, Charlie Friedemann wrote:
> >> > Greetings,
> >> >
> >> > I've been working with blotter the past couple days, and one thing
> >> > I've noticed is that if one calls updatePortf on a portfolio object,
> >> > it fails:
> >> >
> >> > Error in get(Symbol, envir=as.environment(.GlobalEnv)) : Object
> >> 'SPY'
> >> > not found.
> >> >
> >> > I load my daily data in a separate environment using getSymbols, and
> >> > I'm wondering if there is anyway to get blotter to change which
> >> > environment it looks for historical price data in. traceback()
> >> > indicates the call to updatePortf uses the getPrice function in
> >> > quantmod and passes the .GlobalEnv to it.
> >> >
> >> > I've tried adding the environment with the price data to the search
> >> > path, however that did not work.
> >> >
> >> > Does anyone know a way around this issue? I'd rather not have to
> >> keep
> >> > all necessary data in the global environment if possible. Thanks!
> >> >
> >> > _______________________________________________
> >> > 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.
> >>
> >> --
> >> Brian G. Peterson
> >> http://braverock.com/brian/
> >> Ph: 773-459-4973
> >> IM: bgpbraverock
> >>
> >> _______________________________________________
> >> 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.
> >>
> >
>
>
>

	[[alternative HTML version deleted]]

