zerokn0wledge

ChatGPT-built BTC trading bot: random forest signals and Kelly sizing

Thread731 words
Build logToolingAIBitcoinOpenAI ChatGPT$BTC$USDT

Describes building a BTC/USDT trading bot in a few hours with ChatGPT. A random forest uses MA, STD, RSI, MACD, stochastic, liquidity, order flow, news and social indicators, and sizes trades with the Kelly criterion.

Key claims
Bot trades on every minute price update
Features include MA/STD over 5, 10 and 20 periods and the latest 1000 BTC tweets
Trade size uses the Kelly criterion
learned the basics of #Python & #Java last semester yesterday, I used @OpenAI's #ChatGPT to help me build a #trading bot in python that makes automated buy/sell decisions based on the predictions of a random forest machine learning model and it only took me a few hours 馃У 馃く馃憞 first of all, #ChatGPT is just insane. Came across it the day it launched and within only a few weeks, this guy has already become indispensable the #AI literally does everything for me, from creating recipes and shopping lists to debugging and improving my code however, of all the things I have used #ChatGPT for, building this #trading bot is probably the coolest thing but what did I build exactly? as mentioned above, the basis of the bot is a random forest machine learning model a random forest is a type of machine learning model that is used for classification and regression tasks. It is an ensemble model, which means that it is composed of multiple decision trees that work together to make predictions here's how a random forest model works: first, the model randomly selects a subset of the training data and builds a decision tree model on that subset. This process is repeated multiple times, resulting in a group of decision trees (i.e., a "forest") that are all trained on different subsets of the training data when making a prediction, the random forest model combines the predictions of all the individual decision trees in the forest, and the final prediction is the majority vote or average of all the individual predictions to improve the model's predictive accuracy, each decision tree in the forest is "grown" differently. This means that the model randomly selects a different subset of features to consider at each split point in the tree... ...and it also uses a different subset of the training data to build each tree. This helps to reduce overfitting, which is when a model performs well on the training data but poorly on new, unseen data. the model in my bot takes into account a variety of factors and represents each of them in a way that the model can use it to make predictions the model considers a number of #technical indicators: moving average (MA) of the close price over the past 5, 10, and 20 periods standard deviation (STD) of the close price over the past 5, 10, and 20 periods relative strength index (RSI), which is a momentum indicator that measures the strength of a trend moving average convergence divergence (MACD), which is a trend-following momentum indicator that shows the relationship between two moving averages of prices stochastic oscillator, which is a momentum indicator that shows the location of the close price relative to the high and low price over a given period the model also considers a #liquidity indicator, calculated as the ratio of the volume to the average volume over the past 10 periods additionally, it takes into account an order flow indicator, which is the difference between the close price and the moving average of the close price over the past 10 periods moreover, the model also considers news data or more specifically the top headlines and descriptions from various #cryptocurrency news sources finally, the model includes a social media indicator, represented as the number of retweets, likes, and replies for the latest 1000 tweets about #Bitcoin so, based on the model prediction if the price will go up or down, the bot makes trades every time the $BTC / $USDT price data is updated, which in the current version of the code is every minute (will increase interval size tho) to size trades, the bot uses the Kelly criterion, which is a position sizing method that calculates the optimal trade size based on the probability of a trade being successful and the expected return of the trade the formula for calculating the Kelly trade size is as follows: trade_size = (odds_of_success - odds_of_failure) / (expected_return - 1) so that's more or less it. But yeah, pretty damn wild imo that with the assistance of #ChatGPT I was able to build something like this within hours and with rather basic #programming skills #technology is amazing 馃鈥嶁檪锔忊湪 will start it soon and update here on the performance lol its mainly for experimental & educational purposes, but let's see anyone out there experienced with building #ML trading bots?
Open on X

What came next 路 since 28 Dec 2022

Show how the covered asset moved

This build log documents a build without making a call on the token, so price moves since publication are shown as market context.

Mentioned for context
$BTCBitcoinsince publication+388%
Since then

No follow-up pieces on this subject yet. This is the latest take.

Daily closes in USD from DefiLlama and Yahoo Finance. Only a bullish or bearish call in a thesis or market take is tracked; explainers, lists, maps and mentions are neutral context. Not financial advice.

zerokn0wledge avatar
Working together

Research, advisory and builds for deep-tech teams.