我正在尝试通过将他们的 API 与 .NET 结合使用来获取我在 Interactive Brokers TWS 上的所有未结订单。
像那样:
IBClient _client = new IBClient();
_client.Connect("127.0.0.1", 7495, 0);
if(_client.Connected)
{
_client.RequestAllOpenOrders();
}
void _client_OpenOrder(object sender, OpenOrderEventArgs e)
{
Console.WriteLine("Action " + e.Order.Action + " of " + e.Contract.Symbol + " in Status: " + e.OrderState.Status + " order id: " + e.OrderId);
}
但是,该事件似乎只发生一次,即第一个未结订单。
RequestAllOpenOrders()的说明:(IB的)
"Call this method to request the open orders that were placed from all clients and also from TWS. Each open order will be fed back through the openOrder() and orderStatus() functions on the EWrapper."
并且事件仅针对一个未结订单发生。
为什么?
我正在使用 Krs.Ats.IBNet.dll,v2.0.50727 谢谢
最佳答案
好的。 我得到了它... 这一切都是因为从事件处理程序中抛出异常而发生的
void _client_OrderStatus(object sender, OrderStatusEventArgs e)
{
throw new NotImplementedException();
}
但为什么我现在得到所有未结订单的订单 ID 0?
关于c# - OpenOrder 仅针对第一个打开订单的交互式经纪人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38609016/