Developing Professional Trading Algorithms on Zerodha: Insights, Strategies, and Code for Sale

Topic: Showcasing My Professional Trading Algorithms on Zerodha

Hello everyone,

I’m excited to share my journey in developing professional trading algorithms using Zerodha’s API. Over the past few months, I have created two powerful algorithms designed to predict market movements and optimize trading strategies. Below, I’ll provide an overview of these algorithms and share some screenshots of their performance.

Algorithm 1: Random Forest Regressor

This algorithm leverages the Random Forest Regressor to analyze market data and predict price movements. It has been fine-tuned to deliver accurate predictions for high, low, and close prices. Here are some of its key features:

  • Historical Volatility Calculation: Incorporates historical volatility to improve prediction accuracy.
  • Technical Indicators: Utilizes RSI, EMA, and MACD to make informed predictions.
  • Robust Model Tuning: Hyperparameters are optimized using RandomizedSearchCV.

Algorithm 2: Light Gradient Boosting Regressor

The second algorithm employs LightGBM for efficient and precise market predictions. It’s designed to handle large datasets and deliver fast, accurate results. Key features include:

  • Advanced Feature Scaling: Uses StandardScaler to normalize input data.
  • Comprehensive Technical Analysis: Integrates multiple technical indicators such as RSI, EMA, MACD, and VIX.
  • Hyperparameter Optimization: Utilizes RandomizedSearchCV for tuning model parameters.

Source Code Availability

I am offering the source code for both algorithms for sale. If you’re interested in enhancing your trading strategies with these professional tools, please feel free to reach out.

I look forward to your feedback and any questions you may have about these algorithms. Let’s discuss and improve our trading strategies together!

Best regards,

Pranav agarwal

Had I been in your place, I would have use these algos to earn from the market rather than selling here!!

6 Likes

Please provide

  1. Backtest results
  2. Walk forward results. This is especially important as you are using ’ Hyperparameter Optimization’, which imo is a quick and “efficient” way towards ‘curve fitting’. You need to test samples outside your optimized periods.

vijay can we connect ofline i can share details

current crop of algos

Machine learning predictor algorithms
nerual bet predictors
trading execution bot which monitor the prices and based on technical indicators being met execute orders
level breakout/breakouk down bots
Trailing stop loss bots to lock in profits

Hello @Pranav_Agarwal ,

Best wishes for your endeavor !

I have also been doing R&D in quantitative trading for many years.

  1. For which time frames did you develop this algorithm?

  2. Have you been back tested, and what is your winning/failure probability?

In my experience, I don’t use TA, and most of Prof. Quant won’t use that. So, based on your research, how did you decide TA would work with your logic?

Hi their ta was used simply for calcuating the indicators i have a list of four algos with me as if know

Random forest Regressor price predictor bot
Gradient Boost price predictor bot
Order Execution bot - Monitors price in realtime and then based on technical indicator values being fulfilled executes the trade
level Breakout/breakdown bot wherein the user can define the levels at the test/retest can be ascertained and then the trade is taken or avoided
LLM integration execution bots which are connected to open ai

Perhaps they tried the first way to make money and that didn’t work out very well, which is why they are trying the second way? One has to make money somehow, you know?

1 Like

at first glance it might seem like that, however the way i see it as that i am tool creator , i understand coding/programming and i build systems for professional traders to use and make their trading more systematic and efficient

1 Like

Indeed. The moot point is whether your systems work better than the best chimpanzee?

Here is an easy way to convince any skeptic about the efficacy of your tools:

  • Publish on this forum a list of:

    • Ten stocks which, as predicted by your tools, will significantly go up next week
    • Ten stocks which, as predicted by your tools, will significantly go down next week
  • Don’t edit the lists after publishing

    • There is an indicator that shows if a post has been edited
  • Wait for the next week to pass, and tell us all that “I told you so!”

  • Now repeat this once again after a couple of weeks, to show us that your original success was not a fluke.

The reason I ask for the second list, is that any arbitrarily chosen set of ten stocks will likely go up next week, since we are in a bull market. It only requires a chimpanzee to come up with those. If your systems are any good, they should also be able to reliably predict stocks that will go down.

What do you say? Are your tools capable of this?

Overview of the Threshold Breakup/Breakdown Bot

Purpose: The bot is designed to monitor the price of an asset (in this case, a specific instrument identified by instrument_token) and execute trades when certain threshold conditions are met. The bot aims to capitalize on price movements by placing orders when prices cross predefined upper or lower thresholds and exhibit specific behaviors.

Detailed Explanation

1. Initial Setup:

  • API Initialization: The bot uses the Kite Connect API to interact with the trading platform. API credentials (api_key, api_secret, and access_token) are required to authenticate and access market data.
  • User Input: The bot prompts the user to input the initial upper and lower threshold levels, the quantity of the asset to trade (in multiples of 15), and the update interval for the thresholds.

