In live/paper trading (not backtest) can scuedule_function() be used to run a function 10 minutes BEFORE market open? Does the time_rules.market_open param effectively take hours as 0 and minutes as -10 (NEGATIVE 10)? Or minutes cannot be negative? The docs say it should minimum 1.
If the above does not work then is there a way to run a function 10 minutes before market open? I understand blueshift does not guarantee real time.
I can use before_trading_start method but it is scheduled to run 30 minutes beofre open. That is too early for my needs.
Sorry, seems I missed this earlier.
A scheduled function will only be called during trading hours. For example, if you schedule something beyond the trading hours (for e.g. using hours=11, minutes=0 for NSE which is opened for 5 hours 45 minutes per day), the function will never be called. It is not possible to schedule a function using the scheduling API to run before 10 minutes of market open.
The before_trading_start function is the correct API function to do something before the market opens. Now, since the market is not open yet, and no more than last days data are available for the algo (and since we do not support any pre-market orders), ideally it does not make a difference if the the before_trading_start is called 10 or 30 minutes before the market open. The criteria for the design have been 1) if last day's data are available in the data source (which happens much before 30 minutes from open, usually) and 2) if the broker connections are ready to reconnect (usually many brokers runs a connection/ authorization reset before 30 minutes of open) and 3) if enough time left to run user function computation. These had led us to choose 30 minutes before open as the timing for before_trading_start. I am not sure I can envisage a scenario where running it before 10 minutes is important. If you share your use case, we will look in to the issue.