hasquant
Safe HaskellNone
LanguageHaskell2010

QuantLib.Instrument.Energy

Synopsis

Types

Commodity instrument hierarchy

type GenCommodity c = GenInstrument (AnyOf CCommodity' c) Source #

type Commodity = GenCommodity CCommodity Source #

An Instrument; see the hierarchy under GenInstrument.

type GenEnergyCommodity e = GenCommodity (AnyOf CEnergyCommodity' e) Source #

type EnergyCommodity = GenEnergyCommodity CEnergyCommodity Source #

type GenEnergySwap s = GenEnergyCommodity (AnyOf CEnergySwap' s) Source #

type EnergySwap = GenEnergySwap CEnergySwap Source #

An EnergyCommodity; see the hierarchy under GenInstrument.

type EnergyFuture = GenEnergyCommodity CEnergyFuture Source #

An EnergyCommodity; see the hierarchy under GenInstrument.

type EnergyVanillaSwap = GenEnergySwap CEnergyVanillaSwap Source #

An EnergySwap; see the hierarchy under GenInstrument.

type EnergyBasisSwap = GenEnergySwap CEnergyBasisSwap Source #

An EnergySwap; see the hierarchy under GenInstrument.

Costs, errors and positions

type SecondaryCosts = [(String, Either CommodityUnitCost (Double, Currency))] Source #

QuantLib's mapext::any, used with exactly two concrete alternatives across the module (CommodityUnitCost/Money, confirmed from energycommodity.cpp's two any_cast branches) -- bound as a real 2-variant sum rather than a generic any. Passed optionally to every energy-instrument constructor below; [] stands in for upstream's null shared_ptr.

type SecondaryCostAmounts = [(String, (Double, Currency))] Source #

The computed, currency-resolved output of SecondaryCosts -- Commodity::secondaryCostAmounts(), a mapMoney.

data PricingErrorLevel Source #

Constructors

Info 
Warning 
Error 
Fatal 

data PricingError Source #

A single entry of PricingErrors -- tradeId is never set by any constructor path that reaches addPricingError (upstream's own call sites all default it to empty), so it isn't bound.

Instances

Instances details
Show PricingError Source # 
Instance details

Defined in QuantLib.Instrument.Energy

Eq PricingError Source # 
Instance details

Defined in QuantLib.Instrument.Energy

data EnergyDailyPosition Source #

One day's position detail from an EnergySwap leaf's dailyPositions() -- a flat record rather than a (Day, ...) pair, since edpDate already carries the map key.

type CommodityCashFlow = GenCashFlow CCommodityCashFlow Source #

A CashFlow; see the hierarchy under GenCashFlow.

Configuration

data DeliverySchedule Source #

data QuantityPeriodicity Source #

Instances

Instances details
Bounded QuantityPeriodicity Source # 
Instance details

Defined in QuantLib.Internal.Common

Enum QuantityPeriodicity Source # 
Instance details

Defined in QuantLib.Internal.Common

Read QuantityPeriodicity Source # 
Instance details

Defined in QuantLib.Internal.Common

Show QuantityPeriodicity Source # 
Instance details

Defined in QuantLib.Internal.Common

Eq QuantityPeriodicity Source # 
Instance details

Defined in QuantLib.Internal.Common

Constructors

energyFuture Source #

Arguments

:: Int

buySell

-> Quantity 
-> CommodityUnitCost

tradePrice

-> CommodityIndex 
-> CommodityType 
-> SecondaryCosts 
-> IO EnergyFuture 

Construct an energy future: a single mark-to-market position against a CommodityIndex, struck at a fixed CommodityUnitCost trade price. buySell is a signed multiplier (1 to buy, -1 to sell), matching upstream's own Integer buySell (not a Bool). tradePrice/index are not exposed as getters because they only echo these constructor arguments.

energyVanillaSwap Source #

Arguments

:: Bool

payer

-> Calendar 
-> (Double, Currency)

fixedPrice

-> UnitOfMeasure

fixedPriceUnitOfMeasure

-> CommodityIndex 
-> Currency

payCurrency

-> Currency

receiveCurrency

-> PricingPeriods 
-> CommodityType 
-> SecondaryCosts 
-> GenYieldTermStructure y1

payLegTermStructure

-> GenYieldTermStructure y2

receiveLegTermStructure

-> GenYieldTermStructure y3

discountTermStructure

-> IO EnergyVanillaSwap 

Construct a vanilla energy swap: fixed CommodityUnitCost price against a floating CommodityIndex quote, over one or more PricingPeriods. payer selects which leg (fixed or floating) is paid. payReceive/fixedPrice/fixedPriceUnitOfMeasure/index are not bound as getters because they only echo this constructor's arguments; payReceive is simply if payer then 1 else 0.

energyBasisSwap Source #

Arguments

:: Calendar 
-> CommodityIndex

spreadIndex

-> CommodityIndex

payIndex

-> CommodityIndex

receiveIndex

-> Bool

spreadToPayLeg

-> Currency

payCurrency

-> Currency

receiveCurrency

-> PricingPeriods 
-> CommodityUnitCost

basis

-> CommodityType 
-> SecondaryCosts 
-> GenYieldTermStructure y1

payLegTermStructure

-> GenYieldTermStructure y2

receiveLegTermStructure

-> GenYieldTermStructure y3

discountTermStructure

-> IO EnergyBasisSwap 

Construct an energy basis swap: two floating CommodityIndex legs (pay/receive), one of them offset by a fixed CommodityUnitCost basis, over one or more PricingPeriods. spreadToPayLeg selects which leg the basis is added to. payIndex/receiveIndex/basis are not bound as getters -- all are plain, never-mutated echoes of this constructor's own arguments.

createPricingPeriods :: Day -> Day -> Quantity -> DeliverySchedule -> QuantityPeriodicity -> PaymentTerm -> IO PricingPeriods Source #

Split [startDate, endDate) into PricingPeriods of the given quantity, per a DeliverySchedule/QuantityPeriodicity/PaymentTerm combination -- CommodityPricingHelper::createPricingPeriods. Upstream only actually implements two combinations (Monthly with PerMonth, Daily with PerDay); every other DeliverySchedule silently returns [] (no periods, no error -- checked directly against commoditypricinghelpers.cpp, not assumed from the header).

Mutators

addPricingError :: GenCommodity c -> PricingErrorLevel -> String -> String -> IO () Source #

Record a pricing diagnostic against a Commodity/EnergyCommodity leaf (any of EnergyFuture, EnergyVanillaSwap, EnergyBasisSwap), retrievable afterwards via pricingErrors. Mirrors upstream's own default empty detail with a plain "" argument.

Inspectors

discountedAmount :: CommodityCashFlow -> IO (Double, Currency) Source #

The discounted amount, in the global commodity base currency (commoditySettingsCurrency).

Not pure: the shim's own ret(new Currency(...)) is a bad_alloc-only throw point, and letting a C++ exception unwind across the FFI boundary from an unsafePerformIO-backed pure binding is undefined behavior, so this needs the same 'char **e\/preErrorCheck' error channel as any other throwing call.

undiscountedAmount :: CommodityCashFlow -> IO (Double, Currency) Source #

As discountedAmount, without the discount factor applied.

discountedPaymentAmount :: CommodityCashFlow -> IO (Double, Currency) Source #

The discounted amount, in the payment (leg) currency.

discountFactor :: CommodityCashFlow -> Double Source #

The discount factor applied to the base-currency amount.

paymentDiscountFactor :: CommodityCashFlow -> Double Source #

The discount factor applied to the payment-currency amount.

finalized :: CommodityCashFlow -> Bool Source #

Whether this cash flow's payment date has already occurred as of the evaluation date.

secondaryCostAmounts :: GenCommodity c -> IO SecondaryCostAmounts Source #

The currency-resolved secondary costs computed during the most recent pricing (performCalculations()) of this Commodity/EnergyCommodity leaf -- a plain member read, not itself a pricing trigger, so call 'QuantLib.Instrument.npvWithZSpread first if it hasn't been priced yet.

pricingErrors :: GenCommodity c -> IO PricingErrors Source #

Every pricing diagnostic recorded so far (via upstream's own internal calls, or via addPricingError) against this Commodity/EnergyCommodity leaf.

quantity :: GenEnergyCommodity e -> IO Quantity Source #

The commodity quantity of this EnergyCommodity leaf -- either the plain quantity given at construction (EnergyFuture) or the sum across every PricingPeriod (EnergySwap and its leaves, a real computed sum -- see energyswap.cpp). One binding covers both, dispatched virtually on the C++ side.

dailyPositions :: GenEnergySwap s -> IO EnergyDailyPositions Source #

The per-day pricing breakdown computed during this EnergySwap leaf's most recent performCalculations() -- populated only after pricing (call 'QuantLib.Instrument.npvWithZSpread first).

paymentCashFlows :: GenEnergySwap s -> IO [CommodityCashFlow] Source #

The realized/unrealized payment cash flows computed during this EnergySwap leaf's most recent performCalculations() -- populated only after pricing.