PSX Compass: models (v1)

Trained scikit-learn pipelines for PSX Compass, a student project that looks at 20 Pakistan Stock Exchange (PSX) stocks. For one stock it gives:

  • P(UP) / P(DOWN) for the next 1, 5 and 10 trading days
  • an 80% price range for the same horizons (never a single predicted price)

This is an analysis tool, not financial advice. Daily stock direction is very noisy. The results below are only slightly better than guessing. Nothing here is a guarantee.

Files

File What it holds
per_stock/<SYMBOL>.joblib (20 files) One model set per stock (trained on that stock's rows only)
pooled.joblib One model set for all 20 stocks stacked together

Each file is a Python dict saved with joblib. It has version ("v1"), trained_until ("2026-11-13"), cutoff ("2024-05-22"), features (the 9 inputs, in order), dead_zone (0.003), uncertain_band ([0.48, 0.52]), library_versions, and horizons (for 1, 5 and 10 days: the 4 fitted classifiers, the headline model per stock, and the range models), plus the test-block trust numbers.

How to load

import joblib
bundle = joblib.load("per_stock/FATIMA.joblib")
print(bundle["version"], bundle["features"])

Use the same library versions as training, or the pickles may break: Python 3.12, scikit-learn 1.9.1, xgboost 3.4.1, numpy 2.5.5, pandas 3.1.1, joblib 1.6.0.

Data

  • Source: psxdata Python package (public PSX daily price data). No news or other sources.
  • 20 stocks, 49,150 rows, daily data from 2016-12-13 to 2026-11-13 (frozen training snapshot).
  • Market feature: KSE-100 index return.
  • No personal data.

Inputs (exactly 9)

ret_1d, ret_5d, sma20_ratio, vol_10d, gap_pct, vol_ratio, rsi_14, close_pos, mkt_ret

Dates, symbols, raw prices, volume and label columns are never fed to a model.

Labels

  • UP if the return over the horizon is above a dead zone, DOWN if below minus the dead zone, otherwise NO_CHANGE.
  • Dead zone = 0.003 Γ— √h (1 day: 0.30%, 5 days: 0.67%, 10 days: 0.95%).
  • Classifiers train and score on UP/DOWN rows only.
  • Rows with an anomaly flag or a 1-day move above 15% (on the row or the row its label looks into) are dropped.

Method

  • Split by date: the last 25% of distinct dates is the test block (cutoff 2024-05-22), with a gap of h rows after the cutoff.
  • Tuning only inside the training period: GridSearchCV, 5 time-ordered folds, scored by log loss.
  • Every model is a scikit-learn Pipeline (median imputer, StandardScaler, model). Probabilities are calibrated with sigmoid CalibratedClassifierCV. random_state = 42.
  • 4 classifiers: Logistic Regression, Random Forest, XGBoost, SVM (RBF). Pooled SVM learns from 4,000 evenly spaced rows.
  • Baselines: always-majority (all horizons) and same-as-yesterday (1 day).
  • Price range: quantile Gradient Boosting (10% and 90%) on the future return, compared with a volatility baseline (Β±1.28 Γ— vol_10d Γ— √h).
  • Final v1 models are refit with the same settings on all usable rows up to 2026-11-13.

Results (test block, mean over 20 stocks, per_stock strategy)

Lower log loss is better. ROC-AUC 0.500 = guessing.

Horizon Model Log loss ROC-AUC Accuracy
1 day Logistic Regression 0.6932 0.516 0.521
1 day Random Forest 0.6909 0.533 0.529
1 day XGBoost 0.6904 0.536 0.530
1 day SVM 0.6897 0.548 0.533
1 day Majority baseline 0.6922 0.500 0.517
5 days Logistic Regression 0.6941 0.508 0.523
5 days Random Forest 0.6936 0.504 0.512
5 days XGBoost 0.6927 0.515 0.520
5 days SVM 0.6923 0.520 0.520
5 days Majority baseline 0.6939 0.500 0.497
10 days Logistic Regression 0.6966 0.507 0.514
10 days Random Forest 0.6947 0.515 0.521
10 days XGBoost 0.6935 0.519 0.517
10 days SVM 0.6944 0.514 0.516
10 days Majority baseline 0.6958 0.500 0.498

Reading this honestly:

  • Models beat the majority baseline by a very small margin at 1 day. At 5 and 10 days the gap is within noise (the 95% bootstrap intervals overlap).
  • Accuracy is about 51–53% and AUC about 0.50–0.55, as expected for daily stock direction.
  • per_stock vs pooled: a tie at 1 and 5 days; per_stock is ahead at 10 days (average of the 4 classifiers). Range: a tie at all horizons.

80% price range (test block)

Horizon Method Coverage (target 0.80) Width
1 day Quantile GB 0.787 4.77 pp
1 day Volatility baseline 0.785 5.32 pp
5 days Quantile GB 0.790 11.69 pp
5 days Volatility baseline 0.757 12.01 pp
10 days Quantile GB 0.781 16.69 pp
10 days Volatility baseline 0.738 17.04 pp

Overfitting check (mean log loss, train / validation / test, 1 day)

Logistic Regression 0.6878 / 0.6936 / 0.6932, Random Forest 0.6781 / 0.6922 / 0.6909, XGBoost 0.6760 / 0.6926 / 0.6904, SVM 0.6806 / 0.6926 / 0.6897. Tree models fit the training data a little better than validation and test, which is mild overfitting.

Limitations

  • Daily direction is close to random. Do not treat any output as a signal to trade.
  • PSX holidays are not handled when computing target dates.
  • Stock splits are not adjusted for.
  • Models are frozen at 2026-11-13 and never retrain inside the app.
  • Overlapping 5- and 10-day windows make those test rows not fully independent.
  • Predictions use the latest completed session only. A live price is display-only and never fed to a model.

Links

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support