Main Content
Use Numerix to Price Cash Deposits
This example shows how to use the Numerix® CROSSASSET API to price a cash deposit from MATLAB®. The trade parameters are read from the
Cashdeposit1.csv
in the Numerix Data
Trades
folder.
Initialize Numerix environment.
import com.numerix.integration.*; import com.numerix.integration.implementation.*; n = numerix('i:\NumeriX_java_10_3_0\data')
n = Path: 'i:\NumeriX_java_10_3_0\data' RepositoryPath: 'i:\NumeriX_java_10_3_0\data\Repository' Repository: [1x1 com.numerix.integration.implementation.FileSystemRepository] Context: [1x1 com.numerix.integration.implementation.LocalCalculationContext] LookupsPath: 'i:\NumeriX_java_10_3_0\data\Data\LookupRules' MarketsPath: 'i:\NumeriX_java_10_3_0\data\Data\Markets' FixingsPath: 'i:\NumeriX_java_10_3_0\data\Data\Fixings' TradesPath: 'i:\NumeriX_java_10_3_0\data\Data\Trades' Parameters: [1x1 com.numerix.integration.implementation.CalculationParameters]
Create a market.
market = Market('EOD_16-APR-2012', DateExtensions.date('16-APR-2012'), []);
Read the Cashdeposit1.csv
file from the Numerix
Trades
folder.
[~,~,tradeInfo] = xlsread([n.TradesPath '\Cashdeposit1.csv'])
tradeInfo = 'Template' 'String' 'TRADE.IR.CASHDEPOSIT' 'Trade ID' 'ID' 'CASHDEP1001' 'Quote Type' 'String' 'MID' 'Effective Date' 'Date' '4/1/2012' 'Maturity' 'Date' '4/1/2013' 'Notional' 'Double' [ 100] 'Currency' 'Currency' 'USD' 'Coupon Rate' 'Double' [ 0.0500] 'Yield' 'Double' [ 0.0440] 'IR Index' 'String' 'Libor' 'IR Index Tenor' 'Tenor' '3m'
Define a trade instance from the imported CASHDEP1001
instrument.
tradeDescriptor = tradeInfo{1,3}; tradeParameters = java.util.HashMap; numTradeInfoFields = size(tradeInfo,1); for i = 2:numTradeInfoFields switch tradeInfo{i,2} case {'DATE','Date'} tradeParameters.put(tradeInfo{i,1},DateExtensions.date(datestr(tradeInfo{i,3},'dd-mmm-yyyy'))); otherwise tradeParameters.put(tradeInfo{i,1},tradeInfo{i,3}); end end
Create the trade instance.
trade = RepositoryExtensions.createTradeInstance(n.Repository, tradeDescriptor, tradeParameters);
Price the trade.
results = CalculationContextExtensions.calculate(n.Context, trade, market, Request.getAll);
Parse the results for MATLAB and display.
r = n.parseResults(results) disp([r.Name r.Category r.Currency r.Data])
r = Category: {9x1 cell} Currency: {9x1 cell} Name: {9x1 cell} Data: {9x1 cell} 'Modified Duration' 'Price' '' [ 0.9349] 'Accrued Interest' 'Price' 'USD' [ 0.2083] 'Reporting Currency' 'Price' '' 'USD' 'PV' 'Price' 'USD' [ 100.7607] 'Instrument' 'Price' '' [1x85 char] 'Clean Price' 'Price' 'USD' [ 100.5524] 'Convexity' 'Price' '' [ 1.7481] 'YTM' 'Price' '' [] 'Messages' '' '' []
See Also
numerix
| parseResults
| numerixCrossAsset
Related Topics
- Working with Simple Numerix Trades
- Working with Advanced Numerix Trades
- Use Numerix for Interest-Rate Risk Assessment