What is a transaction type calculation?

Prev Next

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 calculation

  • 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 calculation is ignored for a particular transaction if no tax rule set can be found to apply.

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

TransactionSequence calculation

  • Requires side: NO

  • Requires formula: YES

Determines the order in which transactions are processed relative to transactions belonging to other transaction types if all are loaded into LUSID with identical effective at datetimes. More information.

The formula must contain, or resolve to, an integer, even though it is a string field. The lower the number, the higher the priority in the processing queue. A formula can contain the following components:

  • A constant value, for example "1" or "98765".

  • A transaction field, for example "units", or property or derived property, for example "Properties[Transaction/default/GrossConsideration]".

  • An instrument field, for example "Instrument.InstrumentDefinition.InstrumentType".

For example, you could specify a TransactionSequence formula of "2" for a Buy transaction type:

"calculations": [
  {
    "type": "TransactionSequence",
    "formula": "2"
  },
]

…and a TransactionSequence formula of "1" for a Sell transaction type:

"calculations": [
  {
    "type": "TransactionSequence",
    "formula": "1"
  },
]

This means that if a Buy transaction and a Sell transaction are loaded into LUSID with identical effective at datetimes then the Sell transaction is processed first, even if it is loaded second in the same request (and therefore has a slightly later as at entry datetime).

Note you can use LUSID derived property formula syntax to create conditional statements, so for example:

"calculations": [
  {
    "type": "TransactionSequence",
    "formula": "If(Instrument.InstrumentDefinition.InstrumentType eq 'Equity') Then 2 Else 3"
  },
]

Txn:TradeToPortfolioRate calculation

  • 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 calculation is ignored if Transaction/default/TradeToPortfolioRate is explicitly added to a particular transaction.

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

Txn:ExchangeRate calculation

  • 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 calculation is ignored if exchangeRate is explicitly set on a particular transaction.

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

Txn:NotionalAmount calculation

  • Requires side: NO

  • Requires formula: NO

Calculates notional amount for transactions in instruments of type Future.

For most contracts this is txn price * txn units * (contract size / scale factor). The result is stored in the Transaction/default/NotionalAmount system property. See an example.

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

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

Txn:BondInterest calculation

  • 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 calculation is ignored if Transaction/default/BondInterest is explicitly added to a particular transaction.

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

Txn:GrossConsideration calculation

  • Requires side: NO

  • Requires formula: NO

Calculates gross consideration as total consideration before fees in settlement currency:

Instrument type

Calculation

Notes

Future

For transactions that reduce a position (that is, move in the opposite direction to the current holding), LUSID calculates the realised gain as follows:

notionalAmount - (notionalCost + variationMargin)

The sign of the calculated amount determines whether it is a profit (+ve) or a loss (-ve), regardless of the direction of the transaction. So for example, both Sell and CoverShort-style transactions have a positive gross consideration if there is a receipt of profit, and a negative gross consideration if there is a payment of loss. See an example.

For transactions that increase a position, LUSID sets the gross consideration to 0.

Bond, ComplexBond, InflationLinkedBond (but not MBS)

The basic calculation is:

txn units * txn price * exchange rate * (contract size / scale factor)

If the transaction price type is CleanPrice or Price, bond interest is then added (this is the value of the Transaction/default/BondInterest system property, or 0 if it is not set).

If the type is DirtyPrice, bond interest is not added.

See an example.

MBS (modelled as special kind of ComplexBond)

The basic calculation is:

txn price * txn units * exchange rate * current face

If the transaction price type is CleanPrice or Price, bond interest is then added (the value of the Transaction/default/BondInterest system property, or 0 if it is not set).

If the type is DirtyPrice, bond interest is not added.

See an example.

All other instrument types

The calculation is:

txn price * txn units * exchange rate * (contract size / scale factor).

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

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

DeriveTotalConsideration calculation

  • Requires side: NO

  • Requires formula: YES

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

Note: The totalConsideration.amount field must be set to 0 on an input transaction 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. Note that if you include any other calculation in the formula (such as Txn:GrossConsideration) then you must also include that in the transaction type:

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

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]"
  },
  {
    "type": "Txn:GrossConsideration"
  }
]