[R-SIG-Finance] quantstrat: "Error in initPortf"

Mark Knecht markknecht at gmail.com
Sun Dec 1 15:31:26 CET 2013


On Sat, Nov 30, 2013 at 10:27 PM, GiuseppeL <borsaric at gmail.com> wrote:
> Hi,I am studing Guy Yolin's examples (quantstrat-I.Rnw) and I wonder
> if someone can help me with this error message "
>
> Error in initPortf("buyHold", "SPY", initDate = "1997-12-31") :
>   Portfolio buyHold already exists, use updatePortf() or
> addPortfInstr() to update it.In addition: There were 50 or more
> warnings (use warnings() to see the first 50)"
>
> Thanks.
>


Accounts and portfolios are by default stored in .blotter. Once the
code is run once the accounts exist and don't need to be created
again.

ls(.blotter)

You can break the examples into two pieces, one you run once to set
things up and a second one you run when you want to do work. Or, you
can consider adding something like

suppressWarnings(rm("account.ETF_Momentum", pos = .blotter))
suppressWarnings(rm("portfolio.Equity", pos = .blotter))
suppressWarnings(rm("portfolio.Cash", pos = .blotter))

but of course change the names to match what you (or Guy) used.

HTH,
Mark



More information about the R-SIG-Finance mailing list