Test strategy robustness against adversarial agents. Whale attacks, front-running, spoofing, and liquidity draining. Vulnerability scoring and anti-fragile optimization.
A strategy that works in calm markets may collapse when a whale dumps, a front-runner snipes your orders, or a spoofer fakes liquidity. Horizon’s adversarial module simulates these attacks against your strategy and measures the impact. All adversary logic is pure Rust (stateless); simulation orchestration is in Python.
import horizon as hzresult = hz.anti_fragile( pipeline_factory=lambda p: [make_strategy(p)], param_bounds=[ {"name": "spread", "min": 0.02, "max": 0.15}, {"name": "size", "min": 5, "max": 100, "discrete": True}, {"name": "window", "min": 10, "max": 200, "discrete": True}, ], adversaries=[hz.WHALE_PRESET, hz.FRONT_RUNNER_PRESET, hz.SPOOFING_PRESET], pop_size=30, generations=50,)# These parameters are optimized to perform well even under adversarial conditionsprint(f"Anti-fragile spread: {result['best_genome'][0]:.4f}")
Adversarial agents are heuristic simulations, not full market microstructure simulators. They test directional robustness (how your strategy handles unexpected market actions) but do not replicate the exact mechanics of real adversaries. Use them as stress tests, not as precise predictions.