-
Notifications
You must be signed in to change notification settings - Fork 41
fix to support protocol 6.2 changes in L2 streaming example #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it documented somewhere? |
||
//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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah didnt know that. |
||
// 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we can just remove all this code if not usable in 6,2 anymore... |
||
//{ | ||
// Console.WriteLine(msg); | ||
//} | ||
|
||
private void Level2ClientOnError(ErrorMessage msg) | ||
{ | ||
Console.WriteLine(msg); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please put it back to false