Python based Algo trading bot for Nifty / Banknifty futures and options

Overview

Fully automated Alice Blue Algo Trading with Python on NSE and MCX for Nifty / Crude / Banknifty futures and options , absolutely FREE !

This algo trading bot is my first attempt to try, learn and implement my python programming skills. Please use this only for reference and at your own risk.
This repository contains python code to perform algo trading on India, NSE through AliceBlue broker. You need to have a valid AliceBlue client ID, password, 2FA authentication password set and API enabled (ask aliceblue support) to get this working. This program is focused on Nifty and Crude futures with a simple Supertrend with RSI strategy. Initially, I had developed this for windows then later moved to linux (ubuntu) platform on AWS. Now I am working on moving this to Oracle cloud as its free :) and this version works smoothly with the free tier as well ;-)

There are 2 programs:

  1. For Options trading - ab_options.py which uses ab_options.ini as configuration/parameter file.
  2. For Futures trading - ab.py which uses ab.ini as configuration/parameter file.

These programs basically uses 3min (low) , 6min (medium) time frame supertrend and RSI indicators (adjusted through parameters) to generate signals. For any other strategy you need to modify the main program. My wish list includes parameterisation of this strategy peice as well.

There is a background program (ab_bg.py) which runs at the background and helps us to control our algo bot from anywhere using telegram. We can send commands through telegram chats to do various activities in realtime like start/stop trading, set MTM levels, manage SL, get detailed logs etc. basically all the realtime config parameters can be managed/modified through telegram chats.

The main program ab.py/ab_options.py which needs to be scheduled at 8:59:30 AM / 9:14:00 AM daily through linux crontab. Crude(MCX) opens at 9:00 AM and Nifty at 9:15 AM. You can setup AWS instance to start at 8:45 AM and stop at 11:45 PM (After MCX Close) through AWS Lambda. I typically set both of the programs on seperate AWS instances and configure two seperate IDs. You can read through the comments in the ab.py/ab_options.py for detailed understanding.

There is an ab.ini/ab_options.ini file which is the key configuration file through which you can control all the parameters of this program, even at realtime using Telegram chats.

Will update proper documentation soon...

Although this is still work in progress, kindly suggest your feedback. It will help me improve.

Feel free to use/diustrubte this code freely so that new algo developers can get started easily.

You might also like...
A Discord bot to allow people to create lists of random characters, with limit reroll options.

Mugen Bot A small bot I made to practice python and allow people to publically select random characters on a discord server. Uses py-cord, as that is

A discord token nuker With loads of options that will screw an account up real bad, also has inbuilt massreport, GroupChat Spammer and Token/Password/Creditcard grabber and so much more!
A discord token nuker With loads of options that will screw an account up real bad, also has inbuilt massreport, GroupChat Spammer and Token/Password/Creditcard grabber and so much more!

Installation | Important | Changelogs | Discord NOTE: Hazard is not finished! You can expect bugs, crashes, and non-working functions. Please make an

A discord token nuker With loads of options that will screw an account up real bad
A discord token nuker With loads of options that will screw an account up real bad

A discord token nuker With loads of options that will screw an account up real bad, also has inbuilt massreport, GroupChat Spammer and Token/Password/Creditcard grabber and so much more!

A Multi-Tool with 30+Options.
A Multi-Tool with 30+Options.

A Multi-Tool with 30+Options.

This is a cryptocurrency trading bot that analyses Reddit sentiment and places trades on Binance based on reddit post and comment sentiment. If you like this project please consider donating via brave. Thanks.

This is a cryptocurrency trading bot that analyses Reddit sentiment and places trades on Binance based on reddit post and comment sentiment. The bot f

Fully Dockerized cryptocurrencies Trading Bot, based on Freqtrade engine. Multi instances.

Cryptocurrencies Trading Bot - Freqtrade Manager This automated Trading Bot is based on the amazing Freqtrade one. It allows you to manage many Freqtr

A Pancakeswap and Uniswap trading client (and bot) with limit orders, marker orders, stop-loss, custom gas strategies, a GUI and much more.
A Pancakeswap and Uniswap trading client (and bot) with limit orders, marker orders, stop-loss, custom gas strategies, a GUI and much more.

