Back to Community
Schedule function: @beginning of hour open orders, @ close of hour close all orders, @ beginning of next hour open orders... and repeat

I want to trade multiple securities every hour. ie open at the beginning of the hour, close at the end of the hour. Then reopen more orders at the start of the next hour.

I am thinking I schedule my function for every trading hour. The first thing my function does is close all open positions, then immediately opens more up.

My question relates to how quantopian interprets this and how the slippage models fits in. I have a feeling I will be over leveraged accidentally, is this true? My logic is that for a one minute bar (that is the bar that triggers my schedule function to order) it seems odd to close all and reopen new positions instantaneously within that bar.

Currently my code looks like:

close all positions

for i in range(len(context.security_list)):
order_percent(context.security_list[i], 0)

open new positions for i in range(len(context.security_list)):

    if data.can_trade(context.security_list[i]):