Skip to contents

The get_history function allows you to retrieve pricing history, as well as Fundamental and Reference data history through a single function call.

Usage

rd_GetHistory(
  RD = rd_connection(),
  universe = NULL,
  fields = NULL,
  parameters = NULL,
  interval = NULL,
  start = NULL,
  end = NULL,
  adjustments = NULL,
  count = NULL,
  use_field_names_in_headers = TRUE,
  SpaceConvertor = NULL,
  debug = FALSE,
  cache = NULL
)

Arguments

RD

Refinitiv JSON connection object, default is RDConnect()

universe

Instruments to request str or vector

fields

Fields to request str or vector

parameters

a named key value list for setting parameters, Default: NULL

interval

Date interval. Supported intervals are: ["minute", "1min", "5min", "10min", "30min", "60min", "hourly", "1h", "daily", "1d", "1D", "7D", "7d", "weekly", "1W", "monthly", "1M", "quarterly", "3M", "6M", "yearly", "12M", "1Y"]

start

The start date and timestamp of the requested history str, date

end

The end date and timestamp of the requested history str, date

adjustments

Tells the system whether to apply or not apply CORAX (Corporate Actions) events or exchange/manual corrections or price and volume adjustment according to trade/quote qualifier summarization actions to historical time series data. Possible values are ["exchangeCorrection", "manualCorrection", "CCH", "CRE", "RTS", "RPO", "unadjusted", "qualifiers"]

count

The maximum number of data points returned. Values range: 1 - 10000

use_field_names_in_headers

boolean If True - returns field name as column headers for data instead of title, it is advisable to leave this setting to TRUE to prevent the issue with two date columns when using specific fields like e.g.

SpaceConvertor

converts spaces in variables name into one of the following characters ".", "," , "-", "_", default is NULL, use this for compatability with eikon

debug

boolean, default = FALSE, if TRUE, prints out the url used to retrieve the data

cache

Controls caching. NULL (default) defers to getOption("refinitiv_cache", FALSE). TRUE uses the function default TTL (300 s). FALSE disables caching. A positive numeric value sets the cache TTL in seconds. See rd_ClearCache.

Value

data.frame

Details

#section regarding adjustments parameters:

The vector of adjustment types (comma delimiter) that tells the system whether to apply or not apply CORAX (Corporate Actions) events or exchange/manual corrections to historical time series data.

The supported values of adjustments :

  • "unadjusted": Not apply both exchange/manual corrections and CORAX

  • "exchangeCorrection": Apply exchange correction adjustment to historical pricing

  • "manualCorrection": Apply manual correction adjustment to historical pricing i.e. annotations made by content analysts

  • "CCH": Apply Capital Change adjustment to historical Pricing due to Corporate Actions e.g. stock split

  • "CRE":Apply Currency Redenomination adjustment when there is redenomination of currency

  • "RPO":Apply Reuters Price Only adjustment to adjust historical price only not volume

  • "RTS":Apply Reuters TimeSeries adjustment to adjust both historical price and volume

  • "qualifiers":Apply price or volume adjustment to historical pricing according to trade/quote qualifier summarization actions

Merge behavior

When the requested fields include both historical-pricing fields (e.g. BID, TRDPRC_1) and fundamental/reference fields (e.g. TR.Revenue), the function routes them to two different backend endpoints and merges the results with a full outer join on (Instrument, Date).

If the two endpoints return data at different date granularity (e.g. daily prices vs. quarterly fundamentals), the merged result will contain rows where one set of columns is populated and the other is NA. A warning is emitted when the date-count ratio exceeds 5:1 for any instrument.

The result carries a "merge_info" attribute (when both endpoints contributed data) with row counts and merge type. Inspect with attr(result, "merge_info").

For full control over date alignment, call rd_GetHistoricalPricing and rd_GetData separately.

Examples

if (FALSE) { # \dontrun{
RDObject <- RDConnect("your api key here")
timeseries1 <- rd_GetHistory(universe = c("AAPL.O", "NVDA.O"))
timeseries2 <- rd_GetHistory(
  universe = "GOOG.O",
  fields = c("BID", "ASK"), interval = "tick", count = 5
)

test <- rd_GetHistory(
  universe = "AAPL.O",
  fields = c(
    "TR.IssueMarketCap(Scale=6,ShType=FFL)",
    "TR.FreeFloatPct()/100/*FreefloatWeight*/",
    "TR.IssueSharesOutstanding(Scale=3)/*shares outstanding*/",
    "TR.CLOSEPRICE(Adjusted=0)/*close*/"
  ),
  parameters = list(
    "Curn" = "USD",
    "SDate" = "2020-10-27", "EDate" = "2020-12-01"
  )
)

test <- rd_GetHistory(
  universe = c("GOOG.O", "AAPL.O"),
  fields = c("TR.Revenue", "TR.GrossProfit"),
  parameters = list("SDate" = "0CY", "Curn" = "CAD")
)
test <- rd_GetHistory(
  universe = c("GOOG.O", "AAPL.O"),
  fields = c("TR.PriceTargetMean(SDate:0CY)", "TR.LOWPRICE(SDate:0d)")
)


test <- rd_GetHistory(
  universe = c("GOOG.O", "MSFT.O", "FB.O", "AMZN.O"),
  fields = c("TR.Revenue.date", "TR.Revenue", "TR.GrossProfit"),
  parameters = list(
    "Scale" = 6, "SDate" = 0,
    "EDate" = -3, "FRQ" = "FY", "Curn" = "EUR"
  )
)
} # }