[R-SIG-Finance] Blotter package - problem with example.

Jeff Ryan jeff.a.ryan at gmail.com
Mon Mar 1 20:41:26 CET 2010


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 at 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 at 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.
>>
>> Any ideas what could be wrong?
>>
>> I have already reinstall some packages and the problem continues:
>> install.packages("TTR", repos="http://R-Forge.R-project.org")
>> install.packages("xts", repos="http://R-Forge.R-project.org")
>> install.packages("quantmod", repos="http://R-Forge.R-project.org")
>>
>> install.packages("FinancialInstrument", repos="
>> http://R-Forge.R-project.org")
>>
>>
>> Here is my system information:
>>
>>  R.version
>>>
>>              _
>> platform       i386-pc-mingw32
>> arch           i386
>> os             mingw32
>> system         i386, mingw32
>> status
>> major          2
>> minor          10.1
>> year           2009
>> month          12
>> day            14
>> svn rev        50720
>> language       R
>> version.string R version 2.10.1 (2009-12-14)
>>
>>> sessionInfo()
>>>
>> R version 2.10.1 (2009-12-14)
>> i386-pc-mingw32
>>
>> locale:
>> [1] LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252
>> [3] LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C
>> [5] LC_TIME=Portuguese_Brazil.1252
>>
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>
>> other attached packages:
>> [1] blotter_0.4               FinancialInstrument_0.0.2 quantmod_0.3-14
>> [4] TTR_0.20-1                Defaults_1.1-1            xts_0.7-1
>> [7] zoo_1.6-2
>>
>> loaded via a namespace (and not attached):
>> [1] grid_2.10.1    lattice_0.18-3
>>
>> Regards,
>> Robert
>>
>> --------------------------------------------------
>> From: "Brian G. Peterson" <brian at braverock.com>
>> Sent: Monday, March 01, 2010 1:14 PM
>> To: "Mark Breman" <breman.mark at gmail.com>
>> Cc: <r-sig-finance at stat.math.ethz.ch>; "kafkaz" <kafka at centras.lt>
>> Subject: Re: [R-SIG-Finance] Blotter package - problem with example.
>>
>>  Mark Breman wrote:
>>>
>>>> Hi kafkaz,
>>>>
>>>> I also have this problem with the 0 size transactions if I run the
>>>> demo(longtrend).
>>>>
>>>> It looks like there is a small bug in the longtrend.R script in the demo
>>>> directory. The account is not initialized with a beginning equity.
>>>>
>>>> replace the line:
>>>> initAcct(ltaccount,portfolios='longtrend', initDate=initDate)
>>>>
>>>> with:
>>>> initAcct(ltaccount,portfolios='longtrend', initDate=initDate,
>>>> initEq=initEq)
>>>>
>>>> Save the modification and run "demo(longtrend) again. This solved it for
>>>> me.
>>>>
>>>>
>>> Thanks Mark (and Daniel and kafkaz for the confirmation).  I've updated
>>> the demo code and committed the changes to svn on R-Forge.
>>>
>>> Regards,
>>>
>>>  - Brian
>>>
>>> --
>>> Brian G. Peterson
>>> http://braverock.com/brian/
>>> Ph: 773-459-4973
>>> IM: bgpbraverock
>>>
>>> _______________________________________________
>>> R-SIG-Finance at stat.math.ethz.ch 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.
>>>
>>>
>> _______________________________________________
>> R-SIG-Finance at stat.math.ethz.ch 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]]
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch 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.
>



-- 
Jeffrey Ryan
jeffrey.ryan at insightalgo.com

ia: insight algorithmics
www.insightalgo.com



More information about the R-SIG-Finance mailing list