2. Threshold Monitoring and Trading Logic:

  • Variables Initialization: Several flags and counters are initialized to keep track of price movements and trade conditions:
    • upper_crossed, lower_crossed, upper_retested, lower_retested, upper_bounced, lower_bounced: Flags indicating the status of price movements relative to the thresholds.
    • ce_repetitions_counter, pe_repetitions_counter: Counters for conditions met before executing a trade.
    • ce_condition_met, pe_condition_met: Flags indicating if conditions for a Call Option (CE) or Put Option (PE) trade are met.
    • bounce_time: The time when the price bounced off the threshold.
    • previous_price: The last recorded price.
    • ce_trigger_point, pe_trigger_point: Trigger points for executing CE or PE trades.
  • Main Monitoring Loop: The bot continuously monitors the price in a loop:
    • Price Fetching: The bot fetches the latest price using the kite.quote method.
    • Threshold Logic: The bot checks if the price crosses, retests, or bounces off the upper or lower thresholds and updates the flags accordingly.
    • Trade Execution Logic: If the conditions for a trade are met (e.g., price bounces off a threshold and stays within the specified range for a certain time), the bot places a trade order using the kite.place_order method.

3. Order Placement and Trade Conditions:

  • Strike Price Calculation: The bot calculates the strike price for the options to be traded based on the last price and the type of option (CE or PE).
  • Order Placement: The bot places a buy order for the calculated strike price when the conditions are met.
  • Trade Conditions Analysis: The bot includes functions to analyze the market conditions before placing a trade:
    • Trade Condition Analysis: The bot analyzes the trend over the last few periods to determine if a significant portion of the candles are bullish (for CE) or bearish (for PE).
    • Slope Condition Analysis: The bot calculates the slope and curvature of the price trend to determine the overall trend direction.
    • High/Low Condition Analysis: The bot examines the high and low prices over a specified lookback period to identify significant price points.

4. Updating Thresholds:

  • The bot periodically prompts the user to update the upper and lower thresholds and resets the relevant flags and counters when the thresholds are updated.

Key Functions:

  1. get_threshold_and_qty(): Prompts the user for initial threshold levels, quantity, and update interval.
  2. monitor_price_and_trade(): Monitors the price and executes trades based on threshold conditions.
  3. calculate_strike_price(): Calculates the strike price for options.
  4. place_order(): Places a trade order.
  5. trade_condition(): Analyzes market conditions to determine if a trade should be placed.
  6. slope_condition(): Analyzes the slope and curvature of price trends.
  7. high_low_condition(): Examines high and low price points over a lookback period.
  8. fetch_and_print_order_details(): Fetches and prints details of a placed order.

I am not interested anyway, but wont be convinced by this. Results of just handful of trades is pure luck more or less.

Pretty difficult to trust your own system. Even more with other people’s system. That too when it apparently has some complexity.

Title: Threshold Breakup/Breakdown Trading Bot

Function: This bot executes buy or sell orders for BankNifty options based on the price crossing specific threshold levels using the KiteConnect API.

How it works:

API Integration:

Connects to Zerodha’s KiteConnect API using provided API key, API secret, and access token. User Input:

Prompts the user to input initial upper and lower threshold levels. Collects the trade quantity (in multiples of 15) and the interval for updating thresholds. Real-time Monitoring:

Continuously monitors the price of BankNifty in real-time using the KiteConnect API. Updates the real-time data every second, checking for price movements relative to the predefined thresholds. Threshold Logic:

Upper Threshold: Monitors if the price crosses, retests, or bounces off the upper threshold. If the price bounces and holds above the threshold for a certain time, a buy order for a BankNifty Call Option (CE) is placed. Lower Threshold: Monitors if the price crosses, retests, or bounces off the lower threshold. If the price bounces and holds below the threshold for a certain time, a buy order for a BankNifty Put Option (PE) is placed. Order Execution:

Calculates the strike price based on the current price. Places market orders for the corresponding options using the KiteConnect API with specified parameters (variety, exchange, tradingsymbol, transaction_type, quantity, order_type, product). Conditions for executing trades are based on the price behavior relative to the thresholds and a predefined hold time. Trade Conditions Analysis:

Trade Condition: Analyzes the market condition over the last few periods to determine if a trade should be placed, requiring a significant portion of candles to be in favor of the trade type. Slope Condition: Analyzes the slope and curvature of the price trend to determine the overall trend direction. High/Low Condition: Examines high and low price points over a specified lookback period to identify significant price points. Threshold Updates:

Prompts the user to update upper and lower thresholds periodically, resetting relevant flags and counters when updated. Key Functions:

get_threshold_and_qty(): Collects initial setup parameters from the user. monitor_price_and_trade(): Monitors prices and executes trades based on defined conditions. calculate_strike_price(): Calculates the optimal strike price for trading options. place_order(): Places trade orders based on monitored conditions. trade_condition(), slope_condition(), high_low_condition(): Various analyses to ensure optimal timing and conditions for trades. fetch_and_print_order_details(): Fetches and displays details of placed orders for user review. Additional Notes:

