Breeze API Wrapper is a comprehensive Django-based application that serves as a wrapper around the ICICI Breeze API. It allows users to seamlessly integrate their Breeze API credentials to perform various financial data operations, including session generation, instrument data loading, OHLC (Open, High, Low, Close) graph visualization with analysis, and real-time data subscription with tick updates.
Experience the Breeze API Wrapper in action! Visit our live demo at: https://breeze.mnaveedk.com/
- Breeze API Wrapper
- Session Management: Generate and manage sessions using your Breeze API key and secret.
- Instrument Data Loading: Fetch and display detailed information about various financial instruments.
- OHLC Graphs with Analysis: Visualize Open, High, Low, Close data through interactive graphs, complete with analytical tools.
- Real-Time Data Subscription: Subscribe to instruments to receive live tick data updates.
- User-Friendly Frontend: Intuitive interface for seamless interaction with Breeze API functionalities.
- Robust Backend: Powered by Django, Django REST Framework, Celery, and Redis for efficient task management and data handling.
- Secure Data Storage: PostgreSQL database ensures secure and reliable storage of your session and instrument data.
- Backend: Django, Django REST Framework
- Frontend: React.js
- Database: PostgreSQL
- Task Queue: Celery with Redis
- Real-Time Communication: WebSockets via Django Channels
- Containerization: Docker, Docker Compose
- Others: Nginx for reverse proxy, ASGI server for asynchronous capabilities
Before you begin, ensure you have met the following requirements:
- Docker: Install Docker
- Docker Compose: Install Docker Compose
- Breeze API Credentials: Obtain your Breeze API Key and Secret from ICICI Direct
git clone https://github.com/your-username/breeze-api-wrapper.git
cd breeze-api-wrapper
Create a .envs
directory in the root of the project and add an env.dev
file with the necessary environment variables for development.
mkdir .envs
Create a file named env.dev
inside the .envs
directory and add the following content:
# PostgreSQL Configuration
POSTGRES_DB=breeze
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
# Redis Configuration
REDIS_CACHE_URL=redis://redis:6379/0
REDIS_URL=redis://redis:6379/0
# Celery Configuration
CELERY_BROKER_URL=redis://redis:6379/0
CELERY_RESULT_BACKEND=redis://redis:6379/0
Ensure Docker is running on your machine. Then, execute the following command to build and start the containers:
docker-compose up --build
This command will:
- Build Docker images for the backend, frontend, and Nginx services.
- Start PostgreSQL and Redis containers.
- Set up the entire application stack.
Once all containers are up and running, you can access the entire application by visiting:
- Application: http://localhost:8000
Note: Nginx handles the routing for both the frontend and backend, so there's no need to access them separately. Nginx will serve the frontend and proxy API requests to the backend.
-
Clone the Repository:
git clone https://github.com/your-username/breeze-api-wrapper.git cd breeze-api-wrapper
-
Set Up Environment Variables:
Follow the Installation section to set up your
.envs/env.dev
file. -
Run Docker Containers:
docker-compose up --build
-
Access the Application:
Navigate to http://localhost:8000 to start interacting with the application.
-
Backend:
The backend code is mounted as a volume (
./backend/:/app/
), allowing you to make changes locally and see them reflected in real-time without rebuilding the Docker container. -
Frontend:
Similarly, the frontend code is mounted as a volume, enabling live updates during development.
Implement and run your test suites to ensure the application's integrity.
docker-compose exec backend python manage.py test
To monitor the Celery worker logs in real-time, you can use the following methods:
If you have multiple Celery workers (e.g., w1
, w2
, w3
) and want to monitor their logs in real-time, use the tail
command:
docker-compose exec -it breeze-backend sh tail -f /var/log/celery/w1.log /var/log/celery/w2.log /var/log/celery/w3.log
Or use a wildcard to follow all worker logs:
docker-compose exec backend tail -f /var/log/celery/w*.log
Explanation:
tail -f
: Follows the content of files in real-time.- Multiple Files: By specifying multiple files,
tail
will interleave the output, prefixing each line with the file name.
For a more organized view, you can use multitail
to monitor multiple log files in a split-screen terminal window.
Install multitail
(if not already installed):
-
Ubuntu/Debian:
sudo apt-get install multitail
-
CentOS/RHEL:
sudo yum install multitail
Usage:
docker-compose exec backend multitail /var/log/celery/w1.log /var/log/celery/w2.log /var/log/celery/w3.log
Features:
- Displays each log file in its own window within the terminal.
- Provides color highlighting and filtering options.
If you prefer to have all worker logs in one file, you can modify your Celery command:
celery multi restart w1 w2 w3 -A main \
--pidfile=/var/run/celery/%n.pid \
--logfile=/var/log/celery/all_workers.log \
--loglevel=INFO --time-limit=300
Monitoring the Combined Log:
docker-compose exec backend tail -f /var/log/celery/all_workers.log
Considerations:
- Interleaved Logs: Logs from all workers will be mixed together, which might make it harder to distinguish between them.
- Log Rotation: Ensure proper log rotation to prevent the log file from growing indefinitely.
- Permissions: Ensure you have the necessary permissions to read the log files.
- Log Rotation: Implement log rotation mechanisms to prevent log files from consuming excessive disk space.
- Inside Docker Containers: The
docker-compose exec
command runs thetail
command inside the running container.
Contributions are welcome! Please follow these steps to contribute:
-
Fork the Repository
-
Create a Feature Branch
git checkout -b feature/YourFeature
-
Commit Your Changes
git commit -m "Add some feature"
-
Push to the Branch
git push origin feature/YourFeature
-
Open a Pull Request
This project is licensed under the MIT License.
Disclaimer: This project is a wrapper around the ICICI Breeze API and is intended for educational and personal use. Ensure compliance with ICICI's terms of service when using their API.
- ICICI Direct for the Breeze API.
- Django
- Django REST Framework
- Celery
- Redis
- Docker
- Nginx
For any inquiries or support, please contact [email protected].
Happy Coding! 🚀