From 30f648121ca158ae32a9a87f5dab51007db950d6 Mon Sep 17 00:00:00 2001 From: John Higgins Date: Tue, 12 Jul 2022 21:29:46 -0500 Subject: [PATCH 1/2] fix to support protocol 6.2 changes in L2 streaming example --- .../StreamingLevel2/StreamingLevel2Example.cs | 51 +++++++++++++++---- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/src/IQFeed.CSharpApiClient.Examples/Examples/StreamingLevel2/StreamingLevel2Example.cs b/src/IQFeed.CSharpApiClient.Examples/Examples/StreamingLevel2/StreamingLevel2Example.cs index 889d45bd..efba94f3 100644 --- a/src/IQFeed.CSharpApiClient.Examples/Examples/StreamingLevel2/StreamingLevel2Example.cs +++ b/src/IQFeed.CSharpApiClient.Examples/Examples/StreamingLevel2/StreamingLevel2Example.cs @@ -9,7 +9,7 @@ namespace IQFeed.CSharpApiClient.Examples.Examples.StreamingLevel2 { public class StreamingLevel2Example : IExampleAsync { - public bool Enable => false; // *** SET TO TRUE TO RUN THIS EXAMPLE *** + public bool Enable => true; // *** SET TO TRUE TO RUN THIS EXAMPLE *** public string Name => nameof(StreamingLevel2Example); public async Task RunAsync() @@ -32,34 +32,65 @@ public async Task RunAsync() level2Client.System += Level2ClientOnSystem; level2Client.Error += Level2ClientOnError; - level2Client.Summary += Level2ClientOnSummary; - level2Client.Update += Level2ClientOnSummary; + //level2Client.Summary += Level2ClientOnSummary; // protocol 6.1 and prior + //level2Client.Update += Level2ClientOnSummary; // protocol 6.1 and prior + + // Comment/uncomment the following line for MBP data ********************************** + //level2Client.PriceLevelSummary += Level2Client_PriceLevelSummary; + //level2Client.PriceLevelUpdate += Level2Client_PriceLevelSummary; + + // Comment/uncomment the following line for MBO data ********************************** + level2Client.OrderSummary += Level2Client_MBOSummary; + level2Client.OrderUpdate += Level2Client_MBOSummary; + level2Client.Timestamp += Level2ClientOnTimestamp; // Step 6 - Make your streaming Level 2 requests - level2Client.ReqWatch("@ES#"); + // ReqWatch is only supported in protocols 6.1 and below. + // For protocol 6.2+, use ReqWatchMarketByPrice or ReqWatchMarketByOrder + //level2Client.ReqWatchMarketByPrice("@ES#"); // MBP data ******************************* + level2Client.ReqWatchMarketByOrder("@ES#"); // MBO data ******************************* - Console.WriteLine("Watching @ES# for the next 30 seconds... Please be patient ;-)\n"); - await Task.Delay(TimeSpan.FromSeconds(30)); + Console.WriteLine("Watching @ES# (front month) for the next 20 seconds... Please be patient ;-)\n"); + await Task.Delay(TimeSpan.FromSeconds(20)); // Step 7 - Unwatch and unregister events level2Client.ReqUnwatch("@ES#"); - level2Client.Summary -= Level2ClientOnSummary; - level2Client.Update -= Level2ClientOnSummary; + //level2Client.Summary -= Level2ClientOnSummary; // protocol 6.1 and prior + //level2Client.Update -= Level2ClientOnSummary; // protocol 6.1 and prior + + // Comment/uncomment the following 2 lines for MBP data ******************************* + //level2Client.PriceLevelSummary -= Level2Client_PriceLevelSummary; + //level2Client.PriceLevelUpdate -= Level2Client_PriceLevelSummary; + + // Comment/uncomment the following 2 lines for MBO data ******************************* + level2Client.OrderSummary -= Level2Client_MBOSummary; + level2Client.OrderUpdate -= Level2Client_MBOSummary; + level2Client.Timestamp -= Level2ClientOnTimestamp; } - private void Level2ClientOnTimestamp(TimestampMessage msg) + private void Level2Client_PriceLevelSummary(PriceLevelUpdateSummaryMessage msg) // Added for protocol 6.2 MBP { Console.WriteLine(msg); } - private void Level2ClientOnSummary(UpdateSummaryMessage msg) + private void Level2Client_MBOSummary(OrderAddUpdateSummaryMessage msg) // Added for protocol 6.2 MBO { Console.WriteLine(msg); } + private void Level2ClientOnTimestamp(TimestampMessage msg) + { + Console.WriteLine(msg); + } + + //private void Level2ClientOnSummary(UpdateSummaryMessage msg) // protocol 6.1 and prior + //{ + // Console.WriteLine(msg); + //} + private void Level2ClientOnError(ErrorMessage msg) { Console.WriteLine(msg); From f66c98a6a407b7842066926033fe29a903b9f014 Mon Sep 17 00:00:00 2001 From: John Higgins Date: Wed, 22 Feb 2023 10:34:55 -0500 Subject: [PATCH 2/2] Add branch changes to local --- IQFeed.CSharpApiClient | 1 + 1 file changed, 1 insertion(+) create mode 160000 IQFeed.CSharpApiClient diff --git a/IQFeed.CSharpApiClient b/IQFeed.CSharpApiClient new file mode 160000 index 00000000..22fe2be2 --- /dev/null +++ b/IQFeed.CSharpApiClient @@ -0,0 +1 @@ +Subproject commit 22fe2be277820c73d1151b0318fae43e4fdabb8e