Skip to contents

Calculates daily percentage change of a stock price within a given period of time

Usage

percent_change(stock_ticker, start_date, end_date)

Arguments

stock_ticker

A string related to ticker of the stock or ETF, such as "AAPL"

start_date

A date in string format of "YYYY-MM-DD" related to start of data extraction

end_date

A date in string format of "YYYY-MM-DD" related to end of data extraction

Value

A data frame with dates and their corresponding stock price percentage changes

Examples

percent_change("AAPL", "2017-01-01", "2017-01-10")
#> Registered S3 method overwritten by 'quantmod':
#>   method            from
#>   as.zoo.data.frame zoo 
#> # A tibble: 5 x 2
#>   date       percent_change
#>   <date>              <dbl>
#> 1 2017-01-03          0    
#> 2 2017-01-04         -0.001
#> 3 2017-01-05          0.004
#> 4 2017-01-06          0.015
#> 5 2017-01-09          0.024