Escolar Documentos
Profissional Documentos
Cultura Documentos
### About
This worksheet is your warm-up exercises to getting started with some R for
finance, based on examples from the book. It is also your getting started with
problems solving (no R required) and expressing your methods/answers using proper
mathematical symbols and representations.
### Setup
Remember to always set your working directory to the source file location. Go to
'Session', scroll down to 'Set Working Directory', and click 'To Source File
Location'. Read carefully the below and follow the instructions to complete the
tasks and answer any questions. Submit your work to RPubs as detailed in previous
notes.
### Note
Quite often you will need to add your own code chunk. Execute sequentially all code
chunks, preview, publish, and submit link on Sakai following the naming convention.
Make sure to add comments to your code where appropriate. Use own language!
--------------
This task follows the book's R Example 1.1/p. 8 also exhibited in the R-Labs
section R Labs1 from the book’s website (*). In order to work with R in finance we
need to first install the package `quantmod` that allows us to retrieve financial
data and conduct various statistical analysis.
```{r}
# Require will load the package only if not installed
# Dependencies = TRUE makes sure that dependencies are install
if(!require("quantmod",quietly = TRUE))
install.packages("quantmod",dependencies = TRUE, repos = "https://cloud.r-
project.org")
```
<span style="color:red">
##### 1A) Insert in the code chunk below the rest of the code to calculate and
chart the time series for stock GE. Follow the example in the book. Add comments,
where appropriate, explaining what the particular line(s) of code is/are
executing/solving for.
</span>
```{r}
##retrieve historical price data for General Electric Co. from Yahoo Finance
getSymbols('GE',src='yahoo', from="2000-01-01", to="2009-12-30")
##to see headers of file (OHLCV type)
names(GE)
```
This follows the book’s example 1.3.4 R Lab/p. 34 also R Labs 1 from the book’s
website (*).
<span style="color:red">
##### 2A) Insert the code chunk to chart instead the performance of Value Line
Index VLIC (sort of benchmark), and four other stocks of your choice over a time
period dating back one year from present date.
</span>
<span style="color:red">
##### 2B) Write the mathematical form/representation, using proper math symbols, to
describe the formula being calculated and plotted in the code
</span>
<span style="color:red">
##### 2C) Write a paragraph, in your own words, comparing the stock performances
based on your assessment of the companies general business and their valuation vis-
a-vis the market overall performance, and pertinent econonomical factors.
</span>
![Caption Here](img01.png)
This task does not require use of R code. You will however need to type your work
here, using proper mathematical symbols and representations, or include a clear
image capture of your work.
<span style="color:red">
##### 3A) Solve for 1.3.8 Problem/p. 36.
</span>
<span style="color:red">
##### 3B) Solve for 1.3.9 Problem/p. 36
</span>
*[http://computationalfinance.lsi.upc.edu ]
(http://computationalfinance.lsi.upc.edu)