1/33
Looks like no tags are added yet.
Compound return
earnings on earnings
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.
Simple returns
You only earn money on your starting amount
Data container
a variable that holds a value, can be used for future calculation
Output of a=c(45,2,-8,10,1)
What is created?
45 2 -8 10 1
New data container “a” is made
Output of b=1:5 vs b=5:1
1 2 3 4 5
5 4 3 2 1
Output of c=rep(3,5)
3 3 3 3 3
Output of d=seq(2,10,2)
2 4 6 8 10
Uniroot function
Uniroot(x) finds the value of variable (x) that will cause the equation to be closest to 0
Compound return equation
p*(1+r)^years
$root
what is the value that makes the whole equation 0
list
data container that can store other data containers (tables, values, etc)
Output of getSymbols(‘tsla’)
getSymbols: names the data container (TSLA), executes code, and stores it
output of getSymbols(‘tsla’,from=’2018-01-01’):
all data starting from Jan 1st, 2018
getSymbols(‘tsla’,from=’2018-01-01’, to=’2019-12-31’):
all data starting from Jan 1st, 2018 to Dec 31st, 2019
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
auto.assign
lets us name the data container
tail(TSLA,6):
Last 6 rows from the TSLA table
head(TSLA,6):
First 6 rows from the TSLA table
thejoker[row,column]
how to pick a specific row/column
TSLA[‘2018/2019’]
shows rows from 2018 to 2019
first(TSLA[‘2018/2019’],5)
shows the first/last 5 rows from 2018 to 2019
TSLA[‘2019-12’]:
shows rows from December 2019
TSLA[‘2019-12/2019-12-25’]
shows rows in December until December 25th, 2019
last(TSLA[‘2019-12/2019-12-25’],3):
shows the rows of the last 3 transactions in December until December 25th, 2019
as.vector:
takes data from a more advanced data container and converts to a simple vector
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
Dow:
30, 40 countries (not by market share; more volatile)
SPY:
S&P 500 ETF
An ETF (Exchange Traded Funded):
Portfolio of stocks listed on the market that you can buy
Simple return equation
(Sell price / buy price) - 1
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
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
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