0

我使用reqHistoricalData()方法,但调用后它不返回任何内容。我是否需要其他方法来处理数据?

这是我的代码

public void reqHistData (){
  // Create a new contract
  Contract contract = new com.ib.client.Contract();
  contract.symbol("USD");
  contract.secType("CASH");
  contract.currency("EUR");
  contract.exchange("IDEALPRO");

  api.client().reqHistoricalData(1, contract, "20140920 00:00:00", "1 D", "1 day", "TRADES", 0, 2, null);
}
4

1 回答 1

1

该调用是异步的,这意味着您必须等待它返回数据。您可以通过实现EWrapper接口并对回调中返回的数据做一些事情来做到这一点。创建套接字时,您传递回调的包装器。

此示例将仅打印结果。

@Override
public void historicalData(int reqId, String date, double open, double high, double low, double close, int volume, int count, double WAP, boolean hasGaps) {
    System.out.println(EWrapperMsgGenerator.historicalData(reqId, date, open, high, low, close, volume, count, WAP, hasGaps));
}
于 2016-11-29T19:45:21.360 回答