Getting the right charts when you require them can always be tricky which translates to searching for hours on the internet or sometimes even paying for them. But what do you do when you have to get the updated online data all the time? Below is the R-Project code which will help in visualizing the online financial data. In this tutorial, we use “quandmod” package and yahoo data through systematicportfolio.com to Chart the financial data.
Install R-Project from the link below
Once Installed Please Copy-Paste the code below in the R-Console Window
# Step 1: Creating a function called anomalies_plot. # So that we dont have to write the code again # Once the function is created we can use it in future analysis/charting as well.
# Getting the required Library
list.of.packages <- c("quantmod")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
library('quantmod')
# Creating Funtion
anomalies_plot <- function(symbol, start_date, end_date) {
# Download data from Yahoo Finance
data <- getSymbols(symbol, src = "yahoo", from = start_date, to = end_date, auto.assign = FALSE)
# Plot the data
chartSeries(data, name = symbol, theme = "white", major.ticks = "auto")
}
#Step 2: Calling the function anomalies_plot for Symbol "AAPL" from 2015, January 01 till today anomalies_plot("AAPL","2015-01-01",Sys.Date())
The current indicators from the TTR package, as well as a few originating in the “quantmod”, package are:
Indicator | TTR Name | quantmod Name |
---|---|---|
Welles Wilder’s Directional Movement Indicator | ADX | addADX |
Average True Range | ATR | addATR |
Bollinger Bands | BBands | addBBands |
Bollinger Band Width | N/A | addBBands |
Bollinger %b | N/A | addBBands |
Commodity Channel Index | CCI | addCCI |
Chaiken Money Flow | CMF | addCMF |
Chande Momentum Oscillator | CMO | addCMO |
Double Exponential Moving Average | DEMA | addDEMA |
Detrended Price Oscillator | DPO | addDPO |
Exponential Moving Average | EMA | addEMA |
Price Envelope | N/A | addEnvelope |
Exponential Volume Weighted Moving Average | EVWMA | addEVWMA |
Options and Futures Expiration | N/A | addExpiry |
Moving Average Convergence Divergence | MACD | addMACD |
Momentum | momentum | addMomentum |
Rate of Change | ROC | addROC |
Relative Strength Indicator | RSI | addRSI |
Parabolic Stop and Reverse | SAR | addSAR |
Simple Moving Average | SMA | addSMA |
Stocastic Momentum Index | SMI | addSMI |
Triple Smoothed Exponential Oscillator | TRIX | addTRIX |
Volume | N/A | addVo |
Weighted Moving Average | WMA | addWMA |
Williams %R | WPR | addWPR |
ZLEMA | ZLEMA | addZLEMA |
You must log in to post a comment.