Kite doesn't provide any facility to place the order automatically when market opens or to identify that market has opened.
So you will have to
1. Monitor market open by checking time-stamp of ticks received from websocket. Assume, you started your system at 9.05, got pre-open tick by 9.08. The next tick you will receive is when the market opens. So if you check for time-stamp when tick is received and that time-stamp > 910 am, then market is open. First time you encounter this, you can assume market has just opened and place all your market-open orders.
Caveat is that Zerodha will always give you the last tick when you switch on websocket. Using logic above, if you start websocket at 911 am, then you will receive a tick and erroneously you will assume market has opened. Maybe you can add additional test if the timestamp of tick > 915am.
2. A completely different approach: You can keep querying system time usinf datetime.datetime.now(). if that timestamp > 915am, market is open and you can place your order. This could be done by running an infinite loop which keeps checking system time. Once, you identify that market has opened, you can exit the loop.
3. Implementation of Point 2 is better done in a separate thread using python threading module. Threading module is easy to use and if one spends 2-3 hours on it, one can make it work. As a side note, I recommend everyone to try it. It fairly easy and once a trader gets hang of it, it will reward him immensely. He can carry out multiple activities in parallel and run many loops without blocking the execution of remaining code.
4. Point 3 can be easily implemented using threading.Timer method which will automatically create a thread in background and send a trigger when desired time is crossed.
So you will have to
1. Monitor market open by checking time-stamp of ticks received from websocket. Assume, you started your system at 9.05, got pre-open tick by 9.08. The next tick you will receive is when the market opens. So if you check for time-stamp when tick is received and that time-stamp > 910 am, then market is open. First time you encounter this, you can assume market has just opened and place all your market-open orders.
Caveat is that Zerodha will always give you the last tick when you switch on websocket. Using logic above, if you start websocket at 911 am, then you will receive a tick and erroneously you will assume market has opened. Maybe you can add additional test if the timestamp of tick > 915am.
2. A completely different approach: You can keep querying system time usinf datetime.datetime.now(). if that timestamp > 915am, market is open and you can place your order. This could be done by running an infinite loop which keeps checking system time. Once, you identify that market has opened, you can exit the loop.
3. Implementation of Point 2 is better done in a separate thread using python threading module. Threading module is easy to use and if one spends 2-3 hours on it, one can make it work. As a side note, I recommend everyone to try it. It fairly easy and once a trader gets hang of it, it will reward him immensely. He can carry out multiple activities in parallel and run many loops without blocking the execution of remaining code.
4. Point 3 can be easily implemented using threading.Timer method which will automatically create a thread in background and send a trigger when desired time is crossed.