I asked OpenAI's ChatGPT to write me a trading algorithm. It blew my mind.
William Chung
Systematic investing | Quantitative trading | Founder | Strategy | General Management | Payments | Loyalty | Partnerships
It's time to rethink the way you code
If you haven't been living under a rock, you would have heard of the buzz surrounding ChatGPT, a chatbot launched by OpenAI in November 2022. It was built on top of OpenAI's #gpt3 family of large language models and was fine-tuned with both supervised and reinforcement learning techniques.
By now, you would have seen hundreds of posts raving about the numerous use cases for copywriting, resume-writing, solving math problems, and even for writing passive-aggressive texts to your spouse.
Among the large number of use cases that ChatGPT could be applied to, I wanted to explore an underutilized use case - writing code.
"ChatGPT, write me a trading algorithm."
Building a fully-functional trading algorithm from scratch is an extremely challenging task, and I wanted to test the limits of ChatGPT's ability to assist in strategy development.
In order to optimize the capabilities of ChatGPT, I had to make appropriate prompts and questions throughout the conversation. This meant that I had to zoom into the scope and provide sufficient context, including details such as:
With the above in mind, these are the prompts that I gave ChatGPT in order to put the building blocks together:
Believe it or not, these were the only prompts that I gave ChatGPT and it was sufficient enough to create a simple mean reversion #algorithm.
领英推荐
To err is.. AI?
Don't be mistaken - ChatGPT is not perfect. The code generated was filled with bugs and I found myself having to edit up to 50% of the code that ChatGPT provided me with. I also had to tinker with other aspects such as trailing stops, take-profit and stop-loss parameters. The good news is that ChatGPT could assist you in the debugging process to make your life easier. Half an hour or so later, the code was complete.
I back-tested the algorithm for 11.5 years to call its bluff. Why not?
Using tick data, I took the freshly-minted algorithm for a rigorous 11.5-year back-test to see if it is worth its salt. I'll be honest that I had low expectations, and the results surprised me.
With a starting capital of $1,000 USD and a starting lot size of 0.01, the back-test ran from 1 January 2011 to September 2022, yielding the following results:
ChatGPT - A worthy coding assistant
I'll be honest. I was excited by the results. As you can tell, it was a fantastic start. This opens up a plethora of possibilities not just in the field of algorithmic trading, but for software engineering as a whole. If you are a software engineer and is not using ChatGPT to help with you with the development process, give it a shot! You would be pleasantly surprised.
P.S. I've excluded detailed specifics of the development process in order to keep the article succinct. If you're interested to find out more, feel free to drop me a comment or a message!
Health & Wellness, Loyalty & Integrated Marketing, Digital Banking, Media, Luxury, Healthcare, Finance
1 年Congratulations on creating a trading algorithm with ChatGPT! I liked your post on LinkedIn and I'm excited to see how it performs in the market.
Product | Loyalty | Strategy | Innovation
1 年How much time did it save you (or not)?
When, not if, they start charging for the platform, I assume you'd be more than happy to pay for it?