DEV Community

Samuel James Hiotis
Samuel James Hiotis

Posted on

Why I stopped trading and started tendering with AI

Why I Stopped Trading and Started Tendering with AI

For years, I chased the dragon of algorithmic trading. Backtesting strategies, optimizing parameters, chasing slippage… the whole nine yards. I poured countless hours (and frankly, too much money) into building systems that promised to consistently outperform the market. And for a while, some did. But the constant arms race, the changing market conditions, the ever-present threat of black swan events... it was exhausting. I felt like Sisyphus, endlessly pushing a boulder uphill.

Then I stumbled upon a different approach: tendering with AI. Instead of predicting the market, I started focusing on responding to it in a more strategic, less frantic way. This article details my journey from frustrated trader to AI-powered tendering architect, the technical challenges I faced, and why I believe this approach is more sustainable (and potentially more profitable) in the long run.

The Problem with Prediction

Let's be honest: consistently predicting market movements is incredibly difficult. High-frequency trading firms with massive infrastructure and teams of PhDs struggle with it. My personal attempts, while occasionally profitable, always felt precariously balanced. A slight shift in volatility, a new regulatory announcement, a sudden news event - and everything could fall apart.

The fundamental issue is that markets are complex, adaptive systems. They're not static formulas you can crack with clever algorithms. Trying to predict the future is a losing game. What can you control? Your responses to market changes. And that's where tendering comes in.

What is “Tendering” in This Context?

Think of tendering, traditionally, as a bidding process. But instead of bidding for a contract, we’re “bidding” for opportunity. We're identifying moments where market inefficiencies present potential profit, and then strategically deploying capital to exploit them.

Crucially, this isn't about trying to beat the market. It’s about being a sophisticated participant, leveraging AI to assess risk and opportunity, and making calculated bids for short-term advantages.

From Trading Algorithms to Tendering Agents

My existing trading infrastructure was a good starting point. I had a robust data pipeline, a backtesting framework, and experience with various technical indicators. The biggest shift was changing the objective. Instead of maximizing profit per trade, I focused on maximizing opportunity capture rate within defined risk parameters.

Here’s a simplified breakdown of how I transitioned a basic moving average crossover trading algorithm to a tendering agent:

Old (Trading):

# Simplified Moving Average Crossover - Trading Logic
def trade(data, short_window, long_window):
    short_ma = data['Close'].rolling(window=short_window).mean()
    long_ma = data['Close'].rolling(window=long_window).mean()

    if short_ma > long_ma:
        return "BUY"
    elif short_ma < long_ma:
        return "SELL"
    else:
        return "HOLD"
Enter fullscreen mode Exit fullscreen mode

This code simply generates buy/sell signals based on moving average crossovers. It’s a classic, but often unreliable, strategy.

New (Tendering):

# Simplified Tendering Logic
def tender(data, short_window, long_window, risk_tolerance):
    short_ma = data['Close'].rolling(window=short_window).mean()
    long_ma = data['Close'].rolling(window=long_window).mean()
    volatility = data['Close'].rolling(window=20).std() # Calculate 20-day volatility

    # Calculate a 'tender score' based on MA crossover & volatility
    if short_ma > long_ma:
        score = 1 + (volatility / data['Close'].mean()) * 0.5 # Reward higher volatility
    elif short_ma < long_ma:
        score = -1 - (volatility / data['Close'].mean()) * 0.5 # Penalize higher volatility
    else:
        score = 0

    if score > risk_tolerance:
        return "BUY", score
    elif score < -risk_tolerance:
        return "SELL", score
    else:
        return "HOLD", score
Enter fullscreen mode Exit fullscreen mode

Key changes:

  • Tender Score: We now assign a score based on the crossover and volatility. Higher volatility (representing greater potential opportunity and risk) increases the score for buy signals.
  • Risk Tolerance: A risk_tolerance parameter is introduced. We only execute trades (tenders) if the score exceeds this threshold.
  • Output: The function now returns a score alongside the trade signal, allowing for further filtering and weighting.

The Role of Reinforcement Learning (RL)

The initial tendering logic was relatively simple. But to truly optimize the system, I integrated Reinforcement Learning. I used a Proximal Policy Optimization (PPO) agent, trained on historical market data, to dynamically adjust the risk_tolerance and weighting of the tender score components.

Here's a conceptual snippet (using a simplified RL framework):

# Pseudocode - RL Agent Interaction
state = get_market_state(data) # Features like price, volume, volatility, tender_score
action = agent.predict(state) # Agent recommends risk_tolerance adjustment
new_risk_tolerance = action + base_risk_tolerance
trade_signal, tender_score = tender(data, short_window, long_window, new_risk_tolerance)

if trade_signal == "BUY":
    execute_buy_order(amount=calculate_position_size(tender_score)) # Position size scaled by score
    reward = calculate_profit_loss()
    agent.learn(state, action, reward)
Enter fullscreen mode Exit fullscreen mode

The RL agent learns to optimize its actions (adjusting risk_tolerance) based on the rewards it receives (profit/loss). Over time, it becomes adept at identifying scenarios where a higher risk tolerance is justified, and vice versa.

Challenges and Lessons Learned

  • Data Quality is Paramount: RL agents are data-hungry. Clean, accurate, and representative historical data is essential for effective training.
  • Overfitting is a Real Threat: Careful validation and regularization are crucial to prevent the agent from exploiting patterns specific to the training data.
  • Computational Cost: RL training can be resource-intensive. I leveraged cloud computing (AWS) to accelerate the process.
  • Explainability: Understanding why the agent makes certain decisions can be challenging. Monitoring the reward function and analyzing state-action pairs is vital.
  • Transaction Costs: A critical factor! Frequent, small tenders can quickly eat into profits if transaction fees are not accounted for.

Why Tendering Feels More Sustainable

I’ve found that tendering with AI offers several advantages over traditional trading

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.