Skip to content

Tools for building commodity forward, swaps, and futures curves.

License

Notifications You must be signed in to change notification settings

bananapy/curves

Repository files navigation

Commodity Curves

Build Status Azure DevOps coverage NuGet PyPI

Set of tools written in C# for constructing commodity forward/futures/swap curves with a fluent API. Python API also provided which integrates with the pandas library time series types.

Table of Contents

Overview

The curves package contains a set of tools for building commodity forward, swaps, and futures curves.

More specifically, the problem being solved is to take a collection of traded forward prices, and tranform these into a forward curve of homogenous granularity. Additionally the derived curve can constructed to be in a granularity higher than what is traded in the market.

Examples of types of curve which can be constructed using this package:

  • Monthly granularity oil products swap curves from traded monthly, quarterly, and calendar yearly granularity market swap rates.
  • Daily granularity natural gas forward curves from traded daily, weekly, monthly, quarterly, seasonal, and gas year granularity forward and futures prices.
  • Half-hourly granularity power forward curves from traded daily, weekly, monthly, quarterly, and seasonal granularity forward and futures prices.

The resulting curves should be consistent with inputs, in that they average back to the input forward contract prices. This is a necessary to ensure that there are no arbitrage opportunities introduced between input contracts, and the derived forward curve.

Getting Started

Installing

For use from C# install the NuGet package Cmdty.Curves.

PM> Install-Package Cmdty.Curves -Version 0.1.0-beta1

For use from Python install the curves package from PyPI.

> pip install curves

Installing For Python on Linux

Currently only a small amount of testing has been done for the Python package running on Linux (Ubuntu 18.04 LTS running in Windows 10 WSL) via the Mono runtime, using Python version 3.6.8. The following Linux dependencies have to be installed, as listed on the pythonnet wiki:

  • Mono-develop or Mono-complete. Curves was successfully run after installing version 5.20.1.34 of Mono-complete. Note that pythonnet does not work with Mono version 6.x. See this page for instructions on installing older versions of Mono on Linux.
  • clang.
  • libglib2.0-dev.
  • python-dev. Specifically the package python3.6-dev was installed.

It was also found that the PyPI package pycparser had to be installed, in order for the pythonnet PyPI package to install correctly.

Using From C#

For examples of usage see samples/csharp/.

Using From Python

A Python API has been created using pythonnet. See the Jupyter Notebook curves_quick_start_tutorial for an introduction on how to use this.

Technical Documentation

The PDF file max_smoothness_spline.pdf contains details of the mathematics behind the maximum smoothness algorithm.

License

This project is licensed under the MIT License - see the LICENSE file for details

About

Tools for building commodity forward, swaps, and futures curves.

Resources

License

Stars

Watchers

Forks

Packages

No packages published