Is ChatGPT a Viable Trading Strategy Editor?
Following the release of ChatGPT in November of last year by the artificial intelligence (AI) company OpenAI, individuals and researchers alike have been exploring the capabilities of these so-called large language models (LLMs) in a variety of domains. In addition to being able to write essays, poems, bedtime stories for children, and other text, ChatGPT can generate programming code in a variety of languages. This made me wonder if ChatGPT could respond to prompts about systematic trading and write trading strategy code in common scripting languages, such as EasyLanguage. It turns out the answer is YES. In this article, I'll explore some ways to exploit this new technology to write trading strategy code. I'll provide several examples that demonstrate both the benefits and the limitations of LLMs for systematic trading.
What is ChatGPT and How Does it Work?
ChatGPT is a language-processing neural network based on the transformer architecture (GPT is short for "generative pre-trained transformer"). The transformer architecture, originally developed at Google,1 utilizes so-called self-attention to determine the relative importance of the different words — technically, tokens — in the sequence of words comprising the prompt. Unlike recurrent neural networks, which process the input tokens sequentially, transformers process all tokens simultaneously, which allows for longer input sequences and faster training times.2
LLMs are trained by feeding in large amounts of text and adjusting the weights of the neural network so that it can predict the next word in the input sequence. When you type in a prompt, ChatGPT outputs the next word most likely to follow the prompt. It then adds that word to the prompt and outputs the word most likely to follow those words. The process is repeated as each new word is added to the sequence, resulting in sentences, paragraphs, code examples, and so on.3, 4