2

我正在尝试将 COT(交易者承诺报告)加载到 xts 对象中,因此我可以将其绘制在具有不同符号的图表上。

我有这个数据:

           OI      Smart_Long  Smart_Short Comm_Long Comm_Short
2013-01-08 227030      67302       75623     88628      77408
2013-01-15 255620      79789       73214     89670     100277
2013-01-22 260817      83253       62843     92014     115104
2013-01-29 294272      91088       67119    105281     130716
2013-02-05 325352      91454       60687    122242     151926
2013-02-12 286854      85577       61319    108681     139583
2013-02-19 282781      79810       59322    107203     133294

http://pastebin.com/raw.php?i=5Y9nV0Us

这个R代码:

########################################
#Get the data
setInternet2(TRUE)
con = gzcon(url('http://www.systematicportfolio.com/sit.gz', 'rb'))
    source(con)
close(con)

library(quantmod)
EURUSD = getSymbols.fxhistoricaldata('EURUSD', 'hour', auto.assign = F, download=T)
EURO_cot <- read.table("http://pastebin.com/raw.php?i=5Y9nV0Us",header=F,sep=",")

###########################################
#Format the data
EURO_dates <- as.POSIXlt(EURO_cot[,3])
EURO_cot <- EURO_cot[,c(8,9,10,12,13)]

headers2<- c("OI", 
"Smart_Long", "Smart_Short", 
"Comm_Long", "Comm_Short")
colnames(EURO_cot) <- headers2
EURO_xts <- as.xts(EURO_cot, EURO_dates)
###########################################
#Plot the data
chartSeries(to.weekly(EURUSD[,1]['2013-01-01::2013-02-16']))
addTA(EURO_xts[,1]['2013-01-01::2013-02-16'])

Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In min(tav * 0.975, na.rm = TRUE) :
  no non-missing arguments to min; returning Inf
2: In max(tav * 1.05, na.rm = TRUE) :
  no non-missing arguments to max; returning -Inf
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf

感谢您提供的所有帮助!

PS。可从此处下载原始 cot 数据, http://www.cftc.gov/MarketReports/CommitmentsofTraders/HistoricalCompressed/index.htm

期货和期权组合报告下:部分

4

0 回答 0