特定请求的版本号,Interactive Brokers的IBrokers包

时间:2013-08-13 01:44:34

标签: r ibrokers

我正在尝试理解IBrokers软件包,在阅读其Real Time vignettes时,在2.4.1节末尾,该软件包的作者Jeffrey A. Ryan写道:

  

[...]从TWS请求当前时间,需要发送“当前时间”(.swsOutgoingMSG $ REQ CURRENT TIME)的代码:“49”和当前的版本号具体要求。在当前时间的情况下,版本只是字符“1”。

扫描IBrokers软件包的源代码,我注意到作者对不同的请求使用了不同的VERSION编号(例如,对于reqMrktData,VERSION = 9)。无论是谁,当我查看Interactive Brokers API document时,对于reqMktData()函数,我发现该函数不需要“版本号”作为参数。

我还试图寻找对特定请求的版本号以及我们可能需要它的时间/地点的一般解释,但我找不到。

如果有人可以向我提供“VERSION”变量的解释,它的意图/实现,以及我们如何/在哪里可以找到针对Interactive Brokers API的各种请求的版本号列表,我将不胜感激。

提前谢谢

1 个答案:

答案 0 :(得分:2)

  

如果有人可以向我提供“VERSION”变量的解释,它的意图/实现,以及我们如何/在哪里可以找到针对Interactive Brokers API的各种请求的版本号列表,我将不胜感激。

API演变问题。

查看Java(或C ++)API客户端库代码中的class EClientSocket。杰夫瑞恩可能从这里拿起/不得不拿起VERSION数字。

基本上,随着IB平台/服务器功能的发展,客户使用的客户端API有较新版本和较新版本。因此,IB服务器能够处理来自较旧版本的IB API客户端以及较新版本的IB API客户端的请求。 VERSION帮助服务器区分它正在处理的API调用版本。

例如,较新版本的IB客户端API可以reqMktData()用于一次性使用多个腿的整个Combos,而老客户端无法做到这一点。因此,正如您所指出的,对于没有进化的更简单的API,例如cancelHistoricalData()cancelScannerSubscription()等,它是1,但对于倾向于演变的API,可以高达7或9随着时间的推移,例如reqMktData()。

在更低级的术语中,VERSION告诉服务器在send() VERSION之后,客户端将立即在Socket上传递哪些参数。以下是reqScannerSubscription()的代码摘录。请注意send(VERSION);

之后的send(REQ_SCANNER_SUBSCRIPTION);

(请注意,还有两种其他类型的版本号:服务器端(IB服务器/平台)版本号和IB TWS客户端API版本号!这些版本号与您关注的每个API版本号分开对于IB是否真的需要每个API调用,与IB客户端版本分开的VERSION对我来说并不是很明显,但这就是他们现在如何推出的。)

道歉答辩;一看EClientSocket.java就可以清除它! : - )

public synchronized void reqScannerSubscription( int tickerId,
    ScannerSubscription subscription) {
    // not connected?
    if (!m_connected) {
        error(EClientErrors.NO_VALID_ID, EClientErrors.NOT_CONNECTED, "");
        return;
    }

    if (m_serverVersion < 24) {
      error(EClientErrors.NO_VALID_ID, EClientErrors.UPDATE_TWS,
            "  It does not support API scanner subscription.");
      return;
    }

    final int VERSION = 3;

    try {
        send(REQ_SCANNER_SUBSCRIPTION);
        send(VERSION);
        send(tickerId);
        sendMax(subscription.numberOfRows());
        send(subscription.instrument());
        send(subscription.locationCode());

EClientSocket顶部的客户端版本历史记录。

public class EClientSocket {

    // Client version history
    //
    //  6 = Added parentId to orderStatus
    //  7 = The new execDetails event returned for an order filled status and reqExecDetails
    //     Also market depth is available.
    //  8 = Added lastFillPrice to orderStatus() event and permId to execution details
    //  9 = Added 'averageCost', 'unrealizedPNL', and 'unrealizedPNL' to updatePortfolio event
    // 10 = Added 'serverId' to the 'open order' & 'order status' events.
    //      We send back all the API open orders upon connection.
    //      Added new methods reqAllOpenOrders, reqAutoOpenOrders()
    //      Added FA support - reqExecution has filter.
    //                       - reqAccountUpdates takes acct code.
    // 11 = Added permId to openOrder event.
    // 12 = requsting open order attributes ignoreRth, hidden, and discretionary
    // 13 = added goodAfterTime
    // 14 = always send size on bid/ask/last tick
    // 15 = send allocation description string on openOrder
    // 16 = can receive account name in account and portfolio updates, and fa params in openOrder
    // 17 = can receive liquidation field in exec reports, and notAutoAvailable field in mkt data
    // 18 = can receive good till date field in open order messages, and request intraday backfill
    // 19 = can receive rthOnly flag in ORDER_STATUS
    // 20 = expects TWS time string on connection after server version >= 20.
    // 21 = can receive bond contract details.
    // 22 = can receive price magnifier in version 2 contract details message
    // 23 = support for scanner
    // 24 = can receive volatility order parameters in open order messages
    // 25 = can receive HMDS query start and end times
    // 26 = can receive option vols in option market data messages
    // 27 = can receive delta neutral order type and delta neutral aux price in place order version 20: API 8.85
    // 28 = can receive option model computation ticks: API 8.9
    // 29 = can receive trail stop limit price in open order and can place them: API 8.91
    // 30 = can receive extended bond contract def, new ticks, and trade count in bars
    // 31 = can receive EFP extensions to scanner and market data, and combo legs on open orders
    //    ; can receive RT bars 
    // 32 = can receive TickType.LAST_TIMESTAMP
    //    ; can receive "whyHeld" in order status messages 
    // 33 = can receive ScaleNumComponents and ScaleComponentSize is open order messages 
    // 34 = can receive whatIf orders / order state
    // 35 = can receive contId field for Contract objects
    // 36 = can receive outsideRth field for Order objects
    // 37 = can receive clearingAccount and clearingIntent for Order objects

    private static final int CLIENT_VERSION = 37;
    private static final int SERVER_VERSION = 38;
    private static final byte[] EOL = {0};
    private static final String BAG_SEC_TYPE = "BAG";