From ac05d0d69e546037b1ecc3e0bf5dab1fbedcfee5 Mon Sep 17 00:00:00 2001 From: Taha Date: Wed, 14 Jun 2023 13:54:53 -0400 Subject: [PATCH] AutoFitter reads the settings from the settings now --- .../AW2/Bus/SingleVolSurfaceAutoFitSource.cs | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/client/spark/AW2/Bus/SingleVolSurfaceAutoFitSource.cs b/src/client/spark/AW2/Bus/SingleVolSurfaceAutoFitSource.cs index 25e3db25d..f9ae0c326 100644 --- a/src/client/spark/AW2/Bus/SingleVolSurfaceAutoFitSource.cs +++ b/src/client/spark/AW2/Bus/SingleVolSurfaceAutoFitSource.cs @@ -33,7 +33,7 @@ namespace mbts.spark { private void _on_bb_data(object tag, object data) { if (tag.Equals(_vs_input_tag)) - _do_periodic_auto_fit(); + _possibly_autofit(); else if (tag.Equals(_vs_calc_response_tag)) { VolSurfaceCalculationResponse calc_resp = data as VolSurfaceCalculationResponse; bts.Log.Gen.info($"SingleVolSurfaceAutoFitSource._on_bb_data vs_id: {_vs_id} " + @@ -44,10 +44,10 @@ namespace mbts.spark { } private void _on_bb_timer() { - _do_periodic_auto_fit(); + _possibly_autofit(); } - private void _do_periodic_auto_fit() { + private void _possibly_autofit() { var auto_fit_period = _get_auto_fit_periodic(); if (!auto_fit_period.HasValue) return; @@ -60,8 +60,24 @@ namespace mbts.spark { } private Nullable _get_auto_fit_periodic() { - // TODO, get it from vs input - return TimeSpan.FromSeconds(30); + VolSurfaceInput vs_input = _bb.read_state(_vs_input_tag); + if (vs_input == null) + return null; + var fit_settings = + VolSurfaceDataFunctions.get_market_fit_settings(vs_input.surface_settings); + if (fit_settings == null) + return null; + var auto_fit_setting = fit_settings.vs_auto_fit_settings; + if (auto_fit_setting == null) + return null; + if (auto_fit_setting.auto_fit_region == VolSurfaceEnums.VolCurveFitRegion.None) + return null; + var time_based_fit_setting = auto_fit_setting.time_based_settings; + if (time_based_fit_setting == null) + return null; + if (!time_based_fit_setting.period_seconds.HasValue) + return null; + return TimeSpan.FromSeconds(time_based_fit_setting.period_seconds.Value); } private void _send_request() {