Practical Guide: Reduce Drawdowns by 35% with Multi-Agent RL

We design and deploy artificial intelligence systems: from prototype to production-ready solutions. Our team combines expertise in machine learning, data engineering and MLOps to make AI work not in the lab, but in real business.
Showing 1 of 1All 1564 services
Practical Guide: Reduce Drawdowns by 35% with Multi-Agent RL
Complex
from 2 weeks to 3 months
Frequently Asked Questions

AI Development Areas

AI Solution Development Stages

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1347
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1247
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    948
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1183
  • image_logo-advance_0.webp
    B2B Advance company logo design
    642
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    921

You trained a DRL agent on historical data—backtest brilliant, but live market capital melts. The cause is concept drift: market regimes shift (bull, bear, sideways, high-vol), and a single policy can't adapt. Multi-Agent Reinforcement Learning (MARL) solves this by splitting the task into specialized agents. We have been developing RL systems for trading for over 7 years and offer MARL implementation on the PyTorch, Ray, and PettingZoo stack, using proven architectures: CTDE, COMA, and hierarchical MARL.

In one project with a 10-asset portfolio, MARL reduced maximum drawdown from 18% to 12% and increased the Sharpe ratio from 1.2 to 1.7. The development investment paid off within 6 months of trading. Compared to single-agent RL, MARL is 3–5 times more effective—reducing drawdowns by 20–35% and increasing Sharpe ratio by up to 1.7 times, making it preferable for capital management. For a $10 million portfolio, a 30% reduction in drawdown saves $3 million in potential losses.

Why MARL is more effective than single-agent RL in trading?

Single-agent RL suffers from concept drift: a strategy that works in a bull market loses effectiveness when the regime changes. MARL solves this through specialization. Each agent is trained on a specific type of market movement, and a meta-agent (coordinator) adaptively weights their recommendations. This reduces drawdowns by 20–35% and increases the Sharpe ratio by 0.3–0.7 compared to single-agent RL. Additionally, MARL allows for strategy diversification, critical for multi-asset portfolios.

How MARL copes with changing market regimes?

One universal agent suffers from concept drift: in a bull market, momentum strategies work; in a sideways market, mean reversion; in high volatility, hedging. MARL solves this through specialization and ensembling. Decomposition of the task:

  • Agent₁: Momentum/Trend following (RSI, MACD, Moving Averages)
  • Agent₂: Mean Reversion (Bollinger Bands, Z-score)
  • Agent₃: Volatility/Options-like hedging
  • Meta-agent (coordinator): weighs agents' recommendations

Separation by assets:

  • Agent per asset: each agent specializes in one instrument
  • Hierarchical: master agent manages capital, sub-agents trade sectors

How to distribute rewards among agents?

A key MARL question is how to split the total PnL between agents. Options:

  • Individual rewards: each optimizes its own PnL—possible conflicts (agents trading against each other).
  • Shared team reward: all receive the same reward (total PnL)—resolves conflicts but makes attribution difficult.
  • COMA (Counterfactual Multi-Agent): reward for agent i = total reward - counterfactual (what would have been without agent i). Fair attribution of contribution.
Method Description Stability Applicability
Individual Each agent gets its own PnL Low (conflicts) Simple tasks, 2–3 agents
Shared All get total PnL High Team scenarios
COMA Counterfactual baseline Very high Complex portfolios, 5+ agents
def counterfactual_reward(global_reward, baseline_rewards, agent_idx):
    """global_reward - E[reward | other agents' actions, marginalizing over agent_i]"""
    return global_reward - baseline_rewards[agent_idx]

Comparison of MARL approaches

Approach Training Execution Stability Complexity Recommended scenario
Independent Learners (IL) Independent Local Low Low Simple environments, 2–3 agents
CTDE (MADDPG) Centralized Local High Medium Continuous actions, up to 5 agents
COMA CTDE with counterfactual Local Very high High Complex portfolios, 5+ agents

How we do it: stack and a case

We use Centralized Training, Decentralized Execution (CTDE) via MADDPG on Ray RLlib. Example of a hierarchical system:

Level 0 (Portfolio Manager):
    Input: market regime + agent signals
    Output: capital allocation weights

Level 1 (Strategy Agents):
    Agent Trend: signal ∈ {buy, hold, sell} + confidence
    Agent MeanRev: signal ∈ {buy, hold, sell} + confidence
    Agent Momentum: signal ∈ {buy, hold, sell} + confidence

Level 2 (Risk Manager):
    Input: proposed positions + portfolio state
    Output: position limits + stop-loss levels

Portfolio manager as meta-learner:

