Quantifying The Irrational: How To Create The Best LLM Prompt For Automated Trading Strategies
Lessons from Darmok
Important: There is no guarantee that our strategies will have the same performance in the future. We use backtests to compare historical strategy performance. Backtests are based on historical data, not real-time data so the results we share are hypothetical, not real. Forward tests are based on live data, however, they use a simulated account. Any success I have with live trading is untypical. Trading futures is extremely risky. You should only use risk capital to fund live futures accounts and if you do trade live, be prepared to lose your entire account. I recommend using ATS strategies in simulated trading until you/we find the holy grail of trade strategy.
We haven’t found the holy grail of automated trade strategy yet, but we get closer with every strategy. Subscribers, scroll to the bottom for a link to the Q4 Forward Test performance results as of November 8, 2024. Click here for links to all strategy descriptions.
If you have any suggestions or questions, I’d love to hear them.
Contact: Celan at AutomatedTradingStrategies@protonmail.com
Let’s get to it.
It’s all about the prompt..
My fellow traders, it's time we had an honest discussion about our relationships with these curious creatures we call Large Language Models (LLMs). Gone are the days of curt, keyword-driven prompts—if we want to truly unlock their potential, we must learn to communicate with them in the most efficient way.
They are not oracles; they are experts at finding context and prediction, two skills that can greatly assist us on the hunt, but we need to figure out the best way to communicate with them.
If you follow my work, you know that I was raised on Star Trek TNG. One of my favorite episodes is "Darmok". Ranked as one of the best episodes in the series, the Enterprise encounters a race known as the Children of Tamar, which is making first contact. The crew's universal translator fails and Captain Picard must learn to communicate with the Tamarians who speak a language based on metaphors. Both the captain and his crew desperately study the Tamarian language. They find it to be unusually focused on mythical narrative, notably the epic of Darmok, which holds the key to its metaphorical 'code', and therefore to its context and meaning.
I've had my fair share of interactions with various LLMs. Much like Captain Picard's encounter with the Tamarians, effectively communicating with these systems requires an understanding of their unique communication style.
Boldly Trading Where No One Has Traded Before
LLMs have changed the game for traders, but they also come with their own set of frustrations. Sometimes a strategy will compile on the first try, other times it will never compile and you have to start over again. Which again begs the question: Is there a better way to communicate with them?
Yes, but it’s not what you think.
Search engines have trained us to be curt, using brief, keyword-focused queries to retrieve information efficiently. But LLMs require more detailed and expressive prompts to generate the kind of nuanced responses we need on the hunt.
I know some of you might think this is ridiculous. You’re thinking—
Is she really saying that LLMs perform better when you’re nice to them?
Yes, that’s exactly what I’m saying.
Recent research from VMware's NLP Lab suggests that the inclusion of "positive thinking" in LLM prompts improves reasoning capabilities. Whether you believe that statement or not, for those of us developing automated trading systems with LLMs, it has fascinating implications.
DSPy, mentioned in the paper, is a Stanford-developed tool designed to optimize prompts automatically for large language models (LLMs). This tool works by systematically adjusting prompt structures and messages to improve the performance of the LLMs on specific tasks. It’s particularly beneficial for complex prompt engineering as it is supposed to remove much of the trial and error typically required to hand-tune prompts for maximum effectiveness.
The research team used this tool to test 60 combinations of system message snippets across three models (7B to 70B parameters) on the GSM8K dataset.
What did they find?
They discovered something that would make even a Vulcan raise an eyebrow: the most effective prompts aren't just positive—they're eccentric.
The researchers found that combining:
Positive reinforcement: "You're a genius at pattern recognition" with
Creative frameworks: "You're navigating market anomalies in the Alpha Quadrant"
…created a synergistic effect.
The crown jewel of their research? This beauty:
Command, we need you to plot a course through this turbulence and locate the source of the anomaly. Use all available data and your expertise to guide us through this challenging situation.
This prompt didn't just marginally outperform, it crushed traditional approaches.
I know this is hard to believe. If you haven’t been paying attention, it’s a bit like discovering your sophisticated mean reversion algorithm could be outperformed by a Magic 8-Ball as long as you just ask it nicely enough and pretend it’s name is Commander Data. But think about what this could mean. While other traders are still typing "Analyze this chart pattern", you could be deploying prompts that make your LLM feel like it's the most decorated technical analyst in Starfleet. And according to the research, that's not just more fun—it's more profitable.
LLMs have given traders great edge on the hunt. That edge can be further enhanced, not just by using the biggest and baddest model, but by understanding and implementing these counter-intuitive prompt optimization techniques that most traders either don't know about or dismiss as irrational.
My Challenge To You
I challenge you to set aside your previous notions. Dust off your best quotes, weave in a touch of Picard-esque diplomacy, and witness the magic that unfolds.
LLMs thrive on contextual information. Before diving into a complex trading strategy or market analysis, take the time to ensure the LLM understands the relevant background details. This will help it to interpret your messages accurately and respond with greater relevance.
As much as possible, you’ll want to set the stage for your prompt. Provide a model, framework, template, analogy, book, play, character, song, poem, anything that can provide relevant context for what you’re trying to do.
I also like to customize the output as much as possible. This depends on your own personal style, but I like asking the LLM to:
be curious and thorough.
ask the most relevant questions to complete the task (great for those of us with analysis paralysis).
take on different market personas before developing a strategy like Warren Buffet and Jesse Livermore. A few days ago, I started developing a contrarian strategy based on a “high frequency trading algo” persona named Marvin. It helped to anticipate how HFT systems react to the market as a whole.
While crafting prompts as Star Trek episodes might seem absurd, the data is unambiguous: unconventional prompt optimization works. For automated trading systems, this opens new avenues for performance optimization.
Here’s an example of a prompt I recently created. Copy and paste it into the LLM of your choice and see what you get back compared to your regular prompt: