Calibration are not working

Hello,

I installed Strata in Intellij.
When I try to run any example in package com.opengamma.strata.examples.finance, I always get the same error:

Starting curve calibration: configuration and data loaded from files
Exception in thread “main” java.lang.IllegalArgumentException: Error processing resource as CSV file: UnicodeBom.toCharSource(Files.asByteSource(src\main\resources\example-calibration\quotes\quotes.csv))
** at com.opengamma.strata.loader.csv.QuotesCsvLoader.parseSingle(QuotesCsvLoader.java:235)**
** at com.opengamma.strata.loader.csv.QuotesCsvLoader.parse(QuotesCsvLoader.java:199)**
** at com.opengamma.strata.loader.csv.QuotesCsvLoader.load(QuotesCsvLoader.java:101)**
** at com.opengamma.strata.loader.csv.QuotesCsvLoader.load(QuotesCsvLoader.java:84)**
** at com.opengamma.strata.examples.finance.CalibrationCheckExample.calculate(CalibrationCheckExample.java:165)**
** at com.opengamma.strata.examples.finance.CalibrationCheckExample.calculate(CalibrationCheckExample.java:155)**
** at com.opengamma.strata.examples.finance.CalibrationCheckExample.main(CalibrationCheckExample.java:103)**
Caused by: java.io.UncheckedIOException: java.io.FileNotFoundException: src\main\resources\example-calibration\quotes\quotes.csv (The system cannot find the path specified)
** at com.opengamma.strata.collect.Unchecked.propagate(Unchecked.java:362)**
** at com.opengamma.strata.collect.Unchecked.wrap(Unchecked.java:109)**
** at com.opengamma.strata.collect.io.CsvFile.of(CsvFile.java:93)**
** at com.opengamma.strata.collect.io.CsvFile.of(CsvFile.java:72)**
** at com.opengamma.strata.loader.csv.QuotesCsvLoader.parseSingle(QuotesCsvLoader.java:215)**
** … 6 more**
Caused by: java.io.FileNotFoundException: src\main\resources\example-calibration\quotes\quotes.csv (The system cannot find the path specified)
** at java.io.FileInputStream.open0(Native Method)**
** at java.io.FileInputStream.open(FileInputStream.java:195)**
** at java.io.FileInputStream.(FileInputStream.java:138)**
** at com.google.common.io.Files$FileByteSource.openStream(Files.java:130)**
** at com.google.common.io.Files$FileByteSource.openStream(Files.java:120)**
** at com.opengamma.strata.collect.io.UnicodeBom$1.openStream(UnicodeBom.java:89)**
** at com.google.common.io.CharSource.openBufferedStream(CharSource.java:112)**
** at com.google.common.io.CharSource.readLines(CharSource.java:325)**
** at com.opengamma.strata.collect.io.CsvFile.lambda$of$0(CsvFile.java:93)**
** at com.opengamma.strata.collect.Unchecked.wrap(Unchecked.java:107)**
** … 9 more**

Process finished with exit code 1

It looks like the base directory that IntelliJ is running the code from is incorrect. It needs to be the Strata-Examples directory (not the root directory of the whole Strata project). I use Eclipse, but I think it is the “working directory” setting that you need to change: https://www.jetbrains.com/help/idea/run-debug-configuration-application.html

The working directory is already set to Strata.examples.
In the package “finance” of com.opengamma.strata.examples, I have two example that work: CurveScenario and HistoricalScenario, which are both not using CSV Loader.
That is why I think that the problem is related to processing CSV files.

The exception is FileNotFoundException when looking for a specific file: src\main\resources\example-calibration\quotes\quotes.csv. If you have a full clone of the git repo, then that file is correctly located below the examples folder (which should be the working directory). It never gets as far as trying to run the CSV parser - it simply can’t find the file.

To proceed, you are going to have to investigate why it can’t find the file (I can’t help you with that remotely). Check what your working directory is, whether the file is really there underneath the working directory. Perhaps using code like this.

1 Like

Ok thank you, theses examples are now running:
In Run/Debug Configuration, I changed the Working directory from Strata-examples to %MODULE_WORKING_DIR%.

1 Like