I would like to set up a system where Claude Opus can write a C# coded strategy, tell WL8 to execute a backtest, and then review the backtest results. Ideally, this would all happen from the command line, or at least a Visual Studio project, without having to interact with the WL8 GUI. Is anything like this possible?
I've been playing around the last couple days with having Claude actually interact with the WL8 GUI, and while it's possible it's very clunky and prone to breaking if it gets confused about where to click or anything like that. This is why I'm thinking a headless mode would be preferred (and far more cost-efficient).
The end goal here is to let Claude interact with WL8 in a loop, where it can try out an idea in a strategy, review the backtest results, and then further refine the strategy and keep iterating.
I've been playing around the last couple days with having Claude actually interact with the WL8 GUI, and while it's possible it's very clunky and prone to breaking if it gets confused about where to click or anything like that. This is why I'm thinking a headless mode would be preferred (and far more cost-efficient).
The end goal here is to let Claude interact with WL8 in a loop, where it can try out an idea in a strategy, review the backtest results, and then further refine the strategy and keep iterating.
Rename
It's been my experience that AI is not good enough "today" to generate functional code. So the experienced C# programmer still needs to be in the loop to make corrections and optimizations after AI delivers its solution. This is a must in "today's" AI world. And I think we all know that. So having a headless solution may not be the best solution for now if the C# programmer has to still be in the middle.
However, AI can deliver elements to the solution that one may not have otherwise considered. For example, I seen one AI solution for a WL indicator that included code to build "local" TimeSeries objects on the stack instead of the heap. That's a neat trick because the heap requires garbage collection (extra "background" CPU cycles); whereas, the stack doesn't. I wouldn't have thought of that. (I didn't even know the C# code could allocate block storage on the stack, so I learned something.)
I've also seen AI solutions that fail when it comes to numerical analysis or signal processing problems, so if your strategy requires this, I would stick to calling an external numerical analysis (e.g. Math.NET) or signal processing (e.g. NWaves) package yourself, and not strictly depend on AI coding. But AI could "attempt" (with the programmer's corrections) to write the glue logic for calling such packages.
I can't speak for AI's success with calling statistical packages. But I would be interested in your experience here, especially with "robust" statistical analysis (percentiles and quantiles).
However, AI can deliver elements to the solution that one may not have otherwise considered. For example, I seen one AI solution for a WL indicator that included code to build "local" TimeSeries objects on the stack instead of the heap. That's a neat trick because the heap requires garbage collection (extra "background" CPU cycles); whereas, the stack doesn't. I wouldn't have thought of that. (I didn't even know the C# code could allocate block storage on the stack, so I learned something.)
I've also seen AI solutions that fail when it comes to numerical analysis or signal processing problems, so if your strategy requires this, I would stick to calling an external numerical analysis (e.g. Math.NET) or signal processing (e.g. NWaves) package yourself, and not strictly depend on AI coding. But AI could "attempt" (with the programmer's corrections) to write the glue logic for calling such packages.
I can't speak for AI's success with calling statistical packages. But I would be interested in your experience here, especially with "robust" statistical analysis (percentiles and quantiles).
I upvoted this for a different reason. I'd like to be able to run my metastrategy to generate daily signals automatically. For example, I should be able to setup a scheduled task on windows, it starts WL, update checked historical data, and run my metastrategy to generate signals.
I know that different people have different opinion on this, but having this option is always good.
I know that different people have different opinion on this, but having this option is always good.
QUOTE:
I'd like to be able to run my metastrategy to generate daily signals automatically. For example, I should be able to setup a scheduled task on windows,...
So you're saying you want to run WL as a batch process from a script? Can't you already do that with a StrategyRunner process, or am I wrong? (I've never used StrategyRunner, so my concept of it could be wrong.)
QUOTE:
So you're saying you want to run WL as a batch process from a script?
Yes something like this.
QUOTE:
Can't you already do that with a StrategyRunner process
I don't know about this. If that's true I'd like to explore more about it.
I think to schedule a batch COM script, WealthLab.exe needs to accept stdin and stdout as command line arguments, which it's not doing now. But that's a different feature request. stdin would be the strategy filename(s); a list of them.
And the next question is what should the stdout include in the output? I suppose that could be controlled with a couple other /switch parameters. Alternatively, one could pipe stdout into an awk process to filter out (or reformat) the final output.
Come to think of it, WL is going to need the stdin and stdout arguments anyway for the headless implementation, so these needs are related.
And the next question is what should the stdout include in the output? I suppose that could be controlled with a couple other /switch parameters. Alternatively, one could pipe stdout into an awk process to filter out (or reformat) the final output.
Come to think of it, WL is going to need the stdin and stdout arguments anyway for the headless implementation, so these needs are related.
What superticker described with stdin and stdout would be sufficient for my needs. Is there any chance of support being added for something like that?
I started down this path with Claude Code a few months ago. I actually had the WL framework loaded and executing. The problem I encountered was proper initialization of WL with the users environment. I don't suppose anyone knows of a magical call to Initialize() somewhere which will fill in the WL framework with the user's settings? My use case is I need monthly optimization runs over 12 strategies, with Monte Carlo analysis of the NSFs generated. I am currently limited to 3 per month due to the overhead of manually running the Monte Carlo against each of the optimization results.
QUOTE:
The problem I encountered was proper initialization of WL with the user's environment.
You could put in a feature request to let UserStrategyBase take preference parameters so you can initialize it to what you want without the GUI controls.
Normally, with all the WL GUI (WPF) "preference controls," WL would initialize off of those. But if you don't have GUI controls in the first place (headless), then you're going to have to create a parameter object to pass into UserStrategyBase to do that initialization instead.
There's a ton of preference parameters in WL, so this parameter object you're passing into UserStrategyBase will be complicated. But you only need to pass in the parameter values that are different from the defaults.
I completed two of the four or five major new features coming in WL9:
- Strategy AI generator
- Local strategy positions tracker and max open positions handling
The next major features I’m undertaking is a headless WL9 for integration with Claude Code, other platforms.
- Strategy AI generator
- Local strategy positions tracker and max open positions handling
The next major features I’m undertaking is a headless WL9 for integration with Claude Code, other platforms.
OpenRouter could be a good way to gain access to a number of AI platforms.
QUOTE:
The next major features I’m undertaking is a headless WL9 for integration with Claude Code, other platforms.
This is huge!!
@glitch you are a rockstar. Sounds awesome.
My only concern is now the random person on the street will easily be able to compete with our strategies developed over many years of losses and pain - but I guess that's progress!:)
My only concern is now the random person on the street will easily be able to compete with our strategies developed over many years of losses and pain - but I guess that's progress!:)
In the last Patreon stream I challenged Claude to improve my Triple Threat strategy, and it wasn't able to. I think the humans still have an edge for the time being.
I am not so sure about that...
I actually believe this is where the most immediate development efforts should go, for Wealth-Lab or other backtesting frameworks: to facilitate, as soon as possible, a very easy integration with some AI engine.
Just as an example: back in January, without writing a single line of code, I managed to develop a fully working strategy in WL8, using Gemini.
These are the results (since January, it is all out of sample):



It is basically a momentum rotation strategy: I pointed Gemini to Wealth-Lab documentation and to a website with some very lose rules about a possible system.
I actually believe this is where the most immediate development efforts should go, for Wealth-Lab or other backtesting frameworks: to facilitate, as soon as possible, a very easy integration with some AI engine.
Just as an example: back in January, without writing a single line of code, I managed to develop a fully working strategy in WL8, using Gemini.
These are the results (since January, it is all out of sample):
It is basically a momentum rotation strategy: I pointed Gemini to Wealth-Lab documentation and to a website with some very lose rules about a possible system.
Unfortunately, C# (and even less the custom Wealthscript of Wealth-Lab) is not that ChatAI friendly as others (like Python or other scripting language); so it takes a lot of back and forth to get rid of the compilation errors. But, even with all copy paste (from Gemini to Wealth-Lab), I found it well worth it.
In the meantime, I have been using a competing backtesting application that recently introduced integration with Claude Code and I am blown away with the possibilities: I just type my trading idea (or just point it to a website from which I want to borrow it) and it just does it all: codes, backtests, improves, produces reports, etc.
That other competing tool is not so powerful as Wealth-Lab, but its simplicity allowed for a seamless integration (and you could argue that thanks to that, it's maybe more powefull than any other now) - now imagine when Wealth-Lab would be able to allow that integration...
In the meantime, I have been using a competing backtesting application that recently introduced integration with Claude Code and I am blown away with the possibilities: I just type my trading idea (or just point it to a website from which I want to borrow it) and it just does it all: codes, backtests, improves, produces reports, etc.
That other competing tool is not so powerful as Wealth-Lab, but its simplicity allowed for a seamless integration (and you could argue that thanks to that, it's maybe more powefull than any other now) - now imagine when Wealth-Lab would be able to allow that integration...
QUOTE:
I challenged Claude to improve my Triple Threat strategy, and it wasn't able to.
QUOTE:
I am not so sure about that...
I think the fundamental problem with AI solutions is that they are poor at statistical analysis. Remember, we are modeling stochastic processes here, so one needs to do statistical testing on every event. And yes, that means computing a "P" (probability) so you need to compute Z-scores, fit them into a distribution (probability density function), and compute the P for that event. AI solutions miss that step.
The next problem is that classical moment-based statistics fails to work in the presence of outliers because the higher moments (and that includes variance, the second moment) blow up. The best solution is probably to employ robust statistics instead, which isn't taught at the undergraduate level. Alternatively, one could remove the outliers (employ WealthData) before applying a classical statistical analysis.
At any rate, AI fails at the statistical analysis step (and some humans also miss this step).
That may be, but I don't see it as a tool to find the next holy-grail indicator or trading strategy.
I see this a way to enable very quick prototyping of an idea that you might gather from anywhere, improve it and report back for iterating.
A while ago, there was a lot of activity around the post "Laurens Bensdorp's Automated Stock Trading Systems". The main takeaway from that discussion (and the book itself) is that you don't need a great system to do well; you just need a collection (metastrategy in the lingo of WL) of a few decent un-correlated strategies.
And if Wealth-Lab would offer a way of integration with Claude Code (for example) that would allow it to ran a strategy, get results, combine with another, etc; then, it could save hundreds of hours and allow the exploration of other things that, no matter how skilled one is (I am not unfortunately), there is simply not time to try them.
I see this a way to enable very quick prototyping of an idea that you might gather from anywhere, improve it and report back for iterating.
A while ago, there was a lot of activity around the post "Laurens Bensdorp's Automated Stock Trading Systems". The main takeaway from that discussion (and the book itself) is that you don't need a great system to do well; you just need a collection (metastrategy in the lingo of WL) of a few decent un-correlated strategies.
And if Wealth-Lab would offer a way of integration with Claude Code (for example) that would allow it to ran a strategy, get results, combine with another, etc; then, it could save hundreds of hours and allow the exploration of other things that, no matter how skilled one is (I am not unfortunately), there is simply not time to try them.
QUOTE:
... the post "Laurens Bensdorp's Automated Stock Trading Systems". The ... takeaway from that ... is that you don't need a great system to do well;...
I totally agree there. I cherry pick my datasets, and I found how well a stock does in trading is more a function of the stock itself (for a given time block) than the strategy.
I have two production strategies; one is buy-high, and the other is buy-low. When a stock is doing well with one, it often trades well with the other as well. In conclusion, successful trading may depend more on stock screening than on the trading strategies themselves.
You want your stock screener to select stocks with immediate "potential", and that's what this trading business is really all about.
Your Response
Post
Edit Post
Login is required