module Data.FpML.V53.Swaps.Correlation
( module Data.FpML.V53.Swaps.Correlation
, module Data.FpML.V53.Shared.EQ
) where
import Text.XML.HaXml.Schema.Schema (SchemaType(..),SimpleType(..),Extension(..),Restricts(..))
import Text.XML.HaXml.Schema.Schema as Schema
import Text.XML.HaXml.OneOfN
import qualified Text.XML.HaXml.Schema.PrimitiveTypes as Xsd
import Data.FpML.V53.Shared.EQ
data CorrelationAmount = CorrelationAmount
{ correlAmount_calculationDates :: Maybe AdjustableRelativeOrPeriodicDates
, correlAmount_observationStartDate :: Maybe AdjustableOrRelativeDate
, correlAmount_optionsExchangeDividends :: Maybe Xsd.Boolean
, correlAmount_additionalDividends :: Maybe Xsd.Boolean
, correlAmount_allDividends :: Maybe Xsd.Boolean
, correlAmount_correlation :: Maybe Correlation
}
deriving (Eq,Show)
instance SchemaType CorrelationAmount where
parseSchemaType s = do
(pos,e) <- posnElement [s]
commit $ interior e $ return CorrelationAmount
`apply` optional (parseSchemaType "calculationDates")
`apply` optional (parseSchemaType "observationStartDate")
`apply` optional (parseSchemaType "optionsExchangeDividends")
`apply` optional (parseSchemaType "additionalDividends")
`apply` optional (parseSchemaType "allDividends")
`apply` optional (parseSchemaType "correlation")
schemaTypeToXML s x@CorrelationAmount{} =
toXMLElement s []
[ maybe [] (schemaTypeToXML "calculationDates") $ correlAmount_calculationDates x
, maybe [] (schemaTypeToXML "observationStartDate") $ correlAmount_observationStartDate x
, maybe [] (schemaTypeToXML "optionsExchangeDividends") $ correlAmount_optionsExchangeDividends x
, maybe [] (schemaTypeToXML "additionalDividends") $ correlAmount_additionalDividends x
, maybe [] (schemaTypeToXML "allDividends") $ correlAmount_allDividends x
, maybe [] (schemaTypeToXML "correlation") $ correlAmount_correlation x
]
instance Extension CorrelationAmount CalculatedAmount where
supertype v = CalculatedAmount_CorrelationAmount v
data CorrelationLeg = CorrelationLeg
{ correlLeg_ID :: Maybe Xsd.ID
, correlLeg_legIdentifier :: [LegIdentifier]
, correlLeg_payerPartyReference :: Maybe PartyReference
, correlLeg_payerAccountReference :: Maybe AccountReference
, correlLeg_receiverPartyReference :: Maybe PartyReference
, correlLeg_receiverAccountReference :: Maybe AccountReference
, correlLeg_effectiveDate :: Maybe AdjustableOrRelativeDate
, correlLeg_terminationDate :: Maybe AdjustableOrRelativeDate
, correlLeg_underlyer :: Maybe Underlyer
, correlLeg_settlementType :: Maybe SettlementTypeEnum
, correlLeg_settlementDate :: Maybe AdjustableOrRelativeDate
, correlLeg_choice10 :: (Maybe (OneOf2 Money Currency))
, correlLeg_fxFeature :: Maybe FxFeature
, correlLeg_valuation :: Maybe EquityValuation
, correlLeg_amount :: Maybe CorrelationAmount
}
deriving (Eq,Show)
instance SchemaType CorrelationLeg where
parseSchemaType s = do
(pos,e) <- posnElement [s]
a0 <- optional $ getAttribute "id" e pos
commit $ interior e $ return (CorrelationLeg a0)
`apply` many (parseSchemaType "legIdentifier")
`apply` optional (parseSchemaType "payerPartyReference")
`apply` optional (parseSchemaType "payerAccountReference")
`apply` optional (parseSchemaType "receiverPartyReference")
`apply` optional (parseSchemaType "receiverAccountReference")
`apply` optional (parseSchemaType "effectiveDate")
`apply` optional (parseSchemaType "terminationDate")
`apply` optional (parseSchemaType "underlyer")
`apply` optional (parseSchemaType "settlementType")
`apply` optional (parseSchemaType "settlementDate")
`apply` optional (oneOf' [ ("Money", fmap OneOf2 (parseSchemaType "settlementAmount"))
, ("Currency", fmap TwoOf2 (parseSchemaType "settlementCurrency"))
])
`apply` optional (parseSchemaType "fxFeature")
`apply` optional (parseSchemaType "valuation")
`apply` optional (parseSchemaType "amount")
schemaTypeToXML s x@CorrelationLeg{} =
toXMLElement s [ maybe [] (toXMLAttribute "id") $ correlLeg_ID x
]
[ concatMap (schemaTypeToXML "legIdentifier") $ correlLeg_legIdentifier x
, maybe [] (schemaTypeToXML "payerPartyReference") $ correlLeg_payerPartyReference x
, maybe [] (schemaTypeToXML "payerAccountReference") $ correlLeg_payerAccountReference x
, maybe [] (schemaTypeToXML "receiverPartyReference") $ correlLeg_receiverPartyReference x
, maybe [] (schemaTypeToXML "receiverAccountReference") $ correlLeg_receiverAccountReference x
, maybe [] (schemaTypeToXML "effectiveDate") $ correlLeg_effectiveDate x
, maybe [] (schemaTypeToXML "terminationDate") $ correlLeg_terminationDate x
, maybe [] (schemaTypeToXML "underlyer") $ correlLeg_underlyer x
, maybe [] (schemaTypeToXML "settlementType") $ correlLeg_settlementType x
, maybe [] (schemaTypeToXML "settlementDate") $ correlLeg_settlementDate x
, maybe [] (foldOneOf2 (schemaTypeToXML "settlementAmount")
(schemaTypeToXML "settlementCurrency")
) $ correlLeg_choice10 x
, maybe [] (schemaTypeToXML "fxFeature") $ correlLeg_fxFeature x
, maybe [] (schemaTypeToXML "valuation") $ correlLeg_valuation x
, maybe [] (schemaTypeToXML "amount") $ correlLeg_amount x
]
instance Extension CorrelationLeg DirectionalLegUnderlyerValuation where
supertype v = DirectionalLegUnderlyerValuation_CorrelationLeg v
instance Extension CorrelationLeg DirectionalLegUnderlyer where
supertype = (supertype :: DirectionalLegUnderlyerValuation -> DirectionalLegUnderlyer)
. (supertype :: CorrelationLeg -> DirectionalLegUnderlyerValuation)
instance Extension CorrelationLeg DirectionalLeg where
supertype = (supertype :: DirectionalLegUnderlyer -> DirectionalLeg)
. (supertype :: DirectionalLegUnderlyerValuation -> DirectionalLegUnderlyer)
. (supertype :: CorrelationLeg -> DirectionalLegUnderlyerValuation)
instance Extension CorrelationLeg Leg where
supertype = (supertype :: DirectionalLeg -> Leg)
. (supertype :: DirectionalLegUnderlyer -> DirectionalLeg)
. (supertype :: DirectionalLegUnderlyerValuation -> DirectionalLegUnderlyer)
. (supertype :: CorrelationLeg -> DirectionalLegUnderlyerValuation)
data CorrelationSwap = CorrelationSwap
{ correlSwap_ID :: Maybe Xsd.ID
, correlSwap_primaryAssetClass :: Maybe AssetClass
, correlSwap_secondaryAssetClass :: [AssetClass]
, correlSwap_productType :: [ProductType]
, correlSwap_productId :: [ProductId]
, correlSwap_additionalPayment :: [ClassifiedPayment]
, correlSwap_extraordinaryEvents :: Maybe ExtraordinaryEvents
, correlSwap_correlationLeg :: Maybe CorrelationLeg
}
deriving (Eq,Show)
instance SchemaType CorrelationSwap where
parseSchemaType s = do
(pos,e) <- posnElement [s]
a0 <- optional $ getAttribute "id" e pos
commit $ interior e $ return (CorrelationSwap a0)
`apply` optional (parseSchemaType "primaryAssetClass")
`apply` many (parseSchemaType "secondaryAssetClass")
`apply` many (parseSchemaType "productType")
`apply` many (parseSchemaType "productId")
`apply` many (parseSchemaType "additionalPayment")
`apply` optional (parseSchemaType "extraordinaryEvents")
`apply` optional (parseSchemaType "correlationLeg")
schemaTypeToXML s x@CorrelationSwap{} =
toXMLElement s [ maybe [] (toXMLAttribute "id") $ correlSwap_ID x
]
[ maybe [] (schemaTypeToXML "primaryAssetClass") $ correlSwap_primaryAssetClass x
, concatMap (schemaTypeToXML "secondaryAssetClass") $ correlSwap_secondaryAssetClass x
, concatMap (schemaTypeToXML "productType") $ correlSwap_productType x
, concatMap (schemaTypeToXML "productId") $ correlSwap_productId x
, concatMap (schemaTypeToXML "additionalPayment") $ correlSwap_additionalPayment x
, maybe [] (schemaTypeToXML "extraordinaryEvents") $ correlSwap_extraordinaryEvents x
, maybe [] (schemaTypeToXML "correlationLeg") $ correlSwap_correlationLeg x
]
instance Extension CorrelationSwap NettedSwapBase where
supertype v = NettedSwapBase_CorrelationSwap v
instance Extension CorrelationSwap Product where
supertype = (supertype :: NettedSwapBase -> Product)
. (supertype :: CorrelationSwap -> NettedSwapBase)
elementCorrelationSwap :: XMLParser CorrelationSwap
elementCorrelationSwap = parseSchemaType "correlationSwap"
elementToXMLCorrelationSwap :: CorrelationSwap -> [Content ()]
elementToXMLCorrelationSwap = schemaTypeToXML "correlationSwap"