¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

securityDefinitionOptionParameter to get ONLY specific expirations Option Strikes


 

A very good day to everyone. I'm a newbie here and wished to seek some guidance and advise.

By using Python,?I wished to retrieve ONLY specific expirations 20230317 available Option Strikes?(and NOT all the combined Strikes throughout all expirations) with the following codes :-

Code #1
def securityDefinitionOptionParameter(self, reqId, exchange, underlyingConId, tradingClass,
multiplier, expirations, strikes):
for expiration in expirations:
if expiration == "20230317":
strikelist = [strike for strike in strikes]
strikelist = sorted(strikelist)
print(f"Expirations: {expiration}")
print(f"Strikes: {strikelist}")

Code #2
def securityDefinitionOptionParameter(self, reqId, exchange, underlyingConId, tradingClass,
multiplier, expirations, strikes):
for expiration in expirations:
if expiration == "20230317":
for strike in strikes:
strike = sorted(strike)
print(f"Expirations: {expiration}")
print(f"Strikes: {strike}")

But result always comes back with the FULL available strikes combined from ALL expirations date.

I would really appreciate if you can advise me on how to?retrieve ONLY specific expirations 20230317 available?Option?Strikes.

Thanking you in advance for your kind attention.

Best regards.


 

If you are only looking for a specific instrument, or a small set of instruments, you probably are aware that reqContractDetails should allow you to specify contract last trading day (amongst others thing) Isn't it what you need ?


reqSecDefOptParams is explicitly designed to be exhaustive.?
I am not sure your approach is wrong. There is not so many expiration dates that you will waist a lot of IO and CPU with a loop search.