Skip to main content

MIT-licensed open-source backtest engine and cost model from the Arbitrix trading toolkit.

Project description

arbitrix-core

PyPI Python License CI Docs

MIT-licensed open-source backtest engine and cost model from the Arbitrix trading toolkit.

Install

pip install arbitrix-core

Optional extras:

  • arbitrix-core[fast] — enables numba JIT for the SL/TP vectorized loop.
  • arbitrix-core[docs] — mkdocs build dependencies.
  • arbitrix-core[dev] — pytest + ruff.

Quickstart

import pandas as pd

from arbitrix_core import Backtester, BTConfig, Signal, BaseStrategy
from arbitrix_core import costs
from arbitrix_core import load_ohlcv


class SmaCross(BaseStrategy):
    def generate_signals(self, df):
        fast = df["close"].rolling(10).mean()
        slow = df["close"].rolling(30).mean()
        signals = []
        for i in range(1, len(df)):
            if fast.iloc[i - 1] < slow.iloc[i - 1] and fast.iloc[i] > slow.iloc[i]:
                signals.append(Signal(when=df.index[i], action="buy", price=df["close"].iloc[i]))
            elif fast.iloc[i - 1] > slow.iloc[i - 1] and fast.iloc[i] < slow.iloc[i]:
                signals.append(Signal(when=df.index[i], action="sell", price=df["close"].iloc[i]))
        return signals


df = load_ohlcv("eurusd_h1.csv", time_col="datetime")
costs.configure(commission_per_lot=3.0, point_overrides={"EURUSD": 10.0}, allow_provider_lookups=False)
result = Backtester(BTConfig()).run_single(df, SmaCross(), risk_perc=0.01, initial_equity=10_000.0)
print(result.metrics)

Full documentation at https://g14mb0.github.io/arbitrix-core/

Sync to public repo

arbitrix-core is published from the upstream Arbitrix monorepo via subtree split. The private workflow .github/workflows/arbitrix-core-sync.yml force-pushes arbitrix/src/arbitrix_core to https://github.com/G14MB0/arbitrix-core on every push to main or development that touches the subtree, and on workflow_dispatch.

Requirements:

  • Repo secret PUBLIC_REPO_TOKEN — fine-grained PAT with Contents: write scope on G14MB0/arbitrix-core.
  • Public repo development branch is overwritten on every sync. Do not commit directly to that branch.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

arbitrix_core-0.1.6.tar.gz (179.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

arbitrix_core-0.1.6-py3-none-any.whl (68.9 kB view details)

Uploaded Python 3

File details

Details for the file arbitrix_core-0.1.6.tar.gz.

File metadata

  • Download URL: arbitrix_core-0.1.6.tar.gz
  • Upload date:
  • Size: 179.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for arbitrix_core-0.1.6.tar.gz
Algorithm Hash digest
SHA256 54e4ff15c1fe186a738c90007b67e7e8b3ef671d94f62f9672cf65f1f6611966
MD5 4f43bf106d8dba939845d63f2b3d8efb
BLAKE2b-256 736786efee5751ff6ebe9b134b789e51d49c0b2eaa37c9f2e90b040318d1e83e

See more details on using hashes here.

Provenance

The following attestation bundles were made for arbitrix_core-0.1.6.tar.gz:

Publisher: release.yml on G14MB0/arbitrix-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arbitrix_core-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: arbitrix_core-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 68.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for arbitrix_core-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 7075d1d9fe32fde2d91ef7ca110527911a83deeff33f946be150a97c995230e5
MD5 3623bb5d9efbef0c142b0c220444b2c9
BLAKE2b-256 85446eac76283a09e245b8827258cb371a50c0d7512456c43e6c0d909289360f

See more details on using hashes here.

Provenance

The following attestation bundles were made for arbitrix_core-0.1.6-py3-none-any.whl:

Publisher: release.yml on G14MB0/arbitrix-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page