GithubHelp home page GithubHelp logo

bogadib / chartink_kite_amo_mean_reversion Goto Github PK

View Code? Open in Web Editor NEW
19.0 3.0 16.0 7.05 MB

Python Algorithmic Trading code for using zerodha kite to place AMO orders based on Chartink scanner

Home Page: https://algo2t.github.io/chartink_kite_amo_mean_reversion/

License: GNU General Public License v3.0

Shell 0.41% Python 99.59%

chartink_kite_amo_mean_reversion's Introduction

Chartink Vishal Mehta Mean Reversion Scanner

This python script gets the stocks scanned by Mean Reversion scanner from Vishal Mehta. Once the stocks are available, it places AMO (After Market Order) in Zerodha Trading account using kiteconnect APIs.

The scanner can be located on chartink https://chartink.com/screener/vishal-mehta-mean-reversion

If available stocks are more than 10 then the stocks are sorted according to latest close price ascending and only 10 orders are placed.

How to use this repository

Get the code

  • Download the repository as zip
  • Unzip / extract it in a folder preferably on D:\trading Avoid extracting on Desktop

Installation

  • Install Python 3.9.4 latest version as of today (25th April 2021)
  • It can work on python 3.6 and above but it is not tested

Virtual Environment Creation

  • python -m pip install virtualenv on Windows or python3 -m pip install --user virtualenv on Linux

  • Go to the folder D:\trading and then create virtualenv as venv using command as python -m virtualenv venv on Windows or python3 -m virtualenv -p py3 venv on Linux

  • Activate the virtual environment using .\venv\Scripts\activate on Windows or source ./venv/bin/activate on Linux/Mac.

  • Upgrade packages using command python -m pip install -U pip wheel setuptools

  • pip install .\Twisted-21.2.0-py3-none-any.whl (MANDATORY on Windows, to install kiteconnect successfully.)

  • pip install .\TA_Lib-0.4.19-cp39-cp39-win_amd64.whl (OPTIONAL on Windows)

  • pip install -r requirements.txt (NOTE : There is issue while installing pandas on python 3.6.9 downgrade pandas version to 1.1.5)

Important

  • Before running the script, it is very important to generate the enctoken.txt file which is used in config.py file
  • There are 2 ways to do this
    1. Copy Paste the enctoken from Zerodha Web Session using Chrome DevTools, check images in useful snapshots
    2. Another way to do this is to run the login_and_generate_enctoken.py script, this must be done once. May have to run again if you invalidate the session. Run this again if you face any issues. This step will invalidate your web session if you have logged in through browser.

Running the Script

  • Before running the actual script chartink_kite.py you must create .env file same folder
  • Copy the .env.example file or rename it to create a new .env file in the same folder
  • Change the values for USERNAME, PASSWORD and PIN with your own credentials
  • Finally you can run the script using python chartink.py or python3 chartink.py

Note

  • Some lines are commented since this code is not tested in Live Market
  • Stop Loss for the Strategy is not implemented in the script, 3% Stop Loss recommended by Vishal Mehta, people have posted that 4% works better but some people keep Stop Loss based on their own Risk e.g. 2% to 2.5%
  • Similarly, Target or Profit must be kept accordingly to your own Risk Management. Vishal Mehta recommends 6% while some keep it at 4.5%
  • Also, some people exit when the overall MTM / PnL reaches approximately 5% or 6% of invested capital.
  • More images will be added in future. Please check existing images.
  • Coding is still in progress, for any suggestions please open discussions here.

Useful snapshots

  • Cloning repository, creating virutalenv and installing packages

    2021-04-25 05_01_48-WSL-Ubuntu

  • Activating Virtual environment venv

    image

  • Installing all requirements from requirements.txt using pip

    image

    image

  • Below images there is an error which occurred because the session was expired. New enctoken was added to enctoken.txt file

    image

  • Getting the enctoken from the kite dashboard using Chrome DevTool. Copy paste it to enctoken.txt This will help to keep both web session running and script execution will not invalidate web session

    image

  • Kite dashboard orders page before placing AMO orders.

image

  • Executing script and checking output in console

    image

    image

  • Finally checking the orders on the kite dashboard

    image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.