c# - OpenOrder 仅针对第一个打开订单的交互式经纪人

标签 c# events interactive-brokers

我正在尝试通过将他们的 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/

相关文章:

c# - 在 .NET 中通过格式字符串发出冒号

c# - 检查元素是否存在或为空

c# - 用户界面缩放/设置

javascript - 为什么更改事件永远不会在选择框上触发?

JAVA 互动经纪商 API

c# - Azure 托管身份本地调试身份验证失败

javascript - 绑定(bind)事件发射器上的单个事件

c# - 为什么 Winforms Click 事件比 MouseClick 事件慢?

java - Interactive Brokers 订单在 Gateway 和 TWS 中同步吗?

python - 我如何在 Python 中接收来自 IBs API 的数据?