static void TestTradeApi(TradeApi tapi) { tapi.OnAccountStatus += OnAccountStatus; tapi.OnOrderStatus += OnOrderStatus; tapi.OnOrderTrade += OnOrderTrade; { var r = tapi.QueryAccountStatus(); if (r.Value != null) { foreach (var act in r.Value) { Console.WriteLine("account: " + act.AccountId + "," + act.Broker + "," + act.AccountId + "," + act.AccountType); } } else { Console.WriteLine("QueryAccountStatus error: " + r.Msg); } } { var r = tapi.QueryBalance("glsc"); if (r.Value != null) { var bal = r.Value; Console.WriteLine("balance: " + bal.InitBalance + "," + bal.EnableBalance + "," + bal.Margin + "," + bal.FloatPnl + "," + bal.ClosePnl ); } else { Console.WriteLine("QueryBalance error: " + r.Msg); } } { var r = tapi.QueryPositions("glsc"); if (r.Value != null) { foreach (var pos in r.Value) { Console.WriteLine("position: " + pos.Code + "," + pos.Name + "," + pos.Side + "," + pos.InitSize + "," + pos.EnableSize + "," + pos.CurrentSize + "," + pos.TodaySize ); } } else { Console.WriteLine("QueryPositions error: " + r.Msg); } } { var r = tapi.QueryOrders("glsc"); if (r.Value != null) { foreach (var ord in r.Value) { Console.WriteLine("order: " + ord.AccountId + "," + ord.Code + "," + ord.EntrustAction + "," + ord.EntrustPrice + "," + ord.EntrustSize + "," + ord.EntrustDate + "," + ord.EntrustTime + "," + ord.EntrustNo + "," + ord.FillPrice + "," + ord.FillSize + "," + ord.Status + "," + ord.StatusMsg ); } } else { Console.WriteLine("QueryOrders error: " + r.Msg); } } { var r = tapi.QueryTrades("glsc"); if (r.Value != null) { foreach (var trade in r.Value) { Console.WriteLine("order: " + trade.AccountId + "," + trade.FillDate + "," + trade.FillTime + "," + trade.Code + "," + trade.EntrustAction + "," + trade.EntrustNo + "," + trade.FillPrice + "," + trade.FillSize + "," + trade.FillNo ); } } else { Console.WriteLine("QueryTrades error: " + r.Msg); } } { var r = tapi.PlaceOrder("glsc", "000001.SH", 10.0, 100, "Buy"); if (r.Value != null) { var oid = r.Value; Console.WriteLine("PlaceOrder result: " + oid.EntrustNo + "," + oid.OrderId); } else { Console.WriteLine("PlaceOrder error: " + r.Msg); } if (r.Value != null) { var r2 = tapi.CancelOrder("glsc", "000001.SH", r.Value.EntrustNo); if (r2.Value) { Console.WriteLine("CancelOrder result: " + r2.Value); } else { Console.WriteLine("CancelOrder error: " + r2.Msg); } } } while (true) { Thread.Sleep(1000); } }
public void CancelOrder(string Instrument, TThostFtdcDirectionType Direction, string OffsetFlag) { m_Api.CancelOrder(Instrument, Direction, OffsetFlag); }
public void CancelOrder(ref CThostFtdcOrderField pOrder) { m_Api.CancelOrder(ref pOrder); }