GPT-6 Astra Built 200 Python Strategies. Here’s the Winner (300%)

Kurze Zusammenfassung

In diesem Video testet der Autor GPT-6 Astra für die Entwicklung von Handelsstrategien. Er zeigt, wie man den Codex mit Jesse verbindet, um eine trendfolgende Handelsstrategie zu erstellen und diese mittels Backtesting sowie Monte-Carlo-Simulationen zu überprüfen. Nach 200 Versuchen wird eine aussichtsreiche Strategie gefunden, die eine Sharpe-Ratio von 1,87 und eine Rendite von 104 % aufweist.

  • GPT-6 Astra wird getestet und zeigt schnellere und genauere Ergebnisse.
  • Codex wird mit Jesse verbunden, um Handelsstrategien zu entwickeln.
  • Es wird eine trendfolgende Strategie für den Handel mit Apple-USD erstellt.
  • Nach 200 Versuchen wird eine vergleichbare Strategie mit geringen Drawdowns präsentiert.

Testing GPT-6 Astra

Open AI hat GPT-6 Astra veröffentlicht, das sich durch beeindruckende Leistung und höhere Geschwindigkeit im Vergleich zu anderen Modellen auszeichnet. Besonders betont der Autor die Nützlichkeit des Modells für das Schreiben von Handelsstrategien, Backtests und Monte-Carlo-Simulationen. Er hebt hervor, dass die Tools, die dem Modell zur Verfügung stehen, entscheidend für den Erfolg sind. Der Autor verdeutlicht, dass er als Nicht-Finanzberater agiert und das Video zu Bildungszwecken dient.

Connecting Codex to Jesse

Der Autor erklärt, wie man Jesse leicht einrichtet und mit Codex verbindet. Nach dem Starten von Jesse erhält man eine Adresse, die ins Codex eingegeben wird, damit die beiden Systeme kommunizieren können. Nach erfolgreicher Verbindung gibt der Autor Codex den Befehl, eine trendfolgende Handelsstrategie für Apple-USD zu entwickeln, die den angeforderten Kriterien entspricht.

The Trading Strategy Prompt

Der Autor gibt dem Modell spezifische Anweisungen, um eine Handelsstrategie zu entwickeln. Die Anforderungen umfassen unter anderem eine Sharpe-Ratio von mindestens 1,5, ein Risiko von 2 % pro Trade und die Anwendung von Monte-Carlo-Simulationen zur Ergebnisvalidierung. Die Strategie soll sowohl Long- als auch Short-Trades berücksichtigen und nach 200 Versuchen abgeschossen werden, sollte ein optimales Ergebnis nicht erzielt werden.

A Note on Data

Hier wird darauf hingewiesen, dass Nutzer ihre eigenen CSV-Daten in Jesse importieren können und verschiedene Datenanbieter unterstützt werden, darunter Massive und möglicherweise auch DataBento in der Zukunft. Der Autor schlägt vor, dass die Benutzer ihre eigenen Daten für eine genauere Analyse verwenden sollten.

Results After 200 Attempts

Nach 200 Versuchen gibt das Modell die beste Strategie als Version 107 an, mit einer Sharpe-Ratio von 1,87, einer Rendite von 104 % und einem Drawdown von 14 %. Die Kurve zeigt eine stetige Steigerung des Kapitals, mit minimalen Verlustperioden. Die Strategie scheint in verschiedenen Marktbedingungen gut zu funktionieren.

Position Sizing and Fees

Der Autor erklärt, wie die Positionsgröße und Handelsgebühren sich auf das Handelsergebnis auswirken. Es wird festgelegt, dass bei einer maximalen Drawdown von 14 % die Positionsgröße verdoppelt werden könnte, was die endgültige Rendite auf bis zu 200 % erhöhen würde. Bei der Berechnung wird ein hoher Gebührensatz festgestellt und angepasst, um realistischere Ergebnisse zu erzielen.

Reviewing Individual Trades

Einblick in die einzelnen Trades wird gegeben, wobei Gewinner- und Verlierertrades analysiert werden. Der Autor beschreibt eine erfolgreiche Strategie zur Verfolgung von Trends, indem sie Long- und Short-Positionen je nach Marktentwicklung offen analisiert.

Monte Carlo Overfitting Checks

Der Autor führt Monte-Carlo-Tests durch, um die Robustheit der Strategie zu prüfen und mögliche Überanpassungen zu identifizieren. Durch die Verwendung dieser Methode zeigt sich, dass die Sharpe-Ratio der Originalstrategie in einem sicheren Bereich liegt, was darauf hindeutet, dass die Strategie nicht überanpasst ist und in Zukunft potenziell profitabel sein könnte.

