Adding a new asset class to Strata

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:

  1. Asset.java
  2. AssetTrade.java
  3. ResolvedAsset.java
  4. ResolvedAssetTrade.java

strata-measuer

  1. AssetMeasureCalculations.java
  2. AssetTradeCalculationFunction.java
  3. AssetTradeCalculations.java

strata-pricer

  1. DiscountingAssetProductPricer.java
  2. 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.

  1. What does the method AssetTradeCalculationFunction.supportedMeasures() return? It should return a set containing at least Measures.PRESENT_VALUE.

  2. 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