Pancakeswap and Uniswap trading client Adam A A Pancakeswap and Uniswap trading client (and bot) with market orders, limit orders, stop-loss, custom g

Comments
  • STX Issue in Supertrend while trying to run it.

    STX Issue in Supertrend while trying to run it.

    Hi, Can you please let me know why am I getting this issue, also if you have done some update to the code can you please share. STX contains NaN as assigned in ab_lib.py from the supertrend function.

    Traceback (most recent call last): File "C:/Users/Rex/Desktop/Trading/alice_blue-main_Rajesh/ab_options.py", line 1368, in strMsg="BankNifty: #={}, ST_LOW={}, ST_LOW_SL={}, ATR={}, ST_MED={}, ST_MED_SL={}, ltp_bank_ATM_CE={}, ltp_bank_ATM_PE={}".format(df_bank_cnt, super_trend_bank[-1], round(df_bank.ST.iloc[-1]), round(df_bank.ATR.iloc[-1],1), df_bank_med.STX.iloc[-1], round(df_bank_med.ST.iloc[-1]), ltp_bank_ATM_CE, ltp_bank_ATM_PE) File "C:\Users\Rex\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\generic.py", line 5487, in getattr return object.getattribute(self, name) AttributeError: 'DataFrame' object has no attribute 'STX'

    opened by rex3992 5
  • Key error while checking the order history in alice blue

    Key error while checking the order history in alice blue

    Hi, Rajesh

    I am frequently checking the order history of my orderId . Consider it is less than second time frame .

    Following is the error i am getting, looks like the order history dictionary output is missing in between when i am querying.

    Traceback (most recent call last):

    orders = alice.get_order_history()["data"]["completed_orders"] KeyError: 'completed_orders'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):

    Basically my script almost ran for 15 minutes in the loop where it was able to check the status continuously. If you are able to judge, please guide me with some solution.

    Sent the same issue to krishna also. Incase if you are aware please help me.

    On further debug i understood that , after some 5 to 10minutes, there is a break happening for the output too. But that is not creating the exception.

    If we run the following code for 1 hr and notice we can see following 2 conditions :

    1. Sometimes order history output will take a break of more than 30 seconds
    2. Sometimes exception on the "order_complete" handle too.

    Code used for checking :

    while(True): orders=alice.get_order_history()["data"]["completed_orders"] print(f'orders is {orders}')

    Thanks and Regards Arjunesh

    opened by arjuneshm 2
  • Please help me with it

    Please help me with it

    i am getting this error. please help me

    2021-10-04 09:52:40.426895|1|Initialising D:\Python\alice_blue-main\ab.py 2021-10-04 09:52:40.883586|1|Setting up initial sleep time of 2 seconds. Traceback (most recent call last): File "C:\Users\home\AppData\Local\Programs\Python\Python39\lib\configparser.py", line 789, in get value = d[option] File "C:\Users\home\AppData\Local\Programs\Python\Python39\lib\collections_init_.py", line 941, in getitem return self.missing(key) # support subclasses that define missing File "C:\Users\home\AppData\Local\Programs\Python\Python39\lib\collections_init_.py", line 933, in missing raise KeyError(key) KeyError: 'nifty_no_trade_zones'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): File "D:\Python\alice_blue-main\ab.py", line 236, in nifty_no_trade_zones = eval(cfg.get("info", "nifty_no_trade_zones")) File "C:\Users\home\AppData\Local\Programs\Python\Python39\lib\configparser.py", line 792, in get raise NoOptionError(option, section) configparser.NoOptionError: No option 'nifty_no_trade_zones' in section: 'info'

    opened by raypixell 1
Releases(v7.3.8)
Owner
Rajesh Sivadasan
Coding is my passion!
Rajesh Sivadasan
Tiktok 2 Instagram With Python

Tiktok2Instagram 📸 About The Project What it does: Download the source video from a user inputted Tiktok URL. 📙 Add audio to the Tiktok video from a

Carter Belisle 4 Feb 06, 2022
Work with the AWS IP address ranges in native Python.

Amazon Web Services (AWS) publishes its current IP address ranges in JSON format. Python v3 provides an ipaddress module in the standard library that allows you to create, manipulate, and perform ope

AWS Samples 9 Aug 25, 2022
A tiktok mass account creator with undetected selenium and email verification, to bot an account

