Glitch8
 ( 11.64% )
- ago
Hey everyone, we'd like to develop a new Strategy Type in WL8 that would let you enter an English language prompt which would be passed to a specially trained LLM to produce correct WL8 C# code for the Strategy. Of course, you could then open that as a C# Coded Strategy just like you can for a Building Block Strategy.

As we research this, do any AI experts here have any leads on what kind of platform or service we could employ to train our model on WL8 Strategy code to make this a reality?
5
853
38 Replies

Reply

Bookmark

Sort
- ago
#1
OpenAI (https://openai.com/) offers an adaption of their ChatGPT model and allow to train it with custom data.

They call it "fine tuning" (see https://platform.openai.com/docs/guides/fine-tuning)

They warn:
QUOTE:
Fine-tuning OpenAI text generation models can make them better for specific applications, but it requires a careful investment of time and effort.


Also, OpenAI charges for each request, see https://openai.com/api/pricing/


0
- ago
#2
And before you think "I run an LLM an my own PC/Server":

I've heard that (just) the training process of ChatGPT costs $1.5 million. (server rent and electrical energy).

So think twice....
0
Glitch8
 ( 11.64% )
- ago
#3
Hmmm, I don't like the pricing model here :D
0
Glitch8
 ( 11.64% )
- ago
#4
Also we should investigate any models that are specialized for generating source code.
0
- ago
#5
There is also a "public domain" LLM service called "Hugging face" (https://huggingface.co/) but the models available here are not at all comparable to ChatGPT from OpenAI. (I got no meaningful answers from these models).
0
- ago
#6
QUOTE:
models that are specialized for generating source code.


The idea of yours works in two steps:
1. understand what a user tries to describe in plain english.
2. generate a specialized form of output (here: WL8 strategy code)

The first step is the hard one and you need something as powerful as ChatGPT to do it.

The code generation is relatively easy once you got step 1 straight.

0
Glitch8
 ( 11.64% )
- ago
#7
For reference:

https://www.scribbledata.io/blog/the-top-llms-for-code-generation-2024-edition/
0
- ago
#8
I don't think I could put any of my strategies into words (too many details), so how could AI generate the code for such a strategy in the first place?

But an AI code generation tool has some kind of place. I'm just not sure what that tool should look like.

And the user would have to know C# and the WL framework pretty well to determine if the generated code is what he intended. So we are talking about building a programming tool to assist programmers.
0
- ago
#9
Hi, I am an AI trainer and developer and work a lot with GPT.
You could simply use the standard OpenAI model as a “cheap” solution. You don't need your own training data or high costs. Simply enter an instruction in the prompt that GPT should fill in fields for a JSON structure. You then read the response for the respective JSON field from GPT and then fill in the fields with the value from GPT in a fixed JSON structure. Of course you need to validate the response of GPT and maybe ask to retry it, as GPT is not deterministic because of its random value generator (which maybe you can disable). By the way: GPT understands automatically a lot of language, customers could even type the instruction in german language.
0
- ago
#10
QUOTE:
I'm just not sure what that tool should look like.

I have an idea. Let me explain starting with an analogy:

In your car there is a Navigation System. In its original version you have to enter
a city and a street address to express your wishes.

Then a route is calculated and a nice voice explains what to do next.

This is a fixed input mask (city, street) and the rest (very complicated and very advanced technology) is hard wired.

Since a few years it is possible to talk to your navigation system: Bring me to <city>, <street>.

If all works well (and your pronunciation was good enough) this will work the same as above.

Here the natural language input is just a frontend that sits before the fixed input mask.

With things like ChatGPT it is thinkable that a voice input like:
"I want to see the latest James Bond Movie"
will bring you to the local cinema which shows the newest action film with Mr. (or Mrs.?) Bond.

ChatGPT is rather good in inferring an address information form your (rather nebulous) wishes.

BUT: Nobody would use ChatGPT to do the whole thing: Spoken language input to spoken commands where to turn next.

The Large Language Model (ChatGPT) will be used as a frontend for the fixed input mask.

-----

Similar story with a trading strategy:
What we already have is a high level description of single steps (It is called Building Blocks) and some elaborate code generation behind these building blocks (rather advanced technology).

As the next abstraction level I imagine a questionnaire: Let me illustrate with an example:

First Question: What kind of entry do you want (check one):
* Market On Open
* Limit Order
* Stop Order

Second Question: What are additional conditions for your entry?
* None (only possible with stop or limit orders)
* Indicator Based
* Calendar based
* etc

Third Question: What kind of Exit? (check all that apply):
* Time based exit
* Profit Target
* Stop Loss
* Condition
* etc

...

As you might imagine it is rather easy to produce a building block strategy from the results of this questionnaire. The trick here is to condense an unlimited landscape (all possible entries/conditions/exits) in a fixed set of elements that are presented by the computer.

The intermediate building block strategy will allow a user (who is presumably not an advanced coder) to do slight modifications, optimizations, and so forth.

An elaborate version of the questionnaire could ask for
* portfolio (probably an (automatically) optimized portfolio)
* Position Sizing / Risk management
* automatic search for rules and conditions using Strategy Evolver and/or Indicator Selection
* and much more

With such a questionnaire (as a separate tool) in place it is thinkable to create a LLM that is able to extract the answers (for the questionnaire) from some natural text input.
1
- ago
#11
Here is an example how it could work without any kind of training data or high costs:
Inject into the prompt before the customer input the context, and after the customer content the desired output:
0
- ago
#12
QUOTE:
Also we should investigate any models that are specialized for generating source code.


I tried some open source models, and in my mind, nothing can replace ChatGPT 4.
And ChatGPT 5 has training costs of over 1 billion of USD. So I think we should use the best model. And its language independent. There is no reason why it should be only english.
The costs can be moved to the customer. He simply has to provide the OpenAI API key, as he does it with data providers.
2
- ago
#13
QUOTE:
I'm just not sure what that tool should look like.


The scenario I imagine is that what we input is not a vague and confused statement, but a logically expressed explanation of trading rules. The text may look structurally similar to code, but it is not code, and at this point, the tool can help me complete the final step.

And when I want to create an indicator that does not exist in the system, I can input text descriptions, even strategy code written in other languages, and the tool can recognize its logic and convert it into code that Wealth Lab uses.
0
ww58
- ago
#14
The best resource on this topic is https://lmarena.ai/?leaderboard There you can also compare side by side.

As far as my interaction experience goes, Claude is better at generating WL strategy code. The problem with Chatgpt and many others is that it mixes the documentation of version 8 of the program and previous versions. So at the moment no neural network is production ready for WL strategies, fine tuning is needed.
0
vk8
 ( 32.74% )
- ago
#15
I am not really qualified to give real advice. I was just told that Llama 3 is a closed AI that only uses the information that is provided to it and not using any other "outside" information.
0
- ago
#16
Let me describe my use case, which I think is a "doable" implementation.

Currently, I build a strategy from code. It is somewhat simple, but it has a problem. There are many positions purchased that sell after 3 days at a loss when I want to hold a position for 10 to 15 days at a profit.

Currently, to fix rogue position purchases, I look at each one and add constraints so these rogue positions aren't bought in the first place. And this adds complexity to the strategy that takes me 3-4 weeks to refine.

It would be useful if I could tell ChatGPT to take an existing, simple, working strategy and add code to avoid these rogue position purchases altogether. And this is doable because it is a well defined achievable request.

As to whether ChatGPT can beat my statistical library code to remove rogue positions remains to be seen. But what ChatGPT can do is bring in additional external orthogonal metrics to bear down on the problem. And that's where things get interesting. The WL finantic.NLP extension is kind of halfway there. How many people are successfully using it?
0
- ago
#17
One last thing:
It should not generate code, it should create the graphical strategy building blocks. That would be user-friendly.
The user could still create C# code from it.

We can already create today directly C# code from ChatGPT 4. The public training data of ChatGPT 4 knows very well WealthLab and all its features.
1
Glitch8
 ( 11.64% )
- ago
#18
Mmmm I just tried GPT 4 and, as I was afraid of, the code it produced was not workable, it seems to have infusions of WL6 still mixed in.

Like I specified originally, I think the only way this effort could succeed would be for us to augment an existing model with heavy training of WL8 Strategies.

And I'm not convinced having an AI produce a Building Block Strategy is the best way to go or even feasible right now.
4
- ago
#19
IMHO. Claude (Anthropic) is by far the best for coding.

0
- ago
#20
@glitch you can train C-GPT with WL8 - then you could get it to do what you want.

We spent time setting it up to take easyLanguage and writing C## code from it.

the work was close to 95% accurate before we ran out of runway.

So yes it is possible.
0
Glitch8
 ( 11.64% )
- ago
#21
Emartin I’d be interested in hearing more details if you want to share, if so email me at dion@wealth-lab.com.
0
- ago
#22
QUOTE:
I'm not convinced having an AI produce a Building Block Strategy is the best way to go


Please consider this:
The target audience for
"Build a systematic trading strategy from natural language input"
is certainly not the advanced C# programmer, probably more a less experienced coder or a non-coder. I'd say it is for persons who have even problems to build a complex building block strategy.

Then: All an AI can do will have a certain "fuzziness", it is rarely 100% perfect if comes to compile-able, and even less if it comes to working code. The result will require some tweaking in any case.

And users will feel the urge to use the optimizer on the resulting strategy or add something or modify something.

All these requirements are easier to meet if that intermediate result (the output) of the AI is a building block strategy (probably with some new, specialized building blocks).

As a summary of what was said above I see even another intermediate output:
An XML File (or JSON file) that contains the relevant content/information for a strategy in very condensed form (a recipe for a strategy).
Such an file is way easier to create with an AI (see above).
Then the software can produce a building block or C# coded strategy form such an "recipe". This makes sure that the resulting strategy works as intended.
0
Glitch8
 ( 11.64% )
- ago
#23
I feel I want to leverage the already considerable work done in AI code generation. But your idea sounds like a very interesting new finantic extension!
0
- ago
#24
Hi aionda,
Falls das hier nach einem interessanten Projekt für dich klingt, schick mir eine mail: rene dot koch at finantic dot de
Ein Gruß ins Schwobaländle ;)
0
- ago
#25
QUOTE:
The target audience for "Build a systematic trading strategy from natural language input" is certainly not the advanced C# programmer, probably more a less experienced coder or a non-coder.

That's an interesting thought. The problem is many non-coders have trouble expressing themselves in the forum let alone to an AI system. It's really hard to describe a trading system in English. I'm not even sure I could describe one of my own trading systems in English let alone arrive at a profitable result.

For the novice, the best solution is to provide canned examples (either blocks or code) that are profitable. Most of the provided examples (both WL6 and WL8) are not profitable. Now if AI could turn some of those non-profitable examples into profitable ones, then we would really have something. Even I would be interested!
0
- ago
#26
Probably we can come up with a dialog:
User describes what she wants.

AI extracts as much info as possible and fills a "Standard Form"

Software checks results and identifies missing parts.

Software formulates s question, asks for missing information.

Restart at step 1

Iterate until enough information is collected , then create a strategy from the "Standard Form".
0
- ago
#27
QUOTE:
AI extracts as much info as possible and fills a "Standard Form"
Software checks results and identifies missing parts.
Software formulates s question, asks for missing information.

That might work. But will the result be profitable?

I think it would be easier (for now) to generate an AI solution that would take unprofitable sample strategies and make them profitable like magic. After achieving that, then you can tackle harder problems like getting the novice to create his own profitable strategy from a standard form.

---
This reminds me of the first year (2002?) I did my income taxes with an "interview" by the tax preparation software. I didn't feel in control at all (which I didn't like). But I did get my taxes submitted successfully ... eventually. Today I have a professional do it. :)
0
- ago
#28
QUOTE:
will the result be profitable?


