All Downloads are FREE. Search and download functionalities are using the official Maven repository.

.cdm-java.6.0.0-dev.82.source-code.product-template-func.rosetta Maven / Gradle / Ivy

namespace cdm.product.template : <"Template feature concepts to define payouts.">
version "${project.version}"

import cdm.base.math.*
import cdm.base.staticdata.identifier.*
import cdm.base.staticdata.party.*

import cdm.observable.asset.*
import cdm.observable.common.*

import cdm.event.common.*

func FilterTradeLot: <"Filter list of TradeLot based on TradeLot->lotIdentifier.">
    inputs:
        tradeLots TradeLot (0..*) <"List of TradeLots to filter.">
        lotIdentifier Identifier (0..*) <"The lot Identifiers to filter by.">
    output:
        filteredTradeLots TradeLot (0..*)

    add filteredTradeLots: tradeLots filter item -> lotIdentifier = lotIdentifier

func AddTradeLot: <"Add a TradeLot to an existing list of TradeLots.">
    inputs:
        tradableProduct TradableProduct (1..1) <"Input list of TradeLots.">
        newTradeLot TradeLot (1..1) <"The TradeLot to append to the list.">
    output:
        updatedTradableProduct TradableProduct (1..1)

    set updatedTradableProduct: tradableProduct
    add updatedTradableProduct -> tradeLot: newTradeLot

func ReplaceTradeLot: <"Replace TradeLot in with matching TradeLot->lotIdentifier.">
    inputs:
        tradeLots TradeLot (0..*) <"Input list of TradeLots.">
        newTradeLot TradeLot (1..1) <"The TradeLot to replace a matching TradeLot in the list.">
    output:
        mergedTradeLots TradeLot (0..*)

    add mergedTradeLots: <"Where the lot identifier matches, replace the existing TradeLot with the new TradeLot.">
        tradeLots
            extract
                if item -> lotIdentifier = newTradeLot -> lotIdentifier
                        or (item -> lotIdentifier is absent and newTradeLot -> lotIdentifier is absent)
                then newTradeLot
                else item

func CompareTradeLot: <"Compare the Quantity in TradeLot 1 to the Quantity (with the same unit of amount) in TradeLot 2, based on the CompareOp enum.">
    inputs:
        tradeLot1 TradeLot (1..1)
        op CompareOp (1..1)
        tradeLot2 TradeLot (1..1)
    output:
        result boolean (1..1)

    alias unitOfAmounts: tradeLot2 -> priceQuantity -> quantity -> unit distinct

    set result:
        unitOfAmounts
            extract unitOfAmount [
                CompareQuantityByUnitOfAmount(
                        tradeLot1 -> priceQuantity -> quantity
                            extract
                                NonNegativeQuantity {
                                    value: item -> value,
                                    unit: item -> unit,
                                    ...
                                },
                        op,
                        tradeLot2 -> priceQuantity -> quantity
                            extract
                                NonNegativeQuantity {
                                    value: item -> value,
                                    unit: item -> unit,
                                    ...
                                },
                        unitOfAmount
                    )
            ] all = True

func CompareTradeLotToAmount: <"Compare the Quantity amount in TradeLot to the given amount (regardless of unit of amount), based on the CompareOp enum.">
    inputs:
        tradeLot TradeLot (1..1)
        op CompareOp (1..1)
        amount number (1..1)
    output:
        result boolean (1..1)

    set result:
        tradeLot -> priceQuantity -> quantity
            filter item -> value exists
            then extract [ CompareNumbers(item -> value, op, amount) ]
                all = True

func PriceQuantityTriangulation: <"Defines all the scenarios which triangulation can be helpful validation between Prices and Quantities.">
    inputs:
        tradeLots TradeLot (0..*)
    output:
        success boolean (1..1)

    set success:
        if tradeLots count > 0
        then tradeLots
                extract [
                    if item -> priceQuantity -> price -> priceType contains PriceTypeEnum -> CashPrice
                    then CashPriceQuantityNoOfUnitsTriangulation(
                                item -> priceQuantity -> quantity,
                                item -> priceQuantity -> price
                            )
                    else True
                ] all = True
        else True

func FpmlIrd8: <"FpML validation rule ird-8 - If the same party is specified as the payer and receiver, then different accounts must be specified.">
    inputs:
        trade Trade (1..1)
        accounts Account (0..*)
    output:
        success boolean (1..1) <"Validation result">




© 2015 - 2025 Weber Informatics LLC | Privacy Policy