trader.ranking.llm_ranker module

A local model as the ranker.

The first of two layers of failure containment. This one catches TraderError and returns the deterministic fallback order with the error recorded; the pipeline wraps the call in a second, outer try/except anyway, so a bug in this module — a TypeError, not a TraderError — also degrades rather than killing the cycle. Belt and braces, the same discipline trader/discovery/scan.py and trader/cli/main.py apply to discovery, and for the same reason: nothing about ranking may stop trading.

class trader.ranking.llm_ranker.LlmRanker(llm)[source]

Bases: object

Asks a language model to order approved candidates, best first.

Parameters:

llm (LlmProvider)

rank(candidates)[source]

Order the candidates. Never raises.

Short-circuits at zero or one candidate: there is nothing to compare, and the call costs roughly 15 seconds of a cycle for no information.

Parameters:

candidates (Sequence[Candidate])

Return type:

Ranking