No market data function available

Hey @stephen, I m creating a bunch of trades (50000) of different types and I calibrate the market data with multiple scenarios (1000).It m using the data sets provided in the tests on opengamma like for example bondDataSets etc. This is the script of my usecase:

    public static List<Trade> useCase(int quantity) {
        List<Supplier> possible_trades = new ArrayList<>();
        possible_trades.add(TradeFactory::createFxSingle);
        possible_trades.add(TradeFactory::createFxSwapTrade);
        possible_trades.add(TradeFactory::createFxNDFTrade);
        possible_trades.add(TradeFactory::createFxVanillaOptionTrade);
        possible_trades.add(TradeFactory::createSwapTrade);
        possible_trades.add(TradeFactory::createGenericSecurityTrade);
        possible_trades.add(TradeFactory::createCdsTrade);
    //  possible_trades.add(TradeFactory::createBondFutureOptionTrade);
    //  possible_trades.add(TradeFactory::createSwaptionTrade);
    //  possible_trades.add(TradeFactory::createCapFloorTrade);
    //  possible_trades.add(TradeFactory::createBondFutureTrade);

        List<Trade> result = new ArrayList<>();
        for (int i = 0; i < quantity; i++) {
            int random = rng.nextInt(possible_trades.size());
            result.add((Trade) possible_trades.get(random).get());
        }
        return result;
    }
  • If I decomment the line with BondfutureOption , I get this error :

java.lang.IllegalStateException: No market data function available for market data ID of type com.opengamma.strata.pricer.bond.BondFutureVolatilitiesId

at com.opengamma.strata.calc.marketdata.DefaultMarketDataFactory.buildNonObservableData(DefaultMarketDataFactory.java:232)
at com.opengamma.strata.calc.marketdata.DefaultMarketDataFactory.lambda$buildNonObservableData$12(DefaultMarketDataFactory.java:245)
at com.opengamma.strata.collect.Guavate.lambda$toImmutableMap$14(Guavate.java:895)
at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
at com.opengamma.strata.calc.marketdata.DefaultMarketDataFactory.buildNonObservableData(DefaultMarketDataFactory.java:245)
at com.opengamma.strata.calc.marketdata.DefaultMarketDataFactory.createMultiScenario(DefaultMarketDataFactory.java:183)
at com.opengamma.strata.calc.marketdata.DefaultMarketDataFactory.createMultiScenario(DefaultMarketDataFactory.java:94)
at org.jhipster.web.rest.MarketDataOutputAccess.computeLocally(MarketDataOutputAccess.java:46)
at org.jhipster.web.rest.MarketDataOutputAccess.lambda$computeLocallyOrGetFromCache$0(MarketDataOutputAccess.java:52)
at org.jhipster.web.rest.Timed.of(Timed.java:17)
at org.jhipster.web.rest.TimerService.time(TimerService.java:18)
at org.jhipster.web.rest.MarketDataOutputAccess.computeLocallyOrGetFromCache(MarketDataOutputAccess.java:52)
at org.jhipster.web.rest.LCHService.lambda$calculateSync$1(LCHService.java:42)
at org.jhipster.web.rest.Timed.of(Timed.java:17)
at org.jhipster.web.rest.TimerService.time(TimerService.java:18)
at org.jhipster.web.rest.LCHService.calculateSync(LCHService.java:42)
at UseCaseTest.lambda$finalTest$0(UseCaseTest.java:37)
at org.jhipster.web.rest.Timed.of(Timed.java:17)
at org.jhipster.web.rest.TimerService.time(TimerService.java:18)
at UseCaseTest.finalTest(UseCaseTest.java:37)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
  • If I decomment the line with Swaption, I get this error :

java.lang.IllegalStateException: No market data function available for market data ID of type com.opengamma.strata.pricer.swaption.SwaptionVolatilitiesId

at com.opengamma.strata.calc.marketdata.DefaultMarketDataFactory.buildNonObservableData(DefaultMarketDataFactory.java:232)
at com.opengamma.strata.calc.marketdata.DefaultMarketDataFactory.lambda$buildNonObservableData$12(DefaultMarketDataFactory.java:245)
at com.opengamma.strata.collect.Guavate.lambda$toImmutableMap$14(Guavate.java:895)
at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
at com.opengamma.strata.calc.marketdata.DefaultMarketDataFactory.buildNonObservableData(DefaultMarketDataFactory.java:245)
at com.opengamma.strata.calc.marketdata.DefaultMarketDataFactory.createMultiScenario(DefaultMarketDataFactory.java:183)
at com.opengamma.strata.calc.marketdata.DefaultMarketDataFactory.createMultiScenario(DefaultMarketDataFactory.java:94)
at org.jhipster.web.rest.MarketDataOutputAccess.computeLocally(MarketDataOutputAccess.java:46)
at org.jhipster.web.rest.MarketDataOutputAccess.lambda$computeLocallyOrGetFromCache$0(MarketDataOutputAccess.java:52)
at org.jhipster.web.rest.Timed.of(Timed.java:17)
at org.jhipster.web.rest.TimerService.time(TimerService.java:18)
at org.jhipster.web.rest.MarketDataOutputAccess.computeLocallyOrGetFromCache(MarketDataOutputAccess.java:52)
at org.jhipster.web.rest.LCHService.lambda$calculateSync$1(LCHService.java:42)
at org.jhipster.web.rest.Timed.of(Timed.java:17)
at org.jhipster.web.rest.TimerService.time(TimerService.java:18)
at org.jhipster.web.rest.LCHService.calculateSync(LCHService.java:42)
at UseCaseTest.lambda$finalTest$0(UseCaseTest.java:37)
at org.jhipster.web.rest.Timed.of(Timed.java:17)
at org.jhipster.web.rest.TimerService.time(TimerService.java:18)
at UseCaseTest.finalTest(UseCaseTest.java:37)
  • If I decomment the line with CapFloor , I get this error :