Research Report and Strategy Download

Der Autor hebt hervor, dass der Codex einen detaillierten Bericht über die durchgeführten Schritte und Ergebnisse erstellt hat. Dieser Bericht enthält die Erträge anderer Variation der Strategie, was nützlich sein kann, um ein umfassenderes Bild der Handelsstrategie zu erhalten und besser informierte Entscheidungen für zukünftige Handelsaktivitäten zu treffen.

Python Strategy Code Walkthrough

Der Autor gibt einen detaillierten Überblick über den geschriebenen Python-Code, der die Handelsstrategie umsetzt, und erklärt die verwendeten Logiken und Methoden. Es wird erläutert, wie die Eingabewerte verarbeitet werden und welche Bedingungen für das Öffnen oder Schließen von Positionen entscheidend sind. Der Code wird als funktional und gut strukturiert beschrieben, um die Übersichtlichkeit und Effizienz der Handelsstrategie zu gewährleisten.

Summarize any YouTube video in seconds

Get summaries like this one for any video, in your language, with the free Summ app.

Download on the Apple Store
Get it on Google Play

Transkript

YouTube Transcript Generator

0:00 Open AI just released GPT-6 Astro. And besides the really cool animation on their website, I actually use this thing for a few days now, and I found it to be really good. Like, it gets the job so much faster than the other models, and I found it to be more accurate. They're also claiming some crazy benchmarks such as this one on Arc AGI, which is basically it is nailing just everything. Now, they're not really comparing it to something like Fable 5.5, but still this number is just absolutely crazy. But, you know how it is on this channel. What I really care about is the ability of the model to write trading strategies, run backtests on them, optimization to find better parameters, and at the end I want to see some Monte Carlo simulations to ensure the results that it finds for us aren't overfit. Because no matter how

0:45 smart the model is, the tools that we give it are actually more important. Now, if you're new here, I'm going to be writing the strategies using Python. And in order to connect the agent into an algo trading environment, we're going to be using the Jesse framework, which makes this very easy. And yes, it is absolutely free to get started, and everything that I'm showing you on this video is freely accessible to everyone. Now, before I move on, I got to say I am not a financial advisor, and this video is for educational purposes only. So, let's get started. Now, the setup for Jesse is pretty easy. If you haven't already done that, just check out the documentation for how to get started. I've also made videos about it in the past, which you can check out. But, assuming you've already done that, inside your Jesse project, simply run the Jesse run command, and this is going to give us this address, which is the

1:31 MCP address. So, let's copy this. And then, if you want to see how to add that, just check out Jesse's documentation in the connect in Codex section. So, let's copy this address, open another terminal window in the same directory, and paste in this address from the documentation, change the port. There we go. So, now let's open the Codex app. Now, I'm going to be using the desktop version of it, but you can also use the CLI. All right, now let's ask it if it has access to Jesse and of course the model is set to GPT-6 Astra, and I'm also in the correct JC directory. And there we go, it says yes, JCMCP is connected and responding. So, now we are ready to give it the prompt. Hey there, research and find a trend following strategy for trading Apple-USD. Use whichever else indicators that you find suitable for this strategy. I need

2:17 the result to have a sharp ratio of at least 1.5 in the last 2 years. Risk 2% of the account on each trade. Use optimization to improve the results. At the end, apply Monte Carlo simulations to ensure the results are not overfit. Continue until you find strategies that fully meet the requested criteria. Use the hourly time frame for trading side and 4 hours as the anchor time frame. The strategy must take both long and short trades. Ensure the configuration is also in the futures mode and not a spot. Continue until you either reach the results that I asked for or trying at least 200 times before stopping. So, there we go. Now, I am going to include this prompt inside the strategy code, which I will be uploading on our website later. And another thing is that it would be helpful if you actually mention

3:03 the exchange which had that data on your machine. Now, if you've been following my work, you know that recently we added support for importing your own CSV data. We also added support for Massive as a data provider, which you can subscribe to your own account and bring your own API keys, of course. We might also add DataBento soon, but if you have access to it already, they're also really great. You can just download the data and import it. There are also other options, which I am actually using myself and I like them. And if you needed to import custom data, just come to the manage page of Jesse, then click import CSV, and you're good to go. Anyways, now everything seems to be going smoothly, so let's just go back and come back a bit later and see the results. Now, while that's going, I want to quickly remind you guys about our Telegram. It's the fastest way to get notified about my future work, whether

