Skip to content
Prev 5722 / 15274 Next

Blotter package - problem with example.

Brian,
I tried demo('longtrend') and the result is:

# Load data with quantmod
[1] "Loading data"
Error in eval.with.vis(expr, envir, enclos) : 
  could not find function "currency"
In addition: There were 11 warnings (use warnings() to see them)

My problems started, then I tried to add a new transaction:

addTxn(portfolio, "SPY", '2007-01-03', 50, 96.5, -0.05*50) 
[1] "2007-01-03 SPY 50 @ 96.5"
Warning messages:
1: In getInstrument(Symbol) :
  Instrument SPY  not found, please create it first.


I debugged a bit and I found, that getInstrument function fails on this
line:
if (inherits(tmp_instr, "try-error") | !is.instrument(tmp_instr)) {

I suspect, that FinancialInstrument package isn't committed properly.
Currency, stock methods
do not exist in my environment. The version of FI is 0.02, blotter v.0.4

As well, I have noticed, that environment variables are used very heavily.
What is the reason of using
environment variables instead of local variables? For example, in initPortf
method:
if (exists(paste("portfolio", name, sep = "."), envir = .blotter, 
        inherits = TRUE))
I found it frustrating, when I tried to recreate a portfolio and an account,
but I couldn't.

Thanks,
kafka