Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8351681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:42:45+00:00 2026-06-09T08:42:45+00:00

I have a data frame with dates and prices as: >df Price Date 1.25

  • 0

I have a data frame with dates and prices as:

>df
Price  Date
1.25   2012-01-05
...

I create a currency and and stock:

currency("USD")
stock("GSPC", "USD")

I then create an xts object:

GSPC <- xts(df$Price, df$Date)
colnames(GSPC) <- "Close"

The intended use of is to create a blotter portfolio — this works. But when I try to

updatePortf(portfolio, Symbols="GSPC", Dates = current.date)

I get the following error:

Error in get(Symbol, pos = env) : object 'GSPC' not found

GSPC doesn’t show up in “showSymbols()” so I assume that it needs to be registered somewhere. Is there any way to register the symbol?

A very hacky workaround, inspired by another stackoverflow answer is:

GSPC$GSPC.High <- GSPC$Open
GSPC$GSPC.Low <- GSPC$Open
GSPC$GSPC.Close <- GSPC$Open
GSPC$GSPC.Volume <- GSPC$Open
GSPC$GSPC.Adjusted <- GSPC$Open

write.zoo(GSPC, file="GSPC.csv", sep=",")
setSymbolLookup(GSPC=list(src="csv",format="%Y-%m-%d"))

getSymbols("GSPC")

Is there any better way to create the above? I don’t have (need) Volume, high, low, close and adjusted – do I still need them for blotter?

UPDATE
I’ve managed to reproduce the issue and then understant why it is. It seems like you cannot declare the xts objects in the local function environment. Here is a reproducible script:

library(xts)
library(FinancialInstrument)
library(blotter)
library(lubridate)
rm(list=ls(envir=.blotter),envir=.blotter)

runme <- function() {
  currency("USD")
  stock("GSPC", "USD")

  dates <-ymd("2012-03-02") + seq(0,9) * ddays(1)
  prices <- abs(rnorm(10))

  GSPC <- xts(prices, dates)
  colnames(GSPC) <- "Close"

  # Initialise
  initPortf("p", symbols="GSPC", initDate=ymd("2012-01-01"), currency="USD")
  initAcct("a", portfolios="p", initDate=ymd("2012-01-01"), initEq=2e6, currency="USD")

  trade.date <- ymd("2012-03-04")
  addTxn("p", "GSPC", trade.date, 1, GSPC[trade.date])

  updatePortf("p", Symbols="GSPC", Dates = trade.date)
  updateAcct("a", Dates = trade.date)

  updateEndEq("a", Dates = trade.date)

  chart.Posn("p")

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:42:49+00:00Added an answer on June 9, 2026 at 8:42 am

    The blotter package makes use of the FinancialInstrument package. You probably need to define your instrument. I think if you do something like this it should work.

    synthetic("GSPC", currency("USD"))
    

    If not, perhaps you could provide a reproducible example. (we don’t have your portfolio)

    EDIT:

    To more directly answer the question in your title, getSymbols stores a list called .getSymbols in your .GlobalEnv of all Symbols that you have used getSymbols to load. However, I don’t think blotter looks at it.

    EDIT 2:

    The error message you get is telling you that there is no data in your .GlobalEnv named “GSPC”. You have to either have an xts object in your .GlobalEnv, or pass an xts object to updatePortf in the Prices argument. Again, I could give better help if your example were reproducible (not to mention that it would make it more useful for future visitors of this site).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the data: # vector1 dates reading.dates <- as.Date(c(2012-02-13,2012-02-20,2012-02-28)) mydat <- data.frame (ID
I have a data-frame of dates (Date object); see bottom. I'm trying to convert
Say we have the following simple data-frame of date-value pairs, where some dates are
I have a data frame with stock data (date, symbol, high, low, open, close,
I have the following data frame. date id value 2012-01-01 1 0.3 2012-01-01 2
I have a data frame with start dates and end dates, along with the
I have a data frame of daily data: df with four columns: Date, A,
I have a date column in a data frame in chr format as follows:
I have extracted data to a data frame with mixed format dates that need
I have a data.frame as follows: dat <- structure(list(id = 1:4, date = structure(list(sec

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.