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
Proxy-Bot - Python proxy bot for telegram

Proxy-Bot ๐Ÿค– Proxy bot between the main chat and a newcomer, allows all particip

Anton Shumakov 3 Apr 01, 2022
Python API Client for Close

Close API A convenient Python wrapper for the Close API. API docs: http://developer.close.com Support: Close 56 Nov 30, 2022

Droplink URL Shortener Bot, deployable to Heroku and Railway.

Droplink-bot Make short link by using Droplink API key. Made by @dakshy. Installation The Easy Way Required Variables BOT_TOKEN: Create a bot using @B

ToonsHub 5 Jun 25, 2022
Instagram bot for promoting ROKA trainee soldier(just like me)'s consolation letters.

Instagram_bot (ํ•„์ž๋ฅผ ํฌํ•จํ•œ) ๋ชจ๋“  ๋Œ€ํ•œ๋ฏผ๊ตญ ํ›ˆ๋ จ๋ณ‘๋“ค์„ ์œ„ํ•œ ์ธ์Šคํƒ€๊ทธ๋žจ ์ธํŽธ์ง€๊ธฐ์ž…๋‹ˆ๋‹ค. Instagram bot for promoting ROKA trainee soldier(just like me)'s consolation letters. ๋“ค์–ด๊ฐ€๊ธฐ (Ge

Lee, Jongjun 2 Nov 21, 2021
A BOT TO FIND ID OF A STICKER.

sticker id A BOT TO FIND ID OF A STICKER. THIS REPOSITORY HAVE TWO BRANCHES FOR DEPLOY WITH COMMAND & WITHOUT COMMAND. Mandatory variables API_ID - Ge

Ashik Muhammed 3 Dec 29, 2022
Maestral is an open-source Dropbox client written in Python.

Maestral - A light-weight and open-source Dropbox client for macOS and Linux

2.6k Jan 03, 2023
Compares and analyzes GCP IAM roles.

gcp-iam-analyzer I wrote this to help in my day to day working in GCP. A lot of the time I am doing role comparisons to see which role has more permis

Jason Dyke 37 Dec 28, 2022
Bagas Mirror&Leech Bot is a multipurpose Telegram Bot written in Python for mirroring files on the Internet to our beloved Google Drive. Based on python-aria-mirror-bot

- [ MAYBE UPDATE & ADD MORE MODULE ] Bagas Mirror&Leech Bot Bagas Mirror&Leech Bot is a multipurpose Telegram Bot written in Python for mirroring file

4 Nov 23, 2021
Senexia - A powerful telegram bot to manage your groups as effectively as possible

โšก Kenechi bot โšก A Powerful, Smart And Simple Group Manager ... Written with AioG

Akhi 2 Jan 11, 2022
A Python wrapper for the QQ Channel API

A Python wrapper for the QQ Channel API

Fox_white 55 Dec 07, 2022
Modern Desktop Jellyfin Client written in Python and Vue for the UI [WIP]

JellyPlayer Modern Jellyfin Client Installation Install Requirements: Install Python 3 Install dependencies Install node deps for frontend, go to Jell

Prayag Prajapati 57 Dec 12, 2022
Discord bot for user notes.

Noter A discord bot for handling notes for users. Want to keep track of things about your discord users? Then this bot is for you! Links DB Browser fo

Ori 2 Jun 05, 2022
BiliBili-live-barrage-transceiver - A simple python program for sending and receiving barrage in bilibili live room

BiliBili-live-barrage-transceiver - A simple python program for sending and receiving barrage in bilibili live room

zeroy 2 Jan 18, 2022
This Telegram bot allows you to create direct links with pre-filled text to WhatsApp Chats

WhatsApp API Bot Telegram bot to create direct links with pre-filled text for WhatsApp Chats You can check our bot here. The bot is based on the API p

RobotTrick โ€ข ืจื•ื‘ื•ื˜ืจื™ืง 17 Aug 20, 2022
GUI Pancakeswap2 and Uniswap3 trading client (and bot)

GUI Pancakeswap2 and Uniswap3 trading client (and bot) (MOST ADVANCE TRADING BOT SUPPORT WINDOWS LINUX MAC) (AUTO BUY TOKEN ON LUNCH AFTER ADD LIQUIDI

16 Dec 23, 2021
A Telegram Bot written in Python for mirroring files on the Internet to your Google Drive

No support is going to be provided of any kind, only maintaining this for vps user on request. This is a Telegram Bot written in Python for mirroring

Sunil Kumar 42 Oct 28, 2022
Slam Mirror Bot is a multipurpose Telegram Bot written in Python for mirroring files on the Internet to our beloved Google Drive.

Slam Mirror Bot is a multipurpose Telegram Bot written in Python for mirroring files on the Internet to our beloved Google Drive.

Abinash939 1 Oct 10, 2021
fair-test is a library to build and deploy FAIR metrics tests APIs supporting the specifications used by the FAIRMetrics working group.

โ˜‘๏ธ FAIR test fair-test is a library to build and deploy FAIR metrics tests APIs supporting the specifications used by the FAIRMetrics working group. I

Maastricht University IDS 6 Oct 30, 2022
๐Ÿง‘โ€๐Ÿ’ผ Python wrapper for the Seek API

seek-com-au-api ๐Ÿง‘โ€๐Ÿ’ผ Python wrapper for the seek.com.au API (unofficial) Installation Using Python = 3.6: pip install -e git+https://github.com/tomq

Tom Quirk 1 Oct 24, 2021
Network simulation tools

Overview I'm building my network simulation environments with Vagrant using libvirt plugin on a Ubuntu 20.04 system... and I always hated how boring i

Ivan Pepelnjak 219 Jan 07, 2023