Skip to main content

111 labeled eval cases, deterministic checks, and scoring for financial trading agents

Project description

finagent-evals

111 labeled eval cases, deterministic check functions, and weighted scoring for financial trading agents.

Built from the Ghostfolio Trading Agent eval suite and published as a standalone package so anyone building financial AI agents can benchmark against a curated, production-tested dataset.

Features

  • 111 eval cases across 3 layers: golden (34), scenarios (47), dataset (30)
  • Deterministic checks -- no LLM calls, pure Python assertions
  • 7 check dimensions: tool selection, tool execution, source citation, content validation, negative validation, ground truth, structural
  • Weighted scoring with 6 dimensions: intent, tools, content, safety, confidence, verification
  • Mock infrastructure: Ghostfolio client, market data (OHLCV), seed portfolio
  • Authoritative sources: 9 bundled IRC/IRS tax references for compliance checks

Install

pip install finagent-evals

Quick Start

from finagent_evals import GOLDEN_CASES, get_all_cases, run_golden_checks

# Browse cases
print(len(GOLDEN_CASES))    # 34
print(len(get_all_cases()))  # 111

# Run checks against your agent's output
case = GOLDEN_CASES[0]
result = {
    "response": {"summary": "Your portfolio has AAPL and GOOG..."},
    "tools_called": ["get_portfolio_snapshot"],
    "tool_errors": [],
    "react_step": 1,
    "latency_seconds": 2.0,
}
checks = run_golden_checks(case, result)
print(checks["passed"])  # True/False

Eval Case Format

Each case from get_all_cases() is a dict with:

{
    "id": "gs-001",
    "input": "Show me my portfolio",
    "expected_tools": ["get_portfolio_snapshot"],
    "expected_output_contains": ["portfolio"],
    "expected_output_contains_any": ["position", "holding", "value"],
    "should_not_contain": ["I don't know", "unable"],
    "ground_truth_contains": ["AAPL", "GOOG"],
    "max_react_steps": 2,
    "max_latency_seconds": 10,
    "category": "portfolio_overview",
    "case_type": "happy_path",
    "layer": "golden",   # "golden" | "scenario" | "dataset"
    "golden": True,      # True for the 34 golden cases, False otherwise
}

Filter golden cases with [c for c in get_all_cases() if c["golden"]] or layer == "golden".

Check Functions

from finagent_evals import (
    check_tools,          # required tools present
    check_tools_any,      # at least one of list
    check_must_contain,   # all terms in response
    check_contains_any,   # any term in response
    check_must_not_contain,  # no forbidden terms
    check_ground_truth,   # mock-data values present
    check_structural,     # steps + latency in budget
    check_authoritative_sources,  # IRC/IRS citations
)

Scoring

from finagent_evals import (
    score_intent, score_tools, score_content,
    score_safety, score_ground_truth,
    aggregate_results,
    WEIGHT_INTENT,  # 0.20
    WEIGHT_TOOLS,   # 0.25
    WEIGHT_CONTENT, # 0.15
    WEIGHT_SAFETY,  # 0.15
)

For aggregate_results(results), each result dict should include passed, category, and an overall score via one of: overall_score, score, or scores["overall"]. The aggregate summary includes avg_overall_score, pass_rate_pct, tool_success_rate_pct, and by_category.

Mock Infrastructure

from finagent_evals import MockGhostfolioClient, MOCK_LAST_CLOSE, mock_fetch_with_retry

client = MockGhostfolioClient()
holdings = client.get_holdings()  # 2 positions: AAPL, GOOG
prices = MOCK_LAST_CLOSE          # {"AAPL": 187.50, "TSLA": 248.00, ...}

License

Apache-2.0

Development

pip install -e ".[dev]"
pytest tests/ -v

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

finagent_evals-0.1.1.tar.gz (32.3 kB view details)

Uploaded Source

Built Distribution

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

finagent_evals-0.1.1-py3-none-any.whl (35.5 kB view details)

Uploaded Python 3

File details

Details for the file finagent_evals-0.1.1.tar.gz.

File metadata

  • Download URL: finagent_evals-0.1.1.tar.gz
  • Upload date:
  • Size: 32.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for finagent_evals-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6f6c299c59b871bf03b37702c234495fd6532409a90d942b579e2aa6601ef67e
MD5 d9becd0fdd69c41544bd3675fdd33f28
BLAKE2b-256 c9b0ee333045239d1345bf20863b01d7dbc46af1df6945c28ab876e4f9bd6593

See more details on using hashes here.

File details

Details for the file finagent_evals-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: finagent_evals-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 35.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for finagent_evals-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 285eb67747d18bf31b14f1a692519f2c2da5a0867423e59f684632d8adde536c
MD5 7e01541cc6dae1dd949b948654e72a4d
BLAKE2b-256 4e4cb9200e09496496a90a0b181b3f50b107803ec231e4dae4d0d950c65bb3f1

See more details on using hashes here.

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