""" Quality Factor Screener Ranks the tokenized equity universe on return-on-invested-capital, earnings stability, and balance-sheet strength, then holds the top decile with quarterly reconstitution. Asset class : STOCK (tokenized equities (RWA)) Strategies : equity trading, sector rotation Published on Wakehood (https://wakehood.com), a decentralized index of AI trading agents on Robinhood Chain. This is a reference implementation. Wakehood stores and indexes this code; it does not execute it. Review any agent's code yourself before trusting it with capital. """ from __future__ import annotations from dataclasses import dataclass, field ASSET_CLASS = "STOCK" STRATEGY_TAGS = ["equity trading","sector rotation"] @dataclass class Position: symbol: str size: float # signed: positive is long, negative is short entry_price: float @dataclass class Decision: symbol: str target_weight: float # fraction of capital, in [-1, 1] reason: str @dataclass class QualityFactorScreener: """Quality Factor Screener — equity trading, sector rotation.""" max_gross_exposure: float = 1.0 rebalance_threshold: float = 0.05 positions: dict[str, Position] = field(default_factory=dict) def evaluate(self, market: dict) -> list[Decision]: """ Turn a snapshot of market state into target weights. `market` is expected to expose, per symbol, at least: price, and whatever signals this strategy needs (funding, spread, volatility, fundamentals, ...). The concrete feeds are intentionally left to the operator; this skeleton documents the decision logic, not the data plumbing. """ decisions: list[Decision] = [] for symbol, state in market.items(): edge = self._edge(symbol, state) if abs(edge) < self.rebalance_threshold: continue decisions.append( Decision(symbol=symbol, target_weight=self._size(edge), reason=self._why(edge)) ) return decisions def _edge(self, symbol: str, state: dict) -> float: """ The core alpha. For "equity trading, sector rotation", this is where the signal is computed: the sign is the direction, the magnitude is the conviction. Returns a value the sizer maps to a weight. """ raise NotImplementedError("Implement the equity trading signal for this market.") def _size(self, edge: float) -> float: weight = max(-1.0, min(1.0, edge)) return weight * self.max_gross_exposure def _why(self, edge: float) -> str: direction = "long" if edge > 0 else "short" return f"equity trading edge {edge:+.3f} -> {direction}"