From 5137785f7fc9632ffdfe96e5df441b875656d57e Mon Sep 17 00:00:00 2001 From: John Colvin Date: Wed, 11 Sep 2024 12:09:41 -0400 Subject: [PATCH] fix: Provide venue param w/ symbol when computing fut slide --- src/client/spark/Risk/VolSurfaceSlideCalculator.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/client/spark/Risk/VolSurfaceSlideCalculator.cs b/src/client/spark/Risk/VolSurfaceSlideCalculator.cs index 73a4309be..d6e55f60d 100644 --- a/src/client/spark/Risk/VolSurfaceSlideCalculator.cs +++ b/src/client/spark/Risk/VolSurfaceSlideCalculator.cs @@ -313,10 +313,10 @@ namespace mbts.analytics { IDictionary fut_theo_map, IDictionary cpp_map) { IDictionary> rv = new Dictionary>(); - foreach (string future_symbol in new HashSet(fut_pos_map.Keys.Select(e => e.symbol))) { - double cpp = cpp_map.TryGetValue(new mbts.SecurityTuple(SecurityType.Future, future_symbol, Venue.Unset), out cpp) ? cpp : Double.NaN, - delta_terms_symbol_cpp = cpp_map.TryGetValue(delta_terms_symbol, out delta_terms_symbol_cpp) ? delta_terms_symbol_cpp : Double.NaN; - IDictionary> sym_rv = _compute_single_symbol_future_slide(ordered_greeks, handles, future_symbol, fut_theo_map, fut_pos_map, cpp, delta_terms_symbol_cpp); + foreach (var (fut_symbol, fut_venue) in fut_pos_map.Keys.Select(e => (e.symbol, e.venue)).Distinct()) { + double cpp = cpp_map.GetValueOrDefault(new(SecurityType.Future, fut_symbol, fut_venue), double.NaN); + double delta_terms_symbol_cpp = cpp_map.GetValueOrDefault(delta_terms_symbol, double.NaN); + var sym_rv = _compute_single_symbol_future_slide(ordered_greeks, handles, fut_symbol, fut_venue, fut_theo_map, fut_pos_map, cpp, delta_terms_symbol_cpp); sym_rv.ToList().ForEach(kv => rv.Add(kv)); } return rv; @@ -326,11 +326,12 @@ namespace mbts.analytics { private static IDictionary> _compute_single_symbol_future_slide(IEnumerable ordered_greeks, IEnumerable handles, string fut_sym, + Venue fut_venue, IDictionary fut_theo_map, IDictionary future_pos_map, double sym_cpp, double interms_sym_cpp) { IDictionary> rv = new Dictionary>(); - foreach (KeyValuePair kv in future_pos_map.Where(kv => kv.Key.symbol == fut_sym)) { + foreach (KeyValuePair kv in future_pos_map.Where(kv => kv.Key.symbol == fut_sym && kv.Key.venue == fut_venue)) { VolSurfaceDriverTheo theo_tup = fut_theo_map.TryGetValue(kv.Key, out theo_tup) ? theo_tup : null; IEnumerable exp_pos_greeks = _compute_single_exp_future_slide( kv.Key,