investment modeling w/ R - Midterm

0.0(0)
Studied by 2 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/33

encourage image

There's no tags or description

Looks like no tags are added yet.

34 Terms

1
New cards

Compound return

earnings on earnings

2
New cards

Compound return: Example

If you invest $1,000 at a 10% annual gain, year one gives you $100. Year two gives you 10% on $1,100, which is $110.

3
New cards

Simple returns

You only earn money on your starting amount

4
New cards

Data container

a variable that holds a value, can be used for future calculation

5
New cards

Output of a=c(45,2,-8,10,1)

What is created?

  • 45  2  -8  10  1

  • New data container “a” is made


6
New cards

Output of b=1:5 vs b=5:1

  • 1 2 3 4 5

  • 5 4 3 2 1


7
New cards

Output of c=rep(3,5)

3 3 3 3 3

8
New cards

Output of d=seq(2,10,2)

2 4 6 8 10

9
New cards

Uniroot function

Uniroot(x) finds the value of variable (x) that will cause the equation to be closest to 0

10
New cards

Compound return equation

p*(1+r)^years

11
New cards

$root

what is the value that makes the whole equation 0

12
New cards

list

data container that can store other data containers (tables, values, etc)

13
New cards

Output of getSymbols(‘tsla’)

getSymbols: names the data container (TSLA), executes code, and stores it

14
New cards

output of getSymbols(‘tsla’,from=’2018-01-01’):

all data starting from Jan 1st, 2018

15
New cards

getSymbols(‘tsla’,from=’2018-01-01’, to=’2019-12-31’):

all data starting from Jan 1st, 2018 to Dec 31st, 2019

16
New cards

output of thejoker = getSymbols(‘tsla’,from=’2018-01-01’, auto.assign = F):

all data starting from Jan 1st, 2018 to Dec 31st, 2019

  • Tells getSymbols to get the data you want, but name it this (thejoker)

  • New data container created


17
New cards

auto.assign

 lets us name the data container

18
New cards

tail(TSLA,6):

Last 6 rows from the TSLA table

19
New cards

head(TSLA,6):

First 6 rows from the TSLA table

20
New cards

thejoker[row,column]

 how to pick a specific row/column

21
New cards

TSLA[‘2018/2019’]

shows rows from 2018 to 2019

22
New cards

first(TSLA[‘2018/2019’],5)

shows the first/last 5 rows from 2018 to 2019

23
New cards

TSLA[‘2019-12’]:

shows rows from December 2019

24
New cards

TSLA[‘2019-12/2019-12-25’]

shows rows in December until December 25th, 2019

25
New cards

last(TSLA[‘2019-12/2019-12-25’],3):

shows the rows of the last 3 transactions in December until December 25th, 2019

26
New cards

as.vector:

takes data from a more advanced data container and converts to a simple vector

27
New cards

S&P 500:

  • 500 biggest companies in the world

  • “The market” = usually implying the S&P 500

  • Makes up the majority of the stock market

  • Most stable and profitable companies in the market


28
New cards

Dow:

30, 40 countries (not by market share; more volatile)

29
New cards

SPY:

S&P 500 ETF

30
New cards

An ETF (Exchange Traded Funded):

Portfolio of stocks listed on the market that you can buy

31
New cards

Simple return equation

(Sell price / buy price) - 1

32
New cards

as.vector(Ad(last(TSLA[‘2019-12/2019-12-25’])))

Tesla’s adjusted closing price on the last available trading day between December 1 and December 25, 2019

33
New cards

In the problem:

a=c(10,-2,4,1,7)

b=5:1

b[c(5,1,2)]=a[4:2]

What is b[c(5,1,2)] providing us with?

the positions in b that we need to replace SPECIFICALLY in that order

34
New cards

In the problem:

a=c(10,-2,4,1,7)

b=5:1

b[c(5,1,2)]=a[4:2]

What is a[4:2] providing us with?

the values that in a that we will extract and use to replace the values in b