This project is a mock of stock trading application built with Flask. It is intended for portfolio purposes and demonstrates a variety of features typical of a stock trading platform. The application use market data from Finnhub.io.
- User registration and login with hashed passwords
- Stock quote lookup
- Buying and selling stocks
- Viewing portfolio and transaction history
- Adding cash to the account
- Simple captcha verification using hCaptcha
- Data persistence using SQLAlchemy and SQLite
.
├── app.py # Main application file
├── helpers.py # Helper functions
├── templates/ # HTML templates
├── static/ # Static files (CSS, images)
├── requirements.txt # Python dependencies
├── gunicorn.conf.py # Gunicorn configuration
├── Dockerfile # Docker configuration with gunicorn
├── docker-compose.yml # Docker Compose configuration with nginx
├── nginx/
└── nginx.conf # Nginx configuration file
-
Clone the repository:
git clone https://github.com/rafalkk/StockPlayground.git
-
Install the required dependencies:
pip install -r requirements.txt
-
Set the required environment variables:
linux bash:
export API_KEY=your-key export HCAPTCHA_SECRET_KEY=your-key export CAPTCHA_SITE_KEY=your-key
windows powershell:
$env:API_KEY='your-key' $env:HCAPTCHA_SECRET_KEY='your-key' $env:HCAPTCHA_SITE_KEY='your-key'
-
Run the application:
flask run
The application will be available at http://127.0.0.1:5000
.
-
Ensure you have Docker and Docker Compose installed.
-
Use the provided
docker-compose.yml
file. Do not forget to fill in the keys of the APIs in the file.docker-compose up -d
This will set up the application with Nginx as a reverse proxy, making it accessible at default http port 80 http://127.0.0.1
.