A stock prediction application that uses Google's TimesFM (Time Series Foundation Model) to forecast stock prices from Yahoo Finance, with FastAPI serving as the backend API.
The application consists of three main components:
-
stock_predictor.py - Core prediction logic that handles stock data retrieval and forecasting using the TimesFM model. Configurable parameters include:
name: Stock ticker symbol (e.g., AAPL, GOOGL, TSLA)interval: Data sampling frequency (e.g., 1d, 1h, 5m)period: Historical data range (e.g., 1mo, 3mo, 1y)horizon_len: Number of future time steps to predict (e.g., 5, 10, 20)
-
main.py - FastAPI backend server that exposes the API endpoints and serves the frontend through the
templatesandstaticdirectories -
requirements.txt - Python dependencies
This application requires the TimesFM model to be cloned and installed first.
python3 -m venv venv
source venv/bin/activate
git clone https://github.com/google-research/timesfm.git
cd timesfm
pip install -e .[torch]
cd ..
pip install -r requirements.txt