Logo Lanfrica

Dalliso-banda/zamstockpredict

Domain:

socioeconomic

Record type:

model
Creator:
Dal
Host:
A notebook to an ML pipelines that predicts stock prices, forex USD/ZMW readme = """# zambian forex and stock predictor Predicts whether the Zambian Kwacha (ZMW) will strengthen or weaken against the USD over the next 7 days, using copper prices and macro indicators. Built from the Zambian Financial Datasets project β€” 117GB of raw data curated into clean CSVs. --- ## πŸ“Š Model Performance | Model | Accuracy | |---|---| | V1 Random Forest (baseline) | 56.26% | | V2 Random Forest + Macro | **62.62% βœ… winner** | | V2 + Mining stocks | 61.90% | | XGBoost | 56.06% | | 30-day target | 45.83% | **Best used when model confidence is above 70%.** --- ## 🧠 How It Works Copper Price (HG=F) ──┐ ZMW History ─────────────▢ Random Forest ──▢ ZMW UP or DOWN in 7 days Zambian Macro Data β”€β”€β”€β”˜ (200 trees, 17 features) ### Key Insight Copper drives ~70% of Zambia's export earnings. When copper prices sustain a high level over 30 days, the ZMW tends to strengthen. The model's top signals are: 1. `zmw_lag1` β€” yesterday's ZMW rate (momentum) 2. `zmw_ma7` β€” 7-day ZMW trend 3. `copper_ma30` β€” 30-day copper average (not daily moves) 4. `copper_lag30` β€” copper price 30 days ago --- ## πŸ“ Project Structure zamstockpredict/ β”œβ”€β”€ zambian-financial-datasets-main/ # Raw CSVs β”‚ β”œβ”€β”€ afae-dataset/ β”‚ β”‚ β”œβ”€β”€ global_markets.csv # Copper, indices, ETFs β”‚ β”‚ β”œβ”€β”€ zmw_forex_rates.csv # ZMW forex pairs β”‚ β”‚ └── zambia_macroeconomic_data.csv β”‚ └── ziaa-dataset/ β”‚ └── ml_features.csv β”œβ”€β”€ zmw_FINAL_model.pkl # Trained model β”œβ”€β”€ zmw_FINAL_features.pkl # Feature list β”œβ”€β”€ app.py # Streamlit web app β”œβ”€β”€ copper_vs_zmw_fixed.png # Copper vs ZMW chart β”œβ”€β”€ feature_importance.png # Feature importance chart └── backtest_2024.png # 2024 backtest results --- ## πŸš€ Run the App ### Requirements ```bash pip install streamlit scikit-learn pandas numpy yfinance joblib ``` ### Launch ```bash streamlit run app.py ``` Make sure `zmw_FINAL_model.pkl` …