The bot integrates seamlessly with the trading platform, enabling automated trading based on real-time market conditions. It is essential to continuously monitor and adjust the thresholds based on market conditions to maintain the effectiveness of the bot. The bot is intended to assist with trading and does not guarantee profits. It should be used as part of a comprehensive trading strategy considering the inherent risks of financial trading. Available for Sale:

This advanced trading bot is now available for purchase. Enhance your trading strategy with automated real-time monitoring and execution. For more details, pricing, and to see the bot in action, feel free to reach out.

Contact Me:

For more details, pricing, and a demonstration, please contact on [email protected]. Let’s elevate your trading strategy together!

Don’t expect the traders to understand the technical jargons and functions. Not all of them having background in software engineering.
You can consider to place your pitch based on below suggestion.

I think this would be a convincing way.

have developed a sell logic execution bot as well

Introducing the Execute Sell Logic Bot

Overview:

The Execute Sell Logic Bot is a sophisticated algorithmic trading tool designed to automate the selling process of BankNifty options based on real-time price movements. Utilizing Zerodha’s KiteConnect API, this bot enhances your trading strategy by dynamically managing stop-loss and target prices, ensuring optimal trade execution.

Key Features:

  1. API Integration:
  • Connects seamlessly to Zerodha’s KiteConnect API using the provided API key, API secret, and access token.
  • Fetches order details and real-time price data to monitor and execute trades.
  1. User Input:
  • Prompts the user to input crucial trade parameters:
    • Trade type (Call Option - CE or Put Option - PE)
    • Base price at which the trade triggers
    • Target price for profit
    • Initial stop-loss (SL) price
    • Trailing SL increment value
    • Price at which trailing SL activates
  1. Real-time Monitoring:
  • Continuously monitors the price of BankNifty in real-time.
  • Updates the real-time data every second to check for price movements relative to the predefined thresholds and conditions.
  1. Dynamic Stop-Loss Management:
  • Activates a trailing stop-loss based on user-defined parameters.
  • Adjusts the stop-loss dynamically as the price moves in favor of the trade, ensuring profits are protected.
  1. Order Execution:
  • Executes sell orders based on real-time price, target, and stop-loss conditions.
  • Places market orders for the corresponding options using the KiteConnect API with specified parameters (variety, exchange, tradingsymbol, transaction_type, quantity, order_type, product).

Key Functions:

  • get_order_token(kite, order_id): Fetches the tradingsymbol and quantity for the given order ID.
  • execute_sell_logic(kite, order_id, instrument_token): Implements the main sell logic by monitoring real-time prices, updating trailing stop-loss, and executing sell orders when conditions are met.
  • place_sell_order(quantity, token): Places a sell order for the given quantity and token.

How it Works:

  1. Fetching Order Details:
  • Retrieves the tradingsymbol and quantity for the specified order ID using the KiteConnect API.
  1. Setting Trade Parameters:
  • User inputs the trade type (CE or PE), base price, target price, initial stop-loss, trailing SL increment, and activation price.
  1. Real-time Price Monitoring:
  • Continuously fetches the latest price of the instrument and prints it for monitoring.
  • Activates trailing stop-loss if the price crosses the activation point.
  • Adjusts the stop-loss dynamically based on the price movement and user-defined increment.
  1. Executing Sell Orders:
  • Places a sell order if the current price reaches the target price or falls below the stop-loss.
  • Ensures that the sell logic is robust by handling any exceptions during real-time price fetching or order placement.

Additional Notes:

  • The bot integrates seamlessly with the trading platform, enabling automated trade management based on real-time market conditions.
  • It is essential to continuously monitor and adjust the parameters based on market conditions to maintain the effectiveness of the bot.
  • The bot is intended to assist with trading and does not guarantee profits. It should be used as part of a comprehensive trading strategy considering the inherent risks of financial trading.

Available for Sale:

This advanced trading bot is now available for purchase. Enhance your trading strategy with automated real-time monitoring and execution. For more details, pricing, and to see the bot in action, feel free to reach out.

Contact Me:

For more details, pricing, and a demonstration, please contact on [email protected]. Let’s elevate your trading strategy together!

What you are saying is a joke, Bro.
If user has to feed all these inputs, I don’t know what your software will do.
This is not different from Kite trading platform.

If I’m not wrong you have dittoed Kite using their own API.
:grinning:

@Pranav_Agarwal
If you have clean 1 min historical Index Options data and a thorough backtesting Framework for 1 min options, ping me with a tear-sheet and we can talk.

tell me what you need i will send you

no sir, i can explain what i have done in detail

Finding clean historical 1 min Index Options data is a problem (vendor’s data needs to be prepped/cleaned/formatted before you can use it reliably).

My questions

  1. Have you backtested Index Options (1 min data) using python before? Do you have a good workflow?
  2. If yes, can you DM me a tear-sheet/report/result of any backtest you have done (along with the strategy conditions)?