Expiry day Straddle Algo Trading
alembic upgrade head
Install using apt or pip3 sudo apt install gunicorn pip3 install gunicorn
gunicorn --bind 0.0.0.0:8080 wsgi:app
https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04
- sudo apt install nginx
- sudo systemctl status nginx
- sudo systemctl stop nginx
- sudo systemctl start nginx
- sudo systemctl restart nginx
- sudo nginx -t
- sudo nano /etc/systemd/system/gunicorn.service
- Add the following contents
[Unit] Description=Gunicorn instance to serve myproject After=network.target [Service] User=ubuntu Group=ubuntu WorkingDirectory=/home/ubuntu/ExpiryStraddleAlgoTrading #Environment="PATH=/home/sammy/myproject/myprojectenv/bin" ExecStart=/usr/bin/gunicorn --workers 2 --bind unix:gunicorn.sock -m 007 wsgi:app [Install] WantedBy=multi-user.target
- sudo systemctl start gunicorn
- sudo systemctl enable gunicorn
- sudo systemctl status gunicorn
- sudo nano /etc/nginx/sites-available/algotrading-dashboard
server { listen 80; server_name your_domain www.your_domain; location / { include proxy_params; proxy_pass http://unix:/home/ubuntu/ExpiryStraddleAlgoTrading/gunicorn.sock; } }
- sudo ln -s /etc/nginx/sites-available/algotrading-dashboard /etc/nginx/sites-enabled
- sudo nginx -t
- sudo systemctl restart nginx
- Edit /etc/nginx/nginx.conf change user to ubuntu. Else you will see permission issue while connecting to the socket.
14 4 * * 1-5 cd /home/ubuntu/ExpiryStraddleAlgoTrading; python3 main.py --clean-up
15 4 * * 1-5 cd /home/ubuntu/ExpiryStraddleAlgoTrading; python3 main.py --market-feeds --option-type CE
15 4 * * 1-5 cd /home/ubuntu/ExpiryStraddleAlgoTrading; python3 main.py --market-feeds --option-type PE
18 4 * * 1-5 cd /home/ubuntu/ExpiryStraddleAlgoTrading; python3 main.py --trading
# Kill if the process is still running once the process is exited
30 10 * * * pkill -f main.py