⚠️ STILL UNDER DEVELOPEMENT - v1.1-beta ⚠️ Adding PROXY ROTATION Adding EMAIL VERIFICATION Adding USERNAME COMPILER Tiktok Mass Bot Creator v1.1-beta

xtekky 11 Aug 01, 2022
Powerful Telegram bot to countdown to your important events in any group chat.

Powerful Telegram bot to countdown to your important events in any group chat. Live countdown timer.

118 Dec 30, 2022
Tubee is a web application, which runs actions when your subscribed channel upload new videos

Tubee is a web application, which runs actions when your subscribed channel upload new videos, think of it as a better IFTTT but built specifically for YouTube with many enhancements.

Tomy Hsieh 11 Jan 01, 2023
A bot for Large Fry Larrys

GroupMe Bot Driver This driver is written entirely in Python, and with easy configuration in mind. Using this driver, you'll be able to monitor multip

1 Oct 25, 2021
Simple stock price analytics

mune · Mune is an open source python web application built to analyze stocks, named after Homma Munehisa. Currently, the forecasting component is powe

Richard Hong 14 Aug 30, 2021
Discord bot for Ukrfans Discord server

Ukrfans Discord Bot Discord bot for Ukrfans Discord server. 💡 Prerequisites Python ⚙️ Build & Run Create an .env file in the root directory and add t

3 Jun 24, 2022
Financial portfolio optimisation in python, including classical efficient frontier, Black-Litterman, Hierarchical Risk Parity

PyPortfolioOpt has recently been published in the Journal of Open Source Software 🎉 PyPortfolioOpt is a library that implements portfolio optimizatio

Robert Martin 3.2k Jan 02, 2023
Cdk-python-crud-app - CDK Python CRUD App

Welcome to your CDK Python project! You should explore the contents of this proj

Shapon Sheikh 1 Jan 12, 2022
Want to play What Would Rather on your Server? Invite the bot now!😏

What is this Bot? 👀 What You Would Rather? is a Guessing game where you guess one thing. Long Description short Take this example: You typed r!rather

丂ㄚ么乙ツ 2 Nov 17, 2021
Holly ♥️ is usefull group management bot in telegram 🎋

Holly ♥️ is usefull group management bot in telegram 🎋

Kasun bandara 1 Dec 03, 2021
Discord bot that automatically fills out health screenings

Auto Covid Bot Automatically fill out the NYC DOE health screening form by registering with a discord bot School code can be found on https://schoolse

Cleo 2 Jul 29, 2022
A simple python discord bot with commands for moderation and utility.

Discord Bot A simple python discord bot with commands for moderation, utility and fun. Moderation $kick user reason - Kick a user from the server

3 Jan 07, 2022
A userbot made for telegram

𝚃𝙷𝙴 𝙼𝙰𝙵𝙸𝙰𝙱𝙾𝚃 This is a userbot made for telegram. I made this userbot with help of all other userbots available in telegram. All credits go

MafiaBotOP 8 Apr 08, 2022
AutomaTik is an automation system for MikroTik devices with simplicity and security in mind.

AutomaTik Installation AutomaTik is an automation system for MikroTik devices with simplicity and security in mind. Winbox is the main tool for MikroT

Osman Kazdal 4 Dec 05, 2022
API RestFull web de pontos turisticos de certa região

##RESTful Web API para exposição de pontos turísticos de uma região## Propor um novo ponto turístico Moderação dos pontos turísticos cadastrados Lista

Lucas Silva 2 Jan 28, 2022
Script to get a notification when a product, on Amazon Warehouse, is available within a target price

Amazon_Warehouse_Scraping This script aims to scrape Amazon Warehouse and send an email back if there are products whose price matches with the target

2 Oct 25, 2021
Discord bot for polls and votes including STV. Supports hiding results and is written with Discord.py

VoteBot Discord voting bot capable of standard polls, as found in many other bots; anonymous polls, where votes are hidden and totals are only display

6 Nov 15, 2022
Telegram group manager moderen and simple.

Upin Robot A Advanced Powerful, Smart And Intelligent Group Management Bot With New And Powerful Features ... Written with Pyrogram and Telethon... If

Muhammad Nawawi 3 Dec 23, 2021