sql_adapter: Load Price Data from SQL Database

View source: R/data_adapters.R

sql_adapterR Documentation

Load Price Data from SQL Database

Description

Loads stock price data from SQLite database with automatic frequency conversion.

Usage

sql_adapter(
  db_path,
  symbols,
  start_date = NULL,
  end_date = NULL,
  auto_update = TRUE,
  frequency = "daily"
)

Arguments

db_path

Path to SQLite database file

symbols

Character vector of stock symbols to load

start_date

Start date (YYYY-MM-DD) or NULL

end_date

End date (YYYY-MM-DD) or NULL

auto_update

Auto-update database before loading (default: TRUE)

frequency

"daily", "weekly", or "monthly" (default: "daily")

Value

data.table with Date column and one column per symbol

Examples



prices <- sql_adapter(
  db_path   = "sp500.db",
  symbols   = c("AAPL", "MSFT"),
  start_date = "2020-01-01",
  end_date   = "2020-12-31",
  frequency  = "weekly"
)
head(prices)



PortfolioTesteR documentation built on Nov. 5, 2025, 5:23 p.m.