Пример #1
0
        static void Menu(EWrapperImplementation ibClient)
        {
            string select;
            do
            {
                Console.WriteLine("0 - Atsijungti nuo API ir baigti darba");
                Console.WriteLine("1 - Uzsiprenumeruoti realaus laiko duomenis");
                Console.WriteLine("2 - Uzsiprenumeruoti istorinius duomenis");
                Console.WriteLine("3 - Nusiusti limit sandori");
                Console.WriteLine("4 - Nusiusti market sandori");
                Console.WriteLine("5 - nutrakti limit sandori");
                Console.WriteLine("6 - gauti kontrakto info");
                select = Console.ReadLine();

                switch (select)
                {
                    case "0":
                        ibClient.EClientSocket.eDisconnect();
                        break;
                    case "1":
                        _counter++;
                        ibClient.EClientSocket.reqMktData(_counter, MyContracts.GetFacebookStock(), "", false, null);
                        Thread.Sleep(10000);
                        ibClient.EClientSocket.cancelMktData(_counter);
                        break;
                    case "2":
                        _counter++;
                        ibClient.EClientSocket.reqHistoricalData(_counter, MyContracts.GetFacebookStock(),
                            "20151118 23:59:59", "10 D", "1 day", "TRADES", 1, 1, null);
                        Thread.Sleep(10000);
                        ibClient.EClientSocket.cancelHistoricalData(_counter);
                        break;
                    case "3":
                        _counter++;
                        PlacedOrderIds.Add(_counter);
                        ibClient.EClientSocket.placeOrder(_counter, MyContracts.GetFacebookStock(), MyOrders.LimitOrder());
                        Thread.Sleep(100);
                        break;
                    case "4":
                        _counter++;
                        ibClient.EClientSocket.placeOrder(_counter, MyContracts.GetFacebookStock(), MyOrders.MarketOrder());
                        Thread.Sleep(100);
                        break;
                    case "5":
                        ibClient.EClientSocket.cancelOrder(PlacedOrderIds.FirstOrDefault());
                        PlacedOrderIds.Remove(PlacedOrderIds.FirstOrDefault());
                        Thread.Sleep(100);
                        break;
                    case "6":
                        _counter++;
                        ibClient.EClientSocket.reqContractDetails(_counter, MyContracts.GetFacebookStock());
                        Thread.Sleep(100);
                        break;
                }
            } while (!"0".Equals(select));
        }
Пример #2
0
 static void Main(string[] args)
 {
     var allText = File.ReadAllText("counter.txt");
     _counter = Convert.ToInt32(allText);
     var ibClient = new EWrapperImplementation();
     ibClient.EClientSocket.eConnect("127.0.0.1", 7496, 0);
     Thread.Sleep(1000);
     Menu(ibClient);
     File.WriteAllText("counter.txt", _counter.ToString());
 }