Skip to content

Commit

Permalink
289 add adjusted to output (#345)
Browse files Browse the repository at this point in the history
Add adjusted close to output with unadjusted data, following the Yahoo
pattern. This exposes both the adjusted and unadjusted data in a way
that is compatible with other existing sources. It doesn't break
any existing contract (both implied and specified) and doesn't require
a radical re-design of the getSymbols() API.

Closes #345. See #289.
  • Loading branch information
ethanbsmith committed Jan 9, 2022
1 parent 71978df commit 925efe3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions R/getSymbols.R
Original file line number Diff line number Diff line change
Expand Up @@ -1530,10 +1530,11 @@ getSymbols.tiingo <- function(Symbols, env, api.key,

if (adjust) {
stock.data <- stock.data[, c("adjOpen", "adjHigh", "adjLow", "adjClose", "adjVolume")]
colnames(stock.data) <- paste(sym, c("Open", "High", "Low", "Close", "Volume"), sep=".")
} else {
stock.data <- stock.data[, c("open", "high", "low", "close", "volume")]
stock.data <- stock.data[, c("open", "high", "low", "close", "volume", "adjClose")]
colnames(stock.data) <- paste(sym, c("Open", "High", "Low", "Close", "Volume", "Adjusted"), sep=".")
}
colnames(stock.data) <- paste(sym, c("Open", "High", "Low", "Close", "Volume"), sep=".")

# convert data to xts
xts.data <- xts(stock.data, tm.stamps, src="tiingo", updated=Sys.time())
Expand Down

0 comments on commit 925efe3

Please sign in to comment.