A local-first CLI tool for financial market analysis and trend prediction using advanced technical indicators
Sika is a machine learning system designed to predict foreign exchange and commodity market trends using neural networks and technical indicators. Built as a local-first CLI application, it provides a clean, intuitive interface for training models, making predictions, and tracking metrics.
- Feature Engineering: TTM Trend, MACD, RSI, ADX, Stochastic RSI, and INC/DEC
- Model Architecture: Multi-layer perceptron
- Data Processing: Min-Max Scaling
- Model Persistence: Serialized models and scalers as .pkl files
- Comprehensive Logging: Logging with detailed execution traces
| Metric | Value |
|---|---|
| Model Type | Multi-Layer Perceptron Classifier |
| Training Algorithm | L-BFGS Optimizer |
| Default Iterations | 10,000 |
| Feature Count | 7 technical indicators |
| Train/Test Split | 80/20 |
| Typical Accuracy | 80-90% (market-dependent) |
Python 3.12.9
βββ Data Processing
β βββ pandas (2.3.3)
β βββ numpy (2.3.4)
βββ Machine Learning
β βββ scikit-learn (1.7.2)
β βββ scipy (1.17.1)
β βββ ta-lib (0.6.8)
βββ CLI & Display
βββ rich (14.2.0)
βββ colorama (0.4.6)
- Python 3.12.9
- uv package manager
# Clone or download the repository
git clone <repository-url>
cd sika
# Create virtual environment
uv sync
# Install dependencies
uv pip install -r requirements.txt
# Create configuration file
cp .env.example .env# Start interactive mode (recommended)
uv run main.py
# Or run directly
uv run main.py --mode predict --pair XAUUSD --open 2650.50Create a .env file in the project root:
# Data Directories
RAW_DATA_DIR=data/raw
PROCESSED_DATA_DIR=data/processed
MODEL_DIR=models
LOGS_DIR=logs
# Trading Pairs (comma-separated)
TRADING_PAIRS=XAUUSD,EURUSD,GBPUSD
# Data Configuration
START_DATE=2020-01-01
RANDOM_STATE=42
# Model Hyperparameters
TRAIN_SPLIT=0.8
ACTIVATION=logistic
SOLVER=lbfgs
LEARNING_RATE=adaptive
LEARNING_RATE_INIT=0.03
MAX_ITER=10000
MOMENTUM=0.2
EARLY_STOPPING=True
# Feature Selection
SELECTED_FEATURES=TTM_TRND_6,MACD_12_26_9,RSI_14,ADX_14,STOCHRSIk_10_14_3_3,INC_1,DEC_1
TIINGO_KEY = your_tiingo_api_keyflowchart TD
A["<b>data/raw/*.csv</b><br/>(OHLC CSV files)"]
B["<b>Preprocessing & Feature Eng.</b><br/>scripts/data.py<br/>scripts/indicators.py<br/>(scaling, selected features)"]
C["<b>Training (models)</b><br/>scripts/train.py"]
D["<b>Config & CLI</b><br/>.env + config.py<br/>main.py (CLI entrypoint)"]
E["<b>Prediction Engine</b><br/>scripts/predict.py<br/>loads models/PAIR_mlp_classifier.pkl"]
F["<b>Output: CLI display & logs</b><br/>scripts/display.py & logs/sika.log"]
A --> B
B --> C
B --> D
D --> E
E --> F
- High-level pipeline: raw data β preprocessing & indicators β train β model artifacts β prediction β CLI display & logs.
sika/
βββ main.py # CLI entry point
βββ config.py # Configuration management
βββ pyproject.toml # Project metadata
βββ requirements.txt # Python dependencies
β
βββ scripts/ # Core modules
β βββ __init__.py
β βββ train.py # Training pipeline
β βββ predict.py # Prediction engine
β βββ data.py # Data loading & preprocessing
β βββ indicators.py # Technical indicators
β βββ log.py # Accuracy logging
β βββ logger.py # File logging setup
β βββ display.py # CLI display utilities
β
βββ data/ # Data storage
β βββ raw/ # Original OHLC data (CSV)
β βββ processed/ # Processed features
β
βββ models/ # Model persistence
β βββ PAIR_mlp_classifier.pkl
β βββ PAIR_scaler.pkl
β βββ PAIR_metadata.json
β
βββ logs/ # Execution logs
βββ sika.log
Sika uses 7 strategically selected technical indicators:
- Measures trend strength
- Input: Last 6 candles
- Output: Scaled trend intensity
- Momentum oscillator
- Parameters: Fast=12, Slow=26, Signal=9
- Captures trend changes and momentum
- Relative Strength Index
- Range: 0-100 (Overbought/Oversold)
- Identifies reversal opportunities
- Average Directional Index
- Measures trend strength
- Range: 0-100 (Strong/Weak)
- RSI applied to RSI values
- Period: 10, Smoothing: 3
- Momentum confirmation
- Percentage of up candles
- 1-period lookback
- Recent bullish pressure
- Percentage of down candles
- 1-period lookback
- Recent bearish pressure
-
Update
.envconfiguration:TRADING_PAIRS=XAUUSD,EURUSD,YOUR_NEW_PAIR
-
Train model:
python main.py --mode train --pair YOUR_NEW_PAIR
Edit scripts/indicators.py to add or modify indicators:
def custom_indicator(df):
"""Add your custom indicator here"""
return calculated_valuesThen update SELECTED_FEATURES in .env.
Modify .env values:
# For more training: increase MAX_ITER
MAX_ITER=15000
# For faster convergence: adjust learning rate
LEARNING_RATE_INIT=0.05
# For stronger regularization: increase MOMENTUM
MOMENTUM=0.5- Accuracy Range: 80-90% (market-dependent)
- Training Time: 30-120 seconds per pair
- Prediction Latency: <100ms
- Memory Footprint: 100-200MB per session
- Data Requirements: 3-5 years historical data
Note: Accuracy depends heavily on market conditions, pair volatility, and indicator stability. Regular retraining recommended when market regimes change.
# Solution: Train the model first
python main.py --mode train --pair XAUUSD# Solution: Ensure raw CSV exists in data/raw/
# Format should be: PAIRRAW.csv
# Example: XAUUSDRAW.csv# Solution: Retrain model with current indicators
python main.py --mode train --pair XAUUSD# Solution: Reduce MAX_ITER in .env
MAX_ITER=5000# Solution: Reinstall dependencies
pip install -r requirements.txtMonitor multiple forex pairs and commodities with consistent ML-based analysis.
Test trading ideas and validate signals against historical predictions.
Identify trend changes early with high-accuracy predictions.
Understand technical analysis and ML applications in finance.
Analyze market patterns and indicator relationships.
- Use Quality Data: Ensure OHLC data is complete and accurate
- Retrain Regularly: Models degrade over time as market conditions change
- Verify Predictions: Log actual results to track accuracy
- Test Thoroughly: Backtest strategies before live use
- Monitor Accuracy: Track metrics over time to catch degradation
- Optimize Hyperparameters: Experiment with different settings for your pairs
- Handle Missing Data: Clean data before training
| Component | Version | Purpose |
|---|---|---|
| Python | 3.12.9 | Runtime environment |
| scikit-learn | 1.7.2 | Machine learning |
| pandas | 2.3.3 | Data manipulation |
| numpy | 2.3.4 | Numerical computing |
| ta-lib | 0.6.8 | Technical analysis |
| rich | 14.2.0 | Terminal UI |
| joblib | 1.5.3 | Model serialization |
| python-dotenv | 1.2.2 | Configuration |
For questions or issues: reachout at: newmankelvin14@gmail.com
Sika is provided for educational and research purposes only. Trading in financial markets carries substantial risk of loss. Past performance is not indicative of future results. Always conduct thorough backtesting and due diligence before using predictions for live trading. The authors are not responsible for trading losses or decisions made based on predictions from this system.
β If you find this project useful, consider giving it a star!