Algorithmic Trading

Automated TP/SL Management

Trading Bot to automatically manage staggered stop loss and take profit orders on Zerodha

Automated Order ManagementZerodhaWebsocketsWeb DevelopmentAPI DevelopmentPythonFlaskNextjsTypescriptCapital Markets

Problem Statement

In intraday trading, it is difficult for a human to manage multiple positions and all the orders associated with each position. An Indian proprietary trader wanted a trading system that would automatically place and manage staggered TP and SL orders as soon as a manual position is taken in the brokerage account. The system was required to trade on Zerodha and track all types of instruments including stocks, futures, options and commodities.

Challenges

  • The trading bot was required to run in the background on a server and thus extra monitoring safeguards were needed
  • Managing placement and cancellation of large number of orders in different types of instruments

Solution

Summary

I developed a real-time price and account tracking trading system that would detect positions as soon as they are manually entered and places OCO TP and SL orders as per pre-defined rules. The trading system was designed to manage the orders it places such as modification of order prices based on price movement and cancellation of orders in case of manual exits.

Key Features

  • Web application deployed on a server to control the bot
  • User-friendly interface to provide inputs on profit and stop loss orders
  • Ability to turn on/off order placement in specific instrument types
  • Structured tracking of trades data history for analysis
  • Easy monitoring through real-time logs displayed in the web interface

Technologies Used

  • Nextjs with typescript and tailwindcss for frontend
  • Python Flask backend
  • Websockets for real-time data streaming
  • Zerodha API
  • Linux server on AWS
User-friendly Interface for Strategy Inputs

User-friendly Interface for Strategy Inputs

Structured Tracking of Trades

Structured Tracking of Trades

Easy Monitoring through Real-Time Logs

Easy Monitoring through Real-Time Logs

Results & Impact

< 1s

Latency in Order Placement

Have a similar challenge?

Let's discuss how we can develop solutions for your specific use case.

More Case Studies