Class RatesCurvesCsvLoader
- java.lang.Object
-
- com.opengamma.strata.loader.csv.RatesCurvesCsvLoader
-
public final class RatesCurvesCsvLoader extends Object
Loads a set of rates curves into memory by reading from CSV resources.There are three type of CSV files.
The first file is the curve group metadata file. This file has the following header row:
Group Name, Curve Type, Reference, Curve Name
.- The 'Group Name' column is the name of the group of curves.
- The 'Curve Type' column is the type of the curve, "forward" or "discount".
- The 'Reference' column is the reference the curve is used for, such as "USD" or "USD-LIBOR-3M".
- The 'Curve Name' column is the name of the curve.
The second file is the curve settings metadata file. This file has the following header row:
Curve Name, Value Type, Day Count, Interpolator, Left Extrapolator, Right Extrapolator
.- The 'Curve Name' column is the name of the curve.
- The 'Value Type' column is the type of data in the curve, "zero" for zero rates, or "df" for discount factors.
- The 'Day Count' column is the name of the day count, such as "Act/365F".
- The 'Interpolator' and extrapolator columns define the interpolator to use.
The third file is the curve values file. This file has the following header row:
Valuation Date, Curve Name, Date, Value, Label
.- The 'Valuation Date' column provides the valuation date, allowing data from different days to be stored in the same file
- The 'Curve Name' column is the name of the curve.
- The 'Date' column is the date associated with the node.
- The 'Value' column is value of the curve at the date.
- The 'Label' column is the label used to refer to the node.
Each curve must be contained entirely within a single file, but each file may contain more than one curve. The curve points do not need to be ordered.
CSV files sometimes contain a Unicode Byte Order Mark. Callers are responsible for handling this, such as by using
UnicodeBom
.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ImmutableList<RatesCurveGroup>
load(LocalDate marketDataDate, ResourceLocator groupsResource, ResourceLocator settingsResource, Collection<ResourceLocator> curveValueResources)
Loads one or more CSV format curve files for a specific date.static ImmutableListMultimap<LocalDate,RatesCurveGroup>
loadAllDates(ResourceLocator groupsResource, ResourceLocator settingsResource, Collection<ResourceLocator> curveValueResources)
Loads one or more CSV format curve files for all available dates.static ImmutableListMultimap<LocalDate,RatesCurveGroup>
parse(Predicate<LocalDate> datePredicate, CharSource groupsCharSource, CharSource settingsCharSource, Collection<CharSource> curveValueCharSources)
Parses one or more CSV format curve files for all available dates.static void
writeCurveNodes(File file, LocalDate valuationDate, RatesCurveGroup group)
Writes the curve groups definition in a CSV format to a file.static void
writeCurveNodes(Appendable underlying, LocalDate valuationDate, RatesCurveGroup group)
Writes the curve nodes in a CSV format to an appendable.static void
writeCurveSettings(File file, RatesCurveGroup group)
Writes the curve settings in a CSV format to a file.static void
writeCurveSettings(Appendable underlying, RatesCurveGroup group)
Writes the curve settings in a CSV format to an appendable.
-
-
-
Method Detail
-
load
public static ImmutableList<RatesCurveGroup> load(LocalDate marketDataDate, ResourceLocator groupsResource, ResourceLocator settingsResource, Collection<ResourceLocator> curveValueResources)
Loads one or more CSV format curve files for a specific date.Only those quotes that match the specified date will be loaded.
If the files contain a duplicate entry an exception will be thrown.
- Parameters:
marketDataDate
- the curve date to loadgroupsResource
- the curve groups CSV resourcesettingsResource
- the curve settings CSV resourcecurveValueResources
- the CSV resources for curves- Returns:
- the loaded curves, mapped by an identifying key
- Throws:
IllegalArgumentException
- if the files contain a duplicate entry
-
loadAllDates
public static ImmutableListMultimap<LocalDate,RatesCurveGroup> loadAllDates(ResourceLocator groupsResource, ResourceLocator settingsResource, Collection<ResourceLocator> curveValueResources)
Loads one or more CSV format curve files for all available dates.If the files contain a duplicate entry an exception will be thrown.
- Parameters:
groupsResource
- the curve groups CSV resourcesettingsResource
- the curve settings CSV resourcecurveValueResources
- the CSV resources for curves- Returns:
- the loaded curves, mapped by date and identifier
- Throws:
IllegalArgumentException
- if the files contain a duplicate entry
-
parse
public static ImmutableListMultimap<LocalDate,RatesCurveGroup> parse(Predicate<LocalDate> datePredicate, CharSource groupsCharSource, CharSource settingsCharSource, Collection<CharSource> curveValueCharSources)
Parses one or more CSV format curve files for all available dates.A predicate is specified that is used to filter the dates that are returned. This could match a single date, a set of dates or all dates.
If the files contain a duplicate entry an exception will be thrown.
- Parameters:
datePredicate
- the predicate used to select the datesgroupsCharSource
- the curve groups CSV character sourcesettingsCharSource
- the curve settings CSV character sourcecurveValueCharSources
- the CSV character sources for curves- Returns:
- the loaded curves, mapped by date and identifier
- Throws:
IllegalArgumentException
- if the files contain a duplicate entry
-
writeCurveSettings
public static void writeCurveSettings(File file, RatesCurveGroup group)
Writes the curve settings in a CSV format to a file.- Parameters:
file
- the filegroup
- the curve group
-
writeCurveSettings
public static void writeCurveSettings(Appendable underlying, RatesCurveGroup group)
Writes the curve settings in a CSV format to an appendable.- Parameters:
underlying
- the underlying appendable destinationgroup
- the curve group
-
writeCurveNodes
public static void writeCurveNodes(File file, LocalDate valuationDate, RatesCurveGroup group)
Writes the curve groups definition in a CSV format to a file.- Parameters:
file
- the filevaluationDate
- the valuation dategroup
- the curve group
-
writeCurveNodes
public static void writeCurveNodes(Appendable underlying, LocalDate valuationDate, RatesCurveGroup group)
Writes the curve nodes in a CSV format to an appendable.- Parameters:
underlying
- the underlying appendable destinationvaluationDate
- the valuation dategroup
- the curve group
-
-