idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
146,800
public double [ ] getZeroRates ( double [ ] maturities ) { double [ ] values = new double [ maturities . length ] ; for ( int i = 0 ; i < maturities . length ; i ++ ) { values [ i ] = getZeroRate ( maturities [ i ] ) ; } return values ; }
Returns the zero rates for a given vector maturities .
146,801
public static double [ ] [ ] invert ( double [ ] [ ] matrix ) { if ( isSolverUseApacheCommonsMath ) { LUDecomposition lu = new LUDecomposition ( new Array2DRowRealMatrix ( matrix ) ) ; double [ ] [ ] matrixInverse = lu . getSolver ( ) . getInverse ( ) . getData ( ) ; return matrixInverse ; } else { return org . jblas ....
Returns the inverse of a given matrix .
146,802
public static double [ ] [ ] factorReductionUsingCommonsMath ( double [ ] [ ] correlationMatrix , int numberOfFactors ) { double [ ] [ ] factorMatrix = getFactorMatrix ( correlationMatrix , numberOfFactors ) ; for ( int row = 0 ; row < correlationMatrix . length ; row ++ ) { double sumSquared = 0 ; for ( int factor = 0...
Returns a correlation matrix which has rank &lt ; n and for which the first n factors agree with the factors of correlationMatrix .
146,803
public static double [ ] [ ] pseudoInverse ( double [ ] [ ] matrix ) { if ( isSolverUseApacheCommonsMath ) { SingularValueDecomposition svd = new SingularValueDecomposition ( new Array2DRowRealMatrix ( matrix ) ) ; double [ ] [ ] matrixInverse = svd . getSolver ( ) . getInverse ( ) . getData ( ) ; return matrixInverse ...
Pseudo - Inverse of a matrix calculated in the least square sense .
146,804
public static double [ ] [ ] diag ( double [ ] vector ) { double [ ] [ ] diagonalMatrix = new double [ vector . length ] [ vector . length ] ; for ( int index = 0 ; index < vector . length ; index ++ ) { diagonalMatrix [ index ] [ index ] = vector [ index ] ; } return diagonalMatrix ; }
Generates a diagonal matrix with the input vector on its diagonal
146,805
private double [ ] formatTargetValuesForOptimizer ( ) { int numberOfMaturities = surface . getMaturities ( ) . length ; double mats [ ] = surface . getMaturities ( ) ; ArrayList < Double > vals = new ArrayList < Double > ( ) ; for ( int t = 0 ; t < numberOfMaturities ; t ++ ) { double mat = mats [ t ] ; double [ ] mySt...
This is a service method that takes care of putting al the target values in a single array .
146,806
public static ForwardCurveInterpolation createForwardCurveFromDiscountFactors ( String name , double [ ] times , RandomVariable [ ] givenDiscountFactors , double paymentOffset ) { ForwardCurveInterpolation forwardCurveInterpolation = new ForwardCurveInterpolation ( name , paymentOffset , InterpolationEntityForward . FO...
Create a forward curve from given times and discount factors .
146,807
public static ForwardCurveInterpolation createForwardCurveFromMonteCarloLiborModel ( String name , LIBORModelMonteCarloSimulationModel model , double startTime ) throws CalculationException { int timeIndex = model . getTimeIndex ( startTime ) ; ArrayList < RandomVariable > liborsAtTimeIndex = new ArrayList < > ( ) ; in...
Create a forward curve from forwards given by a LIBORMonteCarloModel .
146,808
private void addForward ( AnalyticModel model , double fixingTime , RandomVariable forward , boolean isParameter ) { double interpolationEntitiyTime ; RandomVariable interpolationEntityForwardValue ; switch ( interpolationEntityForward ) { case FORWARD : default : interpolationEntitiyTime = fixingTime ; interpolationEn...
Add a forward to this curve .
146,809
public LinearInterpolatedTimeDiscreteProcess add ( LinearInterpolatedTimeDiscreteProcess process ) throws CalculationException { Map < Double , RandomVariable > sum = new HashMap < > ( ) ; for ( double time : timeDiscretization ) { sum . put ( time , realizations . get ( time ) . add ( process . getProcessValue ( time ...
Create a new linear interpolated time discrete process by using the time discretization of this process and the sum of this process and the given one as its values .
146,810
public StochasticPathwiseLevenbergMarquardt getCloneWithModifiedTargetValues ( List < RandomVariable > newTargetVaues , List < RandomVariable > newWeights , boolean isUseBestParametersAsInitialParameters ) throws CloneNotSupportedException { StochasticPathwiseLevenbergMarquardt clonedOptimizer = clone ( ) ; clonedOptim...
Create a clone of this LevenbergMarquardt optimizer with a new vector for the target values and weights .
146,811
public RandomVariableInterface [ ] getBasisFunctions ( double exerciseDate , LIBORModelMonteCarloSimulationInterface model ) throws CalculationException { ArrayList < RandomVariableInterface > basisFunctions = new ArrayList < RandomVariableInterface > ( ) ; RandomVariableInterface basisFunction ; basisFunction = model ...
Return the regression basis functions .
146,812
private DiscountCurve createDiscountCurve ( String discountCurveName ) { DiscountCurve discountCurve = model . getDiscountCurve ( discountCurveName ) ; if ( discountCurve == null ) { discountCurve = DiscountCurveInterpolation . createDiscountCurveFromDiscountFactors ( discountCurveName , new double [ ] { 0.0 } , new do...
Get a discount curve from the model if not existing create a discount curve .
146,813
public double d ( double x ) { int intervalNumber = getIntervalNumber ( x ) ; if ( intervalNumber == 0 || intervalNumber == points . length ) { return x ; } return getIntervalReferencePoint ( intervalNumber - 1 ) ; }
If a given x is into an interval of the partition this method returns the reference point of the corresponding interval . If the given x is not contained in any interval of the partition this method returns x .
146,814
public double getValue ( ForwardCurveInterface forwardCurve , double swaprateVolatility ) { double swaprate = swaprates [ 0 ] ; for ( double swaprate1 : swaprates ) { if ( swaprate1 != swaprate ) { throw new RuntimeException ( "Uneven swaprates not allows for analytical pricing." ) ; } } double [ ] swapTenor = new doub...
This method returns the value of the product using a Black - Scholes model for the swap rate The model is determined by a discount factor curve and a swap rate volatility .
146,815
public double getRate ( AnalyticModel model ) { if ( model == null ) { throw new IllegalArgumentException ( "model==null" ) ; } ForwardCurve forwardCurve = model . getForwardCurve ( forwardCurveName ) ; if ( forwardCurve == null ) { throw new IllegalArgumentException ( "No forward curve of name '" + forwardCurveName + ...
Return the par FRA rate for a given curve .
146,816
public RandomVariable [ ] getParameter ( ) { double [ ] parameterAsDouble = this . getParameterAsDouble ( ) ; RandomVariable [ ] parameter = new RandomVariable [ parameterAsDouble . length ] ; for ( int i = 0 ; i < parameter . length ; i ++ ) { parameter [ i ] = new Scalar ( parameterAsDouble [ i ] ) ; } return paramet...
Get the parameters of determining this parametric covariance model . The parameters are usually free parameters which may be used in calibration .
146,817
public static DiscountCurveInterface createDiscountCurveFromMonteCarloLiborModel ( String forwardCurveName , LIBORModelMonteCarloSimulationModel model , double startTime ) throws CalculationException { if ( model . getModel ( ) . getDiscountCurve ( ) == null || model . getModel ( ) . getDiscountCurve ( ) . getName ( ) ...
Create a discount curve from forwards given by a LIBORMonteCarloModel . If the model uses multiple curves return its discount curve .
146,818
public static boolean isEasterSunday ( LocalDate date ) { int y = date . getYear ( ) ; int a = y % 19 ; int b = y / 100 ; int c = y % 100 ; int d = b / 4 ; int e = b % 4 ; int f = ( b + 8 ) / 25 ; int g = ( b - f + 1 ) / 3 ; int h = ( 19 * a + b - d - g + 15 ) % 30 ; int i = c / 4 ; int k = c % 4 ; int l = ( 32 + 2 * e...
Test a given date for being easter sunday .
146,819
public static LocalDateTime getDateFromFloatingPointDate ( LocalDateTime referenceDate , double floatingPointDate ) { if ( referenceDate == null ) { return null ; } Duration duration = Duration . ofSeconds ( Math . round ( floatingPointDate * SECONDS_PER_DAY ) ) ; return referenceDate . plus ( duration ) ; }
Convert a floating point date to a LocalDateTime .
146,820
public static double getFloatingPointDateFromDate ( LocalDateTime referenceDate , LocalDateTime date ) { Duration duration = Duration . between ( referenceDate , date ) ; return ( ( double ) duration . getSeconds ( ) ) / SECONDS_PER_DAY ; }
Convert a given date to a floating point date using a given reference date .
146,821
public static LocalDate getDateFromFloatingPointDate ( LocalDate referenceDate , double floatingPointDate ) { if ( referenceDate == null ) { return null ; } return referenceDate . plusDays ( ( int ) Math . round ( floatingPointDate * 365.0 ) ) ; }
Convert a floating point date to a LocalDate .
146,822
public double inverseCumulativeDistribution ( double x ) { double p = Math . exp ( - lambda ) ; double dp = p ; int k = 0 ; while ( x > p ) { k ++ ; dp *= lambda / k ; p += dp ; } return k ; }
Return the inverse cumulative distribution function at x .
146,823
protected void addPoint ( double time , RandomVariable value , boolean isParameter ) { synchronized ( rationalFunctionInterpolationLazyInitLock ) { if ( interpolationEntity == InterpolationEntity . LOG_OF_VALUE_PER_TIME && time == 0 ) { boolean containsOne = false ; int index = 0 ; for ( int i = 0 ; i < value . size ( ...
Add a point to this curveFromInterpolationPoints . The method will throw an exception if the point is already part of the curveFromInterpolationPoints .
146,824
public static String getOffsetCodeFromSchedule ( Schedule schedule ) { double doubleLength = 0 ; for ( int i = 0 ; i < schedule . getNumberOfPeriods ( ) ; i ++ ) { doubleLength += schedule . getPeriodLength ( i ) ; } doubleLength /= schedule . getNumberOfPeriods ( ) ; doubleLength *= 12 ; int periodLength = ( int ) Mat...
Determines the offset code of a forward contract from a schedule . Rounds the average period length to full months .
146,825
public static String getOffsetCodeFromCurveName ( String curveName ) { if ( curveName == null || curveName . length ( ) == 0 ) { return null ; } String [ ] splits = curveName . split ( "(?<=\\D)(?=\\d)" ) ; String offsetCode = splits [ splits . length - 1 ] ; if ( ! Character . isDigit ( offsetCode . charAt ( 0 ) ) ) {...
Determines the offset code of a forward contract from the name of a forward curve . This method will extract a group of one or more digits together with the first letter behind them if any . If there are multiple groups of digits in the name this method will extract the last . If there is no number in the string this m...
146,826
public ScheduleDescriptor generateScheduleDescriptor ( LocalDate startDate , LocalDate endDate ) { return new ScheduleDescriptor ( startDate , endDate , getFrequency ( ) , getDaycountConvention ( ) , getShortPeriodConvention ( ) , getDateRollConvention ( ) , getBusinessdayCalendar ( ) , getFixingOffsetDays ( ) , getPay...
Generate a schedule descriptor for the given start and end date .
146,827
public Schedule generateSchedule ( LocalDate referenceDate , LocalDate startDate , LocalDate endDate ) { return ScheduleGenerator . createScheduleFromConventions ( referenceDate , startDate , endDate , getFrequency ( ) , getDaycountConvention ( ) , getShortPeriodConvention ( ) , getDateRollConvention ( ) , getBusinessd...
Generate a schedule for the given start and end date .
146,828
public static ScheduleInterface createScheduleFromConventions ( LocalDate referenceDate , LocalDate startDate , String frequency , double maturity , String daycountConvention , String shortPeriodConvention ) { return createScheduleFromConventions ( referenceDate , startDate , frequency , maturity , daycountConvention ,...
Generates a schedule based on some meta data . The schedule generation considers short periods . Date rolling is ignored .
146,829
public AnalyticProductInterface getCalibrationProductForSymbol ( String symbol ) { for ( int i = 0 ; i < calibrationProductsSymbols . size ( ) ; i ++ ) { String calibrationProductSymbol = calibrationProductsSymbols . get ( i ) ; if ( calibrationProductSymbol . equals ( symbol ) ) { return calibrationProducts . get ( i ...
Returns the first product found in the vector of calibration products which matches the given symbol where symbol is the String set in the calibrationSpecs .
146,830
public RandomVariable getValue ( double evaluationTime , AssetModelMonteCarloSimulationModel model ) throws CalculationException { if ( exerciseMethod == ExerciseMethod . UPPER_BOUND_METHOD ) { GoldenSectionSearch optimizer = new GoldenSectionSearch ( - 1.0 , 1.0 ) ; while ( ! optimizer . isDone ( ) ) { double lambda =...
This method returns the value random variable of the product within the specified model evaluated at a given evalutationTime . Cash - flows prior evaluationTime are not considered .
146,831
public static HazardCurve createHazardCurveFromSurvivalProbabilities ( String name , double [ ] times , double [ ] givenSurvivalProbabilities ) { HazardCurve survivalProbabilities = new HazardCurve ( name ) ; for ( int timeIndex = 0 ; timeIndex < times . length ; timeIndex ++ ) { survivalProbabilities . addSurvivalProb...
Create a hazard curve from given times and given discount factors using default interpolation and extrapolation methods .
146,832
public SwaptionDataLattice convertLattice ( QuotingConvention targetConvention , double displacement , AnalyticModel model ) { if ( displacement != 0 && targetConvention != QuotingConvention . PAYERVOLATILITYLOGNORMAL ) { throw new IllegalArgumentException ( "SwaptionDataLattice only supports displacement, when using Q...
Convert this lattice to store data in the given convention . Conversion involving receiver premium assumes zero wide collar .
146,833
public SwaptionDataLattice append ( SwaptionDataLattice other , AnalyticModel model ) { SwaptionDataLattice combined = new SwaptionDataLattice ( referenceDate , quotingConvention , displacement , forwardCurveName , discountCurveName , floatMetaSchedule , fixMetaSchedule ) ; combined . entryMap . putAll ( entryMap ) ; i...
Append the data of another lattice to this lattice . If the other lattice follows a different quoting convention it is automatically converted . However this method does not check whether the two lattices are aligned in terms of reference date curve names and meta schedules . If the two lattices have shared data points...
146,834
public double [ ] getMoneynessAsOffsets ( ) { DoubleStream moneyness = getGridNodesPerMoneyness ( ) . keySet ( ) . stream ( ) . mapToDouble ( Integer :: doubleValue ) ; if ( quotingConvention == QuotingConvention . PAYERVOLATILITYLOGNORMAL ) { moneyness = moneyness . map ( new DoubleUnaryOperator ( ) { public double ap...
Return all levels of moneyness for which data exists . Moneyness is returned as actual difference strike - par swap rate .
146,835
public double [ ] getMaturities ( double moneyness ) { int [ ] maturitiesInMonths = getMaturities ( convertMoneyness ( moneyness ) ) ; double [ ] maturities = new double [ maturitiesInMonths . length ] ; for ( int index = 0 ; index < maturities . length ; index ++ ) { maturities [ index ] = convertMaturity ( maturities...
Return all valid maturities for a given moneyness . Uses the fixing times of the fix schedule to determine fractions .
146,836
public int [ ] getTenors ( ) { Set < Integer > setTenors = new HashSet < > ( ) ; for ( int moneyness : getGridNodesPerMoneyness ( ) . keySet ( ) ) { setTenors . addAll ( Arrays . asList ( ( IntStream . of ( keyMap . get ( moneyness ) [ 1 ] ) . boxed ( ) . toArray ( Integer [ ] :: new ) ) ) ) ; } return setTenors . stre...
Return all tenors for which data exists .
146,837
public int [ ] getTenors ( int moneynessBP , int maturityInMonths ) { try { List < Integer > ret = new ArrayList < > ( ) ; for ( int tenor : getGridNodesPerMoneyness ( ) . get ( moneynessBP ) [ 1 ] ) { if ( containsEntryFor ( maturityInMonths , tenor , moneynessBP ) ) { ret . add ( tenor ) ; } } return ret . stream ( )...
Return all valid tenors for a given moneyness and maturity .
146,838
public double [ ] getTenors ( double moneyness , double maturity ) { int maturityInMonths = ( int ) Math . round ( maturity * 12 ) ; int [ ] tenorsInMonths = getTenors ( convertMoneyness ( moneyness ) , maturityInMonths ) ; double [ ] tenors = new double [ tenorsInMonths . length ] ; for ( int index = 0 ; index < tenor...
Return all valid tenors for a given moneyness and maturity . Uses the payment times of the fix schedule to determine fractions .
146,839
private int convertMoneyness ( double moneyness ) { if ( quotingConvention == QuotingConvention . PAYERVOLATILITYLOGNORMAL ) { return ( int ) Math . round ( moneyness * 100 ) ; } else if ( quotingConvention == QuotingConvention . RECEIVERPRICE ) { return - ( int ) Math . round ( moneyness * 10000 ) ; } else { return ( ...
Convert moneyness given as difference to par swap rate to moneyness in bp . Uses the fixing times of the fix schedule to determine fractions .
146,840
private double convertMaturity ( int maturityInMonths ) { Schedule schedule = fixMetaSchedule . generateSchedule ( referenceDate , maturityInMonths , 12 ) ; return schedule . getFixing ( 0 ) ; }
Convert maturity given as offset in months to year fraction .
146,841
private double convertTenor ( int maturityInMonths , int tenorInMonths ) { Schedule schedule = fixMetaSchedule . generateSchedule ( referenceDate , maturityInMonths , tenorInMonths ) ; return schedule . getPayment ( schedule . getNumberOfPeriods ( ) - 1 ) ; }
Convert tenor given as offset in months to year fraction .
146,842
public boolean containsEntryFor ( int maturityInMonths , int tenorInMonths , int moneynessBP ) { return entryMap . containsKey ( new DataKey ( maturityInMonths , tenorInMonths , moneynessBP ) ) ; }
Returns true if the lattice contains an entry at the specified location .
146,843
private double convertToConvention ( double value , DataKey key , QuotingConvention toConvention , double toDisplacement , QuotingConvention fromConvention , double fromDisplacement , AnalyticModel model ) { if ( toConvention == fromConvention ) { if ( toConvention != QuotingConvention . PAYERVOLATILITYLOGNORMAL ) { re...
Convert the value to requested quoting convention . Conversion involving receiver premium assumes zero wide collar .
146,844
public double getCouponPayment ( int periodIndex , AnalyticModel model ) { ForwardCurve forwardCurve = model . getForwardCurve ( forwardCurveName ) ; if ( forwardCurve == null && forwardCurveName != null && forwardCurveName . length ( ) > 0 ) { throw new IllegalArgumentException ( "No forward curve with name '" + forwa...
Returns the coupon payment of the period with the given index . The analytic model is needed in case of floating bonds .
146,845
public double getValueWithGivenSpreadOverCurve ( double evaluationTime , Curve referenceCurve , double spread , AnalyticModel model ) { double value = 0 ; for ( int periodIndex = 0 ; periodIndex < schedule . getNumberOfPeriods ( ) ; periodIndex ++ ) { double paymentDate = schedule . getPayment ( periodIndex ) ; value +...
Returns the value of the sum of discounted cash flows of the bond where the discounting is done with the given reference curve and an additional spread . This method can be used for optimizer .
146,846
public double getValueWithGivenYield ( double evaluationTime , double rate , AnalyticModel model ) { DiscountCurve referenceCurve = DiscountCurveInterpolation . createDiscountCurveFromDiscountFactors ( "referenceCurve" , new double [ ] { 0.0 , 1.0 } , new double [ ] { 1.0 , 1.0 } ) ; return getValueWithGivenSpreadOverC...
Returns the value of the sum of discounted cash flows of the bond where the discounting is done with the given yield curve . This method can be used for optimizer .
146,847
public double getSpread ( double bondPrice , Curve referenceCurve , AnalyticModel model ) { GoldenSectionSearch search = new GoldenSectionSearch ( - 2.0 , 2.0 ) ; while ( search . getAccuracy ( ) > 1E-11 && ! search . isDone ( ) ) { double x = search . getNextPoint ( ) ; double fx = getValueWithGivenSpreadOverCurve ( 0...
Returns the spread value such that the sum of cash flows of the bond discounted with a given reference curve with the additional spread coincides with a given price .
146,848
public double getYield ( double bondPrice , AnalyticModel model ) { GoldenSectionSearch search = new GoldenSectionSearch ( - 2.0 , 2.0 ) ; while ( search . getAccuracy ( ) > 1E-11 && ! search . isDone ( ) ) { double x = search . getNextPoint ( ) ; double fx = getValueWithGivenYield ( 0.0 , x , model ) ; double y = ( bo...
Returns the yield value such that the sum of cash flows of the bond discounted with the yield curve coincides with a given price .
146,849
public double getAccruedInterest ( LocalDate date , AnalyticModel model ) { int periodIndex = schedule . getPeriodIndex ( date ) ; Period period = schedule . getPeriod ( periodIndex ) ; DayCountConvention dcc = schedule . getDaycountconvention ( ) ; double accruedInterest = getCouponPayment ( periodIndex , model ) * ( ...
Returns the accrued interest of the bond for a given date .
146,850
public double getAccruedInterest ( double time , AnalyticModel model ) { LocalDate date = FloatingpointDate . getDateFromFloatingPointDate ( schedule . getReferenceDate ( ) , time ) ; return getAccruedInterest ( date , model ) ; }
Returns the accrued interest of the bond for a given time .
146,851
public static double blackScholesOptionTheta ( double initialStockValue , double riskFreeRate , double volatility , double optionMaturity , double optionStrike ) { if ( optionStrike <= 0.0 || optionMaturity <= 0.0 ) { return 0.0 ; } else { double dPlus = ( Math . log ( initialStockValue / optionStrike ) + ( riskFreeRat...
This static method calculated the vega of a call option under a Black - Scholes model
146,852
public Map < String , Object > getValues ( double evaluationTime , MonteCarloSimulationInterface model ) throws CalculationException { RandomVariableInterface values = getValue ( evaluationTime , model ) ; if ( values == null ) { return null ; } double value = values . getAverage ( ) ; double error = values . getStanda...
This method returns the value of the product under the specified model and other information in a key - value map .
146,853
public double getValue ( double x ) { synchronized ( interpolatingRationalFunctionsLazyInitLock ) { if ( interpolatingRationalFunctions == null ) { doCreateRationalFunctions ( ) ; } } int pointIndex = java . util . Arrays . binarySearch ( points , x ) ; if ( pointIndex >= 0 ) { return values [ pointIndex ] ; } int inte...
Get an interpolated value for a given argument x .
146,854
public RandomVariable [ ] getGradient ( ) { int numberOfVariables = getNumberOfVariablesInList ( ) ; int numberOfCalculationSteps = factory . getNumberOfEntriesInList ( ) ; RandomVariable [ ] omega_hat = new RandomVariable [ numberOfCalculationSteps ] ; omega_hat [ numberOfCalculationSteps - 1 ] = new RandomVariableFro...
Apply the AAD algorithm to this very variable
146,855
public AbstractVolatilitySurfaceParametric getCloneCalibrated ( final AnalyticModel calibrationModel , final Vector < AnalyticProduct > calibrationProducts , final List < Double > calibrationTargetValues , Map < String , Object > calibrationParameters , final ParameterTransformation parameterTransformation , OptimizerF...
Create a clone of this volatility surface using a generic calibration of its parameters to given market data .
146,856
public static double [ ] computeSeasonalAdjustments ( double [ ] realizedCPIValues , int lastMonth , int numberOfYearsToAverage ) { double [ ] averageLogReturn = new double [ 12 ] ; Arrays . fill ( averageLogReturn , 0.0 ) ; for ( int arrayIndex = 0 ; arrayIndex < 12 * numberOfYearsToAverage ; arrayIndex ++ ) { int mon...
Computes annualized seasonal adjustments from given monthly realized CPI values .
146,857
public ProductFactoryCascade < T > addFactoryBefore ( ProductFactory < ? extends T > factory ) { ArrayList < ProductFactory < ? extends T > > factories = new ArrayList < ProductFactory < ? extends T > > ( this . factories . size ( ) + 1 ) ; factories . addAll ( this . factories ) ; factories . add ( 0 , factory ) ; ret...
Add a given factory to the list of factories at the BEGINNING .
146,858
public RandomVariable getValues ( double evaluationTime , LIBORMarketModel model ) { if ( evaluationTime > 0 ) { throw new RuntimeException ( "Forward start evaluation currently not supported." ) ; } LIBORCovarianceModel covarianceModel = model . getCovarianceModel ( ) ; int numberOfComponents = covarianceModel . getLi...
Calculates the squared curvature of the LIBOR instantaneous variance .
146,859
public RandomVariableInterface [ ] getFactorLoading ( double time , double component , RandomVariableInterface [ ] realizationAtTimeIndex ) { int componentIndex = liborPeriodDiscretization . getTimeIndex ( component ) ; if ( componentIndex < 0 ) { componentIndex = - componentIndex - 2 ; } return getFactorLoading ( time...
Return the factor loading for a given time and a given component .
146,860
private RandomVariable getValueUnderlyingNumeraireRelative ( LIBORModelMonteCarloSimulationModel model , Schedule legSchedule , boolean paysFloat , double swaprate , double notional ) throws CalculationException { RandomVariable value = model . getRandomVariableForConstant ( 0.0 ) ; for ( int periodIndex = legSchedule ...
Calculated the numeraire relative value of an underlying swap leg .
146,861
public ConditionalExpectationEstimator getConditionalExpectationEstimator ( double exerciseTime , LIBORModelMonteCarloSimulationModel model ) throws CalculationException { RandomVariable [ ] regressionBasisFunctions = regressionBasisFunctionProvider . getBasisFunctions ( exerciseTime , model ) ; return conditionalExpec...
The conditional expectation is calculated using a Monte - Carlo regression technique .
146,862
public RandomVariable getNumeraire ( double time ) throws CalculationException { int timeIndex = getLiborPeriodIndex ( time ) ; if ( timeIndex < 0 ) { int lowerIndex = - timeIndex - 1 ; int upperIndex = - timeIndex ; double alpha = ( time - getLiborPeriod ( lowerIndex ) ) / ( getLiborPeriod ( upperIndex ) - getLiborPer...
Return the numeraire at a given time . The numeraire is provided for interpolated points . If requested on points which are not part of the tenor discretization the numeraire uses a linear interpolation of the reciprocal value . See ISBN 0470047224 for details .
146,863
private double u_neg_inf ( double x , double tau ) { return f ( boundaryCondition . getValueAtLowerBoundary ( model , f_t ( tau ) , f_s ( x ) ) , x , tau ) ; }
Heat Equation Boundary Conditions
146,864
public double [ ] getRegressionCoefficients ( RandomVariable value ) { if ( basisFunctions . length == 0 ) { return new double [ ] { } ; } else if ( basisFunctions . length == 1 ) { return new double [ ] { value . mult ( basisFunctions [ 0 ] ) . getAverage ( ) / basisFunctions [ 0 ] . squared ( ) . getAverage ( ) } ; }...
Get the vector of regression coefficients .
146,865
private ProductDescriptor getSwapProductDescriptor ( Element trade ) { InterestRateSwapLegProductDescriptor legReceiver = null ; InterestRateSwapLegProductDescriptor legPayer = null ; NodeList legs = trade . getElementsByTagName ( "swapStream" ) ; for ( int legIndex = 0 ; legIndex < legs . getLength ( ) ; legIndex ++ )...
Construct an InterestRateSwapProductDescriptor from a node in a FpML file .
146,866
public static String getVersionString ( ) { String versionString = "UNKNOWN" ; Properties propeties = getProperites ( ) ; if ( propeties != null ) { versionString = propeties . getProperty ( "finmath-lib.version" ) ; } return versionString ; }
Return the version string of this instance of finmath - lib .
146,867
public static String getBuildString ( ) { String versionString = "UNKNOWN" ; Properties propeties = getProperites ( ) ; if ( propeties != null ) { versionString = propeties . getProperty ( "finmath-lib.build" ) ; } return versionString ; }
Return the build string of this instance of finmath - lib . Currently this is the Git commit hash .
146,868
public static DiscountCurve createDiscountCurveFromDiscountFactors ( String name , double [ ] times , double [ ] givenDiscountFactors ) { DiscountCurve discountFactors = new DiscountCurve ( name ) ; for ( int timeIndex = 0 ; timeIndex < times . length ; timeIndex ++ ) { discountFactors . addDiscountFactor ( times [ tim...
Create a discount curve from given times and given discount factors using default interpolation and extrapolation methods .
146,869
public Map < Double , SingleAssetEuropeanOptionProductDescriptor > getDescriptors ( LocalDate referenceDate ) { int numberOfStrikes = strikes . length ; HashMap < Double , SingleAssetEuropeanOptionProductDescriptor > descriptors = new HashMap < Double , SingleAssetEuropeanOptionProductDescriptor > ( ) ; LocalDate matur...
Return a collection of product descriptors for each option in the smile .
146,870
public SingleAssetEuropeanOptionProductDescriptor getDescriptor ( LocalDate referenceDate , int index ) throws ArrayIndexOutOfBoundsException { LocalDate maturityDate = FloatingpointDate . getDateFromFloatingPointDate ( referenceDate , maturity ) ; if ( index >= strikes . length ) { throw new ArrayIndexOutOfBoundsExcep...
Return a product descriptor for a specific strike .
146,871
public RandomVariable [ ] getValues ( double [ ] times ) { RandomVariable [ ] values = new RandomVariable [ times . length ] ; for ( int i = 0 ; i < times . length ; i ++ ) { values [ i ] = getValue ( null , times [ i ] ) ; } return values ; }
Return a vector of values corresponding to a given vector of times .
146,872
public static double getDaycount ( LocalDate startDate , LocalDate endDate , String convention ) { DayCountConventionInterface daycountConvention = getDayCountConvention ( convention ) ; return daycountConvention . getDaycount ( startDate , endDate ) ; }
Return the number of days between startDate and endDate given the specific daycount convention .
146,873
public double getValue ( ForwardCurve forwardCurve , double swaprateVolatility ) { double [ ] swapTenor = new double [ fixingDates . length + 1 ] ; System . arraycopy ( fixingDates , 0 , swapTenor , 0 , fixingDates . length ) ; swapTenor [ swapTenor . length - 1 ] = paymentDates [ paymentDates . length - 1 ] ; TimeDisc...
This method returns the value of the product using a Black - Scholes model for the swap rate with the Hunt - Kennedy convexity adjustment . The model is determined by a discount factor curve and a swap rate volatility .
146,874
public double getDiscountFactor ( AnalyticModelInterface model , double maturity ) { maturity *= timeScaling ; double beta1 = parameter [ 0 ] ; double beta2 = parameter [ 1 ] ; double beta3 = parameter [ 2 ] ; double beta4 = parameter [ 3 ] ; double tau1 = parameter [ 4 ] ; double tau2 = parameter [ 5 ] ; double x1 = t...
Return the discount factor within a given model context for a given maturity .
146,875
public static Schedule createScheduleFromConventions ( LocalDate referenceDate , LocalDate startDate , String frequency , double maturity , String daycountConvention , String shortPeriodConvention , String dateRollConvention , BusinessdayCalendar businessdayCalendar , int fixingOffsetDays , int paymentOffsetDays ) { Lo...
Generates a schedule based on some meta data . The schedule generation considers short periods .
146,876
public Curve getRegressionCurve ( ) { if ( regressionCurve != null ) { return regressionCurve ; } DoubleMatrix a = solveEquationSystem ( ) ; double [ ] curvePoints = new double [ partition . getLength ( ) ] ; curvePoints [ 0 ] = a . get ( 0 ) ; for ( int i = 1 ; i < curvePoints . length ; i ++ ) { curvePoints [ i ] = c...
Returns the curve resulting from the local linear regression with discrete kernel .
146,877
public double getValueAsPrice ( double evaluationTime , AnalyticModel model ) { ForwardCurve forwardCurve = model . getForwardCurve ( forwardCurveName ) ; DiscountCurve discountCurve = model . getDiscountCurve ( discountCurveName ) ; DiscountCurve discountCurveForForward = null ; if ( forwardCurve == null && forwardCur...
Returns the value of this product under the given model .
146,878
public void setDerivatives ( double [ ] parameters , double [ ] [ ] derivatives ) throws SolverException { Vector < Future < double [ ] > > valueFutures = new Vector < Future < double [ ] > > ( parameterCurrent . length ) ; for ( int parameterIndex = 0 ; parameterIndex < parameterCurrent . length ; parameterIndex ++ ) ...
The derivative of the objective function . You may override this method if you like to implement your own derivative .
146,879
private List < String > parseParams ( String param ) { Assert . hasText ( param , "param must not be empty nor null" ) ; List < String > paramsToUse = new ArrayList < > ( ) ; Matcher regexMatcher = DEPLOYMENT_PARAMS_PATTERN . matcher ( param ) ; int start = 0 ; while ( regexMatcher . find ( ) ) { String p = removeQuoti...
Parses a string of space delimited command line parameters and returns a list of parameters which doesn t contain any special quoting either for values or whole parameter .
146,880
public static String load ( LoadConfiguration config , String prefix ) { if ( config . getMode ( ) == Mode . INSERT ) { return loadInsert ( config , prefix ) ; } else if ( config . getMode ( ) == Mode . UPDATE ) { return loadUpdate ( config , prefix ) ; } throw new IllegalArgumentException ( "Unsupported mode " + confi...
Builds sql clause to load data into a database .
146,881
public static Map < String , String > parseProperties ( String s ) { Map < String , String > properties = new HashMap < String , String > ( ) ; if ( ! StringUtils . isEmpty ( s ) ) { Matcher matcher = PROPERTIES_PATTERN . matcher ( s ) ; int start = 0 ; while ( matcher . find ( ) ) { addKeyValuePairAsProperty ( s . sub...
Parses a String comprised of 0 or more comma - delimited key = value pairs .
146,882
public synchronized HttpServer < Buffer , Buffer > start ( ) throws Exception { if ( server == null ) { server = createProtocolListener ( ) ; } return server ; }
Start a server .
146,883
public void setSegmentReject ( String reject ) { if ( ! StringUtils . hasText ( reject ) ) { return ; } Integer parsedLimit = null ; try { parsedLimit = Integer . parseInt ( reject ) ; segmentRejectType = SegmentRejectType . ROWS ; } catch ( NumberFormatException e ) { } if ( parsedLimit == null && reject . contains ( ...
Sets the segment reject as a string . This method is for convenience to be able to set percent reject type just by calling with 3% and otherwise it uses rows . All this assuming that parsing finds % characher and is able to parse a raw reject number .
146,884
public void setReadTimeout ( int millis ) { ClientHttpRequestFactory f = getRequestFactory ( ) ; if ( f instanceof SimpleClientHttpRequestFactory ) { ( ( SimpleClientHttpRequestFactory ) f ) . setReadTimeout ( millis ) ; } else { ( ( HttpComponentsClientHttpRequestFactory ) f ) . setReadTimeout ( millis ) ; } }
The read timeout for the underlying URLConnection to the twitter stream .
146,885
public void setConnectTimeout ( int millis ) { ClientHttpRequestFactory f = getRequestFactory ( ) ; if ( f instanceof SimpleClientHttpRequestFactory ) { ( ( SimpleClientHttpRequestFactory ) f ) . setConnectTimeout ( millis ) ; } else { ( ( HttpComponentsClientHttpRequestFactory ) f ) . setConnectTimeout ( millis ) ; } ...
The connection timeout for making a connection to Twitter .
146,886
private void handleTextWebSocketFrameInternal ( TextWebSocketFrame frame , ChannelHandlerContext ctx ) { if ( logger . isTraceEnabled ( ) ) { logger . trace ( String . format ( "%s received %s" , ctx . channel ( ) , frame . text ( ) ) ) ; } addTraceForFrame ( frame , "text" ) ; ctx . channel ( ) . write ( new TextWebSo...
simple echo implementation
146,887
private void addTraceForFrame ( WebSocketFrame frame , String type ) { Map < String , Object > trace = new LinkedHashMap < > ( ) ; trace . put ( "type" , type ) ; trace . put ( "direction" , "in" ) ; if ( frame instanceof TextWebSocketFrame ) { trace . put ( "payload" , ( ( TextWebSocketFrame ) frame ) . text ( ) ) ; }...
add trace information for received frame
146,888
@ SuppressWarnings ( { "rawtypes" , "unchecked" } ) private IntegrationFlowBuilder getFlowBuilder ( ) { IntegrationFlowBuilder flowBuilder ; URLName urlName = this . properties . getUrl ( ) ; if ( this . properties . isIdleImap ( ) ) { flowBuilder = getIdleImapFlow ( urlName ) ; } else { MailInboundChannelAdapterSpec a...
Method to build Integration Flow for Mail . Suppress Warnings for MailInboundChannelAdapterSpec .
146,889
private IntegrationFlowBuilder getIdleImapFlow ( URLName urlName ) { return IntegrationFlows . from ( Mail . imapIdleAdapter ( urlName . toString ( ) ) . shouldDeleteMessages ( this . properties . isDelete ( ) ) . javaMailProperties ( getJavaMailProperties ( urlName ) ) . selectorExpression ( this . properties . getExp...
Method to build Integration flow for IMAP Idle configuration .
146,890
@ SuppressWarnings ( "rawtypes" ) private MailInboundChannelAdapterSpec getImapFlowBuilder ( URLName urlName ) { return Mail . imapInboundAdapter ( urlName . toString ( ) ) . shouldMarkMessagesAsRead ( this . properties . isMarkAsRead ( ) ) ; }
Method to build Mail Channel Adapter for IMAP .
146,891
protected View postDeclineView ( ) { return new TopLevelWindowRedirect ( ) { protected String getRedirectUrl ( Map < String , ? > model ) { return postDeclineUrl ; } } ; }
View that redirects the top level window to the URL defined in postDeclineUrl property after user declines to authorize application . May be overridden for custom views particularly in the case where the post - decline view should be rendered in - canvas .
146,892
@ SuppressWarnings ( "unchecked" ) public Map < String , ? > decodeSignedRequest ( String signedRequest ) throws SignedRequestException { return decodeSignedRequest ( signedRequest , Map . class ) ; }
Decodes a signed request returning the payload of the signed request as a Map
146,893
public < T > T decodeSignedRequest ( String signedRequest , Class < T > type ) throws SignedRequestException { String [ ] split = signedRequest . split ( "\\." ) ; String encodedSignature = split [ 0 ] ; String payload = split [ 1 ] ; String decoded = base64DecodeToString ( payload ) ; byte [ ] signature = base64Decode...
Decodes a signed request returning the payload of the signed request as a specified type .
146,894
public String getString ( String fieldName ) { return hasValue ( fieldName ) ? String . valueOf ( resultMap . get ( fieldName ) ) : null ; }
Returns the value of the identified field as a String .
146,895
public Integer getInteger ( String fieldName ) { try { return hasValue ( fieldName ) ? Integer . valueOf ( String . valueOf ( resultMap . get ( fieldName ) ) ) : null ; } catch ( NumberFormatException e ) { throw new FqlException ( "Field '" + fieldName + "' is not a number." , e ) ; } }
Returns the value of the identified field as an Integer .
146,896
public Long getLong ( String fieldName ) { try { return hasValue ( fieldName ) ? Long . valueOf ( String . valueOf ( resultMap . get ( fieldName ) ) ) : null ; } catch ( NumberFormatException e ) { throw new FqlException ( "Field '" + fieldName + "' is not a number." , e ) ; } }
Returns the value of the identified field as a Long .
146,897
public Float getFloat ( String fieldName ) { try { return hasValue ( fieldName ) ? Float . valueOf ( String . valueOf ( resultMap . get ( fieldName ) ) ) : null ; } catch ( NumberFormatException e ) { throw new FqlException ( "Field '" + fieldName + "' is not a number." , e ) ; } }
Returns the value of the identified field as a Float .
146,898
public Boolean getBoolean ( String fieldName ) { return hasValue ( fieldName ) ? Boolean . valueOf ( String . valueOf ( resultMap . get ( fieldName ) ) ) : null ; }
Returns the value of the identified field as a Boolean .
146,899
public Date getTime ( String fieldName ) { try { if ( hasValue ( fieldName ) ) { return new Date ( Long . valueOf ( String . valueOf ( resultMap . get ( fieldName ) ) ) * 1000 ) ; } else { return null ; } } catch ( NumberFormatException e ) { throw new FqlException ( "Field '" + fieldName + "' is not a time." , e ) ; }...
Returns the value of the identified field as a Date . Time fields returned from an FQL query are expressed in terms of seconds since midnight January 1 1970 UTC .