node-ib
node-ib copied to clipboard
Partially Populated Option / Production Ready? / Errors in Examples
Hi,
First - cool work here! I really like this lib and it's interface.
Next, I have to dynamically gather available options. In other flavors of the IB API (e.g. C#) I can partially populate an option (i.e. just symbol
and right
) to get all the available expiration dates and strikes in contractDetails
event. In the implementation of option there's an assert on the expiry
and strike
parameters which, if I pass undefined/null, fails the assertion. I can easily change it in local copy of the code but wouldn't it make sense to remove the asserts on these two? Or maybe it would be better to define a "partial option" class for such situations?
Next, I run some of the samples and it seems that everywhere bold
is used without the parenthesis (i.e. "some string".bold
instead of "some string".bold()
) which then causes to print the function defs () and not a bold string...
Finally, I was wondering whether this code is "production level" - is it in use in the wild?
Thanks!
Tomer
I am using it and everything mostly works as advertised..
+1 for ability to request the full option chain, if the ib api supports this
@hhamilto IB doesn't support this for pricing - I've dealt with this problem by writing a class that says "take 100 data lines and update these 1000 options as often as possible"...
@sblackstone Thats for the suggestion!
Would you accept a PR removing the asserts that @tomercagan was talking about in .../lib/contract/option.js
?
assert(_.isString(expiry), 'Expiry must be a string.');
assert(_.isNumber(strike), 'Strike must be a number.');
If I comment the above lines out, the api will return several 'contractDetails'
events, with contract details for all the options on any given underlying.
This is one of the methods that IB suggests for discovering the various options available: https://interactivebrokers.github.io/tws-api/options.html#gsc.tab=0 so it makes sense that this module would support it.
I realize that the reqSecDefOptParams
function is the new way to do it, but for the life of me, I can't figure out what to put for the int underlyingConId
parameter.
@hhamilto That would be a question for @claude2 - he is the maintainer of the project..
@hhamilto If you want the contracts for reqSecDefOptParams for IBM, do a contract lookup for secType=STK symbol=IBM and then use that conId..
reqSecDefOptParams will only spit out expirations and strikes available, so if you want all the contracts, iterate over the expirations, e.g. contract details for secType=OPT symbol=IBM expiry=exp[0] ... etc.