| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
QuantLib.Instrument.Energy
Synopsis
- type GenCommodity c = GenInstrument (AnyOf CCommodity' c)
- type Commodity = GenCommodity CCommodity
- type GenEnergyCommodity e = GenCommodity (AnyOf CEnergyCommodity' e)
- type EnergyCommodity = GenEnergyCommodity CEnergyCommodity
- type GenEnergySwap s = GenEnergyCommodity (AnyOf CEnergySwap' s)
- type EnergySwap = GenEnergySwap CEnergySwap
- type EnergyFuture = GenEnergyCommodity CEnergyFuture
- type EnergyVanillaSwap = GenEnergySwap CEnergyVanillaSwap
- type EnergyBasisSwap = GenEnergySwap CEnergyBasisSwap
- type SecondaryCosts = [(String, Either CommodityUnitCost (Double, Currency))]
- type SecondaryCostAmounts = [(String, (Double, Currency))]
- data PricingErrorLevel
- data PricingError = PricingError {}
- type PricingErrors = [PricingError]
- data EnergyDailyPosition = EnergyDailyPosition {}
- type EnergyDailyPositions = [EnergyDailyPosition]
- type CommodityCashFlow = GenCashFlow CCommodityCashFlow
- type CommodityCashFlows = [CommodityCashFlow]
- data DeliverySchedule
- data QuantityPeriodicity
- energyFuture :: Int -> Quantity -> CommodityUnitCost -> CommodityIndex -> CommodityType -> SecondaryCosts -> IO EnergyFuture
- energyVanillaSwap :: Bool -> Calendar -> (Double, Currency) -> UnitOfMeasure -> CommodityIndex -> Currency -> Currency -> PricingPeriods -> CommodityType -> SecondaryCosts -> GenYieldTermStructure y1 -> GenYieldTermStructure y2 -> GenYieldTermStructure y3 -> IO EnergyVanillaSwap
- energyBasisSwap :: Calendar -> CommodityIndex -> CommodityIndex -> CommodityIndex -> Bool -> Currency -> Currency -> PricingPeriods -> CommodityUnitCost -> CommodityType -> SecondaryCosts -> GenYieldTermStructure y1 -> GenYieldTermStructure y2 -> GenYieldTermStructure y3 -> IO EnergyBasisSwap
- createPricingPeriods :: Day -> Day -> Quantity -> DeliverySchedule -> QuantityPeriodicity -> PaymentTerm -> IO PricingPeriods
- addPricingError :: GenCommodity c -> PricingErrorLevel -> String -> String -> IO ()
- discountedAmount :: CommodityCashFlow -> IO (Double, Currency)
- undiscountedAmount :: CommodityCashFlow -> IO (Double, Currency)
- discountedPaymentAmount :: CommodityCashFlow -> IO (Double, Currency)
- undiscountedPaymentAmount :: CommodityCashFlow -> IO (Double, Currency)
- discountFactor :: CommodityCashFlow -> Double
- paymentDiscountFactor :: CommodityCashFlow -> Double
- finalized :: CommodityCashFlow -> Bool
- secondaryCostAmounts :: GenCommodity c -> IO SecondaryCostAmounts
- pricingErrors :: GenCommodity c -> IO PricingErrors
- quantity :: GenEnergyCommodity e -> IO Quantity
- dailyPositions :: GenEnergySwap s -> IO EnergyDailyPositions
- paymentCashFlows :: GenEnergySwap s -> IO [CommodityCashFlow]
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 #
Instances
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.
Constructors
| PricingError | |
Instances
| Show PricingError Source # | |
Defined in QuantLib.Instrument.Energy Methods showsPrec :: Int -> PricingError -> ShowS # show :: PricingError -> String # showList :: [PricingError] -> ShowS # | |
| Eq PricingError Source # | |
Defined in QuantLib.Instrument.Energy | |
type PricingErrors = [PricingError] Source #
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.
Constructors
| EnergyDailyPosition | |
Fields
| |
Instances
| Show EnergyDailyPosition Source # | |
Defined in QuantLib.Instrument.Energy Methods showsPrec :: Int -> EnergyDailyPosition -> ShowS # show :: EnergyDailyPosition -> String # showList :: [EnergyDailyPosition] -> ShowS # | |
| Eq EnergyDailyPosition Source # | |
Defined in QuantLib.Instrument.Energy Methods (==) :: EnergyDailyPosition -> EnergyDailyPosition -> Bool # (/=) :: EnergyDailyPosition -> EnergyDailyPosition -> Bool # | |
type EnergyDailyPositions = [EnergyDailyPosition] Source #
type CommodityCashFlow = GenCashFlow CCommodityCashFlow Source #
A CashFlow; see the hierarchy under GenCashFlow.
type CommodityCashFlows = [CommodityCashFlow] Source #
Configuration
data DeliverySchedule Source #
Constructors
| DeliveryConstant | |
| DeliveryWindow | |
| DeliveryHourly | |
| DeliveryDaily | |
| DeliveryWeekly | |
| DeliveryMonthly | |
| DeliveryQuarterly | |
| DeliveryYearly |
Instances
data QuantityPeriodicity Source #
Instances
Constructors
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.
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.
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.
undiscountedPaymentAmount :: CommodityCashFlow -> IO (Double, Currency) Source #
As discountedPaymentAmount, without the discount factor applied.
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.