Пример #1
0
 public static object _CreateCashLeg(string objectName,
                                     object[,] paymentDates,
                                     object[,] amounts,
                                     object[,] currencies)
 {
     try
     {
         Date[]     _paymentDates = XU.GetDate1D(paymentDates, "paymentDates");
         Double[]   _amounts      = XU.GetDouble1D(amounts, "amounts");
         Currency[] _currencies   = XU.GetCurrency1D(currencies, "currencies");
         CashLeg    _result       = XLRates.CreateCashLeg(_paymentDates, _amounts, _currencies);
         return(XU.AddObject(objectName, _result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
 public static object _CreateDatesAndRatesCurve(string objectName,
                                                object[,] dates,
                                                object[,] rates,
                                                object[,] currency)
 {
     try
     {
         Date[]             _dates    = XU.GetDate1D(dates, "dates");
         Double[]           _rates    = XU.GetDouble1D(rates, "rates");
         Currency           _currency = XU.GetCurrency0D(currency, "currency", Currency.ANY);
         IDiscountingSource _result   = XLCurves.CreateDatesAndRatesCurve(_dates, _rates, _currency);
         return(XU.AddObject(objectName, _result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #3
0
 public static object _CreateRateForecastCurveFromDiscount(string objectName,
                                                           object[,] floatingRateIndex,
                                                           object[,] discountCurve,
                                                           object[,] fixingCurve)
 {
     try
     {
         FloatingIndex       _floatingRateIndex = XU.GetFloatingIndex0D(floatingRateIndex, "floatingRateIndex");
         IDiscountingSource  _discountCurve     = XU.GetObject0D <IDiscountingSource>(discountCurve, "discountCurve");
         IFloatingRateSource _fixingCurve       = XU.GetObject0D <IFloatingRateSource>(fixingCurve, "fixingCurve", null);
         IFloatingRateSource _result            = XLRates.CreateRateForecastCurveFromDiscount(_floatingRateIndex, _discountCurve, _fixingCurve);
         return(XU.AddObject(objectName, _result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #4
0
 public static object _GetSurvivalProb(object[,] survivalProbabilitySource,
                                       object[,] date1,
                                       object[,] date2)
 {
     try
     {
         var _survivalProbabilitySource =
             XU.GetObject0D <ISurvivalProbabilitySource>(survivalProbabilitySource, "survivalProbabilitySource");
         var _date1  = XU.GetDate0D(date1, "date1");
         var _date2  = XU.GetDate0D(date2, "date2", null);
         var _result = XLCredit.GetSurvivalProb(_survivalProbabilitySource, _date1, _date2);
         return(XU.ConvertToObjects(_result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #5
0
 public static object _CreateEquityCall(string objectName,
                                        object[,] share,
                                        object[,] exerciseDate,
                                        object[,] strike)
 {
     try
     {
         var _share        = XU.GetSpecialType0D <Share>(share, "share");
         var _exerciseDate = XU.GetDate0D(exerciseDate, "exerciseDate");
         var _strike       = XU.GetDouble0D(strike, "strike");
         var _result       = XLEquities.CreateEquityCall(_share, _exerciseDate, _strike);
         return(XU.AddObject(objectName, _result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #6
0
 public static object _CreateCurveModel(string objectName,
                                        object[,] discountCurve,
                                        object[,] rateForecastCurves,
                                        object[,] fxForecastCurves)
 {
     try
     {
         IDiscountingSource    _discountCurve      = XU.GetObject0D <IDiscountingSource>(discountCurve, "discountCurve");
         IFloatingRateSource[] _rateForecastCurves = XU.GetObject1D <IFloatingRateSource>(rateForecastCurves, "rateForecastCurves");
         IFXSource[]           _fxForecastCurves   = XU.GetObject1D <IFXSource>(fxForecastCurves, "fxForecastCurves");
         NumeraireSimulator    _result             = XLValuation.CreateCurveModel(_discountCurve, _rateForecastCurves, _fxForecastCurves);
         return(XU.AddObject(objectName, _result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #7
0
 public static object _FitCurveNelsonSiegel(string objectName,
                                            object[,] anchorDate,
                                            object[,] dates,
                                            object[,] rates)
 {
     try
     {
         var _anchorDate = XU.GetDate0D(anchorDate, "anchorDate");
         var _dates      = XU.GetDate1D(dates, "dates");
         var _rates      = XU.GetDouble1D(rates, "rates");
         var _result     = XLCurves.FitCurveNelsonSiegel(_anchorDate, _dates, _rates);
         return(XU.AddObject(objectName, _result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #8
0
 public static object _CreateDatesAndRatesCurve(string objectName,
                                                object[,] dates,
                                                object[,] rates,
                                                object[,] currency)
 {
     try
     {
         var _dates    = XU.GetDate1D(dates, "dates");
         var _rates    = XU.GetDouble1D(rates, "rates");
         var _currency = XU.GetSpecialType0D(currency, "currency", Currency.ANY);
         var _result   = XLCurves.CreateDatesAndRatesCurve(_dates, _rates, _currency);
         return(XU.AddObject(objectName, _result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #9
0
 public static object FormulaBlackScholes([ExcelArgument(Description = "Strike")] object[,] strike,
                                          [ExcelArgument(Description = "The value date as and Excel date.")] object[,] valueDate,
                                          [ExcelArgument(Description = "The exercise date of the option.  Must be greater than the value date.")] object[,] exerciseDate,
                                          [ExcelArgument(Description = "The spot proce of the underlying at the value date.")] object[,] spotPrice,
                                          [ExcelArgument(Description = "Annualized volatility.")] object[,] vol,
                                          [ExcelArgument(Description = "Continuously compounded risk free rate.")] object[,] riskfreeRate,
                                          [ExcelArgument(Description = "Continuously compounded dividend yield.")] object[,] divYield)
 {
     try {
         return(Formulae.BlackScholes(PutOrCall.Call, XU.GetDouble0D(strike, "strike"),
                                      (XU.GetDate0D(exerciseDate, "exerciseDate") - XU.GetDate0D(valueDate, "valueDate")) / 365.0,
                                      XU.GetDouble0D(spotPrice, "spotPrice"), XU.GetDouble0D(vol, "vol"),
                                      XU.GetDouble0D(riskfreeRate, "riskfreeRate"), XU.GetDouble0D(divYield, "divYield")));
     } catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #10
0
 public static object _CreateCashLeg(string objectName,
                                     object[,] paymentDates,
                                     object[,] amounts,
                                     object[,] currencies)
 {
     try
     {
         var _paymentDates = XU.GetDate1D(paymentDates, "paymentDates");
         var _amounts      = XU.GetDouble1D(amounts, "amounts");
         var _currencies   = XU.GetSpecialType1D <Currency>(currencies, "currencies");
         var _result       = XLRates.CreateCashLeg(_paymentDates, _amounts, _currencies);
         return(XU.AddObject(objectName, _result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #11
0
 public static object _RateConvert(object[,] rate,
                                   object[,] compoundingFrom,
                                   object[,] compoundingTo,
                                   object[,] yearFraction)
 {
     try
     {
         var _rate            = XU.GetDouble0D(rate, "rate");
         var _compoundingFrom = XU.GetSpecialType0D <CompoundingConvention>(compoundingFrom, "compoundingFrom");
         var _compoundingTo   = XU.GetSpecialType0D <CompoundingConvention>(compoundingTo, "compoundingTo");
         var _yearFraction    = XU.GetDouble0D(yearFraction, "yearFraction", double.NaN);
         var _result          = XLConventions.RateConvert(_rate, _compoundingFrom, _compoundingTo, _yearFraction);
         return(XU.ConvertToObjects(_result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #12
0
 public static object _Value(string objectName,
                             object[,] products,
                             object[,] valueDate,
                             object[,] model,
                             object[,] nSims)
 {
     try
     {
         Product[]          _products  = XU.GetObject1D <Product>(products, "products");
         Date               _valueDate = XU.GetDate0D(valueDate, "valueDate");
         NumeraireSimulator _model     = XU.GetObject0D <NumeraireSimulator>(model, "model");
         Int32              _nSims     = XU.GetInt320D(nSims, "nSims", 1);
         ResultStore        _result    = XLValuation.Value(_products, _valueDate, _model, _nSims);
         return(XU.AddObject(objectName, _result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #13
0
 public static object _CreateHWModelDemo(string objectName,
                                         object[,] meanReversion,
                                         object[,] flatVol,
                                         object[,] baseCurve,
                                         object[,] forecastIndices)
 {
     try
     {
         var _meanReversion   = XU.GetDouble0D(meanReversion, "meanReversion");
         var _flatVol         = XU.GetDouble0D(flatVol, "flatVol");
         var _baseCurve       = XU.GetObject0D <IDiscountingSource>(baseCurve, "baseCurve");
         var _forecastIndices = XU.GetSpecialType0D <FloatingIndex>(forecastIndices, "forecastIndices");
         var _result          = XLRates.CreateHWModelDemo(_meanReversion, _flatVol, _baseCurve, _forecastIndices);
         return(XU.AddObject(objectName, _result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #14
0
 public static object _CreateLoanFixedRate(string objectName,
                                           object[,] currency,
                                           object[,] balanceDates,
                                           object[,] balanceAmounts,
                                           object[,] fixedRate)
 {
     try
     {
         var _currency       = XU.GetSpecialType0D <Currency>(currency, "currency");
         var _balanceDates   = XU.GetDate1D(balanceDates, "balanceDates");
         var _balanceAmounts = XU.GetDouble1D(balanceAmounts, "balanceAmounts");
         var _fixedRate      = XU.GetDouble0D(fixedRate, "fixedRate");
         var _result         = XLRates.CreateLoanFixedRate(_currency, _balanceDates, _balanceAmounts, _fixedRate);
         return(XU.AddObject(objectName, _result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #15
0
 public static object _CreateHazardCurve(string objectName,
                                         object[,] referenceEntity,
                                         object[,] anchorDate,
                                         object[,] dates,
                                         object[,] hazardRates)
 {
     try
     {
         var _referenceEntity = XU.GetSpecialType0D <ReferenceEntity>(referenceEntity, "referenceEntity");
         var _anchorDate      = XU.GetDate0D(anchorDate, "anchorDate");
         var _dates           = XU.GetDate1D(dates, "dates");
         var _hazardRates     = XU.GetDouble1D(hazardRates, "hazardRates");
         var _result          = XLCredit.CreateHazardCurve(_referenceEntity, _anchorDate, _dates, _hazardRates);
         return(XU.AddObject(objectName, _result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #16
0
 public static object[,] _EPE(object[,] products,
                              object[,] valueDate,
                              object[,] forwardValueDates,
                              object[,] model,
                              object[,] nSims)
 {
     try
     {
         Product[]          _products          = XU.GetObject1D <Product>(products, "products");
         Date               _valueDate         = XU.GetDate0D(valueDate, "valueDate");
         Date[]             _forwardValueDates = XU.GetDate1D(forwardValueDates, "forwardValueDates");
         NumeraireSimulator _model             = XU.GetObject0D <NumeraireSimulator>(model, "model");
         Int32              _nSims             = XU.GetInt320D(nSims, "nSims");
         Double[]           _result            = XLValuation.EPE(_products, _valueDate, _forwardValueDates, _model, _nSims);
         return(XU.ConvertToObjects(_result));
     }
     catch (Exception e)
     {
         return(XU.Error2D(e));
     }
 }
Пример #17
0
 public static object _CreateLoanFloatingRate(string objectName,
                                              object[,] currency,
                                              object[,] balanceDates,
                                              object[,] balanceAmounts,
                                              object[,] floatingIndex,
                                              object[,] floatingSpread)
 {
     try
     {
         Currency         _currency       = XU.GetCurrency0D(currency, "currency");
         Date[]           _balanceDates   = XU.GetDate1D(balanceDates, "balanceDates");
         Double[]         _balanceAmounts = XU.GetDouble1D(balanceAmounts, "balanceAmounts");
         FloatingIndex    _floatingIndex  = XU.GetFloatingIndex0D(floatingIndex, "floatingIndex");
         Double           _floatingSpread = XU.GetDouble0D(floatingSpread, "floatingSpread");
         LoanFloatingRate _result         = XLRates.CreateLoanFloatingRate(_currency, _balanceDates, _balanceAmounts, _floatingIndex, _floatingSpread);
         return(XU.AddObject(objectName, _result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #18
0
 public static object _CreateZARFRA(string objectName,
                                    object[,] tradeDate,
                                    object[,] notional,
                                    object[,] rate,
                                    object[,] fraCode,
                                    object[,] payFixed)
 {
     try
     {
         var _tradeDate = XU.GetDate0D(tradeDate, "tradeDate");
         var _notional  = XU.GetDouble0D(notional, "notional");
         var _rate      = XU.GetDouble0D(rate, "rate");
         var _fraCode   = XU.GetSpecialType0D <string>(fraCode, "fraCode");
         var _payFixed  = XU.GetBoolean0D(payFixed, "payFixed");
         var _result    = XLRates.CreateZARFRA(_tradeDate, _notional, _rate, _fraCode, _payFixed);
         return(XU.AddObject(objectName, _result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #19
0
 public static object _CreateZARSwap(string objectName,
                                     object[,] startDate,
                                     object[,] tenor,
                                     object[,] rate,
                                     object[,] payFixed,
                                     object[,] notional)
 {
     try
     {
         var _startDate = XU.GetDate0D(startDate, "startDate");
         var _tenor     = XU.GetSpecialType0D <Tenor>(tenor, "tenor");
         var _rate      = XU.GetDouble0D(rate, "rate");
         var _payFixed  = XU.GetBoolean0D(payFixed, "payFixed");
         var _notional  = XU.GetDouble0D(notional, "notional");
         var _result    = XLRates.CreateZARSwap(_startDate, _tenor, _rate, _payFixed, _notional);
         return(XU.AddObject(objectName, _result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #20
0
 public static object _CreateFixedLeg(string objectName,
                                      object[,] currency,
                                      object[,] paymentDates,
                                      object[,] notionals,
                                      object[,] rates,
                                      object[,] accrualFractions)
 {
     try
     {
         var _currency         = XU.GetSpecialType0D <Currency>(currency, "currency");
         var _paymentDates     = XU.GetDate1D(paymentDates, "paymentDates");
         var _notionals        = XU.GetDouble1D(notionals, "notionals");
         var _rates            = XU.GetDouble1D(rates, "rates");
         var _accrualFractions = XU.GetDouble1D(accrualFractions, "accrualFractions");
         var _result           = XLRates.CreateFixedLeg(_currency, _paymentDates, _notionals, _rates, _accrualFractions);
         return(XU.AddObject(objectName, _result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #21
0
 public static object _CreateFXForecastCurve(string objectName,
                                             object[,] baseCurrency,
                                             object[,] counterCurrency,
                                             object[,] fxRateAtAnchorDate,
                                             object[,] baseCurrencyFXBasisCurve,
                                             object[,] counterCurrencyFXBasisCurve)
 {
     try
     {
         Currency           _baseCurrency                = XU.GetCurrency0D(baseCurrency, "baseCurrency");
         Currency           _counterCurrency             = XU.GetCurrency0D(counterCurrency, "counterCurrency");
         Double             _fxRateAtAnchorDate          = XU.GetDouble0D(fxRateAtAnchorDate, "fxRateAtAnchorDate");
         IDiscountingSource _baseCurrencyFXBasisCurve    = XU.GetObject0D <IDiscountingSource>(baseCurrencyFXBasisCurve, "baseCurrencyFXBasisCurve");
         IDiscountingSource _counterCurrencyFXBasisCurve = XU.GetObject0D <IDiscountingSource>(counterCurrencyFXBasisCurve, "counterCurrencyFXBasisCurve");
         Object             _result = XLFX.CreateFXForecastCurve(_baseCurrency, _counterCurrency, _fxRateAtAnchorDate, _baseCurrencyFXBasisCurve, _counterCurrencyFXBasisCurve);
         return(XU.AddObject(objectName, _result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #22
0
 public static object _CreateLoanFloatingRate(string objectName,
                                              object[,] currency,
                                              object[,] balanceDates,
                                              object[,] balanceAmounts,
                                              object[,] floatingIndex,
                                              object[,] floatingSpread)
 {
     try
     {
         var _currency       = XU.GetSpecialType0D <Currency>(currency, "currency");
         var _balanceDates   = XU.GetDate1D(balanceDates, "balanceDates");
         var _balanceAmounts = XU.GetDouble1D(balanceAmounts, "balanceAmounts");
         var _floatingIndex  = XU.GetSpecialType0D <FloatingIndex>(floatingIndex, "floatingIndex");
         var _floatingSpread = XU.GetDouble0D(floatingSpread, "floatingSpread");
         var _result         = XLRates.CreateLoanFloatingRate(_currency, _balanceDates, _balanceAmounts, _floatingIndex,
                                                              _floatingSpread);
         return(XU.AddObject(objectName, _result));
     }
     catch (Exception e)
     {
         return(XU.Error0D(e));
     }
 }
Пример #23
0
 public static object[,] _PFE(object[,] products,
                              object[,] valueDate,
                              object[,] forwardValueDates,
                              object[,] requiredPecentiles,
                              object[,] model,
                              object[,] nSims)
 {
     try
     {
         var _products           = XU.GetObject1D <Product>(products, "products");
         var _valueDate          = XU.GetDate0D(valueDate, "valueDate");
         var _forwardValueDates  = XU.GetDate1D(forwardValueDates, "forwardValueDates");
         var _requiredPecentiles = XU.GetDouble1D(requiredPecentiles, "requiredPecentiles");
         var _model  = XU.GetObject0D <NumeraireSimulator>(model, "model");
         var _nSims  = XU.GetInt320D(nSims, "nSims");
         var _result = XLValuation.PFE(_products, _valueDate, _forwardValueDates, _requiredPecentiles, _model,
                                       _nSims);
         return(XU.ConvertToObjects(_result));
     }
     catch (Exception e)
     {
         return(XU.Error2D(e));
     }
 }