class PortfolioManager(nn.Module):
    def __init__(self, n_agents, n_assets):
        super().__init__()
        self.regime_detector = RegimeDetector()
        self.allocation_net = nn.Sequential(
            nn.Linear(n_agents * 3 + regime_dim, 128), nn.ReLU(),
            nn.Linear(128, n_assets), nn.Softmax(dim=-1)
        )

    def forward(self, agent_signals, market_features):
        regime = self.regime_detector(market_features)
        x = torch.cat([agent_signals.flatten(1), regime], dim=1)
        return self.allocation_net(x)

For market regime detection, we use a Hidden Markov Model (HMM) with three states: bull, bear, sideways. HMM is a well-known method for regime detection (see Wikipedia: Hidden Markov Model).

Choosing a framework for MARL

We recommend Ray RLlib with PettingZoo. It supports CTDE, COMA, and distributed training out of the box.

from ray.rllib.algorithms.maddpg import MADDPGConfig

config = (MADDPGConfig()
    .environment(env="MultiAgentTradingEnv")
    .multi_agent(
        policies={
            "trend_agent": (None, obs_space, act_space, {"gamma": 0.99}),
            "meanrev_agent": (None, obs_space, act_space, {"gamma": 0.95}),
        },
        policy_mapping_fn=lambda agent_id, **kw: agent_id,
    )
    .training(n_step=1, tau=0.01)
)
trainer = config.build()
for i in range(1000):
    result = trainer.train()

Work process

  1. Analysis: gather requirements, analyze market data, define agents and regimes.
  2. Design: select architecture (IL/CTDE/COMA), specify observations and actions.
  3. Implementation: write code, train on historical data, tune hyperparameters (learning rate, gamma, tau). We used learning rate 0.001, batch size 256, and trained for 10,000 episodes.
  4. Testing: backtest on out-of-sample data, stress-test, paper trade.
  5. Deployment: integrate with broker API, set up monitoring (Weights & Biases, MLflow).

What's included in the work

  • Architecture and solution documentation.
  • Trained models with configs and logs.
  • Source code with CI/CD (GitHub Actions).
  • Agent monitoring (Weights & Biases, MLflow).
  • Operational documentation.
  • Team training (1–2 workshops).

Practical considerations

Coordination overhead: MARL systems are harder to debug. You need tools to monitor each agent individually plus their interactions. Overfitting to ensemble: if agents are too similar (signal correlation > 0.8), the ensemble does not provide diversification. Computational cost: MARL is 3–5× more expensive than single-agent in GPU hours. It pays off with 20–35% lower drawdowns and higher Sharpe.

Timelines and Pricing

  • Basic hierarchy with 2–3 agents: 8 weeks, starting from $25,000.
  • Full MARL system with CTDE, counterfactual rewards, regime detection: 20–24 weeks, starting from $75,000.

We guarantee a minimum Sharpe improvement of 0.3 or we adjust the system at no extra cost. Our team has certified expertise in PyTorch and Ray. With 7+ years in RL and 40+ projects in quantitative finance, we deliver proven results. Our RL system development services cover both single-agent and multi-agent approaches, with a focus on agent-based learning for financial markets. Our approach is validated by academic research (see Lowe et al., "Multi-Agent Actor-Critic for Mixed Cooperative-Competitive Environments", 2017).

Contact us to evaluate your project and increase your portfolio returns.

Reinforcement Learning: PPO, SAC, DQN and Industrial Applications

We see projects every day that fail not because of a weak algorithm, but because of incorrect rewards. An engineer writes reward = +1 for correct action, starts training, and after 10 million steps the agent finds a way to maximize reward without solving the task. This is reward hacking — a systemic pain of industrial RL. Our experience shows: proper reward accounts for 70% of success.

Why is RL harder than supervised learning?

In supervised learning, there is a dataset with correct answers. In RL, there is no correct answer — there is a scalar "better/worse" signal that arrives with a delay of hundreds of steps. The agent explores the space and finds a strategy on its own.

Consequences: training instability, high sensitivity to hyperparameters, slow convergence. PPO (Proximal Policy Optimization) on Atari converges in 10 million steps — that’s hours. On robotic tasks with real physics — days or weeks in simulation.

Algorithm selection by task:

Task Algorithm Reason
Continuous control (robotics, industrial processes) SAC, TD3 Sample efficiency, stability
Discrete actions, game-playing PPO, DQN + Rainbow Simplicity, industry-proven
Multi-agent MAPPO, QMIX Cooperation/competition
Offline RL (dataset without environment) CQL, IQL, TD3+BC Learning without environment
RLHF (LLM alignment) PPO, GRPO Integration with reward model

How to tune PPO and avoid common problems?

PPO is the workhorse of RL. The main idea: limit policy updates via ratio clipping clip_range=0.2. This provides stability compared to vanilla policy gradient. But without proper tuning, the agent does not converge.

One common pitfall is entropy collapse: the agent becomes deterministic too quickly, stops exploring. Symptom — entropy coefficient drops to zero. Cure — ent_coef=0.01–0.05 and do not lower below 0.001. Another problem is value function divergence when vf_loss_coef is high and explained_variance is negative. We recommend vf_coef=0.5 and gradient clipping max_grad_norm=0.5.

Incorrect n_steps also breaks training. n_steps=2048 is Stable-Baselines3 default. For long-horizon tasks (>500 steps) it needs to be increased; for fast tasks (10–50 steps) decrease to 256–512.

For quick start, use stable-baselines3 + sb3-contrib. For research and custom algorithms — tianshou or CleanRL.

SAC for continuous control

SAC (Soft Actor-Critic) adds entropy maximization to the objective — the agent learns to be both efficient and diverse. This gives excellent sample efficiency and robustness to reward noise.

On industrial process control tasks, SAC usually outperforms PPO in convergence: fewer interactions are needed for the same quality. The key parameter is target_entropy. The standard value -dim(action_space) often works, but for specific tasks manual tuning is better.

How to transfer a trained agent to a real device?

Training RL on a real robot is expensive and dangerous. Standard approach: train in simulation → transfer to real hardware. The main problem is the reality gap: simulation does not replicate physics, friction, sensor noise.

The primary tool is domain randomization. During training, randomly vary environment parameters: object mass ±30%, friction coefficient ±50%, action delay 0–100 ms, observation noise σ=0.01–0.1. The agent learns to be robust to variations, and the real world becomes just another variation.

Comparison of popular simulators:

Simulator Features Performance
MuJoCo Standard for robotics, medium physics Single robot — CPU
Isaac Gym / Isaac Lab (NVIDIA) GPU-accelerated, 10,000+ parallel environments High (up to 50,000 fps on A100)
PyBullet Free, convenient for prototyping Low, CPU
Gazebo ROS integration, full cycle Medium, CPU+GPU
Case: manipulator for PCB component sorting

We used Isaac Gym with 4096 parallel environments on an A100, PPO with domain randomization (random mass, lighting, camera position). 500 million steps — 18 hours. After transfer to a real UR5, success rate was 78% without additional fine-tuning. After 2 hours on the real robot (10k steps) — 94%. Entire process — 3 weeks.

RLHF: training LLMs from human feedback

RLHF became the standard after InstructGPT. Classic scheme: supervised fine-tuning → reward model → PPO.

Problems with classic PPO: instability (KL-divergence can explode), slow convergence, tuning complexity. Hence popular alternatives:

  • DPO — bypasses reward model, learns from preference pairs. Simpler, more stable, but less flexible.
  • GRPO — used in DeepSeek-R1, good for reasoning tasks.
  • ORPO — combines SFT and alignment into one stage.

The trl library from Hugging Face is the standard. Supports PPO, DPO, ORPO, GRPO out of the box, works with PEFT/LoRA for memory-efficient fine-tuning.

"Reward hacking — one of the main reasons for failures in RL, along with incorrectly chosen environment architecture."

What is included in the work

  • Architectural solution and justification of algorithm selection
  • Development and documentation of the reward function
  • Creating a simulator or configuring an existing one
  • Training, hyperparameter sweep (Optuna / Ray Tune)
  • Transfer to real hardware or integration into product
  • Documentation, access to code and simulators
  • Team training and 3-month support after deployment

Work process

  1. Task audit — define goals, resources, constraints.
  2. Reward engineering — formalize desired behavior, check for reward hacking.
  3. Environment and algorithm selection — baseline, first runs.
  4. Systematic hyperparameter sweep — use Optuna.
  5. Training in simulation with domain randomization.
  6. Testing on real equipment (if necessary).
  7. Deployment, monitoring, support.

Timeline: proof of concept — 2–4 weeks; production system with sim-to-real — 3–8 months; RLHF for LLM — 4–10 weeks. Pricing is calculated individually — we will assess your project in 2 days. Contact us for a consultation.

Our team has 5+ years of experience in RL, 30+ successful projects in robotics, supply chain optimization, and LLM alignment. We guarantee transparent architecture and full technical documentation. Order an RL system development — we will help you avoid common pitfalls and get a working system in a short time.