hasquant
Safe HaskellNone
LanguageHaskell2010

QuantLib.TermStructure.Commodity

Synopsis

Types

type CommodityCurve = GenTermStructure CCommodityCurve Source #

A plain TermStructure leaf (not a YieldTermStructure -- it has no discount-factor semantics, just an interpolated price curve), constructed and consumed by shared_ptr like CallableBondVolatilityStructure/DefaultProbabilityTermStructure, never a Handle. See the hierarchy under GenTermStructure.

type ExchangeContract Source #

Arguments

 = (String, Day, Day, Day)

code, expirationDate, underlyingStartDate, underlyingEndDate

A dated exchange contract: a code, its expiration date, and the start/end dates of the underlying delivery period it corresponds to. A plain tuple, per the Money/Quantity-as-tuple convention -- it carries no calculation of its own upstream, only three inspectors that would just be tuple projections.

type ExchangeContracts = [(Day, ExchangeContract)] Source #

QuantLib's std::map<Date,ExchangeContract>: a set of exchange contracts, keyed by the date priceNearby/underlyingPriceDate roll onto (upstream's own lower_bound walk finds the first key at or after the query date, then steps nearbyOffset - 1 further). Marshalled as an association list, not an actual Map -- the C shim rebuilds the real std::map itself so key order doesn't need to be pre-sorted on the Haskell side.

Constructors

commodityCurve :: String -> CommodityType -> Currency -> UnitOfMeasure -> Calendar -> NonEmpty (Day, Double) -> DayCounter -> IO CommodityCurve Source #

Construct a commodity price curve: a named, interpolated (forward-flat) price curve over a fixed set of dates, for a given commodity type/currency/unit of measure. QuantLib's no-dates constructor populated later via setPrices is not bound, so this is the only way to build one.

Mutators

setBasisOfCurve :: CommodityCurve -> CommodityCurve -> IO () Source #

Chain this curve to a basis curve: prices returned by price/basisOfPrice then include the basis curve's price on top of this curve's own.

Inspectors

Curve metadata and nodes

name :: CommodityCurve -> IO String Source #

The curve's name, as given at construction.

commodityType :: CommodityCurve -> IO CommodityType Source #

The commodity type this curve prices.

unitOfMeasure :: CommodityCurve -> IO UnitOfMeasure Source #

The unit of measure this curve's prices are quoted in.

currency :: CommodityCurve -> IO Currency Source #

The currency this curve's prices are quoted in.

nodes :: CommodityCurve -> IO [(Day, Double)] Source #

The curve's nodes, as (date, price) pairs in construction order.

isEmpty :: CommodityCurve -> Bool Source #

Whether this curve has any nodes.

basisOfCurve :: CommodityCurve -> IO (Maybe CommodityCurve) Source #

The basis curve this curve was chained to via setBasisOfCurve, if any.

Prices and contracts

price :: CommodityCurve -> Day -> IO Double Source #

The curve's price for a date, plus any chained basis curve's price. This is priceNearby with no exchange contracts and offset 0 -- the flat (no nearby-rolling) case, which never touches exchangeContracts upstream either way.

basisOfPrice :: CommodityCurve -> Day -> IO Double Source #

The chained basis curve's price alone (excluding this curve's own price), for a date.

priceNearby :: CommodityCurve -> Day -> ExchangeContracts -> Int -> IO Double Source #

The curve's price for a date, plus any chained basis curve's price, rolling forward onto nearby exchange contracts when nearbyOffset > 0 (upstream's own price never touches exchangeContracts otherwise). price is this with no exchange contracts and offset 0, which reproduces the flat (no-rolling) case exactly.

underlyingPriceDate :: CommodityCurve -> Day -> ExchangeContracts -> Int -> IO Day Source #

The date whose price a nearby roll (nearbyOffset > 0) actually reads: the underlying contract's start date at the nearbyOffset'th exchange contract at or after date. Throws if nearbyOffset <= 0, or if fewer than nearbyOffset contracts are available from date onward.