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
typethat triggers a particular LUSID function.Can have a
sideto pass extra information to the function.Can have a
formulathat drives the function.
Note: The result of a calculation can be examined on an output transaction.
TaxAmounts calculation
Requires
side: YESRequires
formula: NO
Calculates tax amounts due. More information.
Note the following:
The result is stored in the output property specified by the tax rule set.
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: NORequires
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 field must contain, or resolve to, an integer. 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: NORequires
formula: NO
Looks up an exchange rate from the transaction to the portfolio currency in the LUSID Quote Store. More information.
Note the following:
The lookup is performed for the transaction date, not the settlement date (if they are different).
The result is stored in the
Transaction/default/TradeToPortfolioRatesystem property.This calculation is ignored if
Transaction/default/TradeToPortfolioRateis explicitly added to a particular transaction.
"calculations": [
{
"type": "Txn:TradeToPortfolioRate"
}
]Txn:ExchangeRate calculation
Requires
side: NORequires
formula: NO
Looks up an exchange rate from the transaction to the settlement currency in the LUSID Quote Store. More information.
Note the following:
The lookup is performed for the transaction date, not the settlement date (if they are different).
The result is stored in the
exchangeRatefield.This calculation is ignored if
exchangeRateis explicitly set on a particular transaction.
"calculations": [
{
"type": "Txn:ExchangeRate"
}
]Txn:NotionalAmount calculation
Requires
side: NORequires
formula: NO
Calculates notional amount for transactions in instruments of type Future and ContractForDifference. More information.
Note the following:
For most contracts the calculation is
txn price * txn units * (contract size / scale factor).The calculated amount is in transaction currency, not settlement currency (if they are different).
The result is stored in the
Transaction/default/NotionalAmountsystem property. See an example.This calculation is ignored if
Transaction/default/NotionalAmountis explicitly added to a particular transaction.
"calculations": [
{
"type": "Txn:NotionalAmount"
}
]Txn:BondInterest calculation
Requires
side: NORequires
formula: NO
Calculates accrued interest for transactions in instruments of type Bond, ComplexBond, InflationLinkedBond, CdsIndex and CreditDefaultSwap. More information.
Note the following:
The calculated amount is in transaction currency, not settlement currency (if they are different).
Accrual is calculated up to settlement date, not transaction date (if they are different).
The result is stored in the
Transaction/default/BondInterestsystem property. See an example.This calculation is ignored if
Transaction/default/BondInterestis explicitly added to a particular transaction.
"calculations": [
{
"type": "Txn:BondInterest"
}
]Txn:GrossConsideration calculation
Requires
side: NORequires
formula: NO
Calculates gross consideration as an amount including accrued interest but before fees. More information.
Note the following:
The calculated amount is in settlement currency, not transaction currency (if they are different).
The result is stored in the
Transaction/default/GrossConsiderationsystem property.This calculation is ignored if
Transaction/default/GrossConsiderationis explicitly added to a particular transaction.
"calculations": [
{
"type": "Txn:GrossConsideration"
}
]The calculation depends on the instrument type:
Instrument type | Calculation | Notes |
|---|---|---|
| For transactions that increase a position, LUSID sets the gross consideration to | 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 |
For transactions that reduce a position (that is, move in the opposite direction to the current holding), LUSID calculates the realised gain as follows:
| ||
| The basic calculation is:
If the transaction price type is If the type is | |
MBS (modelled as special kind of | The basic calculation is:
If the transaction price type is If the type is | |
| The calculation is:
Accrual is the value of the | See an example. If the transaction price type is |
All other instrument types | The calculation is:
|
DeriveTotalConsideration calculation
Requires
side: NORequires
formula: YES
Calculates total consideration according to a user-specified formula. Note that LUSID typically expects this to be after fees, in contrast with gross consideration which is before fees. More information.
Note: The
totalConsideration.amountfield must be set to0on an input transaction for this calculation to occur. It cannot be omitted. ThetotalConsideration.currencyfield can be set as normal.
Note the following:
The calculated amount is in settlement currency, not transaction currency (if they are different).
The result is stored in the
totalConsideration.amountfield on an output transaction. See an example.This calculation is ignored if
totalConsideration.amountis set to an amount other than0on a particular input transaction.
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 calculations in the formula (such as Txn:GrossConsideration) then you must also include them 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"
}
]