Merge branch 'master' of bitbucket.org:bluetradesys/spark into ice_exec3
This commit is contained in:
commit
b15106dac4
2 files changed
+32
-6
No files matched your search
@@ -2,6 +2,7 @@
|
||||
using bts.co2;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -39,8 +40,29 @@ namespace bts.tests {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static async Task<IEnumerable<SecurityImmutable>> get_multiple_securities(MarketDataRelay relay, IEnumerable<Product> products, SecurityType security_type, MDRequest.Types.Flags flags = MDRequest.Types.Flags.Bbo, Venue v = Venue.Sim) {
|
||||
var request = new MDRequest() { Host = _MD_HOST };
|
||||
request.Channels.AddRange(products.Select(z =>
|
||||
new SecurityChannel() {
|
||||
Time = 0,
|
||||
Flags = (uint)flags,
|
||||
Type = security_type,
|
||||
Exchange = v,
|
||||
Symbol = z.Symbol,
|
||||
TradeCursor = 0,
|
||||
RfqCursor = 0
|
||||
}));
|
||||
|
||||
var result = await relay.requestmd_async(request);
|
||||
|
||||
if (result.success) {
|
||||
return result.value.Channels.Where(s => s.Updates.Count > 0).Select(x => (SecurityImmutable) x.Updates.First().Security);
|
||||
}
|
||||
return Enumerable.Empty<SecurityImmutable>();
|
||||
}
|
||||
|
||||
public static async Task<IEnumerable<FutureContract>> get_expirations(MarketDataRelay relay, string symbol, SecurityType security_type, MDRequest.Types.Flags flags = MDRequest.Types.Flags.Bbo, Venue v = Venue.Sim) {
|
||||
var request = new MDRequest() {
|
||||
var request = new MDRequest() {
|
||||
Host = _MD_HOST,
|
||||
Channels = {
|
||||
new SecurityChannel() {
|
||||
|
||||
@@ -158,18 +158,22 @@ namespace bts.tests.utils {
|
||||
}
|
||||
await Task.Delay(10000);
|
||||
}
|
||||
//UserSymbol.get_all() in MDConsumer.cs
|
||||
|
||||
bts.test.Assert.IsTrue(products != null, "No products found");
|
||||
var filtered_products = products.Products.Where(z => z.Exchange == Venue.Sim && z.Type == SecurityType.Future);
|
||||
bts.test.Assert.IsTrue(filtered_products.Count() > 0, "No suitable products found");
|
||||
IEnumerable<Product> filtered_products = products.Products.Where(z => z.Exchange == Venue.Sim && z.Type == SecurityType.Future);
|
||||
bts.test.Assert.IsTrue(filtered_products.Count() > 0, "No suitable products found"); //products are not guaranteed to have securities, so I need to get the product from the list of securities
|
||||
|
||||
uint? sec_id = null;
|
||||
|
||||
/* get securities if the list is not empty use the top one */
|
||||
|
||||
for(int i = 0; i < 10; i++) {
|
||||
var test_security = await MarketDataUtilities.get_security(mdrelay, filtered_products.First().Symbol, SecurityType.Future, f => true);
|
||||
if(test_security.HasValue) {
|
||||
var test_security = await MarketDataUtilities.get_multiple_securities(mdrelay, filtered_products, SecurityType.Future);
|
||||
|
||||
if(test_security.Count() > 0) {
|
||||
Console.Write("," + i);
|
||||
sec_id = test_security.Value.Id;
|
||||
sec_id = test_security.FirstOrDefault().Id;
|
||||
break;
|
||||
}
|
||||
await Task.Delay(10000);
|
||||
|
||||
Reference in new issue
Block a user