Class RatesCalibrationCsvLoader


  • public final class RatesCalibrationCsvLoader
    extends Object
    Loads a set of definitions to calibrate rates curves 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 calibration nodes file. This file has the following header row:
    Curve Name,Label,Symbology,Ticker,Field Name,Type,Convention,Time,Date,Min Gap,Clash Action,Spread.

    • The 'Curve Name' column is the name of the curve.
    • The 'Label' column is the label used to refer to the node.
    • The 'Symbology' column is the symbology scheme applicable to the ticker used for the market price.
    • The 'Ticker' column is the identifier within the symbology used for the market price.
    • The 'Field Name' column is the field name used for the market price, defaulted to "MarketValue", allowing fields such as 'Bid' or 'Ask' to be specified.
    • The 'Type' column is the type of the instrument, such as "FRA" or "OIS".
    • The 'Convention' column is the name of the convention to use.
    • The 'Time' column is the description of the time, such as "1Y" for a 1 year swap, or "3Mx6M" for a FRA.
    • The optional 'Date' column is the date to use for the node, defaults to "End", but can be set to "LastFixing" or a yyyy-MM-dd date.
    • The optional 'Min Gap' column is the minimum gap between this node and the adjacent nodes.
    • The optional 'Clash Action' column is the action to perform if the nodes are closer than the minimum gap or in the wrong order, defaults to "Exception", but can be set to "DropThis" or "DropOther".
    • The optional 'Spread' column is the spread to add to the instrument.

    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 Detail

      • load

        public static ImmutableMap<CurveGroupName,​RatesCurveGroupDefinition> load​(ResourceLocator groupsResource,
                                                                                        ResourceLocator settingsResource,
                                                                                        ResourceLocator... curveNodeResources)
        Loads one or more CSV format curve calibration files.

        If the files contain a duplicate entry an exception will be thrown.

        Parameters:
        groupsResource - the curve groups CSV resource
        settingsResource - the curve settings CSV resource
        curveNodeResources - the CSV resources for curve nodes
        Returns:
        the group definitions, mapped by name
        Throws:
        IllegalArgumentException - if the files contain a duplicate entry
      • loadWithSeasonality

        public static ImmutableMap<CurveGroupName,​RatesCurveGroupDefinition> loadWithSeasonality​(ResourceLocator groupsResource,
                                                                                                       ResourceLocator settingsResource,
                                                                                                       ResourceLocator seasonalityResource,
                                                                                                       Collection<ResourceLocator> curveNodeResources)
        Loads one or more CSV format curve calibration files with seasonality.

        If the files contain a duplicate entry an exception will be thrown.

        Parameters:
        groupsResource - the curve groups CSV resource
        settingsResource - the curve settings CSV resource
        seasonalityResource - the curve seasonality CSV resource
        curveNodeResources - the CSV resources for curve nodes
        Returns:
        the group definitions, mapped by name
        Throws:
        IllegalArgumentException - if the files contain a duplicate entry
      • parse

        public static ImmutableMap<CurveGroupName,​RatesCurveGroupDefinition> parse​(CharSource groupsCharSource,
                                                                                         CharSource settingsCharSource,
                                                                                         Collection<CharSource> curveNodeCharSources)
        Parses one or more CSV format curve calibration files.

        If the files contain a duplicate entry an exception will be thrown.

        Parameters:
        groupsCharSource - the curve groups CSV character source
        settingsCharSource - the curve settings CSV character source
        curveNodeCharSources - the CSV character sources for curve nodes
        Returns:
        the group definitions, mapped by name
        Throws:
        IllegalArgumentException - if the files contain a duplicate entry
      • parseWithSeasonality

        public static ImmutableMap<CurveGroupName,​RatesCurveGroupDefinition> parseWithSeasonality​(CharSource groupsCharSource,
                                                                                                        CharSource settingsCharSource,
                                                                                                        CharSource seasonalityResource,
                                                                                                        Collection<CharSource> curveNodeCharSources)
        Parses one or more CSV format curve calibration files with seasonality.

        If the files contain a duplicate entry an exception will be thrown.

        Parameters:
        groupsCharSource - the curve groups CSV character source
        settingsCharSource - the curve settings CSV character source
        seasonalityResource - the seasonality CSV character source
        curveNodeCharSources - the CSV character sources for curve nodes
        Returns:
        the group definitions, mapped by name
        Throws:
        IllegalArgumentException - if the files contain a duplicate entry