Is there a function which returns #days to option expiration for 5.6?
Size:
Color:
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.
Size:
Color:
Open up the Strategy Builder and check out the "Calendar Fundamentals" conditions.
Size:
Color:
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?
Size:
Color:
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.)
Size:
Color:
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.
Size:
Color:
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.
Size:
Color:
QUOTE:
// Read Holidays from Markets.xml
To simplify things, I'd suggest using the Holidays property of the Bars.MarketInfo Class.
Size:
Color:
Doh! Is that documented somewhere? ;)
Updated above. Thanks.
Size:
Color:
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.
Size:
Color:
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
Size:
Color: