chart_spreads: Futures contract spreads comparison across years

View source: R/chart_spreads.R

chart_spreadsR Documentation

Futures contract spreads comparison across years

Description

Plots specific contract pairs across years with time being days from expiry.

Usage

chart_spreads(
  cpairs = cpairs,
  daysFromExpiry = 200,
  from = "2012-01-01",
  conversion = c(1, 1),
  feed = "CME_NymexFutures_EOD",
  iuser = "x@xyz.com",
  ipassword = "pass",
  title = "March/April ULSD Nymex Spreads",
  yaxis = "$ per bbl",
  output = "chart"
)

Arguments

cpairs

Tibble of contract pairs - see example for expiry when not expired yet. tibble

daysFromExpiry

Number of days from expiry to compute spreads. numeric

from

From date character

conversion

Defaults to c(1,1) first and second contracts. 42 from $ per gallons to bbls. numeric

feed

Zema Feed Table. character

iuser

Zema user name as character - sourced locally in examples. character

ipassword

Zema user password as character - sourced locally in examples. character

title

Title for chart. character

yaxis

y-axis label. character

output

"chart" for htmlwidget or "data" for tibble.

Value

A plotly object or a dataframe

Author(s)

Philippe Cote

Examples

## Not run: 
cpairs <- dplyr::tibble(
 year = c("2018", "2019", "2020","2021","2022","2023"),
 first = c("@HO8H", "@HO9H", "@HO0H","@HO21H","@HO22H","@HO23H"),
 second = c("@CL8H", "@CL9H", "@CL0H","@CL21H","@CL22H","@CL23H"),
 expiry = c(NA,NA,NA,NA,NA,"2023-02-23")
)
chart_spreads(
  cpairs = cpairs, daysFromExpiry = 200, from = "2012-01-01",
  conversion = c(42, 1), feed = "CME_NymexFutures_EOD",
  iuser = "x@xyz.com", ipassword = "pass",
  title = "March/April ULSD Nymex Spreads",
  yaxis = "$ per bbl",
  output = "data"
)

## End(Not run)


RTL documentation built on May 23, 2026, 5:07 p.m.