Skip to main content

historical

Get historical futures data

Source Code: [link]

openbb.futures.historical(symbols: Union[str, List[str]], start_date: str, end_date: str, source: Optional[str] = "YahooFinance", expiry: Optional[str] = "")

Parameters

NameTypeDescriptionDefaultOptional
symbolsUnion[str, List[str]]The futures symbols you want to retrieve historical data for.
It can be either a single symbol as a string or a list of symbols.
NoneFalse
start_datestrThe start date of the historical data you want to retrieve. The date should be in the format "YYYY-MM-DD".NoneFalse
end_datestrThe end date of the historical data you want to retrieve. The date should be in the format "YYYY-MM-DD".NoneFalse
sourceOptional[str], default "YahooFinance"The source from which you want to retrieve the historical data.
Valid values for the source are "YahooFinance" and "DataBento".
YahooFinanceTrue
expiryOptional[str], default ""The expiry date for futures contracts. This parameter is optional and defaults to an empty string.
It is applicable only when the source is "YahooFinance" and the symbols are futures contracts.
True

Returns

TypeDescription
pd.DataFrameA pandas DataFrame containing the historical data for the given symbols and date range.