Trade on Fed (FOMC) Announcement Dates
Author: gbullr
Creation Date: 5/1/2013 2:08 PM
profile picture

gbullr

#1
How does one create a list/table that checks whether trading on FED Announcement dates can be profitable?

So for example 2 days before to two days after or something like that.

Fed release dates are pre announced so you know when they are going to be but it cannot be programmed like ekections. 1st tuesday in nov of every 4th year etc.

Here are upcoming and hisrtorical fed fund dates:

http://www.federalreserve.gov/monetarypolicy/fomccalendars.htm
2013
April/May 30-1
June 18-19*
July 30-31
September 17-18*
October 29-30
December 17-18*
profile picture

Eugene

#2
From bird's-eye view, one creates a program that downloads the FRB meeting calendar webpage, parses its HTML contents, extracts the list of Fed events and their dates. That's feasible. When I have free time from other projects, I'd like to take it.
profile picture

gbullr

#3
You are a gift from the gods.


On a more general basis:

How does one create a list (that one can manipulate) of specific dates that one can then use in WL to backtest around.

Thanks.

profile picture

Eugene

#4
QUOTE:
How does one create a list (that one can manipulate) of specific dates that one can then use in WL to backtest around.


One could, for instance, create a List<DateTime> and put them into. See C# List for more insight, and you might find a quick illustration below useful:
CODE:
Please log in to see this code.
profile picture

Eugene

#5
Yikes, it took me quite some time to figure out the proper XPath for that FOMC page! But there you have it - a demo strategy that retrieves past and future FOMC meeting dates from that web data source and illustrates how to use them in a trading system.

What's going on under the hood is pretty complex. But C# 4.0 features like anonymous classes together with XPath traversal and LINQ-to-HTML comforts powered by HtmlAgilityPack make the whole strategy under 150 lines.

Prerequisites:

1. Installed Community Components 2012.12 or higher - just because it includes the required HtmlAgilityPack.dll v1.4.6
2. In Strategy Editor, click "References...", scroll down and check: System.Xml and System.Core
3. Until the Editor gets upgraded in WL 6.? to support C#4.0 out of the box, you need to add a reference to System.Core v4.0. Switch to "Other assemblies to reference...", click "Add a reference", find the file called System.Core.dll, highlight it and confirm. The file's placement depends on your OS and WLP "bitness". For 64-bit WLP, choose c:\windows\microsoft.net\framework64\v4.0.30319, for 32-bit WLP it's c:\windows\microsoft.net\framework\v4.0.30319

CODE:
Please log in to see this code.


You should see the following output on a Wealth-Lab chart. Meetings that took a single day are greeenish, multi-day events are green/red:



Buys 2 days before a meeting and exits 2 days after (configurable). Hope that helps.
profile picture

Eugene

#6
With trading rules applied:



P.S. The strategy can have a problem should FOMC decide to start a meeting in December and finish next January; but since that's hardly ever going to happen, I'm not going to fix this potential "issue".
profile picture

gbullr

#7
Would you please help me find a more elegant way of coding what I have done here which is sort of a brute force attack on the problem.

I have the list of fed meeting dates and want to trade 2 days ahead of them in this example (4). I just dont know how to add or subtract valid dates from a datetime list and I have brute forced it.

Thank you.


CODE:
Please log in to see this code.


profile picture

Eugene

#8
On subtracting dates, you will find it among resources mentioned in this FAQ: How do I start with C# ?, in particular on dotnetperls.com.

For the ready-made and elegant solution to this problem that exists for over two months now, don't look no further: see my post #6 and follow instructions there. Thank you for saying thank you.
profile picture

steve3

#9
Hello all-

I just read over an interesting paper which suggests a 5 days after fed meeting buy and 10 days after fed meeting sell for high-beta stocks is an alpha-producing strategy. I was looking over the code and it looks like there's only one parameter (days) -- which is symmetric around the FOMC meeting date. I'm wondering if anyone can help me understand how to change the code to enable two parameters (a "days_after_buy" and "days_after_sell") into this code.

Any help or pointers appreciated.

Here is the paper:

http://faculty.haas.berkeley.edu/vissing/CieslakMorseVissing.pdf
I'm primarily fixed on Figure 2 and Table 3.

Steve
profile picture

Eugene

#10
Steve,

