Skip to main content

Framework

XRTM is built on a 4-layer framework. Each layer is an independent Python package. Use them directly to build custom forecasting systems.

Packages

PackageVersionRoleInstall
xrtm-data0.3.0Schemas & question sourcespip install xrtm-data
xrtm-eval0.3.0Scoring (Brier, ECE, log)pip install xrtm-eval
xrtm-forecast0.7.0Runtime enginepip install xrtm-forecast
xrtm-train0.3.0Backtesting & optimizationpip install xrtm-train

Quick Examples

Load Questions

from xrtm.data.corpora import load_real_binary_questions
questions = load_real_binary_questions(limit=5)

from xrtm.data.providers.online import PolymarketSource
markets = await PolymarketSource().fetch_questions(limit=10)

Score Forecasts

from xrtm.eval import BrierScoreEvaluator, summarize_binary_forecasts

evaluator = BrierScoreEvaluator()
brier = evaluator.score(probability=0.7, ground_truth="yes")

predictions = [(0.7, "yes"), (0.3, "no"), (0.9, "yes")]
summary = summarize_binary_forecasts(predictions)
# {'brier_score': 0.0467, 'ece': 0.1333, 'log_score': 0.1625}

Run Forecasts

from xrtm.forecast.kit.agents.specialists.analyst import ForecastingAnalyst
from xrtm.forecast.core.config.inference import OpenAIConfig
from xrtm.forecast.providers.inference.factory import ModelFactory

config = OpenAIConfig(
model_id="your-model",
base_url="https://your-endpoint",
api_key="sk-...",
)
provider = ModelFactory.get_provider(config)
analyst = ForecastingAnalyst(model=provider)

from xrtm.data.corpora import load_real_binary_questions
question = load_real_binary_questions(limit=1)[0]
forecast = await analyst.run(question)

Provider Support

OpenAI-compatible only. Any endpoint that speaks the OpenAI Chat Completions API works.

Agents

  • ForecastingAnalyst — Structured probabilistic forecasts with causal reasoning traces
  • LLMAgent — Provider-backed agent with tool retrieval
  • RoutingAgent — FAST/SMART tiered routing

Topologies

Composable multi-agent patterns:

  • RecursiveConsensus — Parallel analysts → aggregate → supervisor loop
  • create_debate_graph() — Pro/Con/Judge debate
  • create_fanout_graph() — Fan-out to parallel workers

Backtesting

from xrtm.train import Backtester, BacktestRunner

Dependencies

Each package is intentionally lean:

  • xrtm-data: pydantic, scipy
  • xrtm-eval: pydantic
  • xrtm-forecast: pydantic, openai, aiohttp, sqlalchemy (cache), numpy, freezegun, rich
  • xrtm-train: pydantic + the three framework packages above

Architecture →