#!meta {"kernelInfo":{"defaultKernelName":"csharp","items":[{"name":"csharp","languageName":"csharp"},{"name":"fsharp","languageName":"F#","aliases":["f#","fs"]},{"name":"html","languageName":"HTML"},{"name":"http","languageName":"HTTP"},{"name":"javascript","languageName":"JavaScript","aliases":["js"]},{"name":"mermaid","languageName":"Mermaid"},{"name":"pwsh","languageName":"PowerShell","aliases":["powershell"]},{"name":"value"}]}} #!csharp // Reference the library #r "..\..\bin\QuanTAlib.dll" using QuanTAlib; using System.IO; // 1. Setup: Use existing CSV file // CsvFeed expects a CSV with header: timestamp,open,high,low,close,volume // Timestamp format: YYYY-MM-DD string csvPath = "daily_IBM.csv"; Console.WriteLine($"Using CSV file: {csvPath}"); #!csharp // 2. Initialize CsvFeed // The feed loads the data and prepares it for streaming var feed = new CsvFeed(csvPath); Console.WriteLine("CsvFeed initialized."); #!csharp // 3. Streaming Data // Simulate processing historical data bar by bar Console.WriteLine("\nStreaming data (first 5 bars):"); int count = 0; bool isNew = true; // Get first bar var bar = feed.Next(isNew: true); while (isNew && count < 5) { count++; Console.WriteLine($" Bar {count}: {bar}"); // Get next bar bar = feed.Next(ref isNew); } Console.WriteLine($"Streamed {count} bars."); #!csharp // 4. Batch Fetching // Retrieve a specific range of data Console.WriteLine("\nBatch fetching:"); // Using a date range present in daily_IBM.csv (July 2025) long startTime = new DateTime(2025, 7, 8).Ticks; var interval = TimeSpan.FromDays(1); // Fetch 3 bars starting from July 8th, 2025 var batch = feed.Fetch(5, startTime, interval); Console.WriteLine($"Fetched {batch.Count} bars:"); foreach (var b in batch) { Console.WriteLine($" {b}"); }