MyNixOS website logo
Description

Risk Tool Library - Trading, Risk, 'Analytics' for Commodities.

A toolkit for Commodities 'analytics', risk management and trading professionals. Includes functions for API calls to <https://commodities.morningstar.com/#/>, <https://developer.genscape.com/>, and <https://www.bankofcanada.ca/valet/docs>.

CRAN_Status_Badge metacrandownloads R-CMD-check

Overview

RTL is a purposely designed for traders, analysts and risk practitioners in Commodities and Finance. It also supports delivery of Finance classes from one of the creator also in Academics at the Alberta School of Business.

Send feedback to [email protected]. We welcome feedback, suggestions and collaboration.

Energy Markets Reference Data

  • expiry_table: NYMEX and ICE contracts expiry tables.
  • holidaysOil: Holiday calendars for NYMEX and ICE.
  • tradeCycle: US and Canadian crude oil trading calendars.
  • tickers_eia: Mapping of EIA tickers to crude and refined products markets for building supply demand balances.
  • eiaStorageCap: Historical EIA crude storage capacity by PADD.
  • eiaStocks: Sample data set of EIA.gov stocks for key commodities.

Swap Pricing and Contract Roll Adjustement

  • rolladjust() adjusts continuous contracts returns for roll adjustments using expiry_table.
  • swapCOM() computes Calendar Month Average commodity swap prices.
  • swapInfo() returns all information required to price first line futures contract averaging swap or CMA physical trade, including a current month instrument with prior settlements.
  • swapIRS() computes IRS swap prices.

Charting

  • chart_fwd_curves(): plots historical forward curves, a useful feature to understand the pricing dynamics of a market.
  • chart_zscore() supports seasonality adjusted analysis of residuals, particularly useful when dealing with commodity stocks and/or days demand time series with trends as well as non-constant variance across seasonal periods.
  • chart_eia_steo() and chart_eia_sd() return either a chart or dataframe of supply demand balances from the EIA.
  • chart_spreads() to generate specific contract spreads across years e.g. ULSD March/April. Requires Morninstar credentials.

APIs

Valid credentials for commercial API services are required.

Genscape

Genscape API functions:

  • getGenscapeStorageOil().
  • getGenscapePipeOil().

Morningstar Commodities

Morningstar Marketplace API functions:

  • getPrice(), getPrices() and getCurve() using your own Morningstar credentials. Current feeds included:

    • ICE_EuroFutures and ICE_EuroFutures_continuous.
    • CME_NymexFutures_EOD and CME_NymexFutures_EOD_continuous.
    • CME_NymexOptions_EOD.
    • CME_CbotFuturesEOD and CME_CbotFuturesEOD_continuous.
    • CME_Comex_FuturesSettlement_EOD and CME_Comex_FuturesSettlement_EOD_continuous.
    • LME_AskBidPrices_Delayed.
    • CME_CmeFutures_EOD and CME_CmeFutures_EOD_continuous.
    • CME_STLCPC_Futures.
    • ICE_NybotCoffeeSugarCocoaFutures and ICE_NybotCoffeeSugarCocoaFutures_continuous.
    • Morningstar_FX_Forwards.
    • … see ?getPrice for up to date selection and examples.

GIS Dataset

EIA

  • crudepipelines <- getGIS(url = "https://www.eia.gov/maps/map_data/CrudeOil_Pipelines_US_EIA.zip")
  • refineries <- getGIS(url = "https://www.eia.gov/maps/map_data/Petroleum_Refineries_US_EIA.zip")
  • productspipelines <- getGIS(url = "https://www.eia.gov/maps/map_data/PetroleumProduct_Pipelines_US_EIA.zip")
  • productsterminals <- getGIS(url = "https://www.eia.gov/maps/map_data/PetroleumProduct_Terminals_US_EIA.zip")
  • ngpipelines <- getGIS(url = "https://www.eia.gov/maps/map_data/NaturalGas_InterIntrastate_Pipelines_US_EIA.zip")
  • ngstorage <- getGIS(url = "https://www.eia.gov/maps/map_data/PetroleumProduct_Terminals_US_EIA.zip")
  • nghubs <- getGIS(url = "https://www.eia.gov/maps/map_data/NaturalGas_TradingHubs_US_EIA.zip")
  • lngterminals <- getGIS(url = "https://www.eia.gov/maps/map_data/Lng_ImportExportTerminals_US_EIA.zip")
  • tradeHubs has North Americas crude oil trading hubs (WIP).

Alberta Oil Sands, Petroleum and Natural Gas

  • AB <- getGIS(url = "https://gis.energy.gov.ab.ca/GeoviewData/OS_Agreements_Shape.zip")

Interest Rates

  • usSwapIR: Sample data set output of getIRswapCurve.
  • usSwapCurves: Sample data set output of RQuantlib::DiscountCurve().

Python

A python version of RTL for most functions is available at https://pypi.org/project/risktools/.

Installation

Latest Packagedevtools::install_github("risktoollib/RTL")

CRAN Stableinstall.packages("RTL")

Metadata

Version

1.3.5

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows