How to check if tomorrow is OptionExpiry
Author: dansmo
Creation Date: 2/9/2011 9:56 AM
profile picture

dansmo

#1
Hi,

in a realtime script I need to check if tomorrow is option expiry. Therefore I just wanted to use IsOptionExpiry function but the function needs Bars as input. Is it possible to create a function that uses a DateTime as input for IsOptionExpiry?
profile picture

Eugene

#2
Hi,

What the problem is with passing a future bar to the function in a realtime script? Could have suggested "use DateTimeToBar" but I'm curious.
profile picture

dansmo

#3
Hmm, I thought passing Bars.Count will result in an index out of bounds error? At least I had this error before posting the question. If the script runs on Bars.Count-1 how can I tell that tomorrow is option expir?
CODE:
Please log in to see this code.
?
profile picture

Eugene

#4
CODE:
Please log in to see this code.
profile picture

Cone

#5
Note quite as slick as Eugene's solution (though you'll still have to add a day to the current date)... WealthScript Programming Guide > WealthLab.Rules Classes > OptionExpiryDate

CODE:
Please log in to see this code.

profile picture

dansmo

#6
Thank you!
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).