Skip to main content

Signalab

Tick-level backtesting for quantitative FX and CFD research

Python 3.13+ License: MIT PyPI

Signalab is a research-focused backtesting library that simulates trading at raw tick resolution — every bid/ask update — rather than bar-close approximations. It models the execution mechanics that matter for FX and CFD strategies: bid/ask spread, per-lot commissions, and daily swap/carry costs, with margin tracking and automatic liquidation.


Key features

  • Tick-level simulation — the loop runs on every raw bid/ask update. Indicator signals computed on candles are injected back into the tick stream at exact candle-close timestamps — no lookahead, no bar approximation.

  • Simple and easy to extend — subclass Strategy, implement perform(). Need a custom indicator? Subclass Indicator and implement compute(). That's it!

  • Vectorized computations — indicators and analytics are implemented as vectorized operations on the full data arrays. The engine coordinates the data flow, but all computations are done in batches for maximum performance.

  • Parallel parameter grid — test dozens of strategy/indicator parameter combinations in one command. Run them in parallel and get a ranked report of all runs with their metrics and configs.


Install

pip install signalab

Quick showcase

from signalab import (
    MarketData, BacktestEngine, Account,
    RSI, Strategy, Action
)

class MyStrategy(Strategy):
    def __init__(self, name="My Strategy", label="my_strat", stop_loss=50):
        super().__init__(name=name, label=label)
        self.stop_loss = stop_loss

    def perform(self, market):
        if self.account.floating_pl() < -self.stop_loss:
            self.account.close_all_positions()

        if self.account.open_position_count > 0:
            return

        buy_signals = self.buy_signal_count()
        sell_signals = self.sell_signal_count()
        if buy_signals >= sell_signals:
            self.account.open(Action.BUY, size=0.01)
        else:
            self.account.open(Action.SELL, size=0.01)
        

data   = MarketData.load_from_ticks("EURUSD_ticks.csv")
report = BacktestEngine().run(
    data       = data,
    indicators = [RSI(period=14)],
    strategies = [MyStrategy()],
)

r = report.get_account_report()
print(r.metrics())
# {
#   'total_return': 0.12,
#   'sharpe_ratio': 1.43,
#   'max_drawdown': -0.07,
#   'win_rate': 0.54,
#   ...
# }

More examples and tutorials coming soon!


🚀 Project starter provided by Cookie Pyrate

Metadata

Release files for signalab 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for signalab 0.1.3
File Size Uploaded
signalab-0.1.3.tar.gz 52.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for signalab 0.1.3
File Interpreter ABI Platform
signalab-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 95.0 kB

Release files / signalab-0.1.3.tar.gz

Download URL signalab-0.1.3.tar.gz
Size 52.4 kB
Tags Source
SHA-256 checksum
How to use checksums
aea61b994afb43daad2b93edb7abc233f897f1e7f7c430e866ef078f5fd05b80
BLAKE2b-256 checksum
How to use checksums
71584e40c6e6bfc861346087494389d137f2237aecb55a8d897b4f9caa4c505d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / signalab-0.1.3-py3-none-any.whl

Download URL signalab-0.1.3-py3-none-any.whl
Size 42.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a75aa03ccb70dfcc9a6acb6aa8a8d2b5566bf542ded4ea73902f06f5bc13613
BLAKE2b-256 checksum
How to use checksums
b5d3fd3bae57553ae3ddd40c122d9513c6d10f00c6172673dc60f6405d8e7375
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page