Você está na página 1de 3

---

title: "FINC621 Winter 2018-19 Lab Worksheet 01"


author: "Your Name Here"
date: "Add Date Here"
output:
html_document: default
html_notebook: default
subtitle: Exploration of R in Finance (finc621-lab01)
---

### 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

For clarity, tasks/questions to be completed/answered are highlighted in red color


(color visible only in preview mode) and numbered according to their particular
placement in the task section. Type your answers outside the red color tags!

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!

**Any sign of plagiarism, will result in dissmissal of work!**

--------------

### Task 1: Charting Stock Time Series

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)
```

### Task 2: Comparing Performance of Stocks Time Series

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>

To add math symbols in R Markdown check the link [MathinRmd.html]


( https://www.calvin.edu/~rpruim/courses/s341/S17/from-class/MathinRmd.html).
Many other examples are on Google. Following is an example: $\sum_{n=1}^{10} n^2$.
Other, less preferred options, is to neatly handwrite your equations on a paper or
use own preferred tools like Microsoft Word, take a clear image capture of your
work and include here. Hard to read work will be dismissed.

Below is an example on how to include an image. It is assumed that the image


resides in the same folder as the worksheet. Otherwise the path to the folder where
the image resides needs to be included in the name referencing below.

![Caption Here](img01.png)

### Task 3: Problem(s) Solving

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)

Você também pode gostar