Finding a Trading Idea with ChatGPT and Claude: From Data to Backtesting

Finding a Trading Idea with ChatGPT and Claude: From Data to Backtesting

OsaEngine

Creating a profitable trading strategy requires careful data analysis and understanding of market patterns. To simplify data collection, I used Hydra — arguably the best free tool for downloading market data.

I downloaded minute-level BTCUSDT data for 2024, which amounted to about 25 MB, and exported it as a CSV file.

Hydra also has its own analytics, but you’ll soon see how it falls short of AI capabilities, where you don't even need to code yourself:

However, the main focus of my work wasn't data collection but analysis and finding strategy ideas. Instead of manually searching for approaches, I decided to rely on AI to see what strategies it would suggest, what patterns and inefficiencies it could detect in the data, and how to optimize parameters for testing. With ChatGPT, I was able to perform detailed analysis and backtest the strategy on the data.


Data Preparation

After obtaining the minute-level data, I loaded it into Python (the AI wrote the code; I just typed out my instructions), starting with preprocessing. This included assigning names to each column and merging the date and time into a single column to simplify time series analysis.

Sample data structure in the CSV file:

DateTimeOpenHighLowCloseVolume

2023-12-3121:01:0042613.142629.242610.142625.764.946

Identifying Inefficiencies with AI

After data preprocessing, I asked the AI about potential inefficiencies and patterns that might be useful for strategy development. ChatGPT suggested several approaches:

  1. Volatility Clusters — Hours with high volatility could be suitable for a momentum strategy.
  2. Mean Reversion — When price deviates from the average level, a mean reversion strategy might be appropriate.
  3. Momentum Patterns — During certain hours, a stable price movement was observed, which could be a signal for a trend-following strategy.

Strategy Development

Based on the AI's suggestions, I chose two strategies for testing:

  1. Mean Reversion: Opening a short position when price significantly deviates upward from the mean and a long position when it deviates downward. Closing the position occurs when the price returns to the mean.
  2. Momentum Strategy: Opening a position in the trend direction during periods of increased volatility. If the return is positive and above a threshold, a long position is opened; if negative and below a threshold, a short position is opened.

Each strategy had basic entry and exit rules, as well as stop-losses for risk management.


Backtesting Strategies

With ChatGPT, I was also able to backtest both strategies to see how they would have performed historically. The test results showed an equity curve for the mean reversion strategy (see the graph below).

The graph shows how the portfolio’s capitalization might have changed when following the strategy. It’s clear the strategy demonstrated stable growth during certain periods, though there were also some drawdowns, confirming the importance of parameter tuning and risk management.


Claude.ai

During the process, I also tried using Claude Sonnet by Anthropic, which recently announced its large data analysis functionality (more details here). The idea seemed promising: upload a 25 MB file so that Claude could help with analysis.

However, I encountered several difficulties. Unfortunately, the feature was raw and unfinished — my file wouldn’t even upload. I ended up slicing it into smaller parts, but previous errors quickly led me to the request limit. All I managed to get was an error when trying to build a graph.

Although I like working with Claude, I hope the project engineers refine this feature and significantly expand the data upload window. This would allow more effective analysis of large files and open new possibilities for working with large datasets.


Conclusion

Using ChatGPT allowed me not only to analyze data but also to ask the AI about suitable strategy development methods. This approach not only provided new ideas but also helped quickly test hypotheses and gain recommendations that could go unnoticed with a conventional approach. Using AI to find strategy ideas and parameters opens up new possibilities for flexible and adaptive trading strategy development.



Report Page