I'll provide good "default answers" and suggested answers for all the questions. So if a user simply uses all the provided defaults she will arrive at a very nice (and profitable) system.

There is also the idea to have some analysis results available at each step, so you can judge for yourself how an answer (one of the provided choices) influences the outcome (profitability) of the final trading strategy.

(Such an analysis will run based on the answers given so far)

QUOTE:
I did my income taxes with an "interview" by the tax preparation software. I didn't feel in control at all (which I didn't like).


I understand completely. A remedy could be that the whole process should be as transparent as possible. At any stage you should
* know where you are
* see what the results look like so far
* be able to navigate forth and back and probably correct some earlier answers.
* be able to see the whole picture.
* get enough help to decide the next answer wisely
* see suggestions with (very) good default answers (see above)

QUOTE:
take unprofitable sample strategies and make them profitable like magic.


This is something the finantic.IndicatorSelection extension can do.

I am thinking about incorporating this tool (and other tools) into the questionnaire process. The idea is to run some analysis at each step, the outcome of which suggests some good answers for the current question.

Example: If (in the "Exit" part of the questionnaire) you opted for a
A: "time based exit / timeout"
then the next question would be:
Q: "How many bars do you want to hold a position".
Then there would be a button that generates an analysis plot:
"Profitability versus Hold Time".
You would inspect that graphic and decide if one hold time is better than another.
1
- ago
#29
Well, @Cone, I can't offer any technical insight, but I can offer my perspective from extensive experience in managing the process of creating new products. First, I want to note that from the volume of responses to your initial question infers that there is tremendous interest in some implementation of WL + AI from WL power users. So, there's a potential market for a new product.

