public Vector3 ProcessSmoothing(SmoothingTypes type, float factor, Vector3 vec) { Init(); if (_dataSmoothing == null) { SenseToolkitManager.Instance.SenseManager.session.CreateImpl <PXCMDataSmoothing>(out _dataSmoothing); } if (_smoother3D == null || _type3D != type || factor != _factor3D) { if (_smoother3D != null) { _smoother3D.Dispose(); } CreateSmootherType(type, factor, out _smoother3D); _type3D = type; _factor3D = factor; } PXCMPoint3DF32 point = new PXCMPoint3DF32() { x = vec.x, y = vec.y, z = vec.z }; _smoother3D.AddSample(point); point = _smoother3D.GetSample(); return(new Vector3(point.x, point.y, point.z)); }
public float ProcessSmoothing(SmoothingTypes type, float factor, float sample) { Init(); if (_smoother == null) { SenseToolkitManager.Instance.SenseManager.session.CreateImpl <PXCMSmoother>(out _smoother); } if (_smoother1D == null || _type1D != type || factor != _factor1D) { if (_smoother1D != null) { _smoother1D.Dispose(); } CreateSmootherType(type, factor, out _smoother1D); _type1D = type; _factor1D = factor; } if (_smoother1D != null) { sample = _smoother1D.SmoothValue(sample); } return(sample); }
public Vector2 ProcessSmoothing(SmoothingTypes type, float factor, Vector2 vec) { Init(); if (_smoother == null) { SenseToolkitManager.Instance.SenseManager.session.CreateImpl <PXCMSmoother>(out _smoother); } if (_smoother2D == null || _type2D != type || factor != _factor2D) { if (_smoother2D != null) { _smoother2D.Dispose(); } CreateSmootherType(type, factor, out _smoother2D); _type2D = type; _factor2D = factor; } PXCMPointF32 point = new PXCMPointF32() { x = vec.x, y = vec.y }; point = _smoother2D.SmoothValue(point); return(new Vector2(point.x, point.y)); }
public Quaternion ProcessSmoothing(SmoothingTypes type, float factor, Quaternion vec) { Init(); Vector3 vec3 = new Vector3(vec.x, vec.y, vec.z); vec3 = ProcessSmoothing(type, factor, vec3); float w = vec.w; w = ProcessSmoothing(type, factor, w); return(new Quaternion(vec3.x, vec3.y, vec3.z, w)); }
private void CreateSmootherType(SmoothingTypes type, float factor, out PXCMDataSmoothing.Smoother1D smoother) { switch (type) { case SmoothingTypes.Quadratic: smoother = _dataSmoothing.Create1DQuadratic(factor); break; case SmoothingTypes.Stabilizer: smoother = _dataSmoothing.Create1DStabilizer(7, factor); break; case SmoothingTypes.Weighted: smoother = _dataSmoothing.Create1DWeighted((int)factor); break; case SmoothingTypes.Spring: default: smoother = _dataSmoothing.Create1DSpring(factor); break; } }
public Quaternion ProcessSmoothing(SmoothingTypes type, float factor, Quaternion vec) { Init(); Vector3 vec3 = new Vector3(vec.x, vec.y, vec.z); vec3 = ProcessSmoothing(type, factor, vec3); float w = vec.w; w = ProcessSmoothing(type, factor, w); return new Quaternion(vec3.x, vec3.y, vec3.z, w); }
public float ProcessSmoothing(SmoothingTypes type, float factor, float sample) { Init(); if (_dataSmoothing == null) { SenseToolkitManager.Instance.SenseManager.session.CreateImpl<PXCMDataSmoothing>(out _dataSmoothing); } if (_smoother1D == null || _type1D != type || factor != _factor1D) { if (_smoother1D != null) { _smoother1D.Dispose(); } CreateSmootherType(type, factor, out _smoother1D); _type1D = type; _factor1D = factor; } _smoother1D.AddSample(sample); sample = _smoother1D.GetSample(); return sample; }
public Vector2 ProcessSmoothing(SmoothingTypes type, float factor, Vector2 vec) { Init(); if (_dataSmoothing == null) { SenseToolkitManager.Instance.SenseManager.session.CreateImpl<PXCMDataSmoothing>(out _dataSmoothing); } if (_smoother2D == null || _type2D != type || factor != _factor2D) { if (_smoother2D != null) { _smoother2D.Dispose(); } CreateSmootherType(type, factor, out _smoother2D); _type2D = type; _factor2D = factor; } PXCMPointF32 point = new PXCMPointF32(){x = vec.x, y = vec.y}; _smoother2D.AddSample(point); point = _smoother2D.GetSample(); return new Vector2(point.x, point.y); }
//------------------------------------------------------------------------------------------------ // Copy constructor public FuturesSeriesBuilder(FuturesSeriesBuilder copy2clone) //------------------------------------------------------------------------------------------------ { // Copy constructor carbonEnv_ = copy2clone.carbonEnv_; futuresStaticMoniker_ = copy2clone.futuresStaticMoniker_; startDate_ = copy2clone.startDate_; endDate_ = copy2clone.endDate_; dateRange_ = copy2clone.dateRange_; holidays_ = copy2clone.holidays_; rollMethod_ = copy2clone.rollMethod_; inputTickers_ = copy2clone.inputTickers_; contractTickers_ = copy2clone.contractTickers_; RollingContractSpecs_ = copy2clone.RollingContractSpecs_; ContractMonthLookupTable_ = copy2clone.ContractMonthLookupTable_; interpType_ = copy2clone.interpType_; contractSortOrder_ = copy2clone.contractSortOrder_; smoothingType_ = copy2clone.smoothingType_; FuturesStatic = copy2clone.FuturesStatic == null ? null : copy2clone.FuturesStatic.Clone(); RawFuturesPrices = copy2clone.RawFuturesPrices == null? null: copy2clone.RawFuturesPrices.Clone(); RollingFuturesData = copy2clone.RollingFuturesData == null? null: copy2clone.RollingFuturesData.Clone(); }
// Allows intialisation code reuse //------------------------------------------------------------------------------------------------ private void initFutureSeriesBuilder(List<string> tickers, List<DateTime> daterange, List<DateTime> holidays, string futuresStaticMoniker, ICarbonClient client, string carbonEnv = "PRD", RollMethods rolMthd = RollMethods.FirstNoticeDate, InterpolationTypes interpType = InterpolationTypes.None, List<string> contractSortOrder = null , Dictionary<string,DateTime> rollmap = null, SmoothingTypes smoothingType = SmoothingTypes.None) //------------------------------------------------------------------------------------------------ { // defaults dateRange_ = daterange; startDate_ = daterange.Min(); endDate_ = daterange.Max(); carbonEnv_ = carbonEnv; rollMethod_ = rolMthd; //RollMethods.LastTradeDate; // holidays_ = holidays; futuresStaticMoniker_ = futuresStaticMoniker; interpType_ = interpType; smoothingType_ = smoothingType; if (contractSortOrder == null) { contractSortOrder_ = new List<string>(); } else { contractSortOrder_ = contractSortOrder; } if (rolMthd == RollMethods.Custom && rollmap == null) { throw new ArgumentException("Custom roll dates required for custom rolls!"); } ContractMonthLookupTable_ = new Dictionary<ContractMonths, string> { {ContractMonths.PrevFrontMonth, "PrevFront"}, {ContractMonths.FrontMonth, "Front"}, {ContractMonths.BackMonth, "Back"}, {ContractMonths.SecondBackMonth, "SecondBack"} }; Tuple<List<Tuple<string, ContractMonths>> /*rootTickers*/, List<string> /*contracts*/> tickerListTuple; // Get Static FuturesStatic = getFuturesStatic(tickers, futuresStaticMoniker, client, carbonEnv, out tickerListTuple, startDate_, endDate_, contractSortOrder_); // Add custom roll if present if (rollmap != null) { var sb = new SeriesBuilder<string,DateTime>(); foreach (var kvp in rollmap) { sb.Add(kvp.Key, kvp.Value); } FuturesStatic.AddColumn("custom_roll", sb.Series); } inputTickers_ = tickers; contractTickers_ = tickerListTuple.Item2; RollingContractSpecs_ = tickerListTuple.Item1; var contracts = FuturesStatic.RowKeys.ToList(); // get all the tickers (in case no tickers supplied // Get prices Console.WriteLine("Getting Futures prices"); RawFuturesPrices = getAllFuturesPricesInDateRange(contracts, startDate_, endDate_, client); RawFuturesPrices.Print(); // Align Futures Prices & interpolate gaps alignRawPriceFrameWithDateRange(dateRange_); //interpolateRawPriceFrame(interpType_); }
//------------------------------------------------------------------------------------------------ public FuturesSeriesBuilder(List<string> tickers, List<DateTime> daterange, List<DateTime> holidays, string futuresStaticMoniker, ICarbonClient client, string carbonEnv = "PRD", RollMethods rollMthd = RollMethods.FirstNoticeDate, InterpolationTypes interpType = InterpolationTypes.None, List<string> contractSortOrder = null, Dictionary<string,DateTime> rollmap = null, SmoothingTypes smoothingType = SmoothingTypes.None) //------------------------------------------------------------------------------------------------ { initFutureSeriesBuilder(tickers, daterange, holidays, futuresStaticMoniker, client, carbonEnv, rollMthd, interpType, contractSortOrder, rollmap, smoothingType); }
//------------------------------------------------------------------------------------------------ public FuturesSeriesBuilder(List<string> tickers, DateTime start, DateTime end, string calendarCode, string futuresStaticMoniker, ICarbonClient client, string carbonEnv = "PRD", RollMethods rollMthd = RollMethods.FirstNoticeDate, InterpolationTypes interpType = InterpolationTypes.None, List<string> contractSortOrder = null , Dictionary<string,DateTime> rollmap = null, SmoothingTypes smoothingType = SmoothingTypes.None) //------------------------------------------------------------------------------------------------ { // defaults startDate_ = start; endDate_ = end; carbonEnv_ = carbonEnv; rollMethod_ = rollMthd; //RollMethods.FirstNoticeDate; smoothingType_ = smoothingType; futuresStaticMoniker_ = futuresStaticMoniker; // Holidays holidays_ = new List<DateTime>(); if (calendarCode != "") { var nodaHols = client.GetCalendarAsync(calendarCode).Result.Dates; foreach (LocalDate hol in nodaHols) { holidays_.Add(hol.ToDateTime()); } } // DateRange dateRange_ = new List<DateTime>(); LocalDate currentDate = client.RollDateAsync(DateUtils.ToLocalDate(startDate_), 0, DateUnit.Bd, BusinessDayConvention.Following, calendarCode).Result; LocalDate endDate = DateUtils.ToLocalDate(endDate_); while (currentDate <= endDate) { dateRange_.Add(DateUtils.ToDateTime(currentDate)); currentDate = client.RollDateAsync(currentDate, 1, DateUnit.Bd, BusinessDayConvention.Following, calendarCode).Result; } initFutureSeriesBuilder(tickers, dateRange_, holidays_, futuresStaticMoniker_, client, carbonEnv, rollMthd, interpType, contractSortOrder); }
public Vector3 ProcessSmoothing(SmoothingTypes type, float factor, Vector3 vec) { Init(); if (_smoother == null) { SenseToolkitManager.Instance.SenseManager.session.CreateImpl<PXCMSmoother>(out _smoother); } if (_smoother3D == null || _type3D != type || factor != _factor3D) { if (_smoother3D != null) { _smoother3D.Dispose(); } CreateSmootherType(type, factor, out _smoother3D); _type3D = type; _factor3D = factor; } PXCMPoint3DF32 point = new PXCMPoint3DF32() { x = vec.x, y = vec.y, z = vec.z }; if (_smoother3D != null) point = _smoother3D.SmoothValue(point); return new Vector3(point.x, point.y, point.z); }