static void Main(string[] args) { client = new IBClient {ThrowExceptions = true}; client.TickPrice += client_TickPrice; client.TickSize += client_TickSize; client.Error += client_Error; client.NextValidId += client_NextValidId; client.UpdateMarketDepth += client_UpdateMktDepth; client.RealTimeBar += client_RealTimeBar; client.OrderStatus += client_OrderStatus; client.ExecDetails += client_ExecDetails; client.CommissionReport += client_CommissionReport; Console.WriteLine("Connecting to IB."); client.Connect("127.0.0.1", 7496, 10); //TF = new Future("TF", "NYBOT", "USD", "200909"); //YmEcbot = new Future("YM", "ECBOT", "USD", "200909"); //ES = new Future("ES", "GLOBEX", "USD", "200909"); //SPY = new Future("SPY", "GLOBEX", "USD", "200909"); //ZN = new Future("ZN", "ECBOT", "USD", "200909"); //ZB = new Future("ZB", "ECBOT", "USD", "200909"); //ZT = new Future("ZT", "ECBOT", "USD", "200909"); //ZF = new Future("ZF", "ECBOT", "USD", "200909"); //TickNasdaq = new Index("TICK-NASD", "NASDAQ"); //VolNasdaq = new Index("VOL-NASD", "NASDAQ"); //AdNasdaq = new Index("AD-NASD", "NASDAQ"); //TickNyse = new Index("TICK-NYSE", "NYSE"); //VolNyse = new Index("VOL-NYSE", "NYSE"); //AdNyse = new Index("AD-NYSE", "NYSE"); //New Contract Creation Features //var Google = new Equity("GOOG"); //Forex Test var EUR = new Forex("EUR", "USD"); //Order BuyContract = KrsOrderFactory.CreateOrder(ActionSide.Buy, OrderType.Limit, 560, 0, 1, false, 0); //BuyContract.OutsideRth = false; //BuyContract.LimitPrice = 560; //BuyContract.OrderType = OrderType.Limit; //BuyContract.TotalQuantity = 1; //client.PlaceOrder(503, TF, BuyContract); client.RequestExecutions(NextOrderId++, new KrsExecutionFilter()); client.RequestAllOpenOrders(); client.RequestMarketData(NextOrderId++, EUR, null, false, false); client.RequestMarketDepth(NextOrderId++, EUR, 5); client.RequestRealTimeBars(NextOrderId++, EUR, 5, RealTimeBarType.Midpoint, false); //client.RequestMarketData(NextOrderId++, EUR, null, false, false); while(true) { Thread.Sleep(100); } }
static void Main(string[] args) { client = new IBClient(); client.ThrowExceptions = true; client.TickPrice += client_TickPrice; client.TickSize += client_TickSize; client.Error += client_Error; client.NextValidId += client_NextValidId; client.UpdateMarketDepth += client_UpdateMktDepth; client.RealTimeBar += client_RealTimeBar; client.OrderStatus += client_OrderStatus; client.ExecDetails += client_ExecDetails; Console.WriteLine("Connecting to IB."); client.Connect("127.0.0.1", 7496, 0); TF = new Contract("TF", "NYBOT", SecurityType.Future, "USD", "200909"); YmEcbot = new Contract("YM", "ECBOT", SecurityType.Future, "USD", "200909"); ES = new Contract("ES", "GLOBEX", SecurityType.Future, "USD", "200909"); SPY = new Contract("SPY", "GLOBEX", SecurityType.Future, "USD", "200909"); ZN = new Contract("ZN", "ECBOT", SecurityType.Future, "USD", "200909"); ZB = new Contract("ZB", "ECBOT", SecurityType.Future, "USD", "200909"); ZT = new Contract("ZT", "ECBOT", SecurityType.Future, "USD", "200909"); ZF = new Contract("ZF", "ECBOT", SecurityType.Future, "USD", "200909"); TickNasdaq = new Contract("TICK-NASD", "NASDAQ", SecurityType.Index, "USD"); VolNasdaq = new Contract("VOL-NASD", "NASDAQ", SecurityType.Index, "USD"); AdNasdaq = new Contract("AD-NASD", "NASDAQ", SecurityType.Index, "USD"); TickNyse = new Contract("TICK-NYSE", "NYSE", SecurityType.Index, "USD"); VolNyse = new Contract("VOL-NYSE", "NYSE", SecurityType.Index, "USD"); AdNyse = new Contract("AD-NYSE", "NYSE", SecurityType.Index, "USD"); //New Contract Creation Features Equity Google = new Equity("GOOG"); //Forex Test Forex EUR = new Forex("EUR", "USD"); client.RequestMarketData(14, Google, null, false, false); client.RequestMarketDepth(15, Google, 5); client.RequestRealTimeBars(16, Google, 5, RealTimeBarType.Trades,false); client.RequestMarketData(17, EUR, null, false, false); Order BuyContract = new Order(); BuyContract.Action = ActionSide.Buy; BuyContract.OutsideRth = false; BuyContract.LimitPrice = 560; BuyContract.OrderType = OrderType.Limit; BuyContract.TotalQuantity = 1; //client.PlaceOrder(503, TF, BuyContract); client.RequestExecutions(34, new ExecutionFilter()); client.RequestAllOpenOrders(); while(true) { Thread.Sleep(100); } }