Case study / Algorithmic Trading & Quant Tech

Automated Strategy Generator & Compiler

An automated quantitative research platform that develops and tests algorithmic trading strategies on historical futures data, discovers defensive rules to eliminate losing trades, and automatically converts research into ready-to-run C# code for trading platforms.

The challenge

Designing trading strategies manually is notorious for human bias and curve fitting: traders tweak indicators until a backtest looks profitable on past data, only for the strategy to fail in live markets. Additionally, moving a strategy from Python data science tools into professional execution platforms like NinjaTrader requires rewriting the entire system in C# by hand, a process that takes weeks and introduces costly translation bugs.

The solution

We engineered a self-refining research engine that focuses on finding 'veto rules' (defensive filters that block trades during market conditions that historically lost money) rather than over-optimizing entry indicators. Once an optimal strategy is found, a built-in code compiler automatically converts the Python logic into clean, production-ready C# NinjaScript without writing any code by hand.

High-Speed Market Processing, Zero-Copy Bus & Multi-Timeframe Aggregation

Testing thousands of strategy variations across years of tick and minute-by-minute futures data (CME Nasdaq contracts) requires immense computing speed and careful memory management.

Smartush ingests granular tick data to synthesize 1-minute and N-tick bars, dynamically aggregating them into higher-timeframe series (5-minute, 10-minute, and 60-minute bars). In quantitative research and backtesting optimization, higher-timeframe calculations are often preferable for filtering microstructure noise and accelerating parameter searches, while retaining raw tick precision whenever intra-bar execution depth is needed.

An optimized in-memory data bus shares price and indicator series across test workers without redundant copies, distributing calculations across all available CPU cores using parallel processing and fast C-libraries.

  • Hierarchical multi-timeframe aggregation: Builds 1m, 5m, 10m, and 60m bar series and N-tick bars from tick primitives.
  • In-memory zero-copy architecture enables instant time-series slicing across millions of bars without memory bloat.
  • Parallel technical indicator calculation powered by multi-core CPU execution and optimized C-libraries.

Market Condition Snapshots: Understanding Every Trade

Rather than assuming a single indicator tells the whole story, the engine treats market conditions as an interconnected picture of price behavior.

Automated checkers evaluate candle momentum, volume surges, volatility breakouts, and moving average crossings across lookbacks from 1 to 30 bars. When a simulated trade is entered during a baseline test, the system captures an exact digital snapshot of every active market condition at that precise moment.

  1. 01

    Historical tick and minute futures data is ingested and normalized.

  2. 02

    Multi-core engine calculates indicators and price action geometry in parallel.

  3. 03

    Baseline trading strategy executes simulated trades across historical data.

  4. 04

    System captures a complete snapshot of all technical conditions for every trade.

  5. 05

    Clustering engine groups trades that shared identical market conditions.

  6. 06

    Scoring system selects top-ranked defensive veto rules to block losing setups.

Dynamic Defenses: Finding Veto Rules Instead of Guessing Entries

Most automated backtesters fail because they try to find the 'perfect' indicator setting to enter trades, which almost always results in curve fitting. Smartush takes the opposite approach: it keeps entry rules simple and focuses on finding Dynamic Defenses: defensive veto rules that block trades during market conditions that consistently lose money.

The clustering engine groups historical trades that shared identical technical conditions. A multi-factor scoring algorithm evaluates these cohorts, heavily favoring simple, robust rules over complex ones to prevent overfitting. High-scoring defensive rules are injected into recursive backtests, systematically eliminating losing trades while preserving profitable ones.

  • Condition clustering identifies recurring market environments that consistently lead to losing trades.
  • Multi-factor scoring rewards simple, robust rules to ensure strategies generalize well to live trading.
  • Recursive backtesting verifies that each added defense rule increases net profit and win rate safely.

Universal AST Code Generation: Zero-Manual-Work Multi-Platform Deployment

Moving a winning strategy from Python research into live execution has traditionally been a major bottleneck, requiring software engineers to manually rewrite algorithms for target trading platforms.

Smartush automates this entire handoff with an Abstract Syntax Tree (AST) compiler. The compiler translates Python strategy rules, multi-timeframe bar series (such as 1m base with 5m and 60m aggregations), indicator configurations, and defensive vetoes into clean, strongly typed target code ready for immediate execution.

While C# and NinjaTrader 8 served as our primary production engine for CME futures and equities execution, the AST architecture is platform-agnostic: by understanding target API constraints, modular emitters can generate native code for MetaTrader (MQL), C++, or direct broker APIs, deploying the exact same defensive logic across multiple asset classes.

  • Direct code translation eliminates manual programming errors and cuts deployment time from weeks to seconds.
  • Universal platform extensibility: Primary C# NinjaTrader 8 integration with architectural capability for MetaTrader and broker APIs.
  • Multi-timeframe code emission automatically configures secondary bar series and binds indicator handles.

Technology stack

Technologies used in this project.

Backtesting Engine & Data Architecture

  • Backtesting.py Core Engine
  • Zero-Copy In-Memory Market Data Bus
  • TA-Lib (Optimized C-Libraries)
  • Multi-Core Parallel Execution (Joblib)

Market Analytics & Price Geometry

  • Pandas & NumPy Time-Series Processing
  • Technical Pattern Analysis
  • Multi-Timeframe Market Signal Checks
  • Statistical Significance Testing

Strategy Optimization & Defensive Rules

  • Market Condition Pattern Clustering
  • Multi-Factor Strategy Scoring Engine
  • Recursive Defensive Veto Pipeline
  • Visual Equity Curve Reporting

Automated Code Compilation & Deployment

  • Python-to-C# Code Compiler (AST)
  • C# (.NET Framework 4.8)
  • NinjaTrader 8 NinjaScript Architecture
  • Real-Time Pre-Trade Safety Filters

Related development services

View all projects

Your next step

Let’s define what you need to build.

Bring the idea or the process you want to improve. We’ll start with the requirements, the risks and the right scope.

Discuss Your Project