Class AInterpolation<T,U>
- java.lang.Object
-
- com.activeviam.risk.ref.services.impl.marketdataretrieval.AInterpolation<T,U>
-
- Type Parameters:
T
- The result vector typeU
- The boxed type of an item of the result
- All Implemented Interfaces:
IInterpolation<T,U>
- Direct Known Subclasses:
InterpolationDouble
,InterpolationVector
public abstract class AInterpolation<T,U> extends Object implements IInterpolation<T,U>
Interpolation utility
-
-
Field Summary
Fields Modifier and Type Field Description protected IInterpolationConfiguration
interpolationConfiguration
protected IMaturityConverter
maturityConverter
-
Constructor Summary
Constructors Modifier Constructor Description protected
AInterpolation(IMaturityConverter maturityConverter, IInterpolationConfiguration interpolationConfiguration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
applyCalculation(BiFunction<Double,U,U> calculation, Double pillar, com.quartetfs.fwk.impl.Pair<U,String> applyResult, boolean generateDebugString)
Apply a computation to the result if not null and take care of the debug stringprotected int
computeShift(int pillar, TreeMap<Double,Integer>[] matToLoc, int axis)
This function compute the shift on the data vector corresponding to the given pillar according to the pillar set topologyprotected TreeMap<Double,Integer>
convertBucketToMaturity(RuntimeData<U> runtimeData, IMarketDataRetrievalService.IPillarSet inputPillars)
This function returns an ordered map that can be used to find interpolation vectorsprotected void
generateDebugString(boolean generateDebugString, Double position, com.quartetfs.fwk.impl.Pair<U,String> result, Double p0)
The debug string for a one pillar resultprotected String
getDebugString(com.quartetfs.fwk.impl.Pair<U,String> result)
Extract the debug string of the pair value / debugIMarketDataset<T,U>
getMarketDataInterpolate(RuntimeData<U> runtimeData, IMarketDataset<T,U> inputData)
This function is computing the result by interpolationprotected void
handleDebug(boolean generateDebugString, com.quartetfs.fwk.impl.Pair<U,String> result, Supplier<String> debug)
Fill the debug string with the debug providerprotected com.quartetfs.fwk.impl.Pair<U,String>
interpolate(RuntimeData<U> runtimeData, IMarketDataset<T,U> values, int depth, double[] location, int[] interpolationOrder, TreeMap<Double,Integer>[] matToLoc, int shift)
This function will interpolate an output plot from an input set of valuesprotected void
interpolate(RuntimeData<U> runtimeData, IMarketDataset<T,U> result, IMarketDataset<T,U> values, int depth, double[] location, int[] interpolationOrder, TreeMap<Double,Integer>[] matToLoc, int shift)
This function will fill a vector with interpolated dataprotected com.quartetfs.fwk.impl.Pair<U,String>
interpolation(boolean generateDebugString, Double position, NavigableSet<Double> plots, BiFunction<Double,U,U> preInterpolationCalculation, BiFunction<Double,U,U> postInterpolationCalculation, Function<Double,com.quartetfs.fwk.impl.Pair<U,String>> retriever, com.activeviam.risk.ref.services.impl.marketdataretrieval.AInterpolation.ConvolutionMethod<U> convolution)
Linear interpolation between two plots of a valueprotected NavigableSet<Double>
removeOnePlot(NavigableSet<Double> plots, Double plot)
This function copy a list and remove one plot of it-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.activeviam.risk.ref.services.impl.marketdataretrieval.IInterpolation
getPostMarketDataInterpolationFunction, getPreMarketDataInterpolationFunction, interpolation
-
-
-
-
Field Detail
-
maturityConverter
protected final IMaturityConverter maturityConverter
-
interpolationConfiguration
protected final IInterpolationConfiguration interpolationConfiguration
-
-
Constructor Detail
-
AInterpolation
protected AInterpolation(IMaturityConverter maturityConverter, IInterpolationConfiguration interpolationConfiguration)
-
-
Method Detail
-
getMarketDataInterpolate
public IMarketDataset<T,U> getMarketDataInterpolate(RuntimeData<U> runtimeData, IMarketDataset<T,U> inputData)
This function is computing the result by interpolation- Specified by:
getMarketDataInterpolate
in interfaceIInterpolation<T,U>
- Parameters:
runtimeData
- infrastructure referencesinputData
- the input values to convert- Returns:
- the resulting MD vector
-
convertBucketToMaturity
protected TreeMap<Double,Integer> convertBucketToMaturity(RuntimeData<U> runtimeData, IMarketDataRetrievalService.IPillarSet inputPillars)
This function returns an ordered map that can be used to find interpolation vectors- Parameters:
runtimeData
- infrastructure referencesinputPillars
- The pillar set to convert- Returns:
- an ordered map maturity -> pillar number
-
interpolate
protected void interpolate(RuntimeData<U> runtimeData, IMarketDataset<T,U> result, IMarketDataset<T,U> values, int depth, double[] location, int[] interpolationOrder, TreeMap<Double,Integer>[] matToLoc, int shift)
This function will fill a vector with interpolated data- Parameters:
runtimeData
- infrastructure referencesresult
- the filled vector with the computed resultsvalues
- the input valuesdepth
- the depth of the recursive looplocation
- the current computed location in term of days on each axisinterpolationOrder
- the requested axis order of the interpolationmatToLoc
- the interpolation map and the pillar description in term of nr of daysshift
- the current computed location in term of position in the result vector
-
interpolate
protected com.quartetfs.fwk.impl.Pair<U,String> interpolate(RuntimeData<U> runtimeData, IMarketDataset<T,U> values, int depth, double[] location, int[] interpolationOrder, TreeMap<Double,Integer>[] matToLoc, int shift)
This function will interpolate an output plot from an input set of values- Parameters:
runtimeData
- infrastructure referencesvalues
- the input datadepth
- the current depth of processing, the axis orderlocation
- the coordinates to interpolateinterpolationOrder
- the requested axis order of the interpolationmatToLoc
- the interpolation map and the pillar description in term of nr of daysshift
- the current computed shift in the input data- Returns:
- the current interpolated value x the debug string
-
computeShift
protected int computeShift(int pillar, TreeMap<Double,Integer>[] matToLoc, int axis)
This function compute the shift on the data vector corresponding to the given pillar according to the pillar set topology- Parameters:
pillar
- The pillar number we want to convert into shiftmatToLoc
- The data topologyaxis
- The axis number of the related pillar- Returns:
- A shift compatible with the data vector
-
interpolation
protected com.quartetfs.fwk.impl.Pair<U,String> interpolation(boolean generateDebugString, Double position, NavigableSet<Double> plots, BiFunction<Double,U,U> preInterpolationCalculation, BiFunction<Double,U,U> postInterpolationCalculation, Function<Double,com.quartetfs.fwk.impl.Pair<U,String>> retriever, com.activeviam.risk.ref.services.impl.marketdataretrieval.AInterpolation.ConvolutionMethod<U> convolution)
Linear interpolation between two plots of a value- Parameters:
generateDebugString
- flag to enable the generation of the interpolation debug stringposition
- the position to interpolateplots
- the available reference positionspreInterpolationCalculation
- The functions computed before the interpolation of market data is performed, defined for the current axis.postInterpolationCalculation
- The functions computed after the interpolation of market data is performed, defined for the current axis.retriever
- the function that return the value on a reference plotconvolution
- the function that combines two values for interpolation- Returns:
- the interpolated value
-
removeOnePlot
protected NavigableSet<Double> removeOnePlot(NavigableSet<Double> plots, Double plot)
This function copy a list and remove one plot of it- Parameters:
plots
- the input listplot
- the plot to remove- Returns:
- a copied list with one less plot
-
getDebugString
protected String getDebugString(com.quartetfs.fwk.impl.Pair<U,String> result)
Extract the debug string of the pair value / debug- Parameters:
result
- the pair containing the debug string- Returns:
- the debug string or empty
-
handleDebug
protected void handleDebug(boolean generateDebugString, com.quartetfs.fwk.impl.Pair<U,String> result, Supplier<String> debug)
Fill the debug string with the debug provider- Parameters:
generateDebugString
- is debug enabledresult
- the result that will be filleddebug
- the debug string provider (the string is only computed if needed)
-
generateDebugString
protected void generateDebugString(boolean generateDebugString, Double position, com.quartetfs.fwk.impl.Pair<U,String> result, Double p0)
The debug string for a one pillar result- Parameters:
generateDebugString
- is debug enabledposition
- the requested locationresult
- the result to fillp0
- the retrieved location
-
applyCalculation
protected void applyCalculation(BiFunction<Double,U,U> calculation, Double pillar, com.quartetfs.fwk.impl.Pair<U,String> applyResult, boolean generateDebugString)
Apply a computation to the result if not null and take care of the debug string- Parameters:
calculation
- the conversion functionpillar
- the location for the conversionapplyResult
- the result to modifygenerateDebugString
- is debug activated
-
-