Get startedGet started for free

Getting financial data

1. Getting financial data

The first step in designing any trading system is to actually get financial data.

2. Obtaining data from Yahoo!

While most financial data are priced at an institutional rate, there are some sources of free data of passable quality. The one we will use for this class is yahoo finance. In R, the quantmod library has the getSymbols command, which will create an object in your working environment with the name of the financial asset you obtained.

3. 2 ETFs in this course

In this course, we will be looking at ETFs, exchange traded funds. An exchange-traded fund is a basket of securities that aim to reflect a certain behavior. We will be looking at 2 ETFs in this course: LQD and SPY. LQD, representing a basket of investment-grade corporate debt, will be covered in the course videos. SPY, an ETF that tracks the S&P500 which is a basket of large companies, will be covered in the exercises. The data comes in a format with the following columns: Open, High, Low, Close, Volume, and Adjusted prices.

4. quantmod functions

The quantmod library has the following commands to access each of these columns: Op for open, Hi for high, Lo for low, Cl for close, Vo for volume, and Ad for adjusted. To understand what these terms mean, know that U.S. markets open at 9:30 AM EST (Eastern Standard Time) and close at 4:00 PM. The open is the price at which trading begins, the closing price is the last price that was traded, and the high and low are the maximum and minimum values that the asset reached over the course of the day, respectively. The volume details the number of shares traded, and the adjusted close is the close adjusted for dividends and splits. Dividends are a regular cash payout to the holder of the asset that is not reflected in the raw prices, and splits are when the price of an asset gets cut in half, but the number of shares are increased by two, for instance.

5. Plotting financial data

Furthermore, one can plot this data with the following code displayed.

6. Let's practice!

In the following exercise, you will need to follow this process with a different asset.