2016-05-24 7 views
-2

bt.prep()機能を使用してデータをフォーマットしようとしています。誰かがなぜこれが失敗するのか、うまくいけばそれを修正する方法を説明することができますか? Link to github repoSITを使用するとクリーニングデータが失われる

library(quantmod) 
#Systematic Investor Toolbox 
sit = getURLContent('https://github.com/systematicinvestor/SIT/raw/master/sit.gz', binary=TRUE, followlocation = TRUE, ssl.verifypeer = FALSE) 
con = gzcon(rawConnection(sit, 'rb')) 
source(con) 
close(con) 

data <- getSymbols("USD/EUR",src="oanda",env=NULL) 
bt.prep(data, align='remove.na') 

エラーは次のとおりです。Rilcon42 @

Error in b[[i]] : attempt to select more than one element In addition: Warning message: 
In merge.xts(..., all = all, fill = fill, suffixes = suffixes) : 
    NAs introduced by coercion 

答えて

0

私はあなたがgetSymbolsを呼び出す前にnew.env()を作成する必要があると思う...

library(quantmod) 
library(RCurl) 

#Systematic Investor Toolbox 
sit = getURLContent('https://github.com/systematicinvestor/SIT/raw/master/sit.gz', binary=TRUE, followlocation = TRUE, ssl.verifypeer = FALSE) 
con = gzcon(rawConnection(sit, 'rb')) 
source(con) 
close(con) 

tickers = spl('USD/EUR') 
dataRepo <- new.env() 
getSymbols(tickers, src = "oanda", env = dataRepo, auto.assign = T) 
bt.prep(dataRepo, align='remove.na') 

head(dataRepo$USDEUR,6) 

結果:

> library(quantmod) 
> library(RCurl) 
> 
> #Systematic Investor Toolbox 
> sit = getURLContent('https://github.com/systematicinvestor/SIT/raw/master/sit.gz', binary=TRUE, followlocation = TRUE, ssl.verifypeer = FALSE) 
> con = gzcon(rawConnection(sit, 'rb')) 
> source(con) 
> close(con) 
> 
> tickers = spl('USD/EUR') 
> dataRepo <- new.env() 
> getSymbols(tickers, src = "oanda", env = dataRepo, auto.assign = T) 
[1] "USDEUR" 
> bt.prep(dataRepo, align='remove.na') 
> 
> head(dataRepo$USDEUR,6) 
      USD.EUR 
2015-01-11 0.8445 
2015-01-12 0.8448 
2015-01-13 0.8467 
2015-01-14 0.8489 
2015-01-15 0.8535 
2015-01-16 0.8621 
関連する問題