public static ForwardCurveInterpolation createForwardCurveFromMonteCarloLiborModel ( String name , LIBORModelMonteCarloSimulationModel model , double startTime ) throws CalculationException { int timeIndex = model . getTimeIndex ( startTime ) ; // Get all Libors at timeIndex which are not yet fixed (others null) and times for the timeDiscretizationFromArray of the curves ArrayList < RandomVariable > liborsAtTimeIndex = new ArrayList <> ( ) ; int firstLiborIndex = model . getLiborPeriodDiscretization ( ) . getTimeIndexNearestGreaterOrEqual ( startTime ) ; double firstLiborTime = model . getLiborPeriodDiscretization ( ) . getTime ( firstLiborIndex ) ; if ( firstLiborTime > startTime ) { liborsAtTimeIndex . add ( model . getLIBOR ( startTime , startTime , firstLiborTime ) ) ; } // Vector of times for the forward curve double [ ] times = new double [ firstLiborTime == startTime ? ( model . getNumberOfLibors ( ) - firstLiborIndex ) : ( model . getNumberOfLibors ( ) - firstLiborIndex + 1 ) ] ; times [ 0 ] = 0 ; int indexOffset = firstLiborTime == startTime ? 0 : 1 ; for ( int i = firstLiborIndex ; i < model . getNumberOfLibors ( ) ; i ++ ) { liborsAtTimeIndex . add ( model . getLIBOR ( timeIndex , i ) ) ; times [ i - firstLiborIndex + indexOffset ] = model . getLiborPeriodDiscretization ( ) . getTime ( i ) - startTime ; } RandomVariable [ ] libors = liborsAtTimeIndex . toArray ( new RandomVariable [ liborsAtTimeIndex . size ( ) ] ) ; return ForwardCurveInterpolation . createForwardCurveFromForwards ( name , times , libors , model . getLiborPeriodDiscretization ( ) . getTimeStep ( firstLiborIndex ) ) ; }
Create a forward curve from forwards given by a LIBORMonteCarloModel .