From fddcb585550f7820862ff0b705923c8f3dc331a7 Mon Sep 17 00:00:00 2001 From: Taha Afzal Date: Fri, 11 Feb 2022 12:03:44 -0500 Subject: [PATCH] Getting rid of the TheoPoint that got moved over with TC2 --- .../NMSheetSingleOptionData.cs | 28 +- .../NMSheetSingleOptionDataTaskEye.cs | 4 +- .../NMSheetSingleOptionDataTaskQuoter.cs | 4 +- .../NMSheetSingleOptionMainDataSource.cs | 50 ++-- .../spark/NMSheets/Outside/BBOPacket.cs | 8 +- .../NMSheets/Outside/ExchangeSecurityMap.cs | 10 +- .../spark/NMSheets/Outside/TheoPoint.cs | 279 ------------------ src/client/spark/NMSheets/Outside/TheoTags.cs | 6 - .../NMSheets/Outside/TradeAndPositionTags.cs | 11 - .../tc2/Calculator2/MainForm/ATM/ATMData.cs | 49 ++- .../MainForm/ATM/OptionATMDataSource.cs | 16 +- 11 files changed, 82 insertions(+), 383 deletions(-) delete mode 100644 src/client/spark/NMSheets/Outside/TheoPoint.cs diff --git a/src/client/spark/NMSheets/BlackboardStructure/NMSheetSingleOptionData.cs b/src/client/spark/NMSheets/BlackboardStructure/NMSheetSingleOptionData.cs index cb6b05df5..4b405e08e 100644 --- a/src/client/spark/NMSheets/BlackboardStructure/NMSheetSingleOptionData.cs +++ b/src/client/spark/NMSheets/BlackboardStructure/NMSheetSingleOptionData.cs @@ -18,7 +18,7 @@ namespace BCG { public partial class NMSheetSingleOptionData { private readonly NMSheetSymbol _nmsheet_option; private readonly NMSheetDataRequest _data_request; - private readonly ExpStrikeKeyedData> _theo_data_map = new ExpStrikeKeyedData>(); + private readonly ExpStrikeKeyedData> _theo_data_map = new ExpStrikeKeyedData>(); private readonly Dictionary _option_exp_driver_data; private readonly OptionContractKeyedData _theo_shift_map; private readonly IDictionary _atm_data_map; @@ -35,7 +35,7 @@ namespace BCG { public NMSheetSingleOptionData(NMSheetSymbol option, NMSheetDataRequest data_request, - ExpStrikeKeyedData> theo_data_map, + ExpStrikeKeyedData> theo_data_map, Dictionary option_exp_driver_data, OptionContractKeyedData theo_shift_map, IDictionary atm_data, @@ -63,8 +63,8 @@ namespace BCG { } public static NMSheetSingleOptionData filter_data(NMSheetSingleOptionData data, HashSet seckey_map) { - ExpStrikeKeyedData> theo_data_map = new ExpStrikeKeyedData>(); - foreach (Triplet> t in data._theo_data_map.get_data_linearly()) + ExpStrikeKeyedData> theo_data_map = new ExpStrikeKeyedData>(); + foreach (Triplet> t in data._theo_data_map.get_data_linearly()) if (seckey_map.Contains(t.third.second) || seckey_map.Contains(t.third.third)) theo_data_map.set_data(t.first, t.second, t.third); HashSet exp_map = new HashSet(theo_data_map.get_expirations().Select(exp => new NMSheetExpiration(data._nmsheet_option.option_exchange, data._nmsheet_option.option_name, exp))); @@ -85,7 +85,7 @@ namespace BCG { HashSet filtered_keys = new HashSet(); foreach (var t in _theo_data_map.get_data_linearly()) { var trp = t.third; - mbts.TheoPoint tp = trp.first; + mbts.spark.TheoPoint tp = trp.first; uint call_key = trp.second, put_key = trp.third; // call side BBOPacket call_bbo = _bbo_data_map.TryGetValue(call_key, out call_bbo) ? call_bbo : null; @@ -118,7 +118,7 @@ namespace BCG { public bool security_exist(DateTime expiration, double strike) { return _theo_data_map.get_data(expiration, strike) != null; } public bool get_security_key(DateTime exp, double strike, bool is_call, out uint security_key) { - Triplet t = _theo_data_map.get_data(exp, strike); + Triplet t = _theo_data_map.get_data(exp, strike); security_key = t != null ? (security_key = is_call ? t.second : t.third) : ExchangeSecurityMap.error_key; return security_key != ExchangeSecurityMap.error_key; } @@ -126,8 +126,8 @@ namespace BCG { #region Putting data together (Join) public bool get_row_data(DateTime expiration, double strike, ref double[] cp_row, out NMSheetRowAuxiliaryData aux_data) { - Triplet tp_with_seckey = _theo_data_map.get_data(expiration, strike); - mbts.TheoPoint v = tp_with_seckey == null ? null : tp_with_seckey.first; + Triplet tp_with_seckey = _theo_data_map.get_data(expiration, strike); + mbts.spark.TheoPoint v = tp_with_seckey == null ? null : tp_with_seckey.first; if (v != null) { Tuple driver_bid_ask = _option_exp_driver_detailed_price_data.TryGetValue(expiration, out driver_bid_ask) ? driver_bid_ask : Tuple.Create(Double.NaN, Double.NaN); _fill_theo(v, expiration, strike, cp_row); @@ -153,7 +153,7 @@ namespace BCG { } } - private static void _fill_theo(mbts.TheoPoint v, DateTime exp, double strike, double[] row) { + private static void _fill_theo(mbts.spark.TheoPoint v, DateTime exp, double strike, double[] row) { row[(int)NMSheetColumnName.call_theo] = v.call; row[(int)NMSheetColumnName.put_theo] = v.put; row[(int)NMSheetColumnName.call_delta] = v.cdelta; @@ -168,7 +168,7 @@ namespace BCG { row[(int)NMSheetColumnName.standard_strike] = v.standard_strike; } - private void _fill_cross_alert(BBOPacket c_bbo, BBOPacket p_bbo, double[] data_row, mbts.TheoPoint tp, out NMSheetCallPutWrapper cross_data) { + private void _fill_cross_alert(BBOPacket c_bbo, BBOPacket p_bbo, double[] data_row, mbts.spark.TheoPoint tp, out NMSheetCallPutWrapper cross_data) { double call_theo, put_theo; bool is_proximity_alert_enabled = _settings.setting_alerts.n_proximity_alert_max_ticks > 0; if (_settings.setting_alerts.use_quoteset_mid_for_cross_alerts.Value) { @@ -217,7 +217,7 @@ namespace BCG { } #region Presave Theos - private void _fill_presave_theos(double[] cp_row, mbts.TheoPoint tp, DateTime option_exp, double option_strike) { + private void _fill_presave_theos(double[] cp_row, mbts.spark.TheoPoint tp, DateTime option_exp, double option_strike) { if (_presaved_aw2_theos != null) { mbts.analytics.Theos theos = _presaved_aw2_theos.get_data(option_exp, option_strike); if (theos != null) { @@ -260,7 +260,7 @@ namespace BCG { } #endregion - private void _fill_roll_over_data(double[] cp_row, mbts.TheoPoint tp, DateTime exp, double strike) { + private void _fill_roll_over_data(double[] cp_row, mbts.spark.TheoPoint tp, DateTime exp, double strike) { PNLRollOverDataUnit u; if (_roll_over_data != null && (u = _roll_over_data.getValue(exp, strike, true)) != null) { cp_row[(int)NMSheetColumnName.vol_change] = tp.vol - u.vol; @@ -273,14 +273,14 @@ namespace BCG { #endregion - private static double _compute_theo(mbts.TheoPoint tp, bool is_call, double driver) { + private static double _compute_theo(mbts.spark.TheoPoint tp, bool is_call, double driver) { if (is_call) return mbts.analytics.VolSurfaceCoreFunctions.compute_theo_at_nearbydriver(tp.driver, tp.call, tp.cdelta, tp.cgamma, driver); else return mbts.analytics.VolSurfaceCoreFunctions.compute_theo_at_nearbydriver(tp.driver, tp.put, tp.pdelta, tp.pgamma, driver); } - private static double _compute_theo(mbts.TheoPoint tp, PutOrCall cp, Side side, Tuple driver_bid_ask) { + private static double _compute_theo(mbts.spark.TheoPoint tp, PutOrCall cp, Side side, Tuple driver_bid_ask) { double effective_driver = ((cp == PutOrCall.Call && side == Side.Buy) || (cp == PutOrCall.Put && side == Side.Sell)) ? driver_bid_ask.Item1 : driver_bid_ask.Item2; if (cp == PutOrCall.Call) return mbts.analytics.VolSurfaceCoreFunctions.compute_theo_at_nearbydriver(tp.driver, tp.call, tp.cdelta, tp.cgamma, effective_driver); diff --git a/src/client/spark/NMSheets/BlackboardStructure/NMSheetSingleOptionDataTaskEye.cs b/src/client/spark/NMSheets/BlackboardStructure/NMSheetSingleOptionDataTaskEye.cs index 35531b6be..38136d8e7 100644 --- a/src/client/spark/NMSheets/BlackboardStructure/NMSheetSingleOptionDataTaskEye.cs +++ b/src/client/spark/NMSheets/BlackboardStructure/NMSheetSingleOptionDataTaskEye.cs @@ -4,7 +4,7 @@ using bts.api; namespace BCG { public partial class NMSheetSingleOptionData { - private void _fill_eye_data(Triplet tp_with_seckeys, Tuple driver_bid_ask, BBOPacket call_bbo, BBOPacket put_bbo, + private void _fill_eye_data(Triplet tp_with_seckeys, Tuple driver_bid_ask, BBOPacket call_bbo, BBOPacket put_bbo, ref double[] cp_row, out NMSheetCallPutBidAskWrapper out_eye_data) { NMSheetTaskEyeData call_bid_data, call_ask_data, put_bid_data, put_ask_data; _get_eye_security_side_data(tp_with_seckeys.first, PutOrCall.Call, Side.Buy, tp_with_seckeys.second, driver_bid_ask, call_bbo, out call_bid_data, ref cp_row, @@ -18,7 +18,7 @@ namespace BCG { out_eye_data = new NMSheetCallPutBidAskWrapper(call_bid_data, call_ask_data, put_bid_data, put_ask_data); } - private void _get_eye_security_side_data(mbts.TheoPoint tp, PutOrCall cp, Side side, uint sec_key, Tuple driver_bid_ask, BBOPacket bbo, + private void _get_eye_security_side_data(mbts.spark.TheoPoint tp, PutOrCall cp, Side side, uint sec_key, Tuple driver_bid_ask, BBOPacket bbo, out NMSheetTaskEyeData inp_out_data, ref double[] out_array, NMSheetColumnName inp_edge_col, NMSheetColumnName inp_size_col, NMSheetColumnName eye_price_col) { diff --git a/src/client/spark/NMSheets/BlackboardStructure/NMSheetSingleOptionDataTaskQuoter.cs b/src/client/spark/NMSheets/BlackboardStructure/NMSheetSingleOptionDataTaskQuoter.cs index ea37094a9..60b598965 100644 --- a/src/client/spark/NMSheets/BlackboardStructure/NMSheetSingleOptionDataTaskQuoter.cs +++ b/src/client/spark/NMSheets/BlackboardStructure/NMSheetSingleOptionDataTaskQuoter.cs @@ -4,7 +4,7 @@ using bts.api; namespace BCG { public partial class NMSheetSingleOptionData { - private void _fill_quoter_data(Triplet tp_with_seckeys, Tuple driver_bid_ask, double[] cp_row, out NMSheetCallPutBidAskWrapper out_quoter_data) { + private void _fill_quoter_data(Triplet tp_with_seckeys, Tuple driver_bid_ask, double[] cp_row, out NMSheetCallPutBidAskWrapper out_quoter_data) { NMSheetTaskQuoterData call_bid_data, call_ask_data, put_bid_data, put_ask_data; _get_quoter_security_side_data(tp_with_seckeys.first, PutOrCall.Call, Side.Buy, tp_with_seckeys.second, driver_bid_ask, out call_bid_data, ref cp_row, NMSheetColumnName.call_quoter_set_bid_edge, NMSheetColumnName.call_quoter_set_bid_size, NMSheetColumnName.call_quoter_bid_price, NMSheetColumnName.call_quoter_bid_size); @@ -17,7 +17,7 @@ namespace BCG { out_quoter_data = new NMSheetCallPutBidAskWrapper(call_bid_data, call_ask_data, put_bid_data, put_ask_data); } - private void _get_quoter_security_side_data(mbts.TheoPoint tp, PutOrCall cp, Side side, uint sec_key, Tuple driver_bid_ask, + private void _get_quoter_security_side_data(mbts.spark.TheoPoint tp, PutOrCall cp, Side side, uint sec_key, Tuple driver_bid_ask, out NMSheetTaskQuoterData sheet_quoter_data, ref double[] out_array, NMSheetColumnName inp_edge_col, NMSheetColumnName inp_size_col, diff --git a/src/client/spark/NMSheets/DataProviders/NMSheetSingleOptionMainDataSource.cs b/src/client/spark/NMSheets/DataProviders/NMSheetSingleOptionMainDataSource.cs index 123f72d75..73a3d7585 100644 --- a/src/client/spark/NMSheets/DataProviders/NMSheetSingleOptionMainDataSource.cs +++ b/src/client/spark/NMSheets/DataProviders/NMSheetSingleOptionMainDataSource.cs @@ -78,13 +78,13 @@ namespace BCG { IDictionary> sym_presaved_aw2_theos = _threaded_bb.sec_thread_retrieve_from_cache(_in_bb_presaved_aw2_theos_tag) as IDictionary>; ExpStrikeKeyedData presaved_aw2_theos = (sym_presaved_aw2_theos != null && sym_presaved_aw2_theos.TryGetValue(_nmsheet_symbol, out presaved_aw2_theos)) ? presaved_aw2_theos : null; NMSheetSettings sheet_settings = (NMSheetSettings)_threaded_bb.sec_thread_retrieve_from_cache(_in_bb_sheet_settings_tag) ?? new NMSheetSettings(); - ExpStrikeKeyedData shared_live_theo_data_map = (ExpStrikeKeyedData)_threaded_bb.sec_thread_retrieve_from_cache(_in_bb_live_theos_tag); + ExpStrikeKeyedData shared_live_theo_data_map = (ExpStrikeKeyedData)_threaded_bb.sec_thread_retrieve_from_cache(_in_bb_live_theos_tag); if (data_request != null && live_driver_map != null && shared_live_theo_data_map != null) { - ExpStrikeKeyedData output_theo_data_map = _limit_to_requested_securities(shared_live_theo_data_map, data_request, sheet_settings); + ExpStrikeKeyedData output_theo_data_map = _limit_to_requested_securities(shared_live_theo_data_map, data_request, sheet_settings); output_theo_data_map = _adjust_for_freezes(output_theo_data_map, data_request); _add_vol_shift(output_theo_data_map); - ExpStrikeKeyedData> output_theo_key_data_map = _attach_sec_keys(output_theo_data_map); + ExpStrikeKeyedData> output_theo_key_data_map = _attach_sec_keys(output_theo_data_map); Dictionary option_exp_driver_data_map = _get_option_exp_driver_data_map(data_request, output_theo_data_map, shared_live_theo_data_map, live_driver_map); NMSheetSingleOptionData theo_data = new NMSheetSingleOptionData(_nmsheet_symbol, data_request, @@ -110,7 +110,7 @@ namespace BCG { return rv == null || (bool)rv; } - private ExpStrikeKeyedData _limit_to_requested_securities(ExpStrikeKeyedData theo_data, NMSheetDataRequest data_request, NMSheetSettings sheet_settings) { + private ExpStrikeKeyedData _limit_to_requested_securities(ExpStrikeKeyedData theo_data, NMSheetDataRequest data_request, NMSheetSettings sheet_settings) { HashSet selected_exp_map = new HashSet(); HashSet selected_strike_map = new HashSet(sheet_settings.setting_unselected_strikes); foreach (Triplet t in data_request.expiration_request_list) { @@ -121,23 +121,23 @@ namespace BCG { return theo_data.clone_filtered_set(selected_exp_map, true, selected_strike_map, false); } - private ExpStrikeKeyedData> _attach_sec_keys(ExpStrikeKeyedData theo_map) { - theo_map = theo_map ?? new ExpStrikeKeyedData(); + private ExpStrikeKeyedData> _attach_sec_keys(ExpStrikeKeyedData theo_map) { + theo_map = theo_map ?? new ExpStrikeKeyedData(); ExchangeSecurityMap sec_map = _threaded_bb.sec_thread_retrieve_from_cache(_in_bb_secmap_tag) as ExchangeSecurityMap; if (sec_map != null) return sec_map.attach_sec_keys(theo_map, _electronic_equivelant_symbol, _nmsheet_symbol.option_exchange); else { - ExpStrikeKeyedData> rv = new ExpStrikeKeyedData>(); - foreach (Triplet t in theo_map.get_data_linearly()) - rv.set_data(t.first, t.second, new Triplet(t.third, 0, 0)); + ExpStrikeKeyedData> rv = new ExpStrikeKeyedData>(); + foreach (Triplet t in theo_map.get_data_linearly()) + rv.set_data(t.first, t.second, new Triplet(t.third, 0, 0)); return rv; } } - private ExpStrikeKeyedData _adjust_for_freezes(ExpStrikeKeyedData live_theo_map, NMSheetDataRequest data_request) { + private ExpStrikeKeyedData _adjust_for_freezes(ExpStrikeKeyedData live_theo_map, NMSheetDataRequest data_request) { return live_theo_map; // TODO - // ExpStrikeKeyedData rv = new ExpStrikeKeyedData(); + // ExpStrikeKeyedData rv = new ExpStrikeKeyedData(); // OptionTheoInterpolationData interp_sparse_theo_data = (OptionTheoInterpolationData)_threaded_bb.sec_thread_retrieve_from_cache(_in_bb_precomputed_sparse_theos_tag); // foreach (Triplet t in data_request.expiration_request_list) { // NMSheetExpiration nm_exp = t.first; @@ -146,11 +146,11 @@ namespace BCG { // if (frozen) { // if (interp_sparse_theo_data != null) { // List strike_list_for_exp = live_theo_map.get_strike_list_for_expiration(nm_exp.option_expiration); - // Dictionary strike_theos = StatelessInterpolationCalculator.compute_theos(nm_exp.option_expiration, strike_list_for_exp, interp_sparse_theo_data, frozen_price); + // Dictionary strike_theos = StatelessInterpolationCalculator.compute_theos(nm_exp.option_expiration, strike_list_for_exp, interp_sparse_theo_data, frozen_price); // rv.set_data_for_expiration(nm_exp.option_expiration, strike_theos); // } // } else { - // IDictionary data_for_this_exp = live_theo_map.get_data_for_single_exp(nm_exp.option_expiration); + // IDictionary data_for_this_exp = live_theo_map.get_data_for_single_exp(nm_exp.option_expiration); // if (data_for_this_exp != null) // rv.set_data_for_expiration(nm_exp.option_expiration, data_for_this_exp); // } @@ -159,7 +159,7 @@ namespace BCG { } private Dictionary _get_option_exp_driver_data_map(NMSheetDataRequest data_request, - ExpStrikeKeyedData output_theo_data_map, ExpStrikeKeyedData shared_live_theo_data_map, + ExpStrikeKeyedData output_theo_data_map, ExpStrikeKeyedData shared_live_theo_data_map, Dictionary> live_driver_map) { Dictionary rv = new Dictionary(); foreach (Triplet theo_request in data_request.expiration_request_list) { @@ -175,15 +175,15 @@ namespace BCG { return rv; } - private static double _get_driverprice_for_expiration(ExpStrikeKeyedData theo_data_map, DateTime option_expiration) { - IDictionary exp_data = theo_data_map.get_data_for_single_exp(option_expiration); + private static double _get_driverprice_for_expiration(ExpStrikeKeyedData theo_data_map, DateTime option_expiration) { + IDictionary exp_data = theo_data_map.get_data_for_single_exp(option_expiration); if (exp_data != null) - foreach (mbts.TheoPoint tp in exp_data.Values) + foreach (mbts.spark.TheoPoint tp in exp_data.Values) return tp.driver; return Double.NaN; } - private IDictionary _get_atm_data(ExpStrikeKeyedData theo_data) { + private IDictionary _get_atm_data(ExpStrikeKeyedData theo_data) { NMSheetSettings sheet_settings = (NMSheetSettings)_threaded_bb.sec_thread_retrieve_from_cache(_in_bb_sheet_settings_tag) ?? new NMSheetSettings(); IDictionary option_exp_roll_data = (_threaded_bb.sec_thread_retrieve_from_cache(_in_exp_param_tag) as IDictionary) ?? new Dictionary(); IDictionary atm_data = OptionATMDataSource.compute_atm_data(_nmsheet_symbol.option_name, _get_onefive(), theo_data, option_exp_roll_data); @@ -209,23 +209,23 @@ namespace BCG { #region Vol Shift - private void _add_vol_shift(ExpStrikeKeyedData theo_data) { + private void _add_vol_shift(ExpStrikeKeyedData theo_data) { object obj_map = _threaded_bb.sec_thread_retrieve_from_cache(_in_bb_vol_shift_tag); if (obj_map != null) add_vol_shift(_nmsheet_symbol, theo_data, obj_map as Dictionary); } - internal static void add_vol_shift(NMSheetSymbol apply_to_symbol, ExpStrikeKeyedData theo_data, Dictionary exp_shift_map) { + internal static void add_vol_shift(NMSheetSymbol apply_to_symbol, ExpStrikeKeyedData theo_data, Dictionary exp_shift_map) { foreach (KeyValuePair p in exp_shift_map) { if (p.Key.nmsheet_symbol.Equals(apply_to_symbol)) { DateTime option_expiration = p.Key.option_expiration; double shift = p.Value; if (shift != 0) { - IDictionary exp_theos = theo_data.get_data_for_single_exp(option_expiration); + IDictionary exp_theos = theo_data.get_data_for_single_exp(option_expiration); if (exp_theos != null) { - Dictionary shifted_exp_theos = new Dictionary(); - foreach (KeyValuePair strike_tp in exp_theos) { - mbts.TheoPoint new_tp = (mbts.TheoPoint)strike_tp.Value.Clone(); + Dictionary shifted_exp_theos = new Dictionary(); + foreach (KeyValuePair strike_tp in exp_theos) { + mbts.spark.TheoPoint new_tp = (mbts.spark.TheoPoint)strike_tp.Value.Clone(); add_vol_shift(new_tp, shift); shifted_exp_theos[strike_tp.Key] = new_tp; } @@ -236,7 +236,7 @@ namespace BCG { } } - internal static void add_vol_shift(mbts.TheoPoint v, double shift) { + internal static void add_vol_shift(mbts.spark.TheoPoint v, double shift) { v.call += v.cvega * shift; v.put += v.pvega * shift; } diff --git a/src/client/spark/NMSheets/Outside/BBOPacket.cs b/src/client/spark/NMSheets/Outside/BBOPacket.cs index b63bafcf3..81956ecd7 100644 --- a/src/client/spark/NMSheets/Outside/BBOPacket.cs +++ b/src/client/spark/NMSheets/Outside/BBOPacket.cs @@ -25,7 +25,7 @@ namespace BCG { public static BBOPacket get_null_packet() { return _null_pack; } - public static BidAskAlertZone theo_through_md(BBOPacket md, mbts.TheoPoint tp, bool is_call) { + public static BidAskAlertZone theo_through_md(BBOPacket md, mbts.spark.TheoPoint tp, bool is_call) { if (tp != null && md != null) { double theo = (is_call ? tp.call : tp.put), bid_price = get_bid_price(md), ask_price = get_ask_price(md); if (!Double.IsNaN(theo)) { @@ -40,7 +40,7 @@ namespace BCG { return BidAskAlertZone.none; } - public static bool bid_through_theo(BBOPacket md, mbts.TheoPoint tp, bool is_call) { + public static bool bid_through_theo(BBOPacket md, mbts.spark.TheoPoint tp, bool is_call) { return false; // if (tp != null && md != null && md._md_row != null) // return get_bid_price(md) > (is_call ? tp.call : tp.put); @@ -48,7 +48,7 @@ namespace BCG { // return false; } - public static BidAskAlertZone get_alert_zone(BBOPacket md, mbts.TheoPoint tp, bool is_call, double cross_over) { + public static BidAskAlertZone get_alert_zone(BBOPacket md, mbts.spark.TheoPoint tp, bool is_call, double cross_over) { // if (tp != null && md != null && md._md_row != null) { // double theo_price = is_call ? tp.call : tp.put; // double bid_price = get_bid_price(md); @@ -70,7 +70,7 @@ namespace BCG { return BidAskAlertZone.none; } - public static bool ask_through_theo(BBOPacket md, mbts.TheoPoint tp, bool is_call) { + public static bool ask_through_theo(BBOPacket md, mbts.spark.TheoPoint tp, bool is_call) { // if (tp != null && md != null && md._md_row != null) // return get_ask_price(md) < (is_call ? tp.call : tp.put); // else diff --git a/src/client/spark/NMSheets/Outside/ExchangeSecurityMap.cs b/src/client/spark/NMSheets/Outside/ExchangeSecurityMap.cs index 7cb2d9973..a5136cd61 100644 --- a/src/client/spark/NMSheets/Outside/ExchangeSecurityMap.cs +++ b/src/client/spark/NMSheets/Outside/ExchangeSecurityMap.cs @@ -6,6 +6,8 @@ using System.Threading.Tasks; using bts.api; +using mbts.spark; + namespace BCG { /// /// This is the list of all exchange listed securities @@ -13,7 +15,8 @@ namespace BCG { /// 1. Direct list of securities /// 2. Reverse look up from options to their security keys /// - // TODO: SystemSecurityData will replace this + // TODO: SystemSecurityData will replace this (for backwards Tc2 bckwards compat + // it is created from SystemContractData) public class ExchangeSecurityMap/* : mbts.bb.IExchangeSecurityMap */{ public const uint error_key = 0; private readonly IDictionary _key_sec_map; @@ -21,6 +24,11 @@ namespace BCG { private readonly IDictionary _fut_map; private readonly IDictionary> _spread_map; + + public ExchangeSecurityMap(SystemContractData sc_data){ + + } + public ExchangeSecurityMap(IDictionary key_sec_map, IDictionary option_map, IDictionary fut_map, diff --git a/src/client/spark/NMSheets/Outside/TheoPoint.cs b/src/client/spark/NMSheets/Outside/TheoPoint.cs deleted file mode 100644 index 67ac4eaaa..000000000 --- a/src/client/spark/NMSheets/Outside/TheoPoint.cs +++ /dev/null @@ -1,279 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace mbts { - public class TheoPoint : ICloneable { - //if true, SPX mode -- assumes you hedge the whole thing with combos at the tie price - //false, Merc mode -- assumes you get what you get - private static bool assume_tied_spreads_fully_hedged; - static TheoPoint() { - assume_tied_spreads_fully_hedged = true; - - //mbts.config.Configuration.get().enabled; - } - //Rationale - //If the market is at live_driver, and I pay for a spread tied to locked_driver that is not the current futures price - //and perfectly hedge it, I will receive gamma for that spread that, if in the event the market moves - //to the locked price, I will be able sell additional hedge units against that new delta. - //Thus, here we compute the value of those extra hedge units and incorporate them into the theo. - //Delta's and gammas here are as a percent, like 45 instead of .45 - - //9 Jan 2015 - //Randy / Kev conversation (spurred on by questions from Lorry) - //Let's say we consider a spread buying 2 35 delta options worth 10 bucks a piece at und == 1000 - //Now I do the spread tied to 1010, wherein those options are now worth 14 (delta gets us to 13.5, add .5 for gamma, approx) - //and the delta is now 50 (because of gamma). - //Hedging the delta up at 1010 (the essence of the locked trade), I sell 1 future at 1010 (because 2*50 delta = 1 future) - //BUT I get to sell that future 10 dollars higher than the current market of 1000. - - //I could now turn around and buy that future back at 1000 and yield a profit of 10 bucks on that 1 future, and then - //sell the spread back out at a price of 10 bucks per option (it's current theo at the live market), - //so I'd lose 4 bucks per option (bought at 14 sld at 10), or 8 bucks total on the options, but I made 10 on the future, - //netting me a 2 dollar profit for simply unwinding the trade I just did. - - //Therefore I can choose to reflect this windfall in what we call the gamma-adjusted theoretical value by - //adding that 2 bucks of profit back into the theoretical value of the package. - public static void compute_enhanced_spread(double live_driver, double locked_driver, - double spread_locked_price, double spread_locked_delta_no_futs, double spread_locked_gamma, - double spread_live_price, double spread_live_delta_no_futs, double spread_live_gamma, - double initial_hedge, - - ref double new_spread_price, - ref double spread_delta_difference, ref double unused) { - //travel from locked to live with the option - double spread_change = spread_live_price - spread_locked_price; - - //NEW 10/28/2015 KD travel from locked to live with initial hedge (if it's an exchange-listed covered) - double initial_hedge_change = (assume_tied_spreads_fully_hedged) ? 0.0 - : (initial_hedge * (live_driver - locked_driver)); - - //travel from locked to live with the sold hedge (note it's locked-live here to negate for hedge) - //NEW 11/24/2015 -- only hedge this spread if it's not a covered, hedging it twice doesn't make sense - double hedge_change = 0.0; - if (initial_hedge == 0.0 || assume_tied_spreads_fully_hedged) - hedge_change = (spread_locked_delta_no_futs + initial_hedge) * (locked_driver - live_driver); - - new_spread_price = spread_locked_price + spread_change + initial_hedge_change + hedge_change; - spread_delta_difference = 100.0 * (spread_locked_delta_no_futs - spread_live_delta_no_futs); - unused = 0.0; - } - - public enum InterpolationMethod { - TAYLOR = 0, LINEAR = 1, POLY = 2 - } - - public double call = Double.NaN, put = Double.NaN, - cdelta = Double.NaN, pdelta = Double.NaN, - c_interp_delta = Double.NaN, p_interp_delta = Double.NaN, - cgamma = Double.NaN, pgamma = Double.NaN, - c_interp_gamma = Double.NaN, p_interp_gamma = Double.NaN, - cvega = Double.NaN, pvega = Double.NaN, driver = Double.NaN, - vol = Double.NaN, - /// added 02/18/2014 - c_oev = Double.NaN, p_oev = Double.NaN, - c_slope_vega = Double.NaN, p_slope_vega = Double.NaN, - c_vanna = Double.NaN, p_vanna = Double.NaN, - veganovr = double.NaN, - c_adj_vega = Double.NaN, p_adj_vega = Double.NaN, - c_theta = Double.NaN, p_theta = Double.NaN, fwd = double.NaN, standard_strike = double.NaN, theo_time = Double.NaN, - /// added 7/30/2016 - driver_bid, driver_ask; - - private TheoPoint() { } - - public readonly static TheoPoint shared_null_tp = getNulledObject(); - - public static TheoPoint getNulledObject() { - return new TheoPoint(); - } - - public TheoPoint(double theCall, double thePut, double theCDelta, double thePDelta, double theCVega, double thePVega, double theDriver) { - call = theCall; - put = thePut; - cdelta = theCDelta; - pdelta = thePDelta; - cvega = theCVega; - pvega = thePVega; - driver = theDriver; - } - - public TheoPoint(double theCall, double thePut, double theCDelta, double thePDelta, double theCGamma, double thePGamma, double theCVega, double thePVega, double theVol, double theDriver) - : this(theCall, thePut, theCDelta, thePDelta, theCVega, thePVega, theDriver) { - cgamma = theCGamma; - pgamma = thePGamma; - vol = theVol; - } - - public void copy_from(TheoPoint other) { - call = other.call; - put = other.put; - cdelta = other.cdelta; - pdelta = other.pdelta; - cvega = other.cvega; - pvega = other.pvega; - driver = other.driver; - cgamma = other.cgamma; - pgamma = other.pgamma; - vol = other.vol; - c_oev = other.c_oev; - p_oev = other.p_oev; - c_slope_vega = other.c_slope_vega; - p_slope_vega = other.p_slope_vega; - c_vanna = other.c_vanna; - p_vanna = other.p_vanna; - veganovr = other.veganovr; - c_adj_vega = other.c_adj_vega; - p_adj_vega = other.p_adj_vega; - c_theta = other.c_theta; - p_theta = other.p_theta; - fwd = other.fwd; - standard_strike = other.standard_strike; - theo_time = other.theo_time; - } - - public void copy_view_delta_gamma_to_interp() { - c_interp_delta = cdelta; - p_interp_delta = pdelta; - c_interp_gamma = cgamma; - p_interp_gamma = pgamma; - } - - public void mult_interp_delta_gamma(double delta_mult, double gamma_mult) { - c_interp_delta *= delta_mult; - p_interp_delta *= delta_mult; - c_interp_gamma *= gamma_mult; - p_interp_gamma *= gamma_mult; - } - - public object Clone() { - return new TheoPoint(call, put, cdelta, pdelta, cgamma, pgamma, cvega, pvega, vol, driver) { c_interp_delta = this.c_interp_delta, p_interp_delta = this.p_interp_delta, c_interp_gamma = this.c_interp_gamma, p_interp_gamma = this.p_interp_gamma, standard_strike = this.standard_strike, theo_time = this.theo_time }; - } - - public static double _weighted_mean_taylor_interp(double x1, double f1, double df1, double d2f1, - double x2, double f2, double df2, double d2f2, double x) { - double t_f_x1 = _taylor_interp(x1, f1, df1, d2f1, x), - t_f_x2 = _taylor_interp(x2, f2, df2, d2f2, x); - return (t_f_x1 * Math.Abs(x2 - x) + t_f_x2 * Math.Abs(x1 - x)) / (Math.Abs(x2 - x1)); - } - - public static double _taylor_interp(double x1, double f1, double df1, double d2f1, double x) { - return f1 + df1 * (x - x1) + d2f1 * Math.Pow(x - x1, 2) * 0.5; - } - - private class point_info { - public double x, f, df, d2f; - }; - - public static double _poly_interp(double x1, double f1, double df1, double d2f1, - double x2, double f2, double df2, double d2f2, double x) { - if (x1 == x2) - return f1; - else { - point_info p1 = new point_info() { x = x1, f = f1, df = df1, d2f = d2f1 }, - p2 = new point_info() { x = x2, f = f2, df = df2, d2f = d2f2 }; - double dx = p2.x - p1.x; - double p1mult = (p2.d2f - p1.d2f) * dx * dx; - double p2mult = (p2.df - p1.df - p1.d2f * dx) * dx; - double p3mult = p2.f - p1.f - (p1.df + 0.5 * p1.d2f * dx) * dx; - x = (x - p1.x) / dx; - return p1.f + x * (p1.df * dx + x * (0.5 * p1.d2f * dx * dx + x * (0.5 * p1mult - 4.0 * p2mult + 10.0 * p3mult + x * (-p1mult + 7.0 * p2mult - 15.0 * p3mult + x * (0.5 * p1mult - 3.0 * p2mult + 6.0 * p3mult))))); - } - } - - public static double _linear_interp(double x1, double y1, double x2, double y2, double x) { - /// return SplineCalcsCLR.linear_interp(x, new double[] { x1, x2 }, new double[] { y1, y2 }, 2); - return ((y2 - y1) / (x2 - x1)) * (x - x1) + y1; - } - - //This is a copy of _interp in UIFramework d:/home/darby/bts/blue2-hotfix-akuna/blue2/UIFramework/tc2/Calculator2/InterpolationCalculation/XFEDInterpolationCalculator.cs - //I since removed it from there - public static void interp(InterpolationMethod interp_method, TheoPoint p1, TheoPoint p2, double driver, TheoPoint result, - DateTime exp, double strike) { - if (interp_method == InterpolationMethod.LINEAR) { - result.driver = driver; - result.call = _linear_interp(p1.driver, p1.call, p2.driver, p2.call, driver); - result.put = _linear_interp(p1.driver, p1.put, p2.driver, p2.put, driver); - result.cdelta = _linear_interp(p1.driver, p1.cdelta, p2.driver, p2.cdelta, driver); - result.pdelta = _linear_interp(p1.driver, p1.pdelta, p2.driver, p2.pdelta, driver); - } else if (interp_method == InterpolationMethod.TAYLOR) { - result.driver = driver; - double parity_roll = strike + p1.call - p1.put - p1.driver; - double fwd = driver + parity_roll; - if ((p1.c_interp_gamma == 0.0 || p2.c_interp_gamma == 0.0) && (DateTime.Now.Date >= exp)) { - result.call = Math.Max(fwd - strike, 0.0); - result.cdelta = (strike < fwd) ? 1.0 : 0.0; - //BCG.Utilities.BlueEventLog.logEvent(String.Format("Parity : {0} {1} {2} {3} {4} {5}", p1.driver, p2.driver, driver, exp, strike, true), BCG.Utilities.BlueEventLevel.Information); - } else { - result.call = _weighted_mean_taylor_interp(p1.driver, p1.call, p1.c_interp_delta, p1.c_interp_gamma, - p2.driver, p2.call, p2.c_interp_delta, p2.c_interp_gamma, driver); - result.cdelta = _linear_interp(p1.driver, p1.cdelta, p2.driver, p2.cdelta, driver); - } - - if ((p1.p_interp_gamma == 0.0 || p2.p_interp_gamma == 0.0) && (DateTime.Now.Date >= exp)) { - result.put = Math.Max(strike - fwd, 0.0); - result.pdelta = (strike > fwd) ? -1.0 : 0.0; - //BCG.Utilities.BlueEventLog.logEvent (String.Format ("Parity : {0} {1} {2} {3} {4} {5}", p1.driver, p2.driver, driver, exp, strike, false), BCG.Utilities.BlueEventLevel.Information); - } else { - result.put = _weighted_mean_taylor_interp(p1.driver, p1.put, p1.p_interp_delta, p1.p_interp_gamma, - p2.driver, p2.put, p2.p_interp_delta, p2.p_interp_gamma, driver); - result.pdelta = _linear_interp(p1.driver, p1.pdelta, p2.driver, p2.pdelta, driver); - } - } else if (interp_method == InterpolationMethod.POLY) { - result.driver = driver; - double parity_roll = strike + p1.call - p1.put - p1.driver; - double fwd = driver + parity_roll; - if ((p1.c_interp_gamma == 0.0 || p2.c_interp_gamma == 0.0) && (DateTime.Now.Date >= exp)) { - result.call = Math.Max(fwd - strike, 0.0); - result.cdelta = (strike < fwd) ? 1.0 : 0.0; - //BCG.Utilities.BlueEventLog.logEvent(String.Format("Parity : {0} {1} {2} {3} {4} {5}", p1.driver, p2.driver, driver, exp, strike, true), BCG.Utilities.BlueEventLevel.Information); - } else { - result.call = _poly_interp(p1.driver, p1.call, p1.c_interp_delta, p1.c_interp_gamma, p2.driver, p2.call, p2.c_interp_delta, p2.c_interp_gamma, driver); - result.cdelta = _poly_interp(p1.driver, p1.cdelta, p1.c_interp_gamma, 0.0, p2.driver, p2.cdelta, p2.c_interp_gamma, 0.0, driver); - } - - if ((p1.p_interp_gamma == 0.0 || p2.p_interp_gamma == 0.0) && (DateTime.Now.Date >= exp)) { - result.put = Math.Max(strike - fwd, 0.0); - result.pdelta = (strike > fwd) ? -1.0 : 0.0; - //BCG.Utilities.BlueEventLog.logEvent(String.Format("Parity : {0} {1} {2} {3} {4} {5}", p1.driver, p2.driver, driver, exp, strike, false), BCG.Utilities.BlueEventLevel.Information); - } else { - result.put = _poly_interp(p1.driver, p1.put, p1.p_interp_delta, p1.p_interp_gamma, p2.driver, p2.put, p2.p_interp_delta, p2.p_interp_gamma, driver); - result.pdelta = _poly_interp(p1.driver, p1.pdelta, p1.p_interp_gamma, 0.0, p2.driver, p2.pdelta, p2.p_interp_gamma, 0.0, driver); - } - } - /// the rest can only be linear, because we dont have the derivatives - result.cgamma = _linear_interp(p1.driver, p1.cgamma, p2.driver, p2.cgamma, driver); - result.pgamma = _linear_interp(p1.driver, p1.pgamma, p2.driver, p2.pgamma, driver); - result.cvega = _linear_interp(p1.driver, p1.cvega, p2.driver, p2.cvega, driver); - result.pvega = _linear_interp(p1.driver, p1.pvega, p2.driver, p2.pvega, driver); - result.c_theta = _linear_interp(p1.driver, p1.c_theta, p2.driver, p2.c_theta, driver); - result.p_theta = _linear_interp(p1.driver, p1.p_theta, p2.driver, p2.p_theta, driver); - result.vol = _linear_interp(p1.driver, p1.vol, p2.driver, p2.vol, driver); - result.fwd = _linear_interp(p1.driver, p1.fwd, p2.driver, p2.fwd, driver); - result.standard_strike = _linear_interp(p1.driver, p1.standard_strike, p2.driver, p2.standard_strike, driver); - result.c_adj_vega = _linear_interp(p1.driver, p1.c_adj_vega, p2.driver, p2.c_adj_vega, driver); - result.p_adj_vega = _linear_interp(p1.driver, p1.p_adj_vega, p2.driver, p2.p_adj_vega, driver); - result.c_oev = _linear_interp(p1.driver, p1.c_oev, p2.driver, p2.c_oev, driver); - result.p_oev = _linear_interp(p1.driver, p1.p_oev, p2.driver, p2.p_oev, driver); - result.c_slope_vega = _linear_interp(p1.driver, p1.c_slope_vega, p2.driver, p2.c_slope_vega, driver); - result.p_slope_vega = _linear_interp(p1.driver, p1.p_slope_vega, p2.driver, p2.p_slope_vega, driver); - result.c_vanna = _linear_interp(p1.driver, p1.c_vanna, p2.driver, p2.c_vanna, driver); - result.p_vanna = _linear_interp(p1.driver, p1.p_vanna, p2.driver, p2.p_vanna, driver); - result.veganovr = _linear_interp(p1.driver, p1.veganovr, p2.driver, p2.veganovr, driver); - result.standard_strike = _linear_interp(p1.driver, p1.standard_strike, p2.driver, p2.standard_strike, driver); - result.theo_time = p1.theo_time; - } - - /// Computes theos at a given driver price (extrapolating using taylors) - public static double get_theo_at_driver(TheoPoint tp, double driver, bool is_call) { - tp = tp ?? TheoPoint.shared_null_tp; - double driver_diff = driver - tp.driver; - if (is_call) - return tp.call + (tp.cdelta * driver_diff) + (0.5 * tp.cgamma * driver_diff * driver_diff); - else - return tp.put + (tp.pdelta * driver_diff) + (0.5 * tp.pgamma * driver_diff * driver_diff); - } - } -} \ No newline at end of file diff --git a/src/client/spark/NMSheets/Outside/TheoTags.cs b/src/client/spark/NMSheets/Outside/TheoTags.cs index 0f39e482f..f9589ec42 100644 --- a/src/client/spark/NMSheets/Outside/TheoTags.cs +++ b/src/client/spark/NMSheets/Outside/TheoTags.cs @@ -12,18 +12,12 @@ namespace BCG { // Published by NONE public class PrecomputedOptionTheoTag : KeyedTag { public PrecomputedOptionTheoTag(string option_name) : base(option_name) { } } - public class LiveFutureTheoTag : KeyedTag { public LiveFutureTheoTag(string future_name) : base(future_name) { } } - - public class TheoreticalEdgesTag : mbts.bb.EqualsHelper { } - // Published by NONE public class OptionRollsTag : KeyedTag { public OptionRollsTag(string option_name) : base(option_name) { } } // published by NONE public class PNLRollOverDataTag : KeyedTag { public PNLRollOverDataTag(string option_symbol) : base(option_symbol) { } } - public class CompletePNLRolloverDataTag : mbts.bb.EqualsHelper { } - public class PresaveTheoTag : NamedTag { public PresaveTheoTag(int volsurface_id) : base(volsurface_id) { } diff --git a/src/client/spark/NMSheets/Outside/TradeAndPositionTags.cs b/src/client/spark/NMSheets/Outside/TradeAndPositionTags.cs index 215fb4715..456b5fd54 100644 --- a/src/client/spark/NMSheets/Outside/TradeAndPositionTags.cs +++ b/src/client/spark/NMSheets/Outside/TradeAndPositionTags.cs @@ -13,16 +13,5 @@ namespace BCG { /// // published by NONE public class OptionSymbolPositionTag : KeyedTag { public OptionSymbolPositionTag(string option_symbol) : base(option_symbol) { } } - - /// IEnumeraable of TradeLogUIRow for all the trades in the system - public class TradeLogTag : mbts.bb.EqualsHelper { public TradeLogTag() : base() { } } - - public class FutureSymbolPositionTag : KeyedTag { public FutureSymbolPositionTag(string future_symbol) : base(future_symbol) { } } - - /// Trades done today (after PNL RO) - public class DayTradesTag : mbts.bb.EqualsHelper { public DayTradesTag() : base() { } } - - /// Trades - Day Trades - public class PositionTradesTag : mbts.bb.EqualsHelper { public PositionTradesTag() : base() { } } } } diff --git a/src/client/spark/NMSheets/Outside/tc2/Calculator2/MainForm/ATM/ATMData.cs b/src/client/spark/NMSheets/Outside/tc2/Calculator2/MainForm/ATM/ATMData.cs index 92cfe8808..30a334e7e 100644 --- a/src/client/spark/NMSheets/Outside/tc2/Calculator2/MainForm/ATM/ATMData.cs +++ b/src/client/spark/NMSheets/Outside/tc2/Calculator2/MainForm/ATM/ATMData.cs @@ -3,20 +3,17 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BCG -{ +namespace BCG { /// /// Encapsultes the ATM greeks, for a single option_expiration. /// Also includes the roll and fwd for that exp /// - public class ATMData - { + public class ATMData { public double roll_offset = Double.NaN, fwd = Double.NaN; - public Dictionary strike_vs_data = new Dictionary(); + public Dictionary strike_vs_data = new Dictionary(); public Dictionary> strike_vs_callput_bbo_mid = new Dictionary>(); - public double get_md_midpoint_straddle(double strike) - { + public double get_md_midpoint_straddle(double strike) { Pair p = null; if (strike_vs_callput_bbo_mid.TryGetValue(strike, out p)) return p.first + p.second; @@ -24,33 +21,28 @@ namespace BCG return Double.NaN; } - public double get_vol(double strike) - { - mbts.TheoPoint tp = null; + public double get_vol(double strike) { + mbts.spark.TheoPoint tp = null; return strike_vs_data.TryGetValue(strike, out tp) ? tp.vol : Double.NaN; } - public mbts.TheoPoint get_atm_data_for_closest_strike_to_fwd() - { + public mbts.spark.TheoPoint get_atm_data_for_closest_strike_to_fwd() { double closest_to_fwd_strike = get_strike_closest_to_fwd(); - mbts.TheoPoint rv = null; + mbts.spark.TheoPoint rv = null; strike_vs_data.TryGetValue(closest_to_fwd_strike, out rv); - return rv; + return rv; } - public double get_theo_straddle(double strike) - { - mbts.TheoPoint tp = null; + public double get_theo_straddle(double strike) { + mbts.spark.TheoPoint tp = null; return strike_vs_data.TryGetValue(strike, out tp) ? tp.call + tp.put : Double.NaN; } - public double get_md_midpoint_straddle_minus_theo_straddle (double strike) - { + public double get_md_midpoint_straddle_minus_theo_straddle(double strike) { return get_md_midpoint_straddle(strike) - get_theo_straddle(strike); } - public double get_strike(bool closest) - { + public double get_strike(bool closest) { double[] atm_strikes = strike_vs_data.Keys.ToArray(); if (atm_strikes.Length == 0) return Double.NaN; @@ -62,31 +54,26 @@ namespace BCG public double get_strike_closest_to_fwd() { return get_strike(true); } - public IEnumerable get_sorted_strikes() - { + public IEnumerable get_sorted_strikes() { List rv = new List(strike_vs_data.Keys); rv.Sort(); return rv; } - public void reduce_to_nearest_expiration() - { - if (strike_vs_data.Count > 1) - { + public void reduce_to_nearest_expiration() { + if (strike_vs_data.Count > 1) { double furtherest_strike = get_strike(false); if (strike_vs_data.ContainsKey(furtherest_strike)) strike_vs_data.Remove(furtherest_strike); } } - public static void reduce_to_nearest_expiration(Dictionary atmData) - { + public static void reduce_to_nearest_expiration(Dictionary atmData) { foreach (ATMData d in atmData.Values) d.reduce_to_nearest_expiration(); } - public static Dictionary> get_exp_strike_map(Dictionary atm_data_map) - { + public static Dictionary> get_exp_strike_map(Dictionary atm_data_map) { Dictionary> rv = new Dictionary>(); if (atm_data_map != null) foreach (KeyValuePair p in atm_data_map) diff --git a/src/client/spark/NMSheets/Outside/tc2/Calculator2/MainForm/ATM/OptionATMDataSource.cs b/src/client/spark/NMSheets/Outside/tc2/Calculator2/MainForm/ATM/OptionATMDataSource.cs index 1da63134a..566637966 100644 --- a/src/client/spark/NMSheets/Outside/tc2/Calculator2/MainForm/ATM/OptionATMDataSource.cs +++ b/src/client/spark/NMSheets/Outside/tc2/Calculator2/MainForm/ATM/OptionATMDataSource.cs @@ -12,14 +12,14 @@ namespace BCG { public class OptionATMDataSource { #region stateless helpers internal static void fill_in_bbo(ref Dictionary atm_data_map, - ExpStrikeKeyedData> theo_data, + ExpStrikeKeyedData> theo_data, IDictionary bbo_data) { foreach (KeyValuePair p in atm_data_map) { DateTime exp = p.Key; ATMData exp_atm_data = p.Value; exp_atm_data.strike_vs_callput_bbo_mid = new Dictionary>(); foreach (double k in exp_atm_data.strike_vs_data.Keys) { - Triplet tp = theo_data.get_data(exp, k) ?? new Triplet(null, 0, 0); + Triplet tp = theo_data.get_data(exp, k) ?? new Triplet(null, 0, 0); BBOPacket call_md, put_md; bbo_data.TryGetValue(tp.second, out call_md); bbo_data.TryGetValue(tp.third, out put_md); @@ -32,7 +32,7 @@ namespace BCG { } } - internal static IDictionary compute_atm_data(string option_symbol, double one_five, ExpStrikeKeyedData theo_data, IDictionary opt_exp_rolls) { + internal static IDictionary compute_atm_data(string option_symbol, double one_five, ExpStrikeKeyedData theo_data, IDictionary opt_exp_rolls) { IDictionary exp_vs_drivers = _get_computed_drivers(theo_data); IDictionary rv = new Dictionary(); if (one_five != 0) @@ -46,18 +46,18 @@ namespace BCG { return rv; } - internal static Dictionary _get_computed_drivers(ExpStrikeKeyedData expStrikeTheos) { + internal static Dictionary _get_computed_drivers(ExpStrikeKeyedData expStrikeTheos) { Dictionary rv = new Dictionary(); - foreach (Triplet t in expStrikeTheos.get_data_linearly()) + foreach (Triplet t in expStrikeTheos.get_data_linearly()) if (!rv.ContainsKey(t.first)) rv.Add(t.first, t.third.driver); return rv; } internal static ATMData find_data_for_single_exp(double driver_price, DateTime exp, - ExpStrikeKeyedData theo_data, IDictionary opt_exp_rolls) { + ExpStrikeKeyedData theo_data, IDictionary opt_exp_rolls) { ATMData rv = new ATMData(); - IDictionary strike_theos = theo_data.get_data_for_single_exp(exp); + IDictionary strike_theos = theo_data.get_data_for_single_exp(exp); double roll = 0; // absent offset is 0 offset if (opt_exp_rolls != null) opt_exp_rolls.TryGetValue(exp, out roll); @@ -70,7 +70,7 @@ namespace BCG { return rv; } - internal static double[] find_atm_strikes_for_single_exp(double driver_price, double roll, IDictionary strike_theos) { + internal static double[] find_atm_strikes_for_single_exp(double driver_price, double roll, IDictionary strike_theos) { driver_price += roll; double[] strikes = strike_theos.Keys.ToArray(); Array.Sort(strikes);