Days to Option Expiration
Author: benito747
Creation Date: 12/18/2009 7:15 AM
profile picture

benito747

#1
Is there a function which returns #days to option expiration for 5.6?
profile picture

dansmo

#2
Take a look in the quick ref:

CODE:
Please log in to see this code.


Thiw function will return true if the bar is an expiration date.
profile picture

Cone

#3
Open up the Strategy Builder and check out the "Calendar Fundamentals" conditions.
profile picture

rgfekula

#4
I am having a problem executing a buy n days befor X day (fundamental data). The problem is that n days before X day may fall on a week end or holiday. Seems we should only include day bars for which the market is open. Any idea how to get around this problem?
profile picture

Cone

#5
Is that a Rule in the Strategy Builder? Your own code? Either way, let's see what you've done, and maybe we can help clean it up. (Click the CODE button before pasting code here.)
profile picture

rgfekula

#6
CODE:
Please log in to see this code.

The code has been generated from the rules. I tried to fix using additional code to cover weekends. It seems to be working but I still have a problem on the exit. The idea is to buy before xday and get out day before xday. As it is it can be used but exceptions still occur ie Martin Luthers Holiday (3 in a row of closed days). Also I am not sure if Fidelity posts the xday in a timely fashion so the code could work.
profile picture

Cone

#7
Okay, you're talking about "ex day". "X" sounded more like a variable.

You've got the right rule, but I see what you mean. Calendar days are used in the Rules so that you can take action on a known future event before the bar is present in the chart, which is what you want to do.

QUOTE:
not sure if Fidelity posts the xday in a timely fashion so the code could work.
If you update your data on a daily basis, dividend ex-dates are generally available many days in advance. 8 days? probably. For example, the HPQ dividend ex-date on 3/15/2010 is showing up, as is KO and MRK on 3/11/2010, VZ on 4/7/2010, and even 2 ex dates for WMT on 3/10 and 5/12.

Anyway, here's a new function, TradingDaysBetweenDates (that needs more work before going into Community.Components) that you can use to calculate the number of trading days for future ex dates. When the ex-dates are found in the chart, we know that bar number directly, so the code uses that. But when the next event(s) occur in the future, it uses TradingDaysBetweenDates.

CODE:
Please log in to see this code.



profile picture

Eugene

#8
QUOTE:
// Read Holidays from Markets.xml

To simplify things, I'd suggest using the Holidays property of the Bars.MarketInfo Class.
profile picture

Cone

#9
Doh! Is that documented somewhere? ;)

Updated above. Thanks.
profile picture

rgfekula

#10
QUOTE:
Thanks guys for your fast response. The code you provided works great. Can you recommend any code reference books. My coding experience is Fortran and early basic. I can follow some of the coding but don't have a good reference book.
profile picture

Eugene

#11
Speaking of C# reference books:

Herb Schildt's C# Complete Reference
Some Wrox books like Professional C# by Karli Watson et al.
Troelsen's Pro C# 2008 4th ed.
Ed Deitel's C# How to Program
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).