Spaces:
Sleeping
Sleeping
Add files via upload
Browse files- .dockerignore +24 -0
- .gitignore +1 -1
- Dockerfile +39 -0
- README.md +36 -0
- docker-compose.yml +13 -0
- finbert_labels.json +1 -0
- sentinel_output.txt +0 -0
- test_results.txt +0 -0
- test_results_v2.txt +0 -0
.dockerignore
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__pycache__
|
| 2 |
+
*.pyc
|
| 3 |
+
*.pyo
|
| 4 |
+
*.pyd
|
| 5 |
+
.Python
|
| 6 |
+
env/
|
| 7 |
+
venv/
|
| 8 |
+
.venv/
|
| 9 |
+
pip-log.txt
|
| 10 |
+
pip-delete-this-directory.txt
|
| 11 |
+
.tox/
|
| 12 |
+
.coverage
|
| 13 |
+
.coverage.*
|
| 14 |
+
.cache
|
| 15 |
+
nosetests.xml
|
| 16 |
+
coverage.xml
|
| 17 |
+
*.cover
|
| 18 |
+
*.log
|
| 19 |
+
.git
|
| 20 |
+
.gitignore
|
| 21 |
+
.mypy_cache
|
| 22 |
+
.pytest_cache
|
| 23 |
+
.hypotheses
|
| 24 |
+
portfolio.json
|
.gitignore
CHANGED
|
@@ -5,4 +5,4 @@ venv/
|
|
| 5 |
trained_models/
|
| 6 |
portfolio.json
|
| 7 |
node_modules/
|
| 8 |
-
.DS_StoreΔ«
|
|
|
|
| 5 |
trained_models/
|
| 6 |
portfolio.json
|
| 7 |
node_modules/
|
| 8 |
+
.DS_StoreΔ«
|
Dockerfile
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use an official Python runtime as a parent image
|
| 2 |
+
# Slim version is smaller but full version prevents some build issues with large ML libs
|
| 3 |
+
FROM python:3.10-slim
|
| 4 |
+
|
| 5 |
+
# Set environment variables
|
| 6 |
+
ENV PYTHONDONTWRITEBYTECODE=1
|
| 7 |
+
ENV PYTHONUNBUFFERED=1
|
| 8 |
+
|
| 9 |
+
# Set work directory
|
| 10 |
+
WORKDIR /app
|
| 11 |
+
|
| 12 |
+
# Install system dependencies (needed for some python packages)
|
| 13 |
+
RUN apt-get update && apt-get install -y \
|
| 14 |
+
build-essential \
|
| 15 |
+
curl \
|
| 16 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 17 |
+
|
| 18 |
+
# Install Python dependencies
|
| 19 |
+
RUN pip install --no-cache-dir --upgrade pip
|
| 20 |
+
RUN pip install --no-cache-dir fastapi uvicorn pydantic pandas numpy scikit-learn requests yfinance ta
|
| 21 |
+
# Install heavy ML libraries separately to cache them effectively
|
| 22 |
+
# Installing CPU-only PyTorch to save space if GPU is not needed for inference speed
|
| 23 |
+
RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
|
| 24 |
+
RUN pip install --no-cache-dir transformers xgboost nltk google-generativeai
|
| 25 |
+
|
| 26 |
+
# Download NLTK data (VADER lexicon) during build so we don't download at runtime
|
| 27 |
+
RUN python -c "import nltk; nltk.download('vader_lexicon')"
|
| 28 |
+
|
| 29 |
+
# Copy the code
|
| 30 |
+
COPY backend/ /app/backend/
|
| 31 |
+
COPY frontend/ /app/frontend/
|
| 32 |
+
|
| 33 |
+
# Expose the port
|
| 34 |
+
EXPOSE 8000
|
| 35 |
+
|
| 36 |
+
# Run the application
|
| 37 |
+
# We use /app/backend as part of pythonpath to find modules
|
| 38 |
+
ENV PYTHONPATH=/app/backend
|
| 39 |
+
CMD ["uvicorn", "backend.app:app", "--host", "0.0.0.0", "--port", "8000"]
|
README.md
CHANGED
|
@@ -75,6 +75,42 @@ User β React/HTML Frontend β FastAPI Backend
|
|
| 75 |
4. **Training**: 30 epochs, Adam optimizer, MSE loss, 85/15 train/test split
|
| 76 |
5. **Inference**: Last 60-day window β next 5 closing prices
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
|
|
|
| 80 |
|
|
|
|
|
|
| 75 |
4. **Training**: 30 epochs, Adam optimizer, MSE loss, 85/15 train/test split
|
| 76 |
5. **Inference**: Last 60-day window β next 5 closing prices
|
| 77 |
|
| 78 |
+
---
|
| 79 |
+
|
| 80 |
+
## βοΈ Deployment (Optional)
|
| 81 |
+
|
| 82 |
+
### Docker
|
| 83 |
+
|
| 84 |
+
```dockerfile
|
| 85 |
+
FROM python:3.11-slim
|
| 86 |
+
WORKDIR /app
|
| 87 |
+
COPY backend/ .
|
| 88 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 89 |
+
EXPOSE 8000
|
| 90 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
```bash
|
| 94 |
+
docker build -t stocksense-ai .
|
| 95 |
+
docker run -p 8000:8000 stocksense-ai
|
| 96 |
+
```
|
| 97 |
+
|
| 98 |
+
### Cloud (Render / Railway / Fly.io)
|
| 99 |
+
1. Push to GitHub
|
| 100 |
+
2. Connect repo on Render β set build command: `pip install -r requirements.txt`
|
| 101 |
+
3. Set start command: `uvicorn app:app --host 0.0.0.0 --port 8000`
|
| 102 |
+
|
| 103 |
+
---
|
| 104 |
|
| 105 |
+
## β οΈ Disclaimer
|
| 106 |
+
|
| 107 |
+
This project is for **educational and hackathon demonstration purposes only**.
|
| 108 |
+
Stock market predictions generated by this tool are **not financial advice**.
|
| 109 |
+
Past performance does not guarantee future results. Always consult a qualified
|
| 110 |
+
financial advisor before making investment decisions.
|
| 111 |
+
|
| 112 |
+
---
|
| 113 |
|
| 114 |
+
## π License
|
| 115 |
|
| 116 |
+
MIT β feel free to fork and improve!
|
docker-compose.yml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
services:
|
| 2 |
+
stocksense-app:
|
| 3 |
+
build: .
|
| 4 |
+
container_name: stocksense-container
|
| 5 |
+
ports:
|
| 6 |
+
- "8000:8000"
|
| 7 |
+
volumes:
|
| 8 |
+
# Mount the portfolio.json so it persists outside the container
|
| 9 |
+
- ./backend/portfolio.json:/app/backend/portfolio.json
|
| 10 |
+
environment:
|
| 11 |
+
- PYTHONUNBUFFERED=1
|
| 12 |
+
- GEMINI_API_KEY=AIzaSyCr7849tRiFislGvZhJZqCT8PcFu11RGpo
|
| 13 |
+
restart: unless-stopped
|
finbert_labels.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"0": "positive", "1": "negative", "2": "neutral"}
|
sentinel_output.txt
ADDED
|
Binary file (1.66 kB). View file
|
|
|
test_results.txt
ADDED
|
Binary file (834 Bytes). View file
|
|
|
test_results_v2.txt
ADDED
|
Binary file (516 Bytes). View file
|
|
|