Part 2: Ultimate Trading Bot - GPT-4o, Lost Code, and Questionable Life Choices

Part 2: Ultimate Trading Bot - GPT-4o, Lost Code, and Questionable Life Choices

24th October 2024

Creating a trading bot that could revolutionise my crypto trading strategy? Sounded simple enough in theory. Turns out, it was a bit like wrestling with an octopus: you fix one tentacle and another smacks you in the face.


This second episode covers the technical shitty-gritty of building the bot, from classes to risk modes, as well as the killer setbacks - like GPT colossally fucking up. If you’re wondering if this drove me to drink... yeah of course it did!


The Technical Plan

In theory, the plan was great - set up some clever classes to handle trade execution, load in some AI models for predictive magic, and slot in a few risk management strategies. A tidy bit of AI generated code that could churn out trades like a well-oiled machine and save me hours of manual coding. Or so I thought. Enter GPT-4o, whose ‘performance improvements’ seemed more interested in making my life difficult than actually improving anything.

Main Classes

  • TradeManager: The head honcho. This class is supposed to manage and execute trades based on market conditions and risk settings. But thanks to GPT-4o’s random bouts of ‘optimisation,’ half of the logic regularly disappeared, leaving behind a trail of syntax errors. Instead of executing trades, it left me executing a long line of bug fixes while questioning my life choices.
  • TradeMonitor: This was going to be the golden child. A real-time monitor for trades that could dynamically adjust stop-losses. After GPT-4o decided to add a little 'performance boost', the entire monitor class vanished like a magician’s rabbit, leaving me on several occasions with a dog and pony show. What was once a reliable watchdog over trades suddenly became a memory, leaving hours of reconstruction work. Worth noting that I did keep local backups but these would sometimes be so error ridden it was best to start again anyway :)
  • AIModelManager: The AI brains of the operation, housing models like CNNs and Reinforcement Learning to give my bot a predictive edge. Or at least that was the plan. GPT-4o frequently suggested ‘optimisations’ that deleted random sections of my code, meaning I had to keep re-uploading files just to patch together a Frankenstein of what it once was.


The Mysterious Diff-appearances

One of the most mind-boggling issues I faced during this project was GPT-4o’s tendency to suggest enhancements and then unceremoniously delete random files or chop out crucial sections of code. I had spent hours perfecting the real-time TradeMonitor when GPT-4o, in its infinite wisdom, suggested some optimisations. Before I knew it, the file was half its original size, and the logic that made it work had been neatly snipped away. To add to that the whole interface would become sluggish with each use; eventually becoming unusable through "Error Generating" errors or long drawn out freezing of the application in my browser.


Libraries That GPT-4o Kept Forgetting

  • pybitget: The library I used to interact with the BitGet API. GPT-4o loved to suggest changes that conveniently forgot to re-import this library, leaving bottybot in the dust and me crying and rocking in the corner.
  • tensorflow: Running my AI models, this was essential for the bot to make sense of the market. Of course, when GPT-4o suggested tweaks, it often forgot to include vital pieces of TensorFlow code, as if it was trying to teach the art of missing dependencies.
  • asyncio: The crucial piece that handled all the real-time action. Without it, el bot would grind to a halt. Naturally, GPT-4o decided that some parts of this were ‘unnecessary,’ leaving me with a bot that ran as efficiently as a one-legged horse in a steeplechase.



Article content
My Favourite WTF Moment. GPT takes someone else's conversation from another part of its brain entirely and dumps it as the reason for my 'Too many requests' error!

AI Models That Survived (Somehow)

Miraculously, some of my AI models made it through GPT-4o’s optimisations. The CNNs did their job recognising patterns, and Reinforcement Learning kept the bot learning (though, given the errors, it might’ve been learning how to break down faster). Still, every time GPT-4o suggested a ‘performance tweak’, I held my breath, waiting to see which part of the AI setup would vanish into the void.


Article content
A Pro Blagger, keeping me fobbed off like a junior developer with a 'gift for the gab'

