Skip to main content
Get in touch

I'm always excited to take on new projects and collaborate with innovative minds.

PORTFOLIO In Development

Klytron AI Trading Bot — Algorithmic Trading with Machine Learning

A Python-based algorithmic trading system fusing machine learning signal generation with rule-based risk management. Built for continuous learning, extensibility, and real-world capital preservation — not just backtested theory.

AI & Machine Learning Python FinTech Algorithmic Trading Automation
Klytron AI Trading Bot — Algorithmic Trading with Machine Learning

The Premise: AI-Driven Decisions Without Gambling

Most algorithmic trading systems solve the wrong problem. They optimise for maximum return in backtesting, ignoring the most important variable in live trading: capital preservation under uncertainty.

The Klytron AI Trading Bot was built with the inverse priority: risk management first, signal generation second. No signal, however confident, executes without passing through a multi-layer risk gate.


What the System Does

The bot monitors live market data across multiple assets, applies trained ML models to generate directional signals, and executes trades automatically through exchange APIs — all within a strict risk framework that limits exposure at the position, daily, and portfolio level.

Core capabilities:

  • Machine learning signal generation — Pattern recognition across price action, volume, and derived indicators using scikit-learn and TensorFlow models
  • Multi-timeframe analysis — Signals are validated across multiple timeframes before execution to filter noise
  • Automated strategy execution — Configurable strategies with per-position take-profit, stop-loss, and trailing stop logic
  • Backtesting engine — Historical data simulation with slippage and fee modelling to validate model accuracy before live deployment
  • Portfolio rebalancing — AI-generated weighting signals adjust asset allocations based on momentum and volatility regime
  • Real-time WebSocket feeds — Sub-second market data ingestion from major exchanges

Architecture: Separation of Concerns

The system separates four distinct domains into independent modules that communicate via a message bus:

┌─────────────────────────────────────────────────────────────┐
│                    Klytron Trading Bot                      │
├──────────────┬──────────────┬──────────────┬───────────────┤
│  Data Layer  │  Signal Layer│  Risk Layer  │ Execution Layer│
│              │              │              │               │
│ REST/WebSocket│ ML Models   │ Position Sizer│ Exchange API  │
│ Market Feeds │ Indicators   │ Drawdown Guard│ Order Manager │
│ Historical DB│ Regime Detect│ Corr. Filter  │ Fill Tracker  │
└──────────────┴──────────────┴──────────────┴───────────────┘
                       │
               Audit Log / Metrics

Why this separation matters: Each layer can be modified, retrained, or replaced independently. A new ML model can be hot-swapped into the Signal Layer without touching execution logic. A new exchange can be added to the Execution Layer without changing signal generation.

The Risk Layer (The Most Important Component)

Before any signal reaches the execution layer, it passes through four gates:

  1. Position sizing — Kelly Criterion-inspired sizing algorithm caps individual position risk at a configurable percentage of total portfolio value
  2. Correlation filter — New positions are checked against open positions; correlated entries are suppressed to avoid concentrated sector exposure
  3. Daily drawdown guard — If daily losses exceed a threshold, the system pauses all new entries until the next session
  4. Maximum concurrent positions — A hard cap prevents over-diversification into positions the system cannot actively monitor

The ML Signal Pipeline

# Simplified signal generation pipeline
class SignalPipeline:
    def generate(self, market_data: pd.DataFrame) -> Signal:
        features = self.feature_engineer.transform(market_data)
        raw_signal = self.model.predict_proba(features)
        
        # Only pass signals above confidence threshold
        if raw_signal.confidence < self.config.min_confidence:
            return Signal.NEUTRAL
            
        # Cross-validate with regime detector
        regime = self.regime_detector.current(market_data)
        if not self.strategy.is_valid_for_regime(regime):
            return Signal.NEUTRAL
            
        return Signal(direction=raw_signal.direction, 
                     confidence=raw_signal.confidence,
                     regime=regime)

Technical Stack

Component Technology
Language Python 3.11+
ML Models scikit-learn, TensorFlow, XGBoost
Data Processing pandas, NumPy, TA-Lib
API Integration REST + WebSocket (exchange-specific)
Storage SQLite (local), InfluxDB (time-series metrics)
Infrastructure Docker (containerised), designed for VPS deployment
Testing pytest, custom backtesting harness

Engineering Decisions and Rationale

Why Python (Not JavaScript or Go)?

Python's dominance in the quantitative finance and ML ecosystem is decisive. pandas, TA-Lib, scikit-learn, and TensorFlow are the industry standard. The community, documentation, and tooling for this specific problem domain are unmatched.

Why Not Just Use an Existing Trading Framework?

Frameworks like Zipline and Backtrader are excellent for backtesting, but impose constraints on live execution architecture. Building from first principles produces a system I can audit completely — every risk decision, every order, every model inference produces a log entry I can trace.

When real capital is at risk, the ability to audit every decision is not optional.

Backtesting Approach

The backtesting engine models:

  • Slippage — Market impact estimated from historical bid/ask spreads
  • Transaction costs — Per-trade commissions applied to every simulated fill
  • Look-ahead bias prevention — Strict data windowing ensures models only see data available at the simulated time

Strategies that perform well in backtesting without modelling these factors tend to fail in live deployment. The engine is deliberately conservative to avoid overfitting to historical conditions.


Current Status & Roadmap

The core infrastructure — data ingestion, ML pipeline, risk management, and backtesting harness — is feature-complete.

Active development:

  • Expanding the model ensemble (adding gradient boosting alongside the current neural network stack)
  • Implementing reinforcement learning for dynamic position sizing
  • Building a real-time performance dashboard (Grafana + InfluxDB)

Planned:

  • Live trading integration with a secondary exchange for parallel execution
  • Telegram/Discord alerting for position open/close events and daily P&L summaries

This project is personal R&D and is not offered as a commercial service. It demonstrates the intersection of my AI/ML engineering expertise and financial systems background.

Technologies: AI & Machine Learning Python FinTech Algorithmic Trading Automation

Interested in a Similar Project?

Whether you need a bespoke platform, a cloud-native migration, or AI-integrated automation — I deliver solutions engineered for your specific business outcomes.

Project Details
Client Personal Project / R&D
Year 2025
Category General
Status In Development
Share Project