% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers_get_market.R
\name{get_market_history_candles}
\alias{get_market_history_candles}
\title{Get historical market candles}
\usage{
get_market_history_candles(
  inst_id,
  bar,
  before = NULL,
  limit = 100L,
  config = NULL,
  tz = .okx_default_tz,
  standardize_names = TRUE
)
}
\arguments{
\item{inst_id}{Character. Instrument ID, e.g. `"BTC-USDT"`.}

\item{bar}{Character. Candlestick granularity, e.g. `"1m"`, `"5m"`, `"1H"`.}

\item{before}{Character or `NULL`. Timestamp string like
`"\%Y-\%m-\%d \%H:\%M:\%S"`. If `NULL`, fetch recent history.}

\item{limit}{Integer. Number of bars to retrieve. Default `100L`.}

\item{config}{Optional list. Public endpoint request options, such as
`timeout`; credentials are not required.}

\item{tz}{Character. Time zone for parsing timestamps. Default `"Asia/Hong_Kong"`.}

\item{standardize_names}{Logical. If `TRUE` (default), renames columns to
`timestamp`, `open`, `high`, `low`, `close`, `volume`, `volQuote`.}
}
\value{
A `data.frame` of candlestick bars. If `standardize_names = TRUE`,
column names are normalized. Timestamps are `POSIXct` in `tz`.
}
\description{
Retrieve candlestick data before a specific datetime.
}
\details{
Wraps `/api/v5/market/history-candles`. If `before` is supplied, it is
converted to milliseconds since epoch (in `tz`) and sent as `after=...`
(per OKX semantics: *return data before this time*).
}
\note{
Since okxr 0.1.1
}
\examples{
\dontrun{
cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx")
get_market_history_candles(
  "ETH-USDT-SWAP", bar = "1H",
  before = "2025-08-20 00:00:00", config = cfg
)
}

}
\seealso{
[get_market_candles()]
}
