%% Numerix CAIL Advanced Risk example
%
%  This example uses the Numerix CAIL API to show curve stripping.

%% Initialize Numerix environment.

import com.numerix.integration.*;
import com.numerix.integration.implementation.*;

n = numerix('i:\NumeriX_java_10_3_0\data');

%% Use current market associated with the CAIL environment
markets = get(n.Parameters,'Markets');
currentMarket = markets.get(0);
outInstance = RefObject(currentMarket);

%% Use the curve key IR.USD-LIBOR-3M.MID
n.Context.tryResolveId('CONV.IR.USD-LIBOR-3M',outInstance);
currentInstance = outInstance.argvalue;

%% Set the instance and market
n.Parameters.setMarkets(java.util.Arrays.asList(currentMarket));
n.Parameters.setInstances(java.util.Arrays.asList(currentInstance));

%% Calculate
results = n.Context.calculate(n.Parameters,Request.getAll);

%% Results
% This example returns calculation results from stripping the curve 
% IR.USD-LIBOR-3M.MID.  
r = n.parseResults(results);

disp([r.Instance r.Market])
disp([r.Results{1}.Name r.Results{1}.Category r.Results{1}.Currency r.Results{1}.Data])
disp([r.Results{1}.Name{1}])
disp([r.Results{1}.Data{1}])

%   Copyright 2014 The MathWorks, Inc. 