mattsta / icli

interactive brokers ibkr api command line interface cli giving you the fastest way to lose all your money
Other
84 stars 19 forks source link

Issue trying to add SPX option via icli #2

Closed g5paul closed 1 year ago

g5paul commented 1 year ago

Hi Matt, Really like this CLI you created for IBKR! I've been able to add options for stock and ETFs. I tried to add one for the SPX Index where it can be seen in the TWS app, however when adding it using icli got the following error below

paper> add SPX221117C00387500 2022-10-26 09:37:10.065 | ERROR | eventkit.event:emit:201 - API Error [orderId 59] [code 200]: No security definition has been found for the request for Option(symbol='SPX', lastTradeDateOrContractMonth='20221117', strike=387.5, right='C', exchange='SMART', currency='USD') 2022-10-26 09:37:10.066 | ERROR | icli.lang:run:2444 - Failed to find live contract for: OrderRequest(orders=[Order(side=<Side.UNSET: 64>, multiplier=1, symbol='SPX221117C00387500', limit=None, stop=None)], size=1, start=None, end=None) 2022-10-26 09:37:10.066 | INFO | icli.cli:dorepl:1881 - [add] Duration: 0.1227

Let me know if you need more info/details, kind regards

mattsta commented 1 year ago

Thanks for your interest!

That's an easy fix (just because I type these things so much so it's easy to spot):

You typed SPX221117C00387500 but the correct format would be SPX221117C03875000 (so your original symbol was asking for "$387.50" which isn't a valid SPX strike, but there are also new XSP daily 1/10th SPX options too with hundreds instead of thousands strikes).

Basically the option symbol dollar values go up to $99,999.9999 so $3,875.00 is 03875000 (always 3 cents places too just because of the OCC definition).

Easiest way to remember the format:

I have another batch of changes I need to push out soon too that will change the options logic a bit with SPX vs. SPXW handling, so check for new commits mentioning the change soon (going forward you'd use add SPXW221117C03875000 instead if you want daily SPXW instead of the monthly morning opex legacy SPX options).

g5paul commented 1 year ago

Hi Matt, Ouch! User error on my part. Should have double checked it better. Thanks for clarifying the format! Looking forward to the changes especially for the SPX with daily support! Cheers

mattsta commented 1 year ago

Glad it was easy to resolve!

Added new batch of minor feature updates today. Previously it was converting SPX options to SPXW by default, but now it understands SPXW directly going forward.

updates also have a new shorthand for referencing each quote symbol by line number which helps with re-using long live quote symbols in commands (e.g. :33 for the 33rd line instead of quote symbol in commands; also helps with quote removals since it's easier to zap a single line with remove :22 etc)