用 R 語言做量化投資

jopen 9年前發布 | 71K 次閱讀 R語言 機器學習

整理了一份關于R語言做量化投資的筆記,歡迎大家閱覽,也歡迎感興趣的一起來完善:github地址1

quantmod簡介

1 quantmod是什么?

quantmod是R語言中的金融量化投資分析包,提供量化投資分析一體化解決方案,能夠幫助用戶完成提取數據、數據重整、金融建模、交易回測和模型可視化等諸多環節。

2 quantmod能做什么?

2.1 提取數據

> getSymbols("CHL");
[1] "CHL"
> head(CHL);
           CHL.Open CHL.High CHL.Low CHL.Close CHL.Volume CHL.Adjusted
2007-01-03    45.45    46.84   45.45     46.14    3538300        35.40
2007-01-04    44.25    45.05   43.62     44.43    3210000        34.09
2007-01-05    44.99    44.99   43.12     43.24    2036300        33.17
2007-01-08    43.69    44.07   43.16     43.90    1230200        33.68
2007-01-09    42.98    42.98   41.56     41.85    2566100        32.11
2007-01-10    41.41    42.12   40.86     41.96    1987000        32.19

2.2 數據重整

> getSymbols("GS") #Goldman OHLC from yahoo
[1] "GS"
> is.OHLC(GS) # does the data contain at least OHL and C?
> has.Vo(GS) # how about volume?
> Op(GS) # just the Open column please. 
> seriesHi(GS) # where and what was the high point

2.3 金融數據可視化

> getSymbols("GS") #Goldman OHLC from yahoo
[1] "GS"
> chartSeries(GS) 
> candleChart(GS,subset='2007-12::2008')
> candleChart(GS,theme='white', type='candles')
> reChart(major.ticks='months',subset='first 16 weeks') 
> chartSeries(GS, theme="white",TA="addVo();addBBands();addCCI()")

3 更多知識

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!