2

I have been using a .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. However, the ETRADE API docs says that one must pass some oauthHeader to initialize the CometD session. Does anyone know exactly what that oauthHeader is? Any sample code would be appreciated.

Jimmy
  • 4,610
  • 8
  • 51
  • 71

1 Answers1

1

I modified to the oauth .net library to provide the same oauth header that gets passed to other API http requests:

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

Passing this header to cometd works. I did have to change to a different .net commetd library (nthachus's commetd.net), though; the one I was previously using was ignoring these headers.

Jimmy
  • 4,610
  • 8
  • 51
  • 71
  • I am trying to do the same thing. Can you show how you added the header to cometD in nthachus library? – Jon Kump Jun 27 '18 at 22:05
  • It's been a while now, but I didn't end up using streaming with the E*Trade API; it just didn't work, if I remember correctly. I just poll for order status now. – Jimmy Jun 28 '18 at 13:39