|
Download README.md from helloadhavan/stock-LSTM: direct link, hf CLI and curl.
- Browser
- Download file 2 kB
-
https://huggingface.co/helloadhavan/stock-LSTM/resolve/main/README.md
- Command line
-
hf download hf://helloadhavan/stock-LSTM/README.md
-
curl -L -o README.md https://huggingface.co/helloadhavan/stock-LSTM/resolve/main/README.md
2 kB
metadata
license: mit
datasets:
- helloadhavan/Stock-pile
language:
- en
pipeline_tag: time-series-forecasting
library_name: pytorch
tags:
- lstm
- time-series
- stock-prediction
LSTM Stock Next-Day Predictor
This model was trained on the Stock-Pile dataset. It is a custom LSTM architecture with a learned ticker embedding, trained on about 5 million rows of daily stock data covering hundreds of companies across US, European and Asian markets. Given the previous 30 trading days, it predicts the next day's Open, High, Low, Close and log-Volume. It is a learning and experimentation project, not financial advice.
Files
| File | Purpose |
|---|---|
loader.py |
Model, Normalizer and load_model |
config.json |
Ticker ids, per-ticker normalization statistics and training logs |
stock_predictor/model.pth |
Trained weights |
MODEL_CARD.md |
Architecture, data, evaluation and limitations |
Usage
Download the repo by running:
huggingface-cli download helloadhavan/stock-LSTM
import torch
from .stock-LSTM.loader import load_model, Normalizer
model = load_model("stock_predictor/model.pth", "config.json")
normalizer = Normalizer("config.json")
window = {
"Open": open_t,
"High": high_t,
"Low": low_t,
"Close": close_t,
"Volume": torch.log1p(volume_t),
}
x = normalizer(window, "AAPL")
ticker_id = normalizer.ticker_ids["AAPL"]
ids = torch.full((x.shape[0], 1), float(ticker_id))
inputs = torch.cat([x, ids], dim=-1).unsqueeze(0)
with torch.no_grad():
prediction = model(inputs)
result = normalizer.denormalize(prediction[0], "AAPL")
result["Volume"] = torch.expm1(result["Volume"])
Each tensor in window has shape (30,). denormalize returns a dict of prices and log-Volume, so apply torch.expm1 to get raw volume.
Notes
- Volume must be
log1p-transformed before normalizing. - Only tickers listed in
config.jsonare supported.