What is a transaction type calculation?

A calculation is an optional component of a transaction type that triggers additional functionality for all transactions belonging to that type. 

A calculation:

  • Must have a type that triggers a particular LUSID function.

  • Can have a side to pass extra information to the function.

  • Can have a formula that drives the function.

Note: The result of a calculation can be examined on an output transaction.

TaxAmounts

  • Name of type: TaxAmounts

  • Requires side: YES

  • Requires formula: NO

Calculates tax amounts due. The result is stored in the output property specified by the tax rule set. More information.

Note this is ignored for a particular transaction if no tax rule set can be found to apply.

"calculations": [
  {
    "type": "TaxAmounts",
    "side": "Side1"
  }
]

Txn:TradeToPortfolioRate

  • Name of type: Txn:TradeToPortfolioRate

  • Requires side: NO

  • Requires formula: NO

Looks up an exchange rate from the transaction to the portfolio currency for the transaction date in the LUSID Quote Store. The result is stored in the Transaction/default/TradeToPortfolioRate system property. More information.

Note this is ignored if Transaction/default/TradeToPortfolioRate is explicitly added to a particular transaction.

"calculations": [
  {
    "type": "Txn:TradeToPortfolioRate"
  }
]

Txn:ExchangeRate

  • Name of type: Txn:ExchangeRate

  • Requires side: NO

  • Requires formula: NO

Looks up an exchange rate from the transaction to the settlement currency for the transaction date in the LUSID Quote Store. The result is stored in the exchangeRate field. More information.

Note this is ignored if exchangeRate is explicitly set on a particular transaction.

"calculations": [
  {
    "type": "Txn:ExchangeRate"
  }
]

Txn:NotionalAmount

  • Name of type: Txn:NotionalAmount

  • Requires side: NO

  • Requires formula: NO

Calculates notional amount for transactions in instruments of type Future. For most contracts this is transactionPrice.price * units * instrumentDefinition.contractSize. The result is stored in the Transaction/default/NotionalAmount system property. See an example.

Note this is ignored if Transaction/default/NotionalAmount is explicitly added to a particular transaction.

"calculations": [
  {
    "type": "Txn:NotionalAmount"
  }
]

Txn:BondInterest

  • Name of type: Txn:BondInterest

  • Requires side: NO

  • Requires formula: NO

Calculates accrued interest for transactions in instruments of type Bond, ComplexBond or InflationLinkedBond. The result is stored in the Transaction/default/BondInterest system property. See an example.

Note this is ignored if Transaction/default/BondInterest is explicitly added to a particular transaction.

"calculations": [
  {
    "type": "Txn:BondInterest"
  }
]

Txn:GrossConsideration

  • Name of type: Txn:GrossConsideration

  • Requires side: NO

  • Requires formula: NO

Calculates gross consideration as total consideration before fees. For transactions in:

  • Instruments of type Future:

    • For transactions that reduce a position, this is notionalAmount - (notionalCost + variationMargin).

    • For transactions that increase a position, the gross consideration is set to 0. See an example.

  • Instruments of type Bond, ComplexBond or InflationLinkedBond:

    • The calculation is cleanPV + bondInterest. Note to enable the PV calculation a portfolio must have a recipe registered with the default pricing model set to BondLookupPricer, though no extra market data is required. See an example.

  • All other types of instrument, this is transactionPrice.price * units * exchangeRate.

The result is stored in the Transaction/default/GrossConsideration system property. Note this is ignored if Transaction/default/GrossConsideration is explicitly added to a particular transaction.

"calculations": [
  {
    "type": "Txn:GrossConsideration"
  }
]

DeriveTotalConsideration

  • Name of type: DeriveTotalConsideration

  • Requires side: NO

  • Requires formula: YES

Calculates total consideration according to a user-specified formula. The result is stored in the totalConsideration.amount field. See an example.

Note: The totalConsideration.amount field on a transaction must be set to 0 for this calculation to occur. It cannot be omitted. The totalConsideration.currency field can be set as normal.

For example, for transactions that increase a position you might want to calculate total consideration as gross consideration plus fees.

"calculations": [
  {
    "type": "DeriveTotalConsideration",
    "formula": "Txn:GrossConsideration + Properties[Transaction/Fees/TotalCapitalisedFees]"
  }
]

For transactions that reduce a position you might want to calculate total consideration as gross consideration minus fees.

"calculations": [
  {
    "type": "DeriveTotalConsideration",
    "formula": "Txn:GrossConsideration - Properties[Transaction/Fees/TotalCapitalisedFees]"
  }
]