Thank you Mark and Jeff,

Sys.setenv(TZ="GMT")
solves the NA index problem.

Robert




-----Jeff Ryan <jeff.a.ryan@gmail.com> escreveu: -----


  Para: Mark Breman <breman.mark@gmail.com>
  De: Jeff Ryan <jeff.a.ryan@gmail.com>
  Data: 01/03/2010 16:41
  cc: Robert Iquiapaza <rbali@ufmg.br>, r-sig-finance@stat.math.ethz.ch
  Assunto: Re: [R-SIG-Finance] Blotter package - problem with example.

  One item of note, Sys.timezone on Windows is tricky at best, and wrong
  at worst.

  Check and use Sys.setenv('TZ') or Sys.setenv(TZ="America/Chicago") instead.

  You need to make sure that TZ is a legal variable, or else R (the OS)
  will just ignore (no error) and carry on..

  Bad things ensue...

  Jeff

  On Mon, Mar 1, 2010 at 1:37 PM, Mark Breman <breman.mark@gmail.com> wrote:
  > Hi Robert,
  >
  > What is your timezone setting?
  >
  > type: Sys.timezone()
  >
  > If it's not  "GMT" could you try:
  > Sys.setenv(TZ="GMT")
  > getSymbols('^GSPC', src='yahoo',
  > index.class=c("POSIXt","POSIXct"),from='1998-01-01')
  >
  > and see if GSPC still has a NA in the last record?
  >
  > Regards,
  >
  > -Mark-
  >
  > 2010/3/1 Robert Iquiapaza <rbali@ufmg.br>
  >
  >>
  >> Another problem:
  >>
  >> It appears to be with index in quantmod
  >>
  >> #In my case the result after running
  >> getSymbols('^GSPC', src='yahoo',
  >> index.class=c("POSIXt","POSIXct"),from='1998-01-01')
  >> GSPC
  >>
  >> #is problematic, the last observation has <NA> index!
  >>
  >> ....
  >> 2010-02-22   1110.00   1112.29  1105.38    1108.01  3814440000
  >> 1108.01
  >> 2010-02-23   1107.49   1108.58  1092.18    1094.60  4521050000
  >> 1094.60
  >> 2010-02-24   1095.89   1106.42  1095.50    1105.24  4168360000
  >> 1105.24
  >> 2010-02-25   1101.24   1103.50  1086.02    1102.94  4521130000
  >> 1102.94
  >> 2010-02-26   1103.10   1107.24  1097.56    1104.49  3945190000
  >> 1104.49
  >> <NA>         1130.51   1140.48  1128.12    1130.56  1659000000
  >> 1130.56
  >>
  >> GSPC=to.monthly(GSPC, indexAt='endof')
  >> GSPC
  >> ...
  >> 2010-01-29   1116.56   1150.45  1071.59    1073.87  90947579600 1073.87
  >> 2010-02-26   1073.89   1112.42  1044.50    1104.49  84561340000 1104.49
  >> <NA>         1130.51   1140.48  1128.12    1130.56   1659000000 1130.56
  >>
  >> #So, the next sentence gives an error
  >>
  >>  print("Setting up indicators")
  >>>
  >> [1] "Setting up indicators"
  >>
  >>> GSPC$SMA10m <- SMA(GSPC[,grep('Adj',colnames(GSPC))], 10)
  >>>
  >> nan, nan
  >> Error in merge.xts(..., all = all, fill = fill, suffixes = suffixes) :
  >>  'NA' not allowed in 'index'
  >>
  >> #If I drop the last observation, inserting the following code after
  >> to.monthly,
  >>
  >> GSPC <- GSPC[1:(length(GSPC[,1])-1),]
  >>
  >> #Then, everything goes well with the example.

	[[alternative HTML version deleted]]

