[R-SIG-Finance] Quantmod SMA not working

Jeffrey Ryan jeffrey.ryan at lemnica.com
Mon Mar 5 20:47:16 CET 2012


The problem is that fTrading also has an SMA function.  You can either
load it before loading quantmod/TTR or ... not use it??

Note the conflict when you call library(fTrading) _after_ you load quantmod/TTR

Is there a function in fTrading that you need that isn't in TTR

Jeff

On Mon, Mar 5, 2012 at 1:36 PM, Mark Harrison <harrisonmark1 at gmail.com> wrote:
> I am trying to do some data comparisons and want to use quantmod and
> the addSMA feature.  However, I keep getting errors when I try the
> addSMA command.  I did try the email but nothing I saw answered or
> fixed this issue.
>
> When I run addSMA(20) on my data - examples below - I get the following error:
>
> Error in matrix(ma.tmp[lchob at xsubset, ], nc = NCOL(ma.tmp)) :
>  subscript out of bounds
>
> If I just grab Apple data from Yahoo and run:
>
> chartSeries(AAPL, subset='last 6 months')
> addSMA(20)
>
> The first command works and the chart appears but the addSMA command
> gives me the same error as above.
>
> MyData Example:
>             Open   High    Low  Close
> 2010-12-31 63.270 63.535 63.120 63.425
> 2011-01-03 63.310 63.670 63.085 63.620
> 2011-01-04 63.615 64.040 63.365 63.740
> 2011-01-05 63.770 64.495 63.430 64.415
> 2011-01-06 64.405 64.530 64.070 64.340
> 2011-01-07 64.325 64.490 63.950 64.280
>
> Session Info:
>
> R version 2.14.0 (2011-10-31)
> Platform: x86_64-pc-mingw32/x64 (64-bit)
>
> locale:
> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
> States.1252
> [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
> [5] LC_TIME=English_United States.1252
>
> attached base packages:
> [1] datasets  grDevices utils     graphics  stats     methods   base
>
> other attached packages:
>  [1] blotter_0.8.4              fTrading_2110.77
> fBasics_2110.79
>  [4] MASS_7.3-16                timeSeries_2140.93
> timeDate_2150.95
>  [7] twsInstrument_1.3-1        IBrokers_0.9-3             qmao_1.1.6
> [10] FinancialInstrument_0.10.9 quantmod_0.3-17            TTR_0.21-0
> [13] xts_0.8-4                  zoo_1.7-7
> Defaults_1.1-1
>
> loaded via a namespace (and not attached):
> [1] grid_2.14.0      lattice_0.20-3   quantstrat_0.6.1 tools_2.14.0
>
> _______________________________________________
> R-SIG-Finance at r-project.org 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 lemnica.com

www.lemnica.com
www.esotericR.com

R/Finance 2012: Applied Finance with R
www.RinFinance.com

See you in Chicago!!!!



More information about the R-SIG-Finance mailing list