Skip to content

Server components

Most users run the packaged pineforge-backtest-server command or submit work through FastApiBacktestClient. These objects support applications that embed the service or manage its compiled-strategy cache directly.

create_app

create_app(
    service: BacktestService | None = None,
    *,
    api_key: str | None = None,
) -> FastAPI

BacktestService

BacktestService(
    *,
    max_concurrency: int | None = None,
    max_queue: int | None = None,
    queue_timeout_seconds: float | None = None,
    execution_timeout_seconds: float | None = None,
    release_image: str | None = None,
    entrypoint: Path | None = None,
    run_json_path: Path | None = None,
    cache: CompileCache | None = None,
    executor: Executor | None = None,
)

Admit a bounded number of jobs and execute them in isolated directories.

BacktestServiceError

BacktestServiceError(
    code: str, message: str, *, status_code: int, phase: str
)

Bases: RuntimeError

CompileCache

CompileCache(
    root: Path, *, max_entries: int, max_bytes: int
)

Store .so artifacts atomically and deduplicate concurrent compiles.

acquire async

acquire(key: str) -> Path | None

Atomically look up and reserve an artifact against eviction.

commit_and_acquire async

commit_and_acquire(key: str, temporary: Path) -> Path

Atomically publish and reserve a newly compiled artifact.

The running service also publishes an interactive OpenAPI schema at /docs. See the server guide for HTTP behavior, concurrency, security, and deployment configuration.