Class DataTableBasic

java.lang.Object
net.finmath.singleswaprate.data.DataTableBasic
All Implemented Interfaces:
Serializable, Cloneable, DataTable
Direct Known Subclasses:
DataTableInterpolated, DataTableLinear

public class DataTableBasic extends Object implements DataTable, Cloneable
A basic implementation of DataTable, which provides no means of inter- or extrapolation.
Author:
Christian Fries, Roland Bachl
See Also:
  • Constructor Details

    • DataTableBasic

      public DataTableBasic(String name, DataTable.TableConvention convention, LocalDate referenceDate, SchedulePrototype scheduleMetaData)
      Create an empty table.
      Parameters:
      name - The name of the table.
      convention - The convention of the table.
      referenceDate - The referenceDate of the table.
      scheduleMetaData - The schedule meta data of the table.
    • DataTableBasic

      public DataTableBasic(String name, DataTable.TableConvention convention, LocalDate referenceDate, SchedulePrototype scheduleMetaData, int[] maturities, int[] terminations, double[] values)
      Create a table.
      Parameters:
      name - The name of the table.
      convention - The convention of the table.
      referenceDate - The referenceDate of the table.
      scheduleMetaData - The schedule meta data of the table.
      maturities - The maturities of the points as offset with respect to the reference date.
      terminations - The terminations of the points as offset with respect to the maturity date.
      values - The values at the points.
    • DataTableBasic

      public DataTableBasic(String name, DataTable.TableConvention convention, LocalDate referenceDate, SchedulePrototype scheduleMetaData, List<Integer> maturities, List<Integer> terminations, List<Double> values)
      Create a table.
      Parameters:
      name - The name of the table.
      convention - The convention of the table.
      referenceDate - The referenceDate of the table.
      scheduleMetaData - The schedule meta data of the table.
      maturities - The maturities of the points as offset with respect to the reference date.
      terminations - The terminations of the points as offset with respect to the maturity date.
      values - The values at the points.
  • Method Details

    • upgradeDataTableLight

      public static DataTableBasic upgradeDataTableLight(DataTableLight baseTable, LocalDate referenceDate, SchedulePrototype scheduleMetaData)
      Create a DataTableBasic by upgrading a DataTableLight to allow access via double representation.
      Parameters:
      baseTable - The table to be upgraded.
      referenceDate - The reference date.
      scheduleMetaData - The schedule meta data of the table.
      Returns:
      The upgraded table.
    • addPoint

      public DataTable addPoint(int maturity, int termination, double value)
      Description copied from interface: DataTable
      Add a point to the grid of the table.
      Specified by:
      addPoint in interface DataTable
      Parameters:
      maturity - The maturity of the point as offset with respect to the reference date.
      termination - The termination of the point as offset with respect to the maturity date.
      value - The value at the point.
      Returns:
      The table with the point added.
    • addPoints

      public DataTable addPoints(int[] maturities, int[] terminations, double[] values)
      Description copied from interface: DataTable
      Add an array of points to the table.
      Specified by:
      addPoints in interface DataTable
      Parameters:
      maturities - The maturities of the points as offset with respect to the reference date.
      terminations - The terminations of the points as offset with respect to the maturity date.
      values - The values at the points.
      Returns:
      The table with the point added.
    • getValue

      public double getValue(int maturity, int termination)
      Description copied from interface: DataTable
      Returns the value of the table at a given time. Interpolates if the table is set up to do so.
      Specified by:
      getValue in interface DataTable
      Parameters:
      maturity - The maturity as offset with respect to the reference date.
      termination - The termination as offset with respect to the maturity date.
      Returns:
      Value at the given time.
    • getValue

      public double getValue(double maturity, double termination)
      Description copied from interface: DataTable
      Returns the value of the table at a given time. Interpolates if the table is set up to do so.
      Specified by:
      getValue in interface DataTable
      Parameters:
      maturity - Maturity in double as year fraction with respect to reference date.
      termination - Termination in double as year fraction with respect to reference date.
      Returns:
      Value at the given time.
    • size

      public int size()
      Specified by:
      size in interface DataTable
      Returns:
      The number of data points in the table.
    • containsEntryFor

      public boolean containsEntryFor(int maturity, int termination)
      Description copied from interface: DataTable
      Checks whether the table has an actual entry at the specified coordinates. Note that even if this returns false the table may provide a value when calling getValue on these coordinates as the table may interpolate/extrapolate.
      Specified by:
      containsEntryFor in interface DataTable
      Parameters:
      maturity - The maturity as offset with respect to the reference date.
      termination - The termination as offset with respect to the maturity date.
      Returns:
      True if the table contains a data point at the coordinates, false otherwise.
    • containsEntryFor

      public boolean containsEntryFor(double maturity, double termination)
      Description copied from interface: DataTable
      Checks whether the table has an actual entry at the specified coordinates. Note that even if this returns false the table may provide a value when calling getValue on these coordinates as the table may interpolate/extrapolate.
      Specified by:
      containsEntryFor in interface DataTable
      Parameters:
      maturity - Maturity in double as year fraction with respect to reference date.
      termination - Termination in double as year fraction with respect to reference date.
      Returns:
      True if the table contains a data point at the coordinates, false otherwise.
    • getMaturities

      public TreeSet<Integer> getMaturities()
      Description copied from interface: DataTable
      Get a sorted set view of all maturities in the table.
      Specified by:
      getMaturities in interface DataTable
      Returns:
      The maturities as sorted set.
    • getTerminations

      public TreeSet<Integer> getTerminations()
      Description copied from interface: DataTable
      Get a sorted set view of all terminations in the table.
      Specified by:
      getTerminations in interface DataTable
      Returns:
      The terminations as sorted set.
    • getTerminationsForMaturity

      public TreeSet<Integer> getTerminationsForMaturity(int maturity)
      Description copied from interface: DataTable
      Get a sorted set view of all terminations for a specific maturity in the table.
      Specified by:
      getTerminationsForMaturity in interface DataTable
      Parameters:
      maturity - The maturity for which to get the terminations.
      Returns:
      The terminations as sorted set.
    • getMaturitiesForTermination

      public TreeSet<Integer> getMaturitiesForTermination(int termination)
      Description copied from interface: DataTable
      Get a sorted set view of all maturities for a speceific termination in the table.
      Specified by:
      getMaturitiesForTermination in interface DataTable
      Parameters:
      termination - The termination for which to get the maturities.
      Returns:
      The maturities as sorted set.
    • getName

      public String getName()
      Specified by:
      getName in interface DataTable
      Returns:
      The name of the table.
    • getReferenceDate

      public LocalDate getReferenceDate()
      Description copied from interface: DataTable
      The reference date of the table.
      Specified by:
      getReferenceDate in interface DataTable
      Returns:
      The reference date.
    • getConvention

      public DataTable.TableConvention getConvention()
      Description copied from interface: DataTable
      Returns the convention the table understands its coordinates in. As offset form the reference date.
      Specified by:
      getConvention in interface DataTable
      Returns:
      The convention of the table.
    • getScheduleMetaData

      public SchedulePrototype getScheduleMetaData()
      Specified by:
      getScheduleMetaData in interface DataTable
      Returns:
      The meta data as SchedulePrototype used by the table to convert int and double representations.
    • clone

      public DataTableBasic clone()
      Specified by:
      clone in interface DataTable
      Overrides:
      clone in class Object
      Returns:
      A copy of the table.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString(double unit)
    • getValue

      protected double getValue(DataTableBasic.DoubleKey key)