public static object MortgageLoan_create(
     [ExcelArgument(Description = @"Balance Notional")] double Balance,
     [ExcelArgument(Description = @"Loan Rate")] double Rate,
     [ExcelArgument(Description = @"Loan Spread, Zero if It is a Fixed Rate Loan")]   double Spread,
     [ExcelArgument(Description = @"Maturity Period")] int Maturity,
     [ExcelArgument(Description = @"Rate Resetting Period, the same as Maturity if it is a Fixed Rate Loan")] int Resetting,
     [ExcelArgument(Description = @"Fixed (Fixed) or ARM (ARM)")] string FixedOrARM,
     [ExcelArgument(Description = @"Principal and Interest (PI) or Interest Only (IO)")] string PIOrIO,
     [ExcelArgument(Description = @"Libor Curve as an name")] string LiborCurve)
 {
     if (ExcelDnaUtil.IsInFunctionWizard())
     {
         return(ExcelError.ExcelErrorRef);
     }
     else
     {
         return(GlobalCache.CreateHandle(m_tag, new object[] { Balance, Rate, Spread, Maturity, Resetting, FixedOrARM, PIOrIO, LiborCurve, "MortgageLoan_create" },
                                         (objectType, parameters) =>
         {
             IMortgageLoan loan = construct_loan(Balance, Rate, Spread, Maturity, Resetting, FixedOrARM, PIOrIO, LiborCurve);
             if (loan == null)
             {
                 return ExcelError.ExcelErrorNull;
             }
             else
             {
                 return loan;
             }
         }));
     }
 }
        public static object LiborCurve_create([ExcelArgument(Description = @"Libor Curve as an array")] double[] Libor_Array_)
        {
            if (ExcelDnaUtil.IsInFunctionWizard())
            {
                return(ExcelError.ExcelErrorRef);
            }
            else
            {
                // Libor Curve
                int len = Libor_Array_.Length;
                Debug.Assert(len <= GlobalVar.GlobalMaxMortgageLoanMaturity, "Libor Curve should be EXACTLY of 360 data points" + GlobalVar.GlobalMaxMortgageLoanMaturity);

                return(GlobalCache.CreateHandle(m_tagLibor, new object[] { Libor_Array_, len, "LiborCurve_create" },
                                                (objectType, parameters) =>
                {
                    LiborRates BoERate_Array = construct_LiborCurve(Libor_Array_);
                    if (BoERate_Array == null)
                    {
                        return ExcelError.ExcelErrorNull;
                    }
                    else
                    {
                        return BoERate_Array;
                    }
                }));
            }
        }
예제 #3
0
        public static object SampleOption(
            [ExcelArgument("is whether the instrument is a call (c) or a put (p).",
                           Name = "call_put_flag")] string callPutFlag)
        {
            if (ExcelDnaUtil.IsInFunctionWizard())
            {
                return(ExcelError.ExcelErrorRef);
            }

            callPutFlag = callPutFlag == "p" ? "put" : "call";


            string optName = callPutFlag;


            var ret = GlobalCache.CreateHandle(nameof(SampleOption), new object[] { optName },
                                               (objectType, parameters) =>
            {
                try
                {
                    var instance = TradeFactory.GetInstanceAsync.Task.Result;
                    var option   = instance.EuropeanMonthlyPowerOption(optName).Result;
                    return(option);
                }
                catch (Exception e)
                {
                    return(new object[, ] {
                        { "!Exception! : " + e.Message }
                    });
                }
            });

            if (Equals(ret, ExcelError.ExcelErrorNA))
            {
                return(new object[, ] {
                    { "! WAIT !" }
                });
            }

            return(ret);
        }