Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions IQFeed.CSharpApiClient
Submodule IQFeed.CSharpApiClient added at 22fe2b
Original file line number Diff line number Diff line change
Expand Up @@ -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 ***
Copy link
Owner

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

public string Name => nameof(StreamingLevel2Example);

public async Task RunAsync()
Expand All @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The 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.
Copy link
Owner

Choose a reason for hiding this comment

The 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
Copy link
Owner

Choose a reason for hiding this comment

The 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);
Expand Down