I have attempted to add a new asset class to Strata. It is an OTC asset therefore i have used FRA as an example to go off.
I have added the following classes:
strater-product:
- Asset.java
- AssetTrade.java
- ResolvedAsset.java
- ResolvedAssetTrade.java
strata-measuer
- AssetMeasureCalculations.java
- AssetTradeCalculationFunction.java
- AssetTradeCalculations.java
strata-pricer
- DiscountingAssetProductPricer.java
- DiscountingAssetTradePricer.java
but when I attempt to price the asset using the calc api, i get this error:
cells=[Result{value=null, failure=Failure{reason=CALCULATION_FAILED, message=Error when invoking function âMissingConfigCalculationFunctionâ: No function configured for measures on âAssetTradeâ: for target âŚ
and
java.lang.IllegalStateException: No function configured for measures on âAssetTradeâ]}}]}
Please could you direct me to where the problem is.
I am able to build the asset with no problem and Strata seems to understand the product/asset definition as it prints the information held by the asset to the screen correctly. But I am unable to correctly price the asset. I have only added one measure which is âMeasures.PRESENT_VALUEâ.
Thank you
Hi
There are a couple of things to check.
-
What does the method AssetTradeCalculationFunction.supportedMeasures()
return? It should return a set containing at least Measures.PRESENT_VALUE
.
-
Have you included an instance of AssetTradeCalculationFunction
in the calculation rules you are passing to the calculation runner? If you are only pricing your new asset then you should create the calculation rules like this:
CalculationFunctions calculationFunctions = CalculationFunctions.of(new AssetTradeCalculationFunction());
CalculationRules calculationRules = CalculationRules.of(calculationFunctions);
If you want to price your new asset plus some standard asset classes then you need to add your calculation function to the standard set:
CalculationFunctions assetCalculationFunctions = CalculationFunctions.of(new AssetTradeCalculationFunction());
CalculationFunctions calculationFunctions = StandardComponents.calculationFunctions().composedWith(assetCalculationFunctions);
CalculationRules calculationRules = CalculationRules.of(calculationFunctions);
Thank you,
The AssetTradeCalculationFunction.supportedMeasures()
returns a list: [PresentValue, ResolvedTarget]
. Therefore, I know that measures has been added to the asset classes supported measures.
I added the calculationFunctions and calculationRules logic and it seems the code is now progressing a little further but is now throwing a different error:
failure=Failure{reason=CALCULATION_FAILED, message=Error when invoking function âAssetTradeCalculationFunctionâ for ID âexample~1â: Argument âproductâ must not be null
Which I am unable to understand why it is throwing this error, as when I call asset.getProduct()
, I get the correct output that I expect to get.
From what I can see, AssetTradeCalculationFunction
must be throwing an exception which is caught by the calculation runner and wrapped in a failure Result
. The stack trace is available in the result. Call result.getFailure()
to get the Failure
. The failure will contain one or more FailureItem
instances, available by calling failure.getItems()
. Call item.getStackTrace()
to get the stack trace.
1 Like