The Risk Modes: From Mild Panic to Full-Blown Chaos

The bot’s risk modes were designed to scale from Conservative to God Mode. What I didn’t anticipate was how GPT-4o would take these modes and, well, make them far riskier than intended.

Conservative Mode

The 'safe' option, where the bot makes low-risk trades with small leverage. At least, that’s what it should have been. After a few GPT-4o 'improvements', it felt like the bot had forgotten the meaning of ‘safe’ altogether.

 if risk_mode == DEF_CON3:
 leverage = 1.5 # Small, low-risk leverage. 
trade_size = balance * 0.01 
 if AIModelManager.predict_signal(pair) == SIG_STRONG_BUY':  TradeManager.execute_trade(pair, trade_size, leverage)        

Aggressive Mode

For those who like to live a little dangerously. Bigger trades, higher leverage. After one too many GPT-4o 'performance enhancements', this mode became too aggressive, to the point where my bot was making trades so reckless, I thought it had developed a gambling problem.

if risk_mode == DEF_CON2: 
 leverage = 10 
# High leverage, high risk, high blood pressure. 
trade_size = balance * 0.05 
 if AIModelManager.predict_signal(pair) in [SIG_BUY, SIG_STRONG_BUY]:
TradeManager.execute_trade(pair, trade_size, leverage)        

God Mode

The ultimate in chaos. Maximum leverage, massive trades, and a bot that’s more ‘Hail Mary’ than strategy. After GPT-4o’s random improvements, God Mode was less about calculated risk and more about throwing everything at the market and hoping for divine intervention.

if risk_mode == DEF_CON1: 
 leverage = 20 # Full throttle into financial madness. 
trade_size = balance * 0.1 
stop_loss, profit_target = RiskModeController.get_dynamic_limits(pair)
 if AIModelManager.predict_signal(pair) == SIG_BUY: 
TradeManager.execute_trade(pair, trade_size, leverage, stop_loss, profit_target)        

GPT-4o’s Design Skills: Worse Than a Toddler with Crayons and Biscuits

If you think GPT-4o was bad at managing code, you should see what it does with design. Whenever I asked it to generate some HTML or CSS, it spat out layouts that looked like they were inspired by a child’s first drawing. And I’m talking about a toddler with a crayon in one hand and a biscuit in the other.

Ask GPT-4o for a sleek, modern UI, and you’ll get something that looks like it was cobbled together by a time traveler from the early days of the internet-clunky buttons, misaligned elements, and fonts that make your eyes bleed. Honestly, I’ve seen more cohesive design work from the back of cereal boxes.

  • HTML/JS? Don’t even get me started. Asking GPT-4o to code a functional web page is like giving a toddler a hammer and asking them to build you a house. You’ll get something... but it’s probably not going to stand up for long. The output is usually a tangled mess of code that I’d be embarrassed to show anyone, let alone use in a production environment.

It might sound harsh, but trust me-GPT-4o’s design and web development skills make 90s GeoCities websites look cutting edge. If you want a functional and aesthetically pleasing UI, you’re better off getting in someone experienced. At least the end result would be creative, rather than a shit sandwich. I'll pickup on the dashboard down the line.


Conclusion (pre-burnout)

Working with GPT-4o Canvas is like trying to build a house while someone keeps stealing your tools. Every 'performance improvement' felt like a gamble - would I get an actual improvement, or would half my files vanish, or would I get mental health advice about someone else's kid?

Who knows.

1. File Management Catastrophes

At random intervals, GPT-4o would decide that certain files were unnecessary. Sometimes it would delete a critical component like the Trade Monitor, other times it would remove sections of code that I thought were, you know, important.

2. Code Truncation and Missing Logic

GPT-4o’s habit of cutting off code halfway through or omitting crucial logic was almo



until next time....

x Biff



Swarnava Banerjee

Customer's success is your success

6mo

Love this! God mode, innovative 😃😃

To view or add a comment, sign in

More articles by James Rowley

Insights from the community

Others also viewed

Explore topics