An Open source python server application for distributing public financial data and compute results on a local network, minimizing external requests, and conserving external API usage.
- Stock price scraping and storage using SQLite database
- Stock News gathering and sentiment analysis
- Local Flask server with CORS support for multi-process communications
- RESTful API endpoints for stock predictions and data access
- In-memory caching system for optimal performance
- LSTM-based price prediction using historical data
- Technical indicator calculations
- Support for all S&P 500 companies
- database/ - Stores SQLite databases for:
- Historical price data
- Model predictions
- Stock metadata
- raw data/ - Contains raw data files before processing
- Contains team breakdowns, tasks and other relevant documentation
- Current Project Scope
- notebooks/ - Jupyter notebooks for analysis and model development
- scripts/ - Core Python scripts including:
app.py
- Main Flask applicationinit_all_data.py
- Data initializationprice_prediction.py
- LSTM model implementationget_stock_data.py
- Data retrieval utilities
- Python 3.10+
- pip (Python package manager)
- Docker (optional, for containerized deployment)
- Create and enable a Python virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install requirements:
pip install -r requirements.txt
- Create a
.env
file in the root directory with the following variables:
NEWS_API_ORG_KEY = "API_KEY" # Your News API key from newsapi.org
TESTING_MODE = "True" # Enable testing mode with sample data and limited model training
# Set to "False" for production mode with live data
- Initialize the data and train models:
cd Src/scripts
python init_all_data.py
python app.py
- Build and run using Docker Compose:
docker compose up --build
The application will be available at http://localhost:5000
GET /get_data/{ticker}
Response includes:
- Today's predicted close price
- Historical price data
- Predicted price movement score
- Sentiment-adjusted close price
Example Response:
{
"ticker": "AAPL",
"todays_predicted_close_price": 178.45,
"historical_price_data": [...],
"predicted_price_movement_score": 0,
"adjusted_close_price_based_on_sentiment": 180.25
}
GET /get_available_tickers
Returns a list of all available S&P 500 tickers in the database.
- Uses SQLite databases for storing historical prices and predictions
- Implements an in-memory cache for frequently accessed data
- Thread-safe data access using multiprocessing locks
- Automated model training pipeline
- Stores predictions in a dedicated SQLite database
- Updates predictions periodically with new market data
- Uses Flask's secret key for session management
- Implements CORS for controlled API access
- Runs as non-privileged user in Docker container
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This application is for educational and research purposes only. Trading stocks carries risk, and predictions should not be used as the sole basis for investment decisions.
MIT License