Skip to main content
Ultra Feature. Requires an Ultra subscription. Get started at api.mathematicalcompany.com

Adversarial Simulation

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.

Overview

4 Adversary Types

Whale, front-runner, spoofer, and liquidity drainer.

Vulnerability Scoring

hz.vulnerability_score() quantifies strategy weakness to each attack.

Baseline vs Adversarial

hz.adversarial_sim() compares performance with and without adversaries.

Anti-Fragile Optimization

hz.anti_fragile() evolves parameters that perform well under attack.

Adversary Types


Core Functions

Adversary Actions

Each adversary type has a pure function that produces actions from market state.

hz.compute_simulation_metrics

Compare baseline and adversarial PnL curves.

hz.vulnerability_score

Single score (0-1) for how vulnerable the strategy is.

Types

AdversaryConfig

Preset Configurations


Simulation Functions

hz.adversarial_sim

Run baseline vs adversarial comparison.

hz.anti_fragile

Evolutionary optimization for adversarial robustness. Finds parameters that perform well even under attack.

Examples

Test Strategy Robustness

Find Anti-Fragile Parameters

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.