joshuaulrich / TTR

Technical analysis and other functions to construct technical trading rules with R
GNU General Public License v2.0
330 stars 103 forks source link

Errors in EMV and SNR #49

Closed FrancisHChen closed 7 years ago

FrancisHChen commented 7 years ago

Hi, I found there are two errors in TTR:

  1. EMV function returns two columns with names: 'emv' and 'maEMV'. But the documentation indicates the latter as 'emvMA'.

  2. SNR has a bug in getting column by $: snr <- SNR(HLC, n=10) Error in ATR(HLC, n, ...)$atr : $ operator is invalid for atomic vectors

I might be using the dev version: packageVersion("TTR") [1] ‘0.23.2’

Thanks!

joshuaulrich commented 7 years ago

Thanks for the reports! Both are now fixed.

FrancisHChen commented 7 years ago

Hi Joshuaulrich,

Is it possible to make column names more specific like Name+Period? For example, for moving average looking back 20 days, it returns 'SMA_20'.

In general, people would compare different looking back periods. I have to rename them every time.

braverock commented 7 years ago

It is unlikely that we would change this in TTR, because a lot of external code expects behavior as it is right now. many frameworks which use TTR (like quantstrat) allow labeling of indicator calculations to keep multiple related calcs such as your multiple lookback periods, separate.

braverock commented 7 years ago

it is also rather simple to do:

x <- xts(rnorm(100),as.Date(1:100))
colnames(x) <- 'fake_ret'
x$SMA_20    <- SMA(x,20)