builds
This commit is contained in:
1 parent
6582065be0
commit
2eb3ff4347
6 files changed
+46
-38
No files matched your search
@@ -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<object[], object[]> key_value_tuple<T, TKey>(TableUpdate<T, TKey> source) where TKey : IEquatable<TKey>
|
||||
{
|
||||
return Tuple.Create(source.state.Keys.Cast<object>().ToArray(), source.state.Values.Cast<object>().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<object[], object[]> tup = core.ObservableUpdateExtensions.key_value_tuple((dynamic)data);
|
||||
Tuple<object[], object[]> 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);
|
||||
|
||||
@@ -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<string> topicInfo)
|
||||
protected override ExcelRtdServer.Topic CreateTopic(int topicId, IList<string> 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<object> obs = null;
|
||||
if (bt.service_type == null)
|
||||
return "Unknown ServiceType: " + bt.service_type_string;
|
||||
@@ -93,7 +94,7 @@ namespace bts.excel.rtd
|
||||
}
|
||||
|
||||
|
||||
IObservable<object> subscribe(Topic topic)
|
||||
IObservable<object> 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<object>;
|
||||
if (stream != null)
|
||||
{
|
||||
dynamic dtable = core.ObservableUpdateExtensions.table((dynamic)subscription);
|
||||
dynamic dtable = ObservableUpdateExtensions.Table((dynamic)subscription);
|
||||
stream = dtable as IObservable<object>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<SecurityRequestType>(security_type, true, out type))
|
||||
req.SecurityType = type;
|
||||
else
|
||||
return "Can't Parse Security Type: " + security_type;
|
||||
// SecurityRequestType type;
|
||||
// if (Enum.TryParse<SecurityRequestType>(security_type, true, out type))
|
||||
// req.SecurityType = type;
|
||||
// else
|
||||
// return "Can't Parse Security Type: " + security_type;
|
||||
|
||||
Venue ven;
|
||||
if (Enum.TryParse<Venue>(exchange, true, out ven))
|
||||
req.SecurityVenue = ven;
|
||||
else
|
||||
return "Can't Parse Exchange: " + exchange;
|
||||
req.MdType = MarketDataType.Bbo;
|
||||
// Venue ven;
|
||||
// if (Enum.TryParse<Venue>(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
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace bts.excel
|
||||
{
|
||||
public class APIDispatch
|
||||
{
|
||||
public static Lazy<core.ServiceContext> service_context = new Lazy<core.ServiceContext>(() => new core.ServiceContext(), true);
|
||||
public static Lazy<ServiceContext> service_context = new Lazy<ServiceContext>(() => new ServiceContext(), true);
|
||||
static MethodInfo _locate_meth;
|
||||
readonly static Dictionary<object, object> _services = new Dictionary<object, object>();
|
||||
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;
|
||||
|
||||
Reference in new issue
Block a user