pilwon / node-ib

Interactive Brokers TWS API client library for Node.js
382 stars 134 forks source link

P&L subscription request #172

Open dspasyuk opened 3 years ago

dspasyuk commented 3 years ago

This project seems to be the best and most complete on the Github. Thank you! The new TWS API supports P&L data requests but it looks like this was never implemented. I was trying to do it myself but I am getting the following error: [12345:62:76:1:0:0:0:ERR] Invalid incoming request type - 0

Here are the functions:

`Outgoing.prototype.reqPnL = function (reqId, group, tags) { if (this._controller._serverVersion < C.MIN_SERVER_VER.ACCT_SUMMARY) { return this._controller.emitError('It does not support PNL requests.'); }

var version = 1;

this._send(C.OUTGOING.REQ_PNL, version, reqId, group, tags); };`

`IB.prototype.reqPnL = function (reqId, acctCode, contractID) { assert(.isNumber(reqId), '"reqId" must be an integer - ' + reqId); // assert(.isNumber(contractID), '"contractID" must be an integer - ' + contractID); assert(_.isString(acctCode), '"acctCode" must be a string - ' + acctCode);

this._send('reqPnL', reqId, acctCode, contractID);

return this; };`

Here is the reference for the API function: https://interactivebrokers.github.io/tws-api/pnl.html

Any help appreciated.

tredondo commented 3 years ago

This project seems to be the best and most complete on the Github.

Unfortunately, node-ib is no longer actively maintained, and uses old JS conventions (no async, no types).

See also @maxicus's (ib-tws-api)[https://github.com/maxicus/ib-tws-api], which has higher potential, esp. if the author will consider TypeScript.

dspasyuk commented 3 years ago

the old convention is not a problem, we can easily promisify those functions, I have done this already for some functions, as for ib-tws-api, I tried it and I do not see any advantages in it. It seems to be very incomplete and uses ES6, which I do not like. New nodejs also require importing as a module and it is not always practical. Not to mention the developer is not very collaborative, but maybe it is just my impression.