From 2eb3ff434782fbc76ac4d88efcc3ed3a0a451f33 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Fri, 21 Sep 2018 11:21:08 -0400 Subject: [PATCH] builds --- src/client/spark_excel/rtd/DataParser.cs | 10 +++- src/client/spark_excel/rtd/RTDServer.cs | 11 ++-- src/client/spark_excel/rtd/Subscribe.cs | 56 ++++++++++----------- src/client/spark_excel/rtd/Topic.cs | 2 +- src/client/spark_excel/spark_excel.csproj | 1 + src/client/spark_excel/utils/APIDispatch.cs | 4 +- 6 files changed, 46 insertions(+), 38 deletions(-) diff --git a/src/client/spark_excel/rtd/DataParser.cs b/src/client/spark_excel/rtd/DataParser.cs index e049ff18d..1a415e6cb 100644 --- a/src/client/spark_excel/rtd/DataParser.cs +++ b/src/client/spark_excel/rtd/DataParser.cs @@ -4,6 +4,7 @@ using System.Reflection; using System.Linq; using bts.excel.extensions; using System.Text.RegularExpressions; +using bts.api.core; namespace bts.excel { @@ -191,6 +192,11 @@ namespace bts.excel return val; } + public static Tuple key_value_tuple(TableUpdate source) where TKey : IEquatable + { + return Tuple.Create(source.state.Keys.Cast().ToArray(), source.state.Values.Cast().ToArray()); + } + public static object[,] scatter_data(object data, bool include_field_names = true, Type type_override = null) { if (data == null) @@ -198,9 +204,9 @@ namespace bts.excel bool is_array; Type type = type_override ?? data.GetType(); - if (type.IsGenericType && type.GetGenericTypeDefinition().Equals(typeof(core.TableUpdate<,>))) + if (type.IsGenericType && type.GetGenericTypeDefinition().Equals(typeof(TableUpdate<,>))) { - Tuple tup = core.ObservableUpdateExtensions.key_value_tuple((dynamic)data); + Tuple tup = key_value_tuple((dynamic)data); return scatter_data(tup.Item2, include_field_names, tup.Item2.FirstOrDefault()?.GetType().MakeArrayType()); } Type element_type = analyze_type(type, out is_array); diff --git a/src/client/spark_excel/rtd/RTDServer.cs b/src/client/spark_excel/rtd/RTDServer.cs index f11438684..161aa7cde 100644 --- a/src/client/spark_excel/rtd/RTDServer.cs +++ b/src/client/spark_excel/rtd/RTDServer.cs @@ -6,6 +6,7 @@ using System.Linq; using ExcelDna.Integration; using ExcelDna.Integration.Rtd; using bts.excel.extensions; +using bts.api.core; namespace bts.excel.rtd { @@ -30,11 +31,11 @@ namespace bts.excel.rtd protected override void ServerTerminate() { } - protected override RtdServer.Topic CreateTopic(int topicId, IList topicInfo) + protected override ExcelRtdServer.Topic CreateTopic(int topicId, IList topicInfo) { string[] tagvals = new string[topicInfo.Count - 2]; Array.Copy(topicInfo.ToArray(), 2, tagvals, 0, tagvals.Length); - var bt = new Topic(this, topicId, topicInfo[0], topicInfo[1], tagvals); + var bt = new bts.excel.rtd.Topic(this, topicId, topicInfo[0], topicInfo[1], tagvals); return bt; } @@ -42,7 +43,7 @@ namespace bts.excel.rtd { //return ExcelErrorUtil.ToComError(ExcelError.ExcelErrorNA); newValues = true; - Topic bt = (Topic)topic; + bts.excel.rtd.Topic bt = (bts.excel.rtd.Topic)topic; IObservable obs = null; if (bt.service_type == null) return "Unknown ServiceType: " + bt.service_type_string; @@ -93,7 +94,7 @@ namespace bts.excel.rtd } - IObservable subscribe(Topic topic) + IObservable subscribe(bts.excel.rtd.Topic topic) { var service = APIDispatch.locate_service(topic.service_type); var request = APIDispatch.generate_request(topic.service_type, topic.method_name, topic.parameters[0]); @@ -104,7 +105,7 @@ namespace bts.excel.rtd stream = subscription as IObservable; if (stream != null) { - dynamic dtable = core.ObservableUpdateExtensions.table((dynamic)subscription); + dynamic dtable = ObservableUpdateExtensions.Table((dynamic)subscription); stream = dtable as IObservable; } } diff --git a/src/client/spark_excel/rtd/Subscribe.cs b/src/client/spark_excel/rtd/Subscribe.cs index dcd6d163d..4f9986133 100644 --- a/src/client/spark_excel/rtd/Subscribe.cs +++ b/src/client/spark_excel/rtd/Subscribe.cs @@ -54,39 +54,39 @@ namespace bts.excel.rtd return ExcelErrorUtil.ToComError(ExcelError.ExcelErrorNA); } - #region marketdata - [ExcelFunction] - public static object bts_subscribe_bbo(string symbol, string security_type, string exchange) - { - MarketDataRequest req = new MarketDataRequest(); - req.SecurityName = symbol; + // #region marketdata + // [ExcelFunction] + // public static object bts_subscribe_bbo(string symbol, string security_type, string exchange) + // { + // MarketDataRequest req = new MarketDataRequest(); + // req.SecurityName = symbol; - SecurityRequestType type; - if (Enum.TryParse(security_type, true, out type)) - req.SecurityType = type; - else - return "Can't Parse Security Type: " + security_type; + // SecurityRequestType type; + // if (Enum.TryParse(security_type, true, out type)) + // req.SecurityType = type; + // else + // return "Can't Parse Security Type: " + security_type; - Venue ven; - if (Enum.TryParse(exchange, true, out ven)) - req.SecurityVenue = ven; - else - return "Can't Parse Exchange: " + exchange; - req.MdType = MarketDataType.Bbo; + // Venue ven; + // if (Enum.TryParse(exchange, true, out ven)) + // req.SecurityVenue = ven; + // else + // return "Can't Parse Exchange: " + exchange; + // req.MdType = MarketDataType.Bbo; - string json = Google.Protobuf.JsonFormatter.Default.Format(req); - return bts_subscribe(typeof(MarketDataService).FullName, nameof(MarketDataService.subscribe_marketdata), json); - } + // string json = Google.Protobuf.JsonFormatter.Default.Format(req); + // return bts_subscribe(typeof(MarketDataService).FullName, nameof(MarketDataService.subscribe_marketdata), json); + // } - [ExcelFunction] - public static object bts_subscribe_securities() - { - SecurityRequest req = new SecurityRequest(); + // [ExcelFunction] + // public static object bts_subscribe_securities() + // { + // SecurityRequest req = new SecurityRequest(); - string json = Google.Protobuf.JsonFormatter.Default.Format(req); - return bts_subscribe(typeof(MarketDataService).FullName, nameof(MarketDataService.subscribe_securities), json); - } - #endregion + // string json = Google.Protobuf.JsonFormatter.Default.Format(req); + // return bts_subscribe(typeof(MarketDataService).FullName, nameof(MarketDataService.subscribe_securities), json); + // } + // #endregion } diff --git a/src/client/spark_excel/rtd/Topic.cs b/src/client/spark_excel/rtd/Topic.cs index 18513f846..7340a5665 100644 --- a/src/client/spark_excel/rtd/Topic.cs +++ b/src/client/spark_excel/rtd/Topic.cs @@ -24,7 +24,7 @@ namespace bts.excel.rtd service_type_string = serv_type; method_name = methodname; id = Guid.NewGuid(); - service_type = find_api_type(service_type_string, null, typeof(core.IApiClient)); + service_type = find_api_type(service_type_string, null, typeof(bts.api.core.IApiClient)); request_type = APIDispatch.find_request_type(service_type, method_name); parameters = param; } diff --git a/src/client/spark_excel/spark_excel.csproj b/src/client/spark_excel/spark_excel.csproj index 5371a08ad..1865703d6 100644 --- a/src/client/spark_excel/spark_excel.csproj +++ b/src/client/spark_excel/spark_excel.csproj @@ -33,6 +33,7 @@ + diff --git a/src/client/spark_excel/utils/APIDispatch.cs b/src/client/spark_excel/utils/APIDispatch.cs index da704fb10..710780f0f 100644 --- a/src/client/spark_excel/utils/APIDispatch.cs +++ b/src/client/spark_excel/utils/APIDispatch.cs @@ -14,7 +14,7 @@ namespace bts.excel { public class APIDispatch { - public static Lazy service_context = new Lazy(() => new core.ServiceContext(), true); + public static Lazy service_context = new Lazy(() => new ServiceContext(), true); static MethodInfo _locate_meth; readonly static Dictionary _services = new Dictionary(); const string descriptor_property_name = "Descriptor"; @@ -27,7 +27,7 @@ namespace bts.excel { _locate_meth = service_context.Value.GetType().find_method((_) => { - return _.Name == nameof(core.ServiceContext.locate) && _.IsGenericMethod; + return _.Name == nameof(ServiceContext.locate) && _.IsGenericMethod; })[0]; } return _locate_meth;