~/projects/enular
Enular
A fintech startup making algorithmic trading easier for retail investors, and its alpha backtesting library on PyPI, built on Backtrader.
01What it is
Enular was a fintech startup, registered at Companies House, that set out to make algorithmic trading tools easier for retail investors to use. Buying shares through an app had become straightforward, but turning an idea such as "buy when two conditions are both true" into something that could be tested consistently still took programming skills.
The proposed product was a visual strategy builder. The public release was an alpha Python
library for constructing, backtesting and evaluating strategies, built on the same idea of
reusable components. It is published on PyPI: pip install enular.
02How a strategy is built
A strategy is taken apart into pieces that connect together, in the way the layers of a neural network do:
- Indicators turn market data into a single signal. A moving average, for example, turns past closing prices into a smoothed price series.
- Indicator operations take two signals and produce one, in three kinds: numbers to a number, numbers to a true-or-false signal (such as one value crossing another), and two true-or-false signals combined by one of seven logic gates, such as AND.
- Strategy operations take two signals and turn them into orders: buy or sell instructions, from either numbers or true-or-false signals.
New strategies can also be written by extending the library's classes and redefining their trade logic.
The library's main example chains these together. A crossover operation compares the MACD line with the Acceleration/Deceleration oscillator, an XOR gate combines that signal with a second one, and an AND strategy operation turns the result into orders.
A second example trades several assets at once from a stochastic oscillator. It opens a long position when the fast and slow lines are both below 20 and momentum is rising, and a short position when both are above 80. Each trade is a bracket order: a limit entry 0.5% from the close, a 3% stop-loss and a 6% take-profit, valid for ten days.
03How the library works
The library is built on Backtrader's Cerebro engine, with fixes taken from Backtrader2, the community-maintained continuation of Backtrader. Alongside the strategy components, it provides a collection of indicators, data streaming from Yahoo Finance and paper trading. Cerebro is given a data feed and a strategy, then runs the strategy over historical market data. The strategy evaluates its rules as each new price arrives and sends orders to a simulated broker, which fills them and tracks the positions and the portfolio's value. The result shows what the rules would have done under the assumptions of the test.
The repository's example configures a Yahoo Finance data feed, sets a fixed position size, runs the strategy, reports the change in portfolio value and plots the result. A second example sweeps through different fast and slow moving-average periods and ranks the runs by Sharpe ratio. A sweep like this shows which settings scored well on the chosen data; drawing conclusions from it would also need testing on unseen periods and allowing for trading costs.
04The planned product
The pitch proposed a drag-and-drop web interface, with blocks for market data, indicators, comparisons, logic and orders. A beginner could connect the blocks and test a strategy without writing Python, while more experienced users could modify or contribute components. The design also included tutorials and an environment for comparing backtest results.
A broker connection was planned too: investors would link their own brokerage account through an API, starting with Interactive Brokers, so that a strategy could eventually place real orders. Machine learning components, a strategy library, templates, documentation and a user forum were also on the roadmap. The company's website was a separate application, built with Django.
05What happened next
The library went through a series of pre-alpha releases on PyPI from May 2022, reaching an alpha, version 1.0.0, in April 2023, while a visual prototype of the platform was in development. Time and funding constraints ended development before the no-code platform and the broker connection were built.