Welcome to StockWise API, a Django-based application for stock price predictions, backtesting strategies, and generating financial reports.
StockWise is a stock analysis tool that provides historical data on stock prices, predictions using machine learning models, and backtests strategies to help make informed investment decisions.
- Fetch historical stock data using Alpha Vantage API.
- Predict stock prices using machine learning models.
- Backtest strategies using moving averages.
- Generate PDF reports comparing historical and predicted stock prices.
Ensure you have the following installed on your machine:
- Python 3.10+
- Docker (for containerized deployment)
- Alpha Vantage API Key - You'll need to sign up for a free API key at Alpha Vantage to fetch stock data.
First, clone the repository to your local machine:
git clone https://github.com/parthsolanke/stockwise.git
cd stockwise
Create a Python virtual environment and activate it:
# For Linux/macOS
python3 -m venv venv
source venv/bin/activate
# For Windows
python -m venv venv
venv\Scripts\activate
With the virtual environment activated, install all the required dependencies:
pip install -r requirements.txt
You will need to create a .env
file in the root of your project with the following content:
DEBUG=value
DJANGO_SECRET_KEY=value
DJANGO_ALLOWED_HOSTS=value
ALPHA_VANTAGE_API_KEY=value
API_BASE_URL=value
DB_NAME=value
DB_USER=value
DB_PASSWORD=value
DB_HOST=value
DB_PORT=value
REDIS_URL=value
Note: Replace
value
with your actual values.
Run the following commands to make the necessary database migrations and migrate:
python manage.py makemigrations core
python manage.py migrate
To run the application locally, use the following command:
python manage.py runserver
The application will be available at: http://127.0.0.1:8000/
If you prefer to run the application using Docker, follow these steps:
-
Build the Docker Image:
In the root of your project directory, run:
docker build -t stockwise .
-
Run the Docker Container:
Once the image is built, you can run it with the following command:
docker run -p 8000:8000 --env-file .env stockwise
This will start the app in a Docker container, making it accessible at http://localhost:8000/
.
Refer to API doc
To deploy this project, follow these steps:
-
Build the Docker Image:
Run the following command to build the Docker image:
docker build -t stockwise .
-
Run the Container:
Run the Docker container on your server using:
docker run -d -p 8000:8000 --env-file .env stockwise
The application will now be live on
http://your-server-ip:8000
.
- Database errors: Ensure you've run migrations and seeded data before accessing the API.
- Docker build issues: Make sure you have the latest version of Docker installed and your
.env
file is properly configured. - API Key issues: Ensure your Alpha Vantage API key is valid and correctly stored in the
.env
file.