R Learning notes: Quantmod get stock data and draw charts (1) __r Learning

Source: Internet
Author: User

Original: http://www.quantmod.com/examples/intro/

With Quantmod, you can obtain data from many data sources, including:

Yahoo! Finance (OHLC data) The Federal Reserve Bank of St. Louis fred® (11,000 economic series), Google Finance (OHLC data) Oanda, The Currency Site (FX and Metals) MySQL database (local data) R binary format (. RData and. RDA CSV file (. csv)

Get Data:

Getsymbols ("GOOG", src= "Yahoo")

Take a look at the data obtained:


Drawing:

Paint results:


Get AAPL data and paint:

RM (AAPL)
getsymbols ("AAPL", src= "Yahoo") 


Draw the AAPL Candle chart:

Download XPTUSD data:

This data has only 2 columns of date and time:


Draw a graph:

The picture is very fast.

Custom Paint:

ChartSeries (To.weekly (XPTUSD), up.col= ' White ', dn.col= ' Blue ')

Require (TTR) 
getsymbols ("AAPL") 
chartseries (AAPL) 
ADDMACD () 

Very good, can draw the indicator graph:


Then, the signal is generated from the data.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.