3:50 it's a new tutorial or a tool that I create. >> Also, don't forget to check out our free Discord where more than 5,000 members like you and I are hanging out there and helping out each other with algo trading so we can all succeed together. The links for both are down in the description. >> There we go. So, the final result is here and something I really like about CodeX is that we get a really nice summary of the final work and there's not even much to scroll because usually when I make it these videos, I have to scroll so much back just to show you guys what the model asked and what I told it later or things like that. But in this case, as you can see, there isn't much. Now, I'm missing one message. I don't know why, but basically what happened was that the model did a little bit of work and then it was like, "Hey, I couldn't find exactly what you were looking for." But then I specifically told it, "Hey, I needed you

4:37 to try 200 times before stopping." So, this is probably my fault. I have to maybe make the initial prompt bit more strict, but the final result is that it tried 200 different variations of the strategy and compared the results of them. And now it's telling me the best strategy was version 107. And here's the result. So, the sharp is 1.87 with a return of 104% with a drawdown of 14% and here's also the result of Monte Carlo. So, this already looks so good that I may not even need to open it in the browser, but I'm going to. So, let's open the backtest result. There we go. So, this already looks really good. Like this equity curve we can pretty much say it's going up steady except maybe in

5:23 this period, but in anywhere else it was just great. And that goes not just for this period which the market was going up already, but even here when it was going down, the equity curve was going up. So, you could say it's a safe strategy for most market regimes. Now, in this period also, the market was even slightly going up, but the strategy went down. So, this is something to remember. Next, we can see the five worst drawdown periods. It's not looking that bad except, again, this period. Next, we can see the monthly returns. Most months, it is positive, which is great, but in this year, we ended in a negative number. Although, it wasn't the full year, so that's just something to remember that even a strategy that looks good on its equity curve, it does not mean that it's going to make you money like every

6:09 single month or even a year. Now, moving on, the P&L was 104. The max drawdown was minus 14, which means we can pretty much double this position size. I mean, it's going to depend on your risk appetite. For me, up to minus 30% is fine. So, this number allows me to double this position size, and by doing that, the final P&L is also going to be like 200% instead of 100. In fact, I'm going to do that right now. So, let's go and change the source code of the strategy, and this is pretty much where we define the position sizing. So, I could just simply double this, go back, and rerun this. Now, it says we cannot submit an order with this size, which basically means that it's running out of capital. So, that means we need to increase the leverage size in the settings. Also,

6:56 this fee is really high. Like, this isn't okay. I'm going to set this to this because if we trade this on an exchange such as lighter, we can see that by default, we're going to be trading with zero fees. So, this number would be more than enough for my use case for the slippage simulation. So, going to set this to this, and then for the leverage, we're going to increase it to like six. Now, this doesn't mean that we're going to be using six X leverage. It's just the number or the maximum that we're going to be allowed. So, let's run it one more time. All right, so it failed again, but looking at the code, it's using the leverage directly in the calculation. Now, I never do it like this myself. So, instead, we're going to do something else. We're going to consider this to

7:41 stay whatever it was in the previous example. So, we're going to set this to two and hopefully this should work now. There we go. So, now it's making 300% actually. So, this is awesome. The max drawdown is minus 26. All right, so this might be because of this setting actually cuz it did not expect it to make more. So, if we change annualization to 252 because this one 24/7 markets such as crypto which might be the case for us actually because if I trade this on somewhere like lighter, this should probably be how we should calculate it. But when I set it to this and if I get better numbers, still it could be because that previous number

8:27 was using significantly higher trading fees. There we go. Actually, yeah, I was I was wrong because you see that number actually had nothing to do with the calculation for the P&L or the max drawdown. It only affected the sharp ratio which now is 1.65. So, here's the equity curve now. It's clearly beating the buy and hold with a pretty acceptable max drawdown for me and the sharp is 1.65 and the average holding time is 200 hours. So, this is going to be like multiple days. I don't really like this value here because it means sometimes you have to hold a position for multiple days. But that's probably the cost of trading the hourly time frame anyway. So, moving on, let's take a look at the trades that it took. So, let's choose losing trade. All right, so

9:12 it shorted here and had to close here because price went up. This one was a winning one. So, we went long here and closed it here. We can also sort to see the best ones first. This one for example was a really good short. Let me zoom out. All right, so this one was a great long. So, this is good actually. The strategy is able to hold a position while the the trend is continuing. So, this is a good thing. And lastly, let's take a look at this. All right. Now, of course, we could also plot some indicator values on the chart, so we can see those as well. But, I'm going to leave that to you if you'd like to. Just simply ask the agent to do it. Just simply say add charts, and it will do it for you. All right. So, the values

