Refinitiv Data Library for Python

get_history

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

Module

refinitiv.data

Syntax

get_history( universe, fields=None, interval=None, start=None, end=None, adjustments=None, count=None, use_field_names_in_headers=False )

Parameters

Value Description Data type Optional Default value
universe Instruments to request str or list No -
fields Fields to request str or list Yes None
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"] str Yes None
start The start date and timestamp of the requested history str, date, datetime, timedelta Yes None
end The end date and timestamp of the requested history str, date, datetime, timedelta Yes None
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"] str Yes None
count The maximum number of data points returned. Values range: 1 - 10000 int Yes None
use_field_names_in_headers If True - returns field name as column headers for data instead of title bool Yes False

Returned value

A pandas.DataFrame with fields in columns and instruments as row index.

Usage

The following example demonstrates the last 50 ticks of historical pricing data:

import refinitiv.data as rd

# open session
rd.open_session()

df = rd.get_history(
    universe="GOOG.O",
    fields=["BID", "ASK"],
    interval="tick",
    count=5
)
print(df)

# close session
rd.close_session()

This example produces the following output:

GOOG.O                      BID     ASK
Timestamp                              
2022-08-11 22:30:22.567  119.90  120.16
2022-08-11 22:31:02.653  119.90  120.16
2022-08-11 22:31:11.701  119.88  120.16
2022-08-11 22:31:11.749  119.90  120.16
2022-08-11 22:31:22.840  119.90  120.16

The following example demonstrates fundamental and the historical pricing date:

from datetime import date, timedelta

import refinitiv.data as rd

# open session
rd.open_session()

# display today's date
print(f"Today is {date.today()}\n")

df = rd.get_history(
    universe=["IBM"],
    fields=['BID', "ASK", 'TR.RevenueMean.currency', "TR.RevenueMean"],
    interval='1h',
    use_field_names_in_headers=False,
    start=timedelta(-30),
    end=timedelta(0)
)
print(df.to_string())

# close session
rd.close_session()

This example produces the following output:

Today is 2022-08-12

IBM                     BID     ASK Currency Revenue - Mean
Timestamp                                                  
2022-07-12 00:00:00    <NA>    <NA>      USD    60926572250
2022-07-13 00:00:00    <NA>    <NA>      USD    60922436870
2022-07-13 08:00:00     139  139.79     <NA>           <NA>
2022-07-13 09:00:00     139  139.58     <NA>           <NA>
2022-07-13 10:00:00  139.23  139.99     <NA>           <NA>
2022-07-13 11:00:00  139.09  139.65     <NA>           <NA>
2022-07-13 12:00:00  138.15  138.25     <NA>           <NA>
2022-07-13 13:00:00  137.23  137.27     <NA>           <NA>
2022-07-13 14:00:00  137.85  137.89     <NA>           <NA>

None.