joined fills and orders with security
This commit is contained in:
1 parent
8bcec6b898
commit
fe3b46eb14
7 files changed
+131
-12
No files matched your search
@@ -23,13 +23,19 @@ namespace bts.api.md
|
||||
public ChannelUpdate data;
|
||||
}
|
||||
|
||||
readonly ConcurrentDictionary<security_key, Data> _data = new ConcurrentDictionary<security_key, Data>();
|
||||
readonly ConcurrentDictionary<security_key, Data> _data = new ConcurrentDictionary<security_key, Data>();
|
||||
readonly ConcurrentDictionary<security_key, string> _security_names = new ConcurrentDictionary<security_key, string>();
|
||||
readonly static Lazy<MarketDataRelay> _md = new Lazy<MarketDataRelay>(() => locate(), true);
|
||||
readonly Lazy<MDRequest> _subscription = new Lazy<MDRequest>(() => load_request());
|
||||
public MarketDataClient()
|
||||
private MarketDataClient()
|
||||
{
|
||||
}
|
||||
|
||||
public static MarketDataClient create()
|
||||
{
|
||||
return new MarketDataClient();
|
||||
}
|
||||
|
||||
static MDRequest load_request()
|
||||
{
|
||||
var req = new MDRequest();
|
||||
@@ -56,6 +62,12 @@ namespace bts.api.md
|
||||
return null;
|
||||
}
|
||||
|
||||
public string lookup_security_name(security_key key)
|
||||
{
|
||||
_security_names.TryGetValue(key, out string value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public Security find_security(Func<Security, bool> filter)
|
||||
{
|
||||
return _data.Values.Select(x => x.data.Security).Where(xx => filter(xx)).FirstOrDefault();
|
||||
@@ -201,6 +213,14 @@ namespace bts.api.md
|
||||
/// <returns></returns>
|
||||
public async Task start_pump(TimeSpan? interval = null)
|
||||
{
|
||||
var rep = await _md.Value.request_names_async(new VoidMessage()); int count = 0;
|
||||
do
|
||||
{
|
||||
foreach (var s in rep.value.Securities)
|
||||
foreach (var ss in s.Names)
|
||||
_security_names[ss.Key] = ss.Value;
|
||||
}
|
||||
while (!rep.success && count++ < 5);
|
||||
while (true)
|
||||
{
|
||||
var reply = await _md.Value.requestmd_async(_subscription.Value);
|
||||
@@ -246,6 +266,12 @@ namespace bts.api.md
|
||||
}
|
||||
}
|
||||
|
||||
public async void run_pump_async(TimeSpan? interval = null)
|
||||
{
|
||||
await this.start_pump(interval);
|
||||
}
|
||||
|
||||
|
||||
readonly CancellationTokenSource _cts = new CancellationTokenSource();
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user