Using ChatGPT to create an AI trading bot
Creating an AI trading bot using ChatGPT and Composer - A no-code trading bot creator
In today's fast-paced world of technology, ChatGPT stands out as an impressive language model that is transforming how we interact with the digital realm. Created by OpenAI, ChatGPT boasts remarkable abilities in natural language understanding and generation, offering users a highly adaptable tool for a wide range of uses. ChatGPT operates in a Q&A format, allowing you to ask questions/enter instructions, while ChatGPT will answer and also remember previous instructions you gave it.
The focus of this piece is on the cutting-edge functionality available in Composer which enables you to use ChatGPT-4, the latest generative large language model (LLM) by OpenAI to help create your trading strategies with artificial intelligence (AI). GPT4 was released in March 2023 and has significant improvements to GPT3 and other previous models. OpenAI describes GPT4 as ‘Our most capable model, great for tasks that require creativity and advanced reasoning’. This model provides an incredible breakthrough in the trading space as GPT4 can support you across the board, from trading ideation to trading execution.
Composer is the tool we’ll use for this tutorial. It allows you to build trading algorithms with AI, backtest them, then execute—all in one platform.
Why are we using Composer in this tutorial? Composer uses ChatGPT4 which is the latest AI model by OpenAI (released in March 2023). Composer has also invested heavily in finetuning the ChatGPT4 model specifically for the trading use case. Therefore you get a much better AI assistant for trading use cases (you can test it on the free plan and it's included as part of the Pro Plan).
We will use ChatGPT4 to create a trading strategy from scratch. This tutorial is suitable for beginners all the way up to advanced traders. You don’t need any coding experience.
Step 1 - Head to Composer and click on the ‘Create’ section.
Composer is the tool we’ll use for this tutorial. It allows you to build trading algorithms with AI, backtest them, then execute—all in one platform. On the Create page you’ll have the option to “Create with AI”. Note: Composer offers stocks and ETF trading (no crypto at this time).


Step 2 - Describe the type of trading strategy you want to create.
For some context, Chat GPT is a natural language processing (NLP) model so you interact with it in a question/answer style.
Start by asking the AI assistant what type of strategy you are looking for. The AI trading assistant will then create the code for your strategy and provide an explanation of what it does. Don’t worry if this code looks confusing (you won’t need to use it directly). This will be a very basic baseline which you will then use to tailor to your risk profile and trading requirements.
The example we'll use: "I think that AI is going to take off. Can you build me a strategy with exposure to AI?"

Step 3 - Click “Insert and Backtest”.
This places the code that the AI assistant has created into the visual editor. Here it’s much easier to see how the logic works. You can also edit the strategy directly in this editor e.g. you may want to use the various indicators e.g. relative strength index or moving average to filter your assets.
If you scroll down, you’ll arrive at the backtester so you can use professional grade data to understand how the trading bot would have performed historically. There is also detailed performance metrics for the trading bot e.g. maximum drawdown, calmar ratio, sharpe ratio etc. You can also find how the bot would have allocated across assets each day.
In our example, the AI assistant has created a strategy with a basket of AI stocks, nice! But there's more work to do.



Step 4 - Continue the conversation and finetune your strategy.
Head back to the AI assistant chat box. Based on your own trading experience, the backtests, and your trading requirements, adjust the strategy as necessary. This could include asking the AI assistant to find ways to diversify the strategy, reduce the volatility, add a hedge, or change the strategy based on different market conditions. There are so many different paths you could take here. Once the AI assistant provides you with an updated strategy, insert it and backtest in the editor.
In our example, we can ask the chatbot: "this is cool, but I'd like to add a hedge in case AI doesn't do as well as I expect."
The AI assistant provides a 10% hedge in the form of Gold and Long Term Treasury Bonds. In the visual editor, you could also change the strategy to use other technical indicators on the Composer platform or rules-based logic e.g. If SPY is down by X, move to gold and long term treasury bonds, else stay in the tech stocks.


Step 5 - Invest with the click of a button.
Composer automatically executes your trades for you based on your rebalancing schedule. Composer is a Registered Investment Advisor (RIA) and they are regulated by FINRA and the SEC. Funds are protected up to $500k through SIPC and the custodian is BMO Harris bank.

Common Mistakes
If you find that the AI assistant throws an error, this can be due to a few common pitfalls.
1) Ensure that you are only using the indicators currently available on the Composer Symphony Editor. E.g. You can't currently as AI assistant to create the Composer code for a trading bot that trades based on CPI as CPI is not a function you can use in Composer yet.
2) Sometimes, the stock ticker will be imported into the Composer Symphony editor but may require manual editing of the name in case ChatGPT has misspelt the ticker name or the ticker name has changed since ChatGPT was released. ChatGPT may also suggest tickers that may now not be traded publicly.
You can find the full documentation here.
Summary
As you can see, Composer's AI assistant with ChatGPT4 is a versatile tool that can assist you in building a personalised strategy based on your needs. The AI assistant can also help you change the rebalancing frequency of your investment strategies to ensure they follow the desired schedule. When it comes to identifying potential investment options, the AI assistant can provide recommendations for ETFs and stocks in particular sectors, such as technology, energy, or healthcare, according to your preferences. Another great use of the tool is finding and replace assets within existing strategies.
I hope I've provided some initial inspiration for you to create your own AI trading bot. I look forward to seeing what you create!
Important Disclosures
Investing in securities involves risks, including the risk of loss, including principal. Composer Securities LLC is a broker-dealer registered with the SEC and member of FINRA / SIPC. The SEC has not approved this message.
Certain information contained in here has been obtained from third-party sources. While taken from sources believed to be reliable, Composer has not independently verified such information and makes no representations about the accuracy of the information or its appropriateness for a given situation. In addition, this content may include third-party advertisements; Composer has not reviewed such advertisements and does not endorse any advertising content contained therein.
This content is provided for informational purposes only, as it was prepared without regard to any specific objectives, or financial circumstances, and should not be relied upon as legal, business, investment, or tax advice. You should consult your own advisers as to those matters. References to any securities or digital assets are for illustrative purposes only and do not constitute an investment recommendation or offer to provide investment advisory services. Furthermore, this content is not intended as a recommendation to purchase or sell any security and performance of certain hypothetical scenarios described herein is not necessarily indicative of actual results. Any investments referred to, or described are not representative of all investments in strategies managed by Composer, and there can be no assurance that the investments will be profitable or that other investments made in the future will have similar characteristics or results.
Charts and graphs provided within are for informational purposes solely and should not be relied upon when making any investment decision. Past performance is not indicative of future results. The content speaks only as of the date indicated. Any projections, estimates, forecasts, targets, prospects, and/or opinions expressed in these materials are subject to change without notice and may differ or be contrary to opinions expressed by others. Please see Composer's Legal Page for additional important information.