Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Identifying Non Farm Payrolls (first friday of each month)

What would the code look like to identify the first friday of each month. If you wanted to restrict your algo to trade only these days. Of this subset of days, if you wanted to restrict your algo to trade only after certain time (minutes) interval after release of the data. Data is released at 8:30 am EST.

9 responses

if (NFP) day,

if (minutes) after 8:30 AM EST, than check condition A
if condition A true, than buy (SID A) at market, quantity (account balance/current SID A market price)
if (minutes) after 8:30 AM EST, than check condition B
if condition B true, than buy (SID B) at market, quantity (account balance/current SID B market price)

if condition A position active, and condition A becomes false, than exit condition A position at market price
if condition B position active, and condition B becomes false, than exit condition B position at market price

if at the 3:30 pm EST condition A position or condition B position active, exit position and stop algo

To avoid putting in a market order with a quantity greater than current account balance will cover, calculate quantity and subtract 10 from quantity before market order is submitted.

Since there are only 12 dates/year, writing the dates into the algo itself may be a easier solution.

You'll want to use schedule_function for your date/time management: https://www.quantopian.com/help#ide-schedulefunction

Keep in mind that orders can only be submitted during trading hours, 9:30AM - 4PM EST. Quantopian doesn't support pre or post auction pools. That should give you a heads start!

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

This Friday is NFP day, volatility metrics will be through the roof unless things quiet down across the Pacific. Last Friday should have been but it was a holiday. If any coders wish to collaborate let me know.

The concept works off the smallest timeframe available which is the 1 minute bar chart. Ideally a tick chart is best.

I have a pretty good read of price action in the markets unfortunately only some of that understanding can be translated to code.

I've just written a Quantopian algorithm to identify the first trading Friday of each month. Here is its log output pasted from the window:

2015-01-02PRINTTrading 2015-01-02 Fri  
2015-02-06PRINTTrading 2015-02-06 Fri  
2015-03-06PRINTTrading 2015-03-06 Fri  
2015-04-10PRINTTrading 2015-04-10 Fri  
2015-05-01PRINTTrading 2015-05-01 Fri  
2015-06-05PRINTTrading 2015-06-05 Fri  
2015-07-10PRINTTrading 2015-07-10 Fri  
2015-08-07PRINTTrading 2015-08-07 Fri  
2015-09-04PRINTTrading 2015-09-04 Fri  
2015-10-02PRINTTrading 2015-10-02 Fri  
2015-11-06PRINTTrading 2015-11-06 Fri  
2015-12-04PRINTTrading 2015-12-04 Fri  
End of logs.  

Markets were closed on April 3rd for Good Friday, and on July 3rd in observance of July 4th.

Interested in writing something in time for tomorrow?

Sure.. Send me a message privately on what framework you would like to collaborate. I'm open to 50:50 model, give me some biographical information also/CV.

Krishna

I sent you a private message. It should be in the inbox, or spam folder, of the account Quantopian has on file.

I clicked on your name, then pressed a button in the upper-right corner marked "Send a message to Krishna". Try sending one to me.