R/stock.R

Defines functions calculate_delta

# Change from previous day
calculate_delta <-
  function(x) {
    previous_day_value <-
      c(
        x[1],
        x[-length(x)]
      )


    map2(
      x,
      previous_day_value,
      function(x, y) {
        x - y
      }
    ) %>%
      unlist()
  }
meerapatelmd/cerebro documentation built on July 16, 2022, 5:44 p.m.