Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Using schedule_function every day BUT mondays. Possible?

I know that I can launch a function every day once the market has started and 1 minute has passed (having a full 1 minuto candlestick):

schedule_function(my_function,  
                      date_rule=date_rules.every_day(),  
                      time_rule=time_rules.market_open(hours=0, minutes=1))  

But what if I wanted to launch the function every day but mondays? Is it possible to combine two conditions somehow?

My target here is to launch the function every day but mondays, first tradeable day of the month and monthly expiration friday (3rd of the month, usually).

Any easy way to achieve this?

EDIT: I asume I can always check current simulation datetime in my_function, but would be lovely to achieve it in an elegant, pythonic way at the schedule_function call.

7 responses

Would something like this work?

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.

Sure, I used get_datetime().date().dayofweek, but of course it works. Just saying it would be cleaner and more elegant if we could do this with a complex schedule_function call

For every day BUT mondays you can combine four schedule_function calls

Well, this is an option too. But I am also looking for a way of avoiding first tradeableday of the mont, which would mean 30-31 rules if done this way.

Bring it on Roman.

Ok, this is a harder one:

Avoid monthly expiration day. I have achieved skipping it if it is the third friday of the month in a similar way to your last example, but we all know this is not always the case due to holidays. So, any idea to get the correct monthly expiration day?