java.lang.IllegalStateException: No market data function available for market data ID of type com.opengamma.strata.pricer.capfloor.IborCapletFloorletVolatilitiesId

at com.opengamma.strata.calc.marketdata.DefaultMarketDataFactory.buildNonObservableData(DefaultMarketDataFactory.java:232)
at com.opengamma.strata.calc.marketdata.DefaultMarketDataFactory.lambda$buildNonObservableData$12(DefaultMarketDataFactory.java:245)
at com.opengamma.strata.collect.Guavate.lambda$toImmutableMap$14(Guavate.java:895)
at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
at com.opengamma.strata.calc.marketdata.DefaultMarketDataFactory.buildNonObservableData(DefaultMarketDataFactory.java:245)
at com.opengamma.strata.calc.marketdata.DefaultMarketDataFactory.createMultiScenario(DefaultMarketDataFactory.java:183)
at com.opengamma.strata.calc.marketdata.DefaultMarketDataFactory.createMultiScenario(DefaultMarketDataFactory.java:94)
at org.jhipster.web.rest.MarketDataOutputAccess.computeLocally(MarketDataOutputAccess.java:46)
at org.jhipster.web.rest.MarketDataOutputAccess.lambda$computeLocallyOrGetFromCache$0(MarketDataOutputAccess.java:52)
at org.jhipster.web.rest.Timed.of(Timed.java:17)
at org.jhipster.web.rest.TimerService.time(TimerService.java:18)
at org.jhipster.web.rest.MarketDataOutputAccess.computeLocallyOrGetFromCache(MarketDataOutputAccess.java:52)
at org.jhipster.web.rest.LCHService.lambda$calculateSync$1(LCHService.java:42)
at org.jhipster.web.rest.Timed.of(Timed.java:17)
at org.jhipster.web.rest.TimerService.time(TimerService.java:18)
at org.jhipster.web.rest.LCHService.calculateSync(LCHService.java:42)
at UseCaseTest.lambda$finalTest$0(UseCaseTest.java:37)
at org.jhipster.web.rest.Timed.of(Timed.java:17)
at org.jhipster.web.rest.TimerService.time(TimerService.java:18)
at UseCaseTest.finalTest(UseCaseTest.java:37)
  • If I decomment the line with Bondfuture, I get this error :

java.lang.IllegalArgumentException: Legal entity discounting lookup has no repo curve defined for ‘OG-Ticker~GOVT1-BOND1’ and ‘OG-Ticker~GOVT1’

at com.opengamma.strata.measure.bond.DefaultLegalEntityDiscountingMarketDataLookup.requirements(DefaultLegalEntityDiscountingMarketDataLookup.java:180)
at com.opengamma.strata.measure.bond.BondFutureTradeCalculationFunction.requirements(BondFutureTradeCalculationFunction.java:150)
at com.opengamma.strata.measure.bond.BondFutureTradeCalculationFunction.requirements(BondFutureTradeCalculationFunction.java:63)
at com.opengamma.strata.calc.runner.CalculationTask.requirements(CalculationTask.java:153)
at com.opengamma.strata.calc.runner.CalculationTasks.requirements(CalculationTasks.java:248)
at com.opengamma.strata.calc.marketdata.MarketDataRequirements.of(MarketDataRequirements.java:87)
at org.jhipster.web.rest.LCHService.lambda$calculateSync$0(LCHService.java:39)
at org.jhipster.web.rest.Timed.of(Timed.java:17)
at org.jhipster.web.rest.TimerService.time(TimerService.java:18)
at org.jhipster.web.rest.LCHService.calculateSync(LCHService.java:39)
at UseCaseTest.lambda$finalTest$0(UseCaseTest.java:37)
at org.jhipster.web.rest.Timed.of(Timed.java:17)
at org.jhipster.web.rest.TimerService.time(TimerService.java:18)
at UseCaseTest.finalTest(UseCaseTest.java:37)

Can you explain how to solve this ?

Note that I’m not sure what TradeFactory does.

In general though, the error indicates you have not populated the instance of MarketData with the correct market data. For swaptions you need an instance of SwaptionVolatilities for example, keyed by the SwaptionVolatilitiesId indicated. All the other errors are fundamentally the same.