Anything in the stock market will book profit in a bull market only. The motivation is to book profit without investing much time and effort. It just shows that simple compounding algorithms can beat complex technical analysis over long term.
Be aware while using the algorithm, Any investment in stock market is subjected to market risks, including this algorithm.
This repo contains scripts to trade using Zerodha's KITE API.
- The automatic disciplined compounding, low risk and low time/effort nature of makes it a good passive income tool (medium term).
- Intraday trading based on technical analysis is also a good passive income tool (once you have mastered it). However, requires more manual time/effort and has more risk.
- Disciplined Compounding without manual intervention: The biggest advantage of autotrader is that the least amount of human emotions, time, and effort will be involved, allowing small profits to compound over a long period of time without interruptions.
- Low Risk: The algorithm, the instrument of trade, and the margins/units are selected to have the least possibility of losing money.
- Need to pay server charges. Charges are minimal and can be further reduced if deployed on lambda.
- Need to pay API charges. This can be shared among small group of known people.
- Need to maintain it once in a while. Once set, very less frequent changes would be required.
- Increased accounting: Can be automated.
- Manual intervention is still required daily/monthly: For CDSL authorization and request token.
Transfer money on Account Settlement.
- Buy certain units (150) of an instrument.
- If the opening price is lower than last day closing price by a certain margin (1 percent).
- If the closing price is lower than current day opening price by a certain margin (1 percent).
- In both the above cases create a GTT to sell when the bought stocks are up by 1 percent.
- Git clone the repo using
git clone git@github.com:rushout09/AutoTrader.git
. - Run the following command to install Deta CLI
curl -fsSL https://get.deta.dev/cli.sh | sh
- Open a new CLI and run
deta --help
to confirm installation succeeded. - Login and deploy using command:
deta login
anddeta new
- Set the env variables:
deta update -e .env
- Set the cron:
deta cron set "40,50 3,9 ? * MON-FRI *"
- Deploy again using:
deta deploy
- View logs:
deta logs
- Useful links:
Generate and add your ssh key to GitHub account:
ssh-keygen -t ed25519 -C "user@example.com"
cat ~/.ssh/id_ed25519.pub
- Paste the above key to github -> profile -> settings -> GPG and keys.
- Git clone the repo using
git clone git@github.com:rushout09/AutoTrader.git
. - Create and activate virtualenv using:
sudo apt update
sudo apt install python3.10-venv
python3 -m venv venv
.- Activate the virtualenv using
source venv/bin/activate
.
- Install the dependencies using
pip3 install -r requirements.txt
- Rename the sample.env file to .env the project root
cp sample.env .env
- Get the
REQUEST_TOKEN
by hitting the following URL:https://kite.zerodha.com/connect/login?v=3&api_key={api_key}
- Paste the updated
REQUEST_TOKEN
and other required variables in.env
file. - Start the script using
python3 app.py
- Paste the updated
REQUEST_TOKEN
and other required variables in.env
file. - Edit the autotrade.service file with correct Working directory path and python3 path.
- Copy the autotrade.service file:
sudo cp autotrade.service /lib/systemd/system/autotrade.service
- Refresh demon registry:
sudo systemctl daemon-reload
- Start the service:
sudo service autotrade start
- Send alerts on transactions/orders.
- Get user input to confirm order transaction via call or message.
- Automate accounting. Add script to use
db.log
to generate report. - Include the past results in ReadMe.
This project needs a lot of help from Open Source community. We need help in writing documentation, testcases, and integrations for upcoming platforms. This project is a good starting point for people getting started with open source programming. Please feel free to ask questions and contribute in any way possible.
Copyright (c) 2022, Rushabh Agarwal All rights reserved.
This source code is licensed under the BSD-style license found in the LICENSE file in the root directory of this source tree.