Keyboard Shortcuts
Лайки
Пошук
No definition for SPX option using LocalSymbol
Could somebody advise why I'm getting "No security definition" error for a contract with this local symbol : C SPX 20241218 5945 W
Security: SPX index
Strike: 5945
Side: Call
Expiration: 2024-12-18
Type: Weekly
Trying to send order to buy and sell SPX index options. When I set separate contract properties such as strike, symbol, expiration, currency, and exchange, place order request returns error "ambiguous definition" because API returns the same expiration date for monthly and weekly options.
There are several ways to make contract definition for option unique, e.g. using TradingClass or LocalSymbol properties. When I try to use LocalSymbol I get error "No security definition found"
Example of local symbol that I used : C SPX 20241218 5945 W
Format mentioned in the docs : TWS API: Basic Contracts
|
For SPX OPT you have to set up `Contract.TradingClass` as `SPX` for monthlies and `SPXW` for daily/weekly expiration. Do not define `LocalSymbol`. For naked SPX options, just do `Symbol`, `SecType`, `Exchange`, `Currency`, `TradingClass`, `Strike`, `Right` and `LastTradeDateOrContractMonth`. Good luck, Daniel.
--
Daniel |
The Contract Inspector shows you the actual local symbol to use. US options and European options have different local symbol formats: you’ve tried to use the European format for a US option.
The local symbol you need is:
SPXW 241218C05945000
which is probably in your screenshot, except it’s too small and fuzzy to read.
Richard
From: twsapi@groups.io <twsapi@groups.io> On Behalf Of Andy Sanders via groups.io
Sent: 19 December 2024 05:16 To: twsapi@groups.io Subject: [TWS API] No definition for SPX option using LocalSymbol
Could somebody advise why I'm getting "No security definition" error for a contract with this local symbol : C SPX 20241218 5945 W
Security: SPX index Strike: 5945 Side: Call Expiration: 2024-12-18 Type: Weekly
Trying to send order to buy and sell SPX index options. When I set separate contract properties such as strike, symbol, expiration, currency, and exchange, place order request returns error "ambiguous definition" because API returns the same expiration date for monthly and weekly options.
There are several ways to make contract definition for option unique, e.g. using TradingClass or LocalSymbol properties. When I try to use LocalSymbol I get error "No security definition found"
Example of local symbol that I used : C SPX 20241218 5945 W Format mentioned in the docs : TWS API: Basic Contracts
|
Yes, I mentioned that I can use TradingClass to separate monthly and weekly options. The problem is that it is supposed to be generic method that I could use to form a contract for any security type, SPX index option, QQQ stock option, ES futures option. In this case, it is not clear what I should provide in the TradingClass property.
If there is a strict rule that defines how TradingClass needs to be set, e.g. symbol name + expiration type = SPXW, then I could use TradingClass instead of LocalSymbol but I haven't seen any docs describing how to set TradingClass depending on SecType. LocalSymbol does define specific format for all type of options, it is more generic, so I decided to go with it. |
For the future readers.
I was using data coming from Schwab and each SPX contract had two dates, "LastTradingDate" and "ExpirationDate". I was trying to use option contract expiring the same day to place order in IB but it was rejected because even though contract is expiring today, the last trading day for that contract was yesterday. |
Повідомлення
Більше