static void Main() { IB_Client client = new IB_Client(); bool ret = client.ConnectToTWS("127.0.0.1", 7496); if (ret) { Console.WriteLine("connect successful."); } //client = new IB_Client(); //client.ConnectToTWS("127.0.0.1", 7496); //client.DefaultAccout = "DU229332"; string acc_id = client.DefaultAccout; Console.WriteLine(acc_id); client.add("AAPL"); client.add("FOP.CL.201807.C.71", "NYMEX", "USD"); //client.add("EURUSD"); var es = client.get("FOP.CL.201807.C.71"); var ask = es.Ask; var bid = es.Bid; var ask_size = es.Ask_Size; var bid_size = es.Bid_Size; int a = 2; while (a-- > 1) { //client.BuyLimitOrder("AAPL", 1000, 170); //Console.ReadKey(); Thread.Sleep(1000); } Thread.Sleep(1000); //string str = client.wrapper.orderInfo; //Console.WriteLine(str); client.CancelAllOrders(); //client.wrapper.ClientSocket.reqPositions(); //Console.WriteLine(client.ReqPositions()); Thread.Sleep(1000); Console.WriteLine("Open Order Begin"); client.wrapper.ClientSocket.reqAllOpenOrders(); Thread.Sleep(20000); client.Disconnect(); Console.ReadKey(); }
public int BuyTest() { client.add("AAPL"); return(client.Buy("AAPL", 1000)); //return true; }
private void btnSubscribe_Click(object sender, EventArgs e) { client.add(txtAssetID.Text); }