9:59 look good. But, now the question is are the values overfit? Because, yes, the backtest is looking good. And don't forget this is the result of 200 tryouts from the agent. So, this wasn't gained that easily. Now, to answer this question in Jesse, we like to use this tool called Monte Carlo candle. So, basically, there are two types of Monte Carlo in the Jesse framework. The first one is where we shuffle the trades, and it tells us about the position sizing and how much worse scenarios we have to consider. But, the type that I'm using here is called Monte Carlo candles, which is like a stress testing the strategy. So, we're changing the candles, let's say we're adding some noise to it, but not exactly actually. But, the point is we do that sort of thing to see, okay, so if the price data

10:45 was slightly different, would the strategy fall apart or not? And in this case, you can see the equity curve of the original backtest, which is this orange line, is right in the middle. In other words, if you read this table, the Sharpe ratio of the original backtest was 1.58, while the best 5%, which are like the lucky simulations or the lucky situations, was 2.45. But, in our case, it's 1.58. And what I want to see is this value being less than this. And in this case, it's definitely less. I also want it to be close to the median as much as possible, which in this case is 1.30. So, we can conclude that the Sharpe ratio is closer to this value, and we can say the chances of the strategy being overfit is low. Now, notice that we can never say there's 100% chance that this is or any other

11:33 strategy is not worth it at all, okay? Because there's never a guarantee of future returns for any strategy, and that includes this one as well. But overall, this looks good. All right, next we can see that the agent actually prepared the report file for us. So, all the steps that it took and the results with more details can be read inside this report file. So, in case you were wondering like what was the result for other variations that it wrote, you can also check them out here. So, this wasn't really just a blind answer that I got from an agent. So, if for example, this was an actual person that I sent to go and do research and come back with the results for me, we could have simply read this. And in fact, you remember what I just said about trading fees? I can see here that this is the fee value that the agent set. But both, for

12:18 example, on lighter exchange or on Hyperliquid, this is not going to be the fees that I will be paying. It's going to be significantly less than this. So, by changing this in the backtest that I ran myself, the results were improved a lot. So, this is a good thing because if it was the other way around, it was something to be concerned about because you don't want to be paying more trading fees when live trading this the strategy, right? You want to actually pay more in your simulations to basically bulletproof your strategy against something like slippage in real world. But in this case, it's the opposite. So, it was already paying more. So, that's a good sign as well. Now, I am going to submit this on our website where you can get the code of the strategy or check out its results on other symbols such as ETH or BTC or

13:05 other trading periods or time frames. But just one thing to remember is that on our website, we still don't have access to data other than ETH, BTC, or SOL. So, I will be probably submitting this with something like BTC, but in your case, you need to ensure to import your own data for Apple from any provider that you already have access to and use that. I will update our website soon because these days we can get pretty good data from Binance for example even for these assets or any other crypto exchange and that is completely free to access. Now let's read the code a little bit. So it's doing a lot of calculations inside the before method of Jesse. It's setting a lot of variables inside here such as the anchor direction entry long or entry short which are basically boolean conditions. Now I don't usually write

13:50 the code myself like this but this is perfectly acceptable and then here inside the actual functions that we use to check the entry rule of the strategy the shoot long and shoot short it's using those values from here and inside the entry size it's calculating the position sizing. It's also setting the surplus value or things like that and then inside the go long and go short methods it's simply submitting those values using the self.buy and self.sell functions of Jesse then that's it. So it's passing the quantity and the price. Now the price is the current price in this moment which means it's going to be a market order. And then once the position is actually open we're basically saying that if it's a long position submit the surplus like this. So this is going to be the quantity of and then the surplus price. That's it

14:37 and then in the update position method which is basically our way of saying that whenever a new candle closes and if we have an open position we're going to be getting the direction from here and we're saying that okay so if it's long position the direction is one otherwise it's minus one for a short position and then we're saying that if the current value of the direction is basically the opposite of our position size then we want to liquidate the current position. So nothing fancy and if that's not the case then we want to check another thing which is if the current ATR values is bigger than four times of the entry ATR then we also want to liquidate. So this is basically checking the current volatility. So it's a very interesting

15:23 filter that I've never seen before. So, it's basically saying that if the volatility is just too much right now, then we want to close. So, yeah, that's very weird. So, but it seems to be working just fine. So, before I leave you guys, don't forget to check out our roadmap page and vote on whichever feature that you would like me to add to the framework first. And please like the video and post a comment and let me know what you think and what sort of videos you would like me to make next. And if you haven't subscribed to the channel, please make sure to do so because I make tutorials just like this one all the time. Thank you so much for watching. I'll see you guys next time.

Share

Zusammenfassungen von YouTube-Videos