E*Trade API 使用 CometD 进行流式传输

E*Trade API Streaming with CometD

我一直在使用.net library to create an oauth session, and submit, modify and cancel orders using the ETRADE api. Now I need to listen for account & order events. As per the ETRADE API documentation, they use CometD & long poling. I did find a .net CometD implementation。然而,ETRADE API 文档说必须通过一些 oauthHeader 来初始化 CometD 会话。有谁知道那个 oauthHeader 是什么?任何示例代码将不胜感激。

我修改了 oauth .net 库以提供传递给其他 API http 请求的相同 oauth header:

public string GetOauthAuthorizationHeader(string url)
{
    NameValueCollection headers = _session.Request(_accessToken).Post().ForUrl(url).GetRequestDescription().Headers;
    return headers[Parameters.OAuth_Authorization_Header];
}

将此 header 传递给 cometd 有效。不过,我确实必须更改为不同的 .net commetd 库 (nthachus's commetd.net);我之前使用的那个忽略了这些 headers.