Here is a system variation with two parameters including "exit after Y days". It should work smoothly assuming you have WLP 6.7 (otherwise you may wish to follow installation instructions in post #6):

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

steve3

#11
Eugene,

This is excellent. Thanks for your diligence on this.

One additional change: It looks like the best returns involve a buy 5 days *after* the meeting and a sell 10 days after. But it's not letting me use negative numbers of the "Days before" parameter. What changes need to be made to enable this?

Thanks again. Good stuff.

Steve
profile picture

Eugene

#12
This should do it: now are supported "before" (negative numbers) or "after" for both start/end dates. (Not sure if exiting before a meeting would make sense). Anyway:

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

mikesblack

#13
Greetings,
I have been trying to make this code run, but have been unsuccessful. Nothing happens, including getting the Debug and Error window. I believe I followed the prerequisites as posted before in this thread other than being able to find references in the strategy monitor to select System.Xml.

I am running WL 6.8 on a Win 7 X64 machine. All extensions are up to date.

Can you help me figure this out?

Thanks,

Mike
profile picture

Eugene

#14
Still working perfectly on Daily data in Strategy window mode after adding references to System.Xml and System.Core.
profile picture

gbullr

#15
Strategy no longer works post Sept 2015. what am I doing wrong. Thanks and sorry. Just super strage.

CODE:
Please log in to see this code.


Thanks a lot for help
profile picture

Eugene

#16
Wow, what a persistence (in the wrong direction)!

Not sure why you insist on using this primitive hard-coded kludge (with constructs like "Bars.Count-4") and disregard my completely automated strategy that has been working for years (fortunately, the Fed is conservative enough and doesn't change its website's HTML layout) and my effort to help you (as it was your request).

But if you're looking for help on this, just see post #9. Nothing has changed since 2013!
profile picture

gbullr

#17
I can't get yours to work. That is why.. while mine works just fine until sept 2015 for some damned reason which post 9 does not resolve. On my computer your code generates no trades.

Where do I get system.xml where do I get system.linq

Furthermore when the fed chooses to change the format / of the page my thing would still work and yours may not; therefore I'd rather have the retarded version that I understand cause it is idiot proof (me) vs the y2k version that blows up when you actually need it.


And finally your thing does not have data older than 2011 which does not make for good backtests.

profile picture

Eugene

#18
QUOTE:
Where do I get system.xml where do I get system.linq

Post #6, steps 1 and 2. There's no need to "get it to work": all it takes is to follow the brief instruction and make a few extra clicks. It's super easy.

QUOTE:
On my computer your code generates no trades.

Sure, because there's a compiler error in the Editor that you get due to not following the instruction.

QUOTE:
Furthermore when the fed chooses to change the format / of the page my thing would still work and yours may not

At least in about three months that code will be working 3 years w/o modification.

QUOTE:
And finally your thing does not have data older than 2011 which does not make for good backtests.

I had to work with the link that you provided in post #1.
profile picture

hefrei

#19
It seems as if the fed webpage has changed and the algo is unable to scrape the dates anymore. Is anybody else having these issues?

Potentially this could be a more "stable" source of fed meeting data?

https://fraser.stlouisfed.org/title/677#!535298
profile picture

Eugene

#20
Thanks for the heads-up Heiko.

Previously (2012-2016), the Fed has never abbreviated the months like "Jan/Feb" in 2017. It was like "April/May" in 2013. Although this change came unexpected to the strategy, it's trivial to fix. I've updated it so all it takes for you is to download it.

To do it, click "Download..." in Wealth-Lab's "Open Strategy" dialog and make sure that "Download public strategies" is checked. After downloading and opening the "...[Rev.A]" version, references to required components (System.Core and System.Xml) should be picked up automatically. You're all set.

P.S. I've updated the code above just in case someone else stumbles on them here but it's highly suggested to avoid copy/paste from the older forum posts with required reference manipulations. Instead just download the strategies directly from Wealth-Lab.
profile picture

hefrei

#21
Wow - that was quick. Thanks a lot for your help.
profile picture

Eugene

#22
Attention: Due to a breaking change to HTML layout on Fed's website, Strategy stopped working. I've fixed both the code in this thread and uploaded a "Revision B". To grab it, click "Download" in Wealth-Lab's "Open Strategy" dialog.