/// <summary> /// Gets the Last trading day by year. This takes an array of years. /// </summary> /// <param name="exchangeCommodityName">Name of the exchange commodity.</param> /// <param name="yearsArray">The array of years as integers.</param> /// <param name="mainCycle">if set to <c>true</c> [main cycle].</param> /// <returns>A range of dates.</returns> public object[,] LastTradingDayByYear(string exchangeCommodityName, Excel.Range yearsArray, Boolean mainCycle) { List <int> unqVals = DataRangeHelper.StripIntRange(yearsArray); var dates = LastTradingDayHelper.GetLastTradingDays(exchangeCommodityName, unqVals.ToArray(), mainCycle); var resVals = RangeHelper.ConvertArrayToRange(dates); return(resVals); }
/// <summary> /// Gets the Last trading based on a given month. /// </summary> /// <param name="exchangeCommodityName">Name of the exchange commodity.</param> /// <param name="monthsArray">The array of months.</param> /// <param name="yearsArray">The array of years as integers.</param> /// <returns></returns> public object[,] LastTradingDayByMonth(string exchangeCommodityName, Excel.Range monthsArray, Excel.Range yearsArray) { List <int> unqMonths = DataRangeHelper.StripIntRange(monthsArray); List <int> unqYears = DataRangeHelper.StripIntRange(yearsArray); List <DateTime> dates = LastTradingDayHelper.GetLastTradingDays(exchangeCommodityName, unqMonths.ToArray(), unqYears.ToArray()); var resVals = RangeHelper.ConvertArrayToRange(dates); return(resVals); }
///<summary> ///</summary> ///<param name="ratedaysAsArray"></param> ///<param name="rateamtsAsArray"></param> ///<param name="divdaysAsArray"></param> ///<param name="divamtsAsArray"></param> ///<param name="voltimesAsArray"></param> ///<param name="volatilitiesAsRange"></param> ///<param name="spot"></param> ///<param name="callstrike"></param> ///<param name="putstrike"></param> ///<param name="maturity"></param> ///<param name="kappa"></param> ///<param name="theta"></param> ///<param name="sigma"></param> ///<param name="profiletimes"></param> ///<param name="confidence"></param> ///<param name="tstepSize"></param> ///<param name="simulations"></param> ///<param name="seed"></param> ///<returns></returns> public double[,] GetCollarPCE(Excel.Range ratedaysAsArray, Excel.Range rateamtsAsArray, Excel.Range divdaysAsArray, Excel.Range divamtsAsArray, Excel.Range voltimesAsArray, Excel.Range volatilitiesAsRange, double spot, double callstrike, double putstrike, double maturity, double kappa, double theta, double sigma, Excel.Range profiletimes, double confidence, double tstepSize, int simulations, int seed) { //Map Ranges var rateamts = DataRangeHelper.StripDoubleRange(rateamtsAsArray); var divamts = DataRangeHelper.StripDoubleRange(divamtsAsArray); var voltimes = DataRangeHelper.StripDoubleRange(voltimesAsArray); var divdays = DataRangeHelper.StripIntRange(divdaysAsArray); var ratedays = DataRangeHelper.StripIntRange(ratedaysAsArray); var profile = DataRangeHelper.StripDoubleRange(profiletimes); var volatilities = volatilitiesAsRange.Value[System.Reflection.Missing.Value] as object[, ]; var volatilitiesAsDoubles = RangeHelper.RangeToDoubleMatrix(volatilities); List <OrcWingParameters> volSurf = UnpackWing(volatilitiesAsDoubles, voltimes.ToArray(), spot, ratedays.ToArray(), rateamts.ToArray(), divdays.ToArray(), divamts.ToArray()); CleanDivs(ref divdays, ref divamts); double[,] results = EquityPCEAnalytics.GetCollarPCE("CollarPCE", ratedays.ToArray(), rateamts.ToArray(), divdays.ToArray(), divamts.ToArray(), volSurf, spot, callstrike, putstrike, maturity, kappa, theta, sigma, profile.ToArray(), confidence, tstepSize, simulations, seed); //int n = profiletimes.Length; //var lhs = new double[profiletimes.Length]; //for (int i = 0; i < n; i++) //{ // lhs[i] = results[i, 1]; //} return(results); }