https://github.com/hemangjoshi37a/hjalgos
AI based algorithmic trading platform for zerodha users
https://github.com/hemangjoshi37a/hjalgos
aitrading algotrading transformers zerodha
Last synced: 6 months ago
JSON representation
AI based algorithmic trading platform for zerodha users
- Host: GitHub
- URL: https://github.com/hemangjoshi37a/hjalgos
- Owner: hemangjoshi37a
- License: mit
- Created: 2024-11-01T11:33:43.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-08T06:32:53.000Z (about 1 year ago)
- Last Synced: 2025-03-28T18:51:59.979Z (10 months ago)
- Topics: aitrading, algotrading, transformers, zerodha
- Language: HTML
- Homepage: https://hjalgos.hjlabs.in/
- Size: 66.6 MB
- Stars: 6
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# hjAlgos ๐
[](LICENSE)
[](https://github.com/hemangjoshi37a/hjAlgos)
[](https://github.com/hemangjoshi37a/hjAlgos/fork)
**hjAlgos** is the premier open-source algorithmic trading platform tailored for Zerodha and other leading trading platforms. Harness the power of advanced machine learning models to predict stock prices and execute trades in real-time. Seamlessly integrated with Zerodha for trading and Appwrite for backend services, hjAlgos offers a transparent and automated trading experience for both novice and seasoned traders.

## ๐ Table of Contents
- [๐ Features](#-features)
- [๐ Demo and Backtests](#-demo-and-backtests)
- [๐ Installation](#-installation)
- [Prerequisites](#prerequisites)
- [Clone the Repository](#clone-the-repository)
- [Create and Activate a Virtual Environment](#create-and-activate-a-virtual-environment)
- [Install Dependencies](#install-dependencies)
- [Setup Environment Variables](#setup-environment-variables)
- [Initialize Appwrite Collections](#initialize-appwrite-collections)
- [Load Normalization Parameters](#load-normalization-parameters)
- [Load the Pre-trained Model](#load-the-pre-trained-model)
- [๐ Project Structure](#-project-structure)
- [๐ก Usage](#-usage)
- [Running the Predictor](#running-the-predictor)
- [Running the Web Application](#running-the-web-application)
- [๐ Contributing](#-contributing)
- [๐งพ License](#-license)
- [๐ซ How to Reach Me](#-how-to-reach-me)
- [๐ Other Projects](#-other-projects)
- [๐ค Sponsorship](#-sponsorship)
## ๐ Features
- **Advanced Stock Prediction:** Utilizes a Transformer-based neural network for highly accurate stock price predictions.
- **Real-Time Trading:** Automatically executes buy and sell orders based on the latest predictions.
- **User-Friendly Interface:** Intuitive web interface built with Flask and Bokeh for seamless visualization of predictions and trade history.
- **Backtesting:** Analyze historical performance of trading strategies with comprehensive backtest results.
- **Secure and Scalable:** Employs environment variables for secure configuration management and scalable backend services.
- **Open Source Transparency:** Full access to the codebase, fostering trust and community-driven enhancements.
- **Automated Precision:** Execute trades 24/7 with millisecond accuracy, eliminating human error.
- **Data-Driven Decisions:** Leverage advanced analytics to make informed trading choices.
- **Seamless Integration:** Easily connect with Zerodha API and other popular platforms.
- **Continuous Improvement:** Benefit from community-driven updates and enhancements.
- **Risk Management:** Implement advanced risk controls to protect your investments.
## ๐ Demo and Backtests
- **Live Demo:** [https://hjalgos.hjlabs.in](https://hjalgos.hjlabs.in)
- **Backtest Results:** [https://hjalgos.hjlabs.in/backtest/](https://hjalgos.hjlabs.in/backtest/)
## ๐ Installation
### Prerequisites
- **Python 3.8+**
- **Zerodha Account** with API access
- **Appwrite Account**
- **GPU** (optional, for faster model inference)
### Clone the Repository
```bash
git clone https://github.com/hemangjoshi37a/hjAlgos.git
cd hjAlgos
```
### Create and Activate a Virtual Environment
```bash
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
### Install Dependencies
```bash
pip install -r requirements.txt
```
### Setup Environment Variables
Create a `.env` file in the root directory based on the provided `.env.example`.
```bash
cp .env.example .env
```
Edit the `.env` file and fill in your credentials:
```dotenv
# .env
# Flask Secret Key
SECRET_KEY=your_very_secure_secret_key
# Appwrite Configuration
APPWRITE_ENDPOINT=https://cloud.appwrite.io/v1
APPWRITE_PROJECT_ID=your_project_id
APPWRITE_API_KEY=your_api_key
APPWRITE_DATABASE_ID=your_database_id
# Zerodha Credentials
ZERODHA_USER_ID=your_zerodha_user_id
ZERODHA_PASSWORD=your_zerodha_password
ZERODHA_TOTP_KEY=your_totp_key
```
> **โ ๏ธ Security Tip:**
> **Never commit your `.env` file to version control systems like GitHub.** To prevent accidental exposure, ensure `.env` is listed in your `.gitignore` file.
### Initialize Appwrite Collections
Ensure that the required collections (`users`, `trades`, `predictions`) are created in your Appwrite project.
### Load Normalization Parameters
Ensure that `mean.pkl` and `std.pkl` files are present in the project directory. These files are used for normalizing input data.
### Load the Pre-trained Model
Ensure that `stock_predictor_model.pth` is present in the project directory.
## ๐ Project Structure
```
hjAlgos/
โโโ app.py
โโโ predictor.py
โโโ templates/
โ โโโ index.html
โโโ static/
โ โโโ images/
โ โโโ totp_info.png
โโโ requirements.txt
โโโ .env.example
โโโ .gitignore
โโโ README.md
โโโ LICENSE
```
## ๐ก Usage
### Running the Predictor
The `predictor.py` script continuously fetches stock data, runs predictions using the ML model, and saves predictions to the Appwrite database.
```bash
python predictor.py
```
### Running the Web Application
The `app.py` script runs the Flask web application, providing a user interface for managing trading sessions, viewing predictions, and monitoring trade history.
```bash
python app.py
```
Access the web app at [http://localhost:5000](http://localhost:5000)
## ๐ Contributing
Contributions are welcome! Please follow these steps:
1. **Fork the repository**
2. **Create your feature branch:**
```bash
git checkout -b feature/YourFeature
```
3. **Commit your changes:**
```bash
git commit -m 'Add some feature'
```
4. **Push to the branch:**
```bash
git push origin feature/YourFeature
```
5. **Open a Pull Request**
Please ensure your code adheres to the project's coding standards and includes appropriate tests.
For detailed contribution guidelines, please refer to [CONTRIBUTING.md](CONTRIBUTING.md).
## ๐งพ License
This project is licensed under the [MIT License](LICENSE). See the [LICENSE](LICENSE) file for details.
## ๐ซ How to Reach Me
[
](https://hjlabs.in/) ย
[
](https://wa.me/917016525813) ย
[
](https://t.me/hjlabs) ย
[
](mailto:hemangjoshi37a@gmail.com) ย
[
](https://www.linkedin.com/in/hemang-joshi-046746aa) ย
[
](https://www.facebook.com/hemangjoshi37) ย
[
](https://twitter.com/HemangJ81509525) ย
[
](https://www.tumblr.com/blog/hemangjoshi37a-blog) ย
[
](https://stackoverflow.com/users/8090050/hemang-joshi) ย
[
](https://www.instagram.com/hemangjoshi37) ย
[
](https://in.pinterest.com/hemangjoshi37a) ย
[
](http://hemangjoshi.blogspot.com) ย
[
](https://gitlab.com/hemangjoshi37a)
## ๐ Other Projects
Explore more projects by the author:
- [TrendMaster](https://github.com/hemangjoshi37a/TrendMaster) - Advanced trend analysis tool for traders.
- [hjalgos_notebooks](https://github.com/hemangjoshi37a/hjalgos_notebooks) - Jupyter notebooks for hjAlgos strategies.
- [Zerodha-Brokerage-Calculator](https://github.com/hemangjoshi37a/Zerodha-Brokerage-Calculator) - A calculator for Zerodha brokerage fees.
- [TeleTest](https://github.com/hemangjoshi37a/TeleTest) - Telegram bot for testing trading signals.
- [Tradingview-Webhook-Manager](https://github.com/hemangjoshi37a/Tradingview-Webhook-Manager) - Manage TradingView webhooks effectively.
- [Algotrading_Multi_account_Modern_UI](https://github.com/hemangjoshi37a/Algotrading_Multi_account_Modern_UI) - Modern UI for managing multiple algotrading accounts.
- [pyPortMan](https://github.com/hemangjoshi37a/pyPortMan) - Python portfolio manager for tracking investments.
## ๐ค Sponsorship
This project is sponsored by [hjLabs](https://hjlabs.in).
---