Skip to main content

Futures

The functions from the OpenBB Terminal Futures menu is part of the SDK layer, and provides methods for programmatically accessing the data and charts associated with them. Get started by importing the OpenBB SDK to the Python script or Jupyter Notebook file.

How to Use

Below is a brief description of each function within the Futures module:

PathTypeDescription
openbb.futures.curveFunctionFutures Forward Curve Data
openbb.futures.curve_chartFunctionFutures Forward Curve Chart
openbb.futures.searchFunctionSearch Available Futures
openbb.futures.historicalFunctionHistorical OHLC+V Data
openbb.futures.historical_chartFunctionChart Historical Price of Individual Contracts

Examples

Import Statements

The examples here will assume that the block below is included at the top of the file:

from openbb_terminal.sdk import openbb
import pandas as pd
%matplotlib inline

Futures can be searched by description, exchange, or category.

openbb.futures.search(description = 'Eurodollar')
TickerDescriptionExchangeCategory
66GEEurodollar FuturesCMEcurrency
67GLBOne-Month Eurodollar FuturesCMEcurrency
152SEDSED (SOFR-Eurodollar) Spread FuturesCMEbonds

The historical front-month price is captured to a DataFrame with:

Curve

The forward curve data for a symbol is fetched with:

eurodollar = openbb.futures.curve('GE')
ExpirationFutures
2022-11-01 00:00:0095.3561
2022-12-01 00:00:0094.9925
2023-01-01 00:00:0094.985
2023-02-01 00:00:0094.9
2023-03-01 00:00:0094.825

To display a chart of the data, use curve_chart:

openbb.futures.curve_chart(symbol = 'GE')

openbb.futures.curve_chart

Historical

The historical function can fetch the historical front-month price:

wti_continuous = obb.futures.historical('CL')

Or, while actively trading, individual contracts. The example below requests historical data for the December WTI contract from 2023 to 2030, starting at the first recorded trading day of the December 2030 contract.

cl_2312 = openbb.futures.historical(symbols = ['CL'], expiry = '2023-12')
cl_2312 = cl_2312.rename(columns={'Adj Close':'2023-12'})
cl_2412 = openbb.futures.historical(symbols = ['CL'], expiry = '2024-12')
cl_2412 = cl_2412.rename(columns={'Adj Close':'2024-12'})
cl_2512 = openbb.futures.historical(symbols = ['CL'], expiry = '2025-12')
cl_2512 = cl_2512.rename(columns={'Adj Close':'2025-12'})
cl_2612 = openbb.futures.historical(symbols = ['CL'], expiry = '2026-12')
cl_2612 = cl_2612.rename(columns={'Adj Close':'2026-12'})
cl_2712 = openbb.futures.historical(symbols = ['CL'], expiry = '2027-12')
cl_2712 = cl_2712.rename(columns={'Adj Close':'2027-12'})
cl_2812 = openbb.futures.historical(symbols = ['CL'], expiry = '2028-12')
cl_2812 = cl_2812.rename(columns={'Adj Close':'2028-12'})
cl_2912 = openbb.futures.historical(symbols = ['CL'], expiry = '2029-12')
cl_2912 = cl_2912.rename(columns={'Adj Close':'2029-12'})
cl_3012 = openbb.futures.historical(symbols = ['CL'], expiry = '2030-12')
cl_3012 = cl_3012.rename(columns={'Adj Close':'2030-12'})

historical = pd.DataFrame(data = [cl_2312['2023-12'],cl_2412['2024-12'],cl_2512['2025-12'],cl_2612['2026-12'],cl_2712['2027-12'],cl_2812['2028-12'],cl_2912['2029-12'],cl_3012['2030-12']]).transpose()
historical = historical.dropna()

historical
Date2023-122024-122025-122026-122027-122028-122029-122030-12
2020-01-24 00:00:0049.6150.1450.751.5651.6351.6351.6351.63
2020-01-27 00:00:0049.9450.651.1851.0551.1251.1251.1251.12
2020-01-28 00:00:0050.1750.7851.2351.5551.6251.6251.6251.62
2020-01-29 00:00:0050.0750.6451.1351.651.6751.6751.6751.67
2020-01-30 00:00:0050.2750.9151.4451.4951.5651.5651.5651.56
2022-11-09 00:00:0076.6971.6268.0165.162.5260.1758.1256.49
2022-11-10 00:00:007771.6467.8964.8662.2659.9157.8656.23
2022-11-11 00:00:0078.8173.169.2266.1963.661.2559.257.57
2022-11-14 00:00:0077.472.3568.8966.1563.6261.2559.1357.5
2022-11-15 00:00:0078.8273.6670.1467.3664.9462.6260.4958.68