
Jupiter Platform
Trading Platform Optimization
Overview
The Problem
Apex Invest BF had a trading platform for backtesting strategies on historical data. The problem was time: each backtest over three years of historical data took four and a half hours in NodeJS. With thousands of strategies to validate and parameters to optimize, iteration was impossible. A researcher could test at most 5-6 strategies per day.
Code analysis showed the root cause: nested for loops reading millions of CSV rows one at a time. Each market tick was loaded from disk, parsed from string to number, then processed individually. Three layers of inefficiency stacked on top of each other.
The Solution
I rewrote the calculation engine in Python with three fundamental optimizations.
First: I replaced Python loops with NumPy vectorized operations. Instead of processing one tick at a time, NumPy works on the entire array in a single operation using the processor's SIMD instructions. For the most critical sections I used Numba, which JIT-compiles Python code to native C at runtime: C speed without changing Python syntax.
Second: I replaced CSV with Parquet columnar format. A CSV file loads everything into memory even if you only need 3 columns out of 50. Parquet reads only the requested columns, reducing I/O by 70%. Historical data compressed in Parquet occupies a fraction of the original CSV size.
Third: parallel processing. Each strategy runs on a separate CPU core. The system can test 10 strategies simultaneously on the same hardware.
The system integrates with IG.com for historical data and live trading, calculates drawdown, Sharpe ratio, and margin call simulations in real-time during each test, and uses Monte Carlo to validate statistical robustness of strategies before running them with real money.
The Result
From four and a half hours to under 10 minutes per strategy. 95% time saved. A researcher can test hundreds of strategies in a day instead of weeks. I/O dropped 70% thanks to Parquet.
Key Features
- Backtesting 95% faster: from 4+ hours to less than 10 minutes per strategy
- Vectorized NumPy operations + Numba JIT for critical sections: native C calculations instead of Python
- Columnar Parquet format -70% I/O: reads only necessary columns instead of entire CSV
- Real-time risk management: drawdown, Sharpe ratio, margin call simulation during tests