Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Rebalance versus schedule_function - sudtleties...

Hi everyone, this forum is great!

After reading on the forum and the documentation, I have a question...

Why using:
schedule_function(rebalance,
date_rules.every_day(),
time_rules.market_open())

if the Schedule_function perform the same task everyday:
schedule_function( date_rules.every_day(), time_rules.market_open())

In my mind, someone would use rebalance at the different time to add more safety to the algo performance...

What am I missing here?

Thanks

Johanne(a very dedicated beginner) :)

4 responses

You mean with high volumes to try to frustrate any front-running by insiders on Wall Street?

One can schedule a 'rebalance' for many times a day. This could be done with a simple 'for loop':

period_in_minutes = 5  
for minutes_offset in range(1, 390, period_in_minutes):  
    # 390 minutes in a full trading day (6.5 x 60)  
    schedule_function(  
            my_rebalance,  
            date_rules.every_day(),  
            time_rules.market_open(minutes=minutes_offset),  
            half_days = True)  

There is certainly variability in volume and pricing thoughout a day, but depending upon your algorithm, this variability may not impact your total results much. Try running your algorithm at different times and see how much of an impact it has.

One BIG reason you may wish to trade/rebalance once a day is that it greatly simplifies your order logic. If you are trying to trade multiple times a day then you will need to look at any outstanding orders and if there are any orders that have been partially filled. You may also need to cancel some existing orders and then wait and see that they were actually canceled. This is all doable but also adds a lot of complexity. Verify this complexity has a payoff. At least you may want to start simple and add this later.

A simple effective way to capitalize on intra-day price movements is to use limit orders. If you expect price to vary during the day, then simply put in a single limit order, at the beginning of the day, at the extremes of that variance. I would generally ALWAYS trade using limit orders as best practices anyway.

From your rseponse, what I understand, also, is the importance of being vigilant, even if the algo supposed to be "automated". This knowledge that you are bringing, gives a general understanding, that helps connecting the documentation in a concrete setting.

Thanks for you clear explanation, it's appreciated!

Johanne

Blue,

I don't have the money for high volume... :) yet...