Following the Lean Startup methodology, the question becomes what is a Minimally Viable Product (MVP)? The Lean Startup MVP approach would advise to start with *something* that does *something* useful (an MVP) using WL + AI. Avoid a moonshot approach because the true market "need" is still unknown as well as technical feasibility being also unknown.

In other words, initially target something small, doable, and useful (an MVP). See how users respond to release 1 and go from there.
2
- ago
#30
Glitch

I like this request and Chat GPT 4.0 does a pretty good job of understanding the request and creating the code. I just asked it for the code to create support and resistance lines in Wealth-lab version 8 and this is the code it produced. I do not know C# very well so I cannot tell how well it did but this is my prompt and response for you to review:

Yes I know this BUT can I give you a real world request like - Please provide the C# code for welath-lab version 8 that draws support and resistance lines on the selected stock in the graph?
ChatGPT said:
ChatGPT
Absolutely, I can create a script for Wealth-Lab 8 in C# that draws support and resistance lines on a selected stock in the chart. Here's a basic example:

C# Code for Wealth-Lab Version 8: Drawing Support and Resistance Lines
csharp
Copy code
CODE:
using WealthLab.Backtest; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; public class SupportResistanceLines : UserStrategyBase { public SupportResistanceLines() { // Define the parameters of the strategy } public override void Initialize(BarHistory bars) { // Add any required indicators here PlotIndicator(new SMA(bars.Close, 50), "SMA(50)", Color.Gray); // Optional example } public override void Execute(BarHistory bars, int idx) { // Find the recent highest high (resistance) and lowest low (support) int lookbackPeriod = 20; // Customize as needed double resistance = bars.High.Maximum(idx - lookbackPeriod, idx); double support = bars.Low.Minimum(idx - lookbackPeriod, idx); // Draw the support and resistance lines DrawLine("ResistanceLine", idx - lookbackPeriod, resistance, idx, resistance, Color.Red, LineStyle.Solid, 2); DrawLine("SupportLine", idx - lookbackPeriod, support, idx, support, Color.Green, LineStyle.Solid, 2); } }
Explanation:
Initialize:

Here, you can add indicators for visual or calculation purposes. For instance, a simple moving average (SMA) is plotted as an example.
Execute:

Calculates the support and resistance lines using the highest high and lowest low over a specified lookback period.
Uses DrawLine to draw these levels on the chart.
Customization:

You can adjust the lookbackPeriod variable to control how far back the strategy looks for support and resistance.
Modify the colors and styles of the lines as needed.
Steps to Use:
Copy the code into Wealth-Lab's C# scripting environment.
Compile and run the script.
Apply it to a stock chart to see the support and resistance lines.
Let me know if you'd like to refine this further!

Thoughts?
0
- ago
#31
I think you need to consider your target audience for this feature. I am comfortable working with the building blocks and my approach to date has been 'try to do it in BB's and if that doesnt work, get as cloase as possible. THen export to c# and try to modify as necessary'. I think i understand most of the BB's capabilities now so adding a feature to create a BB strategy would be of little value. I need assistance with implementing ideas that cannot be implemented using BB's and would prefer the tool to generate c# code. Relying on BB's, even if you implement some new ones to support the chat feature, will still be restrictive in my opinion.

In addition, my experience with using chatgpt for python is that i have more success if I import the code to chatgpt, then ask it to make the necessary modifications instead of asking it to do something from scratch. So i think the ability to import your c# code and then ask for mods would be very helpful.
3
- ago
#32
Tl;dr I don't need something to help me program, I need something to test a bunch of different alternatives quickly.

I'll come at this from a different perspective. After using WL for 2+ years I've found the BB system to be incredibly useful - so much so that whenever I want to code something today I start with a simple BB strategy and then copy/customize the code from there for my strategies.

My learning curve with WL has been determining what indicators and entry/exit options to use. The trial and error of working on a strategy, failing, more learning, minor success, etc. was the biggest hurdle I had to overcome. The options within WL are so vast that it can be intimidating trying to figure out where to start.

Having a tutor, or guide, or tool to help move me along that learning curve would have the most value to me, then and today. I spend a lot of time reworking existing strategies with new ideas but it takes a long time to code/back test, etc. If there was a system that could take my initial idea and then quickly test numerous alternatives it would be a huge win.

The Genetic Evolver is a nice first step along that path, but having an AI tool that can start with my strategy ideas rather than generate random indicators/parameters would be a killer app IMO.

0
- ago
#33
QUOTE:
I need something to test a bunch of different alternatives quickly.... My learning curve with WL has been determining what indicators and entry/exit options to use.

You might want to try the https://www.wealth-lab.com/extension/detail/finantic.IndicatorSelection extension to help find the most effective indicator for your strategy.

But the bottom line is to avoid indicators that watch price action alone. I would concentrate on indicators that take BarHistory (bars) input instead so they are modeling both price and volume action together.

Also, adding some external metrics (S&P500, VIX, earnings, etc) helps.
1
- ago
#34
How about developing an AI screener that can provide a list of etfs, sectors, stocks, etc. to trade with the highest probability of success.

Identifying the correct stocks to trade is critical.

Basic stuff like when earnings hit or when a sector is about to go good or bad. Often a company reports and the other stocks in the sector are hit, but maybe they should not be.

AI is great for looking at transcripts. Maybe it looks at transcripts from similar companies and indicates if it is a broken company or a broken sector.

Like XLV is in continuous decline with RFK and the UNH ECO incident. It would be great to have a screener scouring for this info and providing alerts along with identifying associated companies that may be impacted.
0
- ago
#35
QUOTE:
You might want to try the https://www.wealth-lab.com/extension/detail/finantic.IndicatorSelection extension to help find the most effective indicator for your strategy.

But the bottom line is to avoid indicators that watch price action alone. I would concentrate on indicators that take BarHistory (bars) input instead so they are modeling both price and volume action together.

Also, adding some external metrics (S&P500, VIX, earnings, etc) helps.


Thanks, Superticker, I'm always looking for new ideas.

My comment was more general, though - there are tools available, eg the Indicator Selection and genetic evolver. Using AI to help determine the indicators within a strategy would be yet another, and potentially more powerful, tool in the arsenal.

0
- ago
#36
WL-Copilot

I fully agree with innertrader in Post #29: Start with a MVP/something easy.

Why don't you start with an AI that helps configuring and using WL ? A WL-Copilot!
For a beginner WL can be challening...the number of post here in several dissions is really big and overwhelming.

Especially, if the user wants to do something "special". Imaging you could ask in natural language:
A very speciall example:
"I want to build a system, which trades the dax 30 components intraday at Xetra. I use InteractiveBrokers for trading and for intrady data. What do I need to setup?"

To solve such problems, you don't need to "train" an AI. But you need an AI comparable to googles notebookLM, that uses only dedicated inputs like the actual WL8 discussions, handbooks, blog, etc - information you provide. This will reduce haluzination or answers based on old WL6/7 information.

Step two of the MVP could be: Navigation you to the setup pages in WL and propose values.
0
Glitch8
 ( 11.64% )
- ago
#37
That sounds really promising! We're going to evaluate notebookLM. Any other possible candidates that you can think of that would be worth exploring?
0
Glitch8
 ( 11.64% )
- ago
#38
Since we’re already Azure based I’m thinking Azure AI with the Bring your own Data could work for powering a co-pilot, analyzing it now.
0

Reply

Bookmark

Sort