Metadata-Version: 2.4
Name: arbitrix-core
Version: 0.1.8a1
Summary: MIT-licensed open-source backtest engine and cost model from the Arbitrix trading toolkit.
Author: Arbitrix Team
License: MIT License
        
        Copyright (c) 2026 Arbitrix Team
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/G14MB0/arbitrix-core
Project-URL: Documentation, https://g14mb0.github.io/arbitrix-core/
Project-URL: Repository, https://github.com/G14MB0/arbitrix-core
Project-URL: Issues, https://github.com/G14MB0/arbitrix-core/issues
Keywords: backtesting,quant,trading,finance,cost-model
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Office/Business :: Financial :: Investment
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas>=2.0
Requires-Dist: numpy>=1.26
Requires-Dist: python-dateutil>=2.9
Requires-Dist: pytz>=2024.1
Provides-Extra: fast
Requires-Dist: numba>=0.59; extra == "fast"
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-cov>=4.1; extra == "dev"
Requires-Dist: ruff>=0.5; extra == "dev"
Requires-Dist: wheel>=0.43; extra == "dev"
Provides-Extra: docs
Requires-Dist: mkdocs>=1.5; extra == "docs"
Requires-Dist: mkdocs-material>=9.5; extra == "docs"
Requires-Dist: mkdocstrings[python]>=0.24; extra == "docs"
Dynamic: license-file

# arbitrix-core

[![PyPI](https://img.shields.io/pypi/v/arbitrix-core.svg)](https://pypi.org/project/arbitrix-core/)
[![Python](https://img.shields.io/pypi/pyversions/arbitrix-core.svg)](https://pypi.org/project/arbitrix-core/)
[![License](https://img.shields.io/pypi/l/arbitrix-core.svg)](https://github.com/G14MB0/arbitrix-core/blob/main/LICENSE)
[![CI](https://github.com/G14MB0/arbitrix-core/actions/workflows/ci.yml/badge.svg)](https://github.com/G14MB0/arbitrix-core/actions/workflows/ci.yml)
[![Docs](https://github.com/G14MB0/arbitrix-core/actions/workflows/docs.yml/badge.svg)](https://g14mb0.github.io/arbitrix-core/)

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

## Install

```bash
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

```python
import pandas as pd

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


class SmaCross(BaseStrategy):
    symbol = "EURUSD"
    timeframe = "H1"

    def prepare(self, df):
        prepared = df.copy()
        fast = df["close"].rolling(10).mean()
        slow = df["close"].rolling(30).mean()
        prepared["cross_up"] = (fast.shift(1) <= slow.shift(1)) & (fast > slow)
        prepared["cross_down"] = (fast.shift(1) >= slow.shift(1)) & (fast < slow)
        return prepared.dropna()

    def on_bar(self, row, portfolio):
        if row["cross_up"]:
            return [Signal(when=row.name, action="buy", price=float(row["close"]))]
        if row["cross_down"]:
            return [Signal(when=row.name, action="sell", price=float(row["close"]))]
        return []

    def stop_distance_points(self, row):
        return 0.002


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)
instrument = InstrumentConfig(
    ib_symbol="EURUSD",
    point_value=10.0,
    contract_size=1.0,
    tick_size=0.0001,
    min_order_size=0.01,
)
result = Backtester(BTConfig(), instruments={"EURUSD": instrument}).run_single(
    df,
    SmaCross(),
    risk_perc=0.01,
    initial_equity=10_000.0,
)
print(result.metrics)
```

`run_single` remains the mono-provider API. Multiprovider and multisymbol code
uses the additive `run_market` API with the `FeedKey` / `MarketFrames` ->
`PreparedMarket` -> `MarketBars` contract.

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

## Sync to public repo

`src/arbitrix_core` is the canonical source and is published from the upstream
Arbitrix monorepo via subtree split. The private workflow
`.github/workflows/arbitrix-core-sync.yml` force-pushes that subtree 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.
