SoftTraderBackend/Program.cs

46 lines
976 B
C#

using Backend.MarketDataRequest;
using IBApi;
using System;
using System.Collections.Generic;
using System.Threading;
namespace Backend
{
public static class Program
{
public static void Main(string[] args)
{
var Gateway = new IBGatewayControl();
Gateway.Start("127.0.0.1", 4002, 1);
while (!Gateway.IsApiReady)
{
Thread.Sleep(50);
}
var request = new HistoricalEquityRequest
{
RequestId = 1,
Symbol = "NVDA",
EndDateTime = "20260311 11:00:00 US/Eastern",
Duration = "3600 S",
BarSize = HistoricalBarSize.FiveMins,
WhatToShow = HistoricalWhatToShow.Trades,
UseRth = true,
KeepUpToDate = false,
FormatDate = 1
};
List<Bar> bars = Gateway.RequestHistoricalBlocking(
request,
TimeSpan.FromSeconds(15));
Console.WriteLine();
Console.WriteLine($"Received {bars.Count} bars. Continue program here.");
// do next step here, for example save to database
Gateway.Disconnect();
}
}
}