mathpaquette / IQFeed.CSharpApiClient

IQFeed.CSharpApiClient is fastest and the most well-designed C# DTN IQFeed socket API connector available
MIT License
120 stars 43 forks source link

How can I download Level 2 historical Tic data from yestereday? #159

Open CBrauer opened 11 months ago

CBrauer commented 11 months ago

Hey,

I have the following test program that I can run when the market is open. It downloads 10 current trades for "AAPL":

using IQFeed.CSharpApiClient;
using IQFeed.CSharpApiClient.Lookup;
using System.Diagnostics;

namespace IQFeedSample;
class Program
{
    private static async void Run()
    {
        IQFeedLauncher.Start("1855220", "Foobar112356", "MY_CHARTS", "1.0");
        var lookupClient = LookupClientFactory.CreateNew();
        lookupClient.Connect();
        var tickMessages = await lookupClient.Historical.GetHistoryTickDatapointsAsync("AAPL", 10);
        foreach(var message in tickMessages) {
            //var message = tickMessages.FirstOrDefault();
            Debug.Assert(message != null);
            var date_time = message.Timestamp;
            var last = message.Last;
            var tradeVolume = message.LastSize;
            var totalVolume = message.TotalVolume;
            var bid = message.Bid;
            var ask = message.Ask;
            Console.WriteLine($"{date_time}: tradeVol: {tradeVolume,3}, totalVol: {totalVolume,3}, last: {last,7:f3}, bid: {bid,7:f3}, ask: {ask,7:f3}");
        }
    }
    static void Main()
    {
        Run();
        Console.WriteLine("Press any key to exit...");
        Console.ReadKey();
    }
}

Suppose today's date is 8/17/2023. How can I modify the above code to set the download date to yesterday (8/16/2023)?

Charles

bryaan commented 2 weeks ago

Level 2 data is not the same as tick data. IqFeed does not provide historical L2 data.