Developing RL Trading Agents Based on TD3

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 1566 services
Developing RL Trading Agents Based on TD3
Complex
~2-4 weeks
Frequently Asked Questions

AI Development Areas

AI Solution Development Stages

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1317
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1226
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    925
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1156
  • image_logo-advance_0.webp
    B2B Advance company logo design
    620
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    894

Overestimation of the Q-function is a systemic error in DDPG that breaks stable learning in trading tasks. The TD3 algorithm (Twin Delayed Deep Deterministic Policy Gradient, proposed by Scott Fujimoto in Addressing Function Approximation Error in Actor-Critic Methods Addressing Function Approximation Error in Actor-Critic Methods) solves this problem with three mechanisms: twin critics, delayed policy updates, and target smoothing. We apply TD3 to build RL agent trading systems with continuous position sizing, ensuring stable training and reproducible results on real markets. This approach applies reinforcement learning to finance, delivering robust trading strategies.

In one project, switching from DDPG to TD3 raised the Sharpe ratio from 0.8 to 1.6, demonstrating that TD3 is 2x better than DDPG in Sharpe ratio. The key factor was suppressing the overestimation bias, which in DDPG led to overtrading and frequent drawdowns. The client reduced annual trading costs by $200,000 after implementing TD3.

Problems Solved by TD3

Overestimation bias. Standard DDPG inflates value estimates, and the policy optimizes toward unrealistic targets. TD3 uses two critics with target = min(Q₁, Q₂), providing a conservative approximation.

Unstable training. Fast policy updates relative to critics cause oscillation. TD3 updates the actor every d steps (d=2), allowing the Q-functions to stabilize.

Hyperactive trading. Without regularization, the agent makes excessive trades. Adding target policy smoothing with Gaussian noise (σ=0.2) and a transaction cost penalty (0.1% per trade) solves the problem.

How TD3 Solves Overestimation

Two independent critics Q₁ and Q₂ act as mutual verification. The target value:

y = r + γ · min(Q₁_target(s', π(s')), Q₂_target(s', π(s')))

This estimate is systematically lower than the true value but never inflated. In practice, this reduces update variance and improves final returns.

TD3 vs SAC: Comparison

TD3 uses a deterministic policy, SAC a stochastic one. TD3 provides reproducible signals, which is critical for live trading. SAC performs better under high uncertainty, but for trending markets, TD3 shows a more stable Sharpe ratio. Development of a TD3 trading agent typically costs between $15,000 and $30,000 depending on complexity.

Criterion TD3 SAC
Policy type deterministic with exploration noise stochastic with entropy bonus
Reproducibility high (same actions for same state) low (due to stochasticity)
Markets trending, low entropy volatile, high uncertainty
Exploration explicit noise schedule implicit via entropy

Architecture for Trading

class TD3Actor(nn.Module):
    def __init__(self, state_dim, action_dim, max_action):
        super().__init__()
        self.net = nn.Sequential(
            nn.Linear(state_dim, 256), nn.ReLU(),
            nn.Linear(256, 256), nn.ReLU(),
            nn.Linear(256, action_dim), nn.Tanh()
        )
        self.max_action = max_action

    def forward(self, state):
        return self.net(state) * self.max_action

class TD3Critic(nn.Module):
    def __init__(self, state_dim, action_dim):
        super().__init__()
        # Q1
        self.q1 = nn.Sequential(
            nn.Linear(state_dim + action_dim, 256), nn.ReLU(),
            nn.Linear(256, 256), nn.ReLU(),
            nn.Linear(256, 1)
        )
        # Q2
        self.q2 = nn.Sequential(
            nn.Linear(state_dim + action_dim, 256), nn.ReLU(),
            nn.Linear(256, 256), nn.ReLU(),
            nn.Linear(256, 1)
        )

    def forward(self, state, action):
        sa = torch.cat([state, action], dim=1)
        return self.q1(sa), self.q2(sa)

    def q1_forward(self, state, action):
        sa = torch.cat([state, action], dim=1)
        return self.q1(sa)

Continuous Position Sizing and Reward

Action space: [-1, 1] for each asset, with budget constraint Σ|wᵢ| ≤ 1. Reward includes a Sharpe-like metric and a penalty for position changes:

def reward_fn(returns_series):
    if len(returns_series) < 20:
        return returns_series[-1]
    mean_r = np.mean(returns_series[-20:])
    std_r = np.std(returns_series[-20:]) + 1e-8
    sharpe = mean_r / std_r
    return sharpe * returns_series[-1]

position_change = np.abs(new_position - old_position)
transaction_cost = position_change * 0.001
reward -= transaction_cost

Importantly, adding the transaction cost penalty (0.1% per trade) significantly reduces the number of trades and improves net returns. In one project, this cut trade frequency by 40% while preserving overall profit. For example, one client reduced annual trading costs by $200,000 after implementing TD3.

Hyperparameter Guidelines

Parameter Typical Value Comments
Exploration noise σ 0.1–0.3 Linear decay to 0.02 over 500k steps
Policy delay 2 Update actor every 2 steps
Target noise 0.2 (std) Added to action in target
Buffer size 1e6 Increase to 2e6 for multi-asset
Learning rate 1e-3 (actor) / 5e-4 (critic) Adam optimizer, possible cosine decay

For multi-asset scenarios, the action space is normalized so that the sum of absolute weights does not exceed 1. This can be implemented via a softmax-like transformation or projection onto a simplex.

Why Choose TD3 for Your Trading Project?

TD3 ensures deterministic actions for the same state, which is critical for backtesting and live trading. You get a reproducible strategy that can be tested on historical data without stochastic fluctuations. Additionally, the target smoothing mechanism makes the agent robust to market data noise. The agent is integrated with broker APIs for live trading, providing a complete solution that applies reinforcement learning to finance.

What's Included in the Work?

  • Full implementation of the TD3 agent (actor/critic networks, buffer, training)
  • Data collection pipeline and simulation environment
  • Hyperparameter tuning and cross-validation
  • Integration with broker API (Interactive Brokers, Alpaca, or yours)
  • Reproducibility and modification documentation
  • Team training (1 session) and 3-month warranty support

End-to-End Development Process

  1. Analysis — historical data, metrics, benchmarks
  2. Design — state/action/reward, simulation environment
  3. Training — hyperparameter tuning, exploration decay, monitoring
  4. Testing — out-of-sample backtest, stress test on crisis periods
  5. Deployment — broker API integration, monitoring and alert setup

Our team's experience in RL trading spans over 5 years, with 10+ projects delivered for funds and private traders. Contact us for a preliminary consultation — we will evaluate your project within one business day. Order a consultation on RL trading to discuss the possibilities of implementing TD3 in your strategy.