OS: Linux, Software Versions: Python 2.6.6, PHP 7.3
• Login to Zerodha
• Place Bracket Orders
• Exit Positions
• Status updates on Telegram bot
• Web Interface
1. Login to Zerodha Account, generate access token, save in database.
2. Page to manage "Primary Settings", "Trade Settings" & "Stock Settings" (check attachments)
3. Manage = Add + Edit + Delete, or just upload csv files at once to update all settings
4. Create bot (1) in my telegram account and push proper error message whenever it encounters
5. bot (2) to push status updates for; Login Status, Advanced Orders Placed, Opening Orders Places, M2M by strategy at frequency set, M2M hit Stop Loss with net loss incurred, M2M hit Target Profit with net profit, final status of positions at 2:55 PM
6. bot (3) to push end of day net M2M by Strategy and Funds available in account, Margin Utilized
7. Log every details and events in mysql database (option to disable once the program is running successfully, should be able to re enabled if any error occurs in future)
8. Access to python script shall be restricted by login id and password
9. At 6PM fetch the Trade Log and update in database for future analysis.
10. Fetch strategy wise settings from "Trade Settings"
11. Schedule to run the program by Strategy defined in “Trade Settings”
12. Fetch the list of stocks “StockSettings” for scheduled strategy where Date column = Daily or Current Date
13. Fetch OHLC for the stocks listed (previous step)
14. If for the list of stocks fetched; Entry_Type, Entry_Price & Quantity is NOT mentioned
a. Check for list of stocks where Open Price = Today High and Open Price = Today Low
b. Shortlist stocks based on % change (stocks whose % change is greater than defined % and less than defined %), if total shortlisted stocks are greater than “Max_Positions” defined in Trade settings, sort the list by absolute % change (ASC Order) to short list again.
15. If for the list of stocks fetched; Entry_Type, Entry_Price & Quantity is mentioned
a. For the list of stocks if Entry_Type = BUY; check Current Market Price is Less than Entry Price and Day High is Less than Entry Price. if Entry_Type = SELL; check Current Market Price is Greater than Entry Price and Day Low is Greater than Entry Price
16. Divide capital to selected stocks
17. If Nifty_Index_Check = TRUE for the strategy, check if % Change is >= Nifty_Index_Min_Change, proceed with placing order if condition is satisfied, else ABORT
18. Place Bracket Order with entry price, stop loss and target profit, trailing stop loss
a. BUY if Open Price = Today Low : Entry Price = Today High + Trigger_Price_Addon
b. SELL if Open Price = Today High : Entry Price = Today Low - Trigger_Price_Addon
19. Exit all stocks by strategy at defined time or if any of the pre defined conditions met.
20. Check M2M by strategy (net profit or net loss of open positions), exit all positions (including pending) by strategy if M2M is >= target profit or <= stop loss (ex. if M2M <= -1000 rs or M2M >= 2000 rs exit \positions)
21. When exit command is triggered based on Trade Settings, Exiting positions shall happen in two phases
a. Phase 1: update bracket orders exit price to current market price (iteration 1)
b. Phase 2: if the positions does not close per iteration 1, force exit positions.
22. Stop checking once all open/pending positions by strategy are closed
Final Clean up:
23. Check and force exit all open positions and pending orders every 5 minutes starting 2:55 PM to 3:15 PM, this shall execute each time independently and not in loop, to ensure if there is any error to close the positions at first time, it should try to close them on next run
• Primary Settings (like credentials and overall settings)
• Trade Settings (at strategy level)
• Stocks Entry (at scrip level)
• Daily Trade Log
Skills Required: Python/PHP, MySQL, Telegram Bot, Proficiency in using Zerodha KITE API