Wealth-Lab Version 5 (.NET) 5.0
Does exist possibility to create completely independent threads from script in WL5?
I would like to create threads from Strategy which have independent position management.
I tried to use commands:
CODE:
Please log in to see this code.
But new threads can not use most of commands like ClearPositions, buyatlimit and other. They can execute only like Parent.ClearPositions and this will be same for all threads.
I know that WL5 can have completely independent threads because if you will create new mane workspace from menu it will be completely independent. Can I do same from strategy?
Thanks
Size:
Color:
I'd like to be wrong on this, but most likely no. The reason is that a Strategy - just like ChartScripts in WL4 - executes on every bar and then "dissolves" until another bar. You can create threads, and even Windows GUI forms in WL5 strategies on-the-fly, but they are going to disappear after the execution is finished - till next time.
Size:
Color:
what about strategy for backtesting? I guess they didn't disappear until finished.
Size:
Color:
Let's start the other way: what is this "independent position management"?
Size:
Color:
Hi Eugene,
I would like to make next algorithm for backtesting:
1. run Master thread. this thread will organize cycle by index in dataset.
CODE:
Please log in to see this code.
and for example will run 7-8 additional Slave Thread. to each thread it will pass index like parameter for analyzing.
2. Slave thread will receive index for analyze. First line in script for example this:
CODE:
Please log in to see this code.
but it doesn't work for thread. It is work only in this context:
CODE:
Please log in to see this code.
but in this context it will be same for all threads.
Of course i can use this line:
CODE:
Please log in to see this code.
After creating independent Bars, I am going to run my strategy with one set of parameters and save results to file. After this
CODE:
Please log in to see this code.
and run with other set. And create cycles for parameter sets.
But again, in the Slave threads doesn't work function like:
CODE:
Please log in to see this code.
and other which work with Positions. They work only in context:
CODE:
Please log in to see this code.
and it is same for all threads.
I know that WL5 can have completely independent threads because if you will create new mane workspace from menu it can work with same strategy but with different datasets simultaneously and without any problem.
thanks
Size:
Color:
Sorry for asking again. Does exist possibility to run new thread from strategy which will have separated position management?
Size:
Color:
Why would you want these independent threads, could you elaborate please?
Size:
Color:
I want to these threads because I am using them now. Now I create new workspaces and in each run same script with different datasets. My back-testing strategy use 1800 stock with 1 min scale. For analyze 1 month one 8 threads (8 core, 2 quad processors) need around 23 hours.
It will be more comfortable to run these thread automatically from strategy.
Size:
Color:
But why is threading required? What tasks are required of each thread?
This is interesting, but I'm not afraid to admit you're trying to do something that I've never even thought about doing in a script. We're trying to understand why you need to do it because in the thousands of scripts that we've collectively written over the years, threading has never been required - not even once.
Size:
Color:
Hi Cone,
If little bit abstract from WL, and ask question why any parallel integration needed. Any task can be done by serial integration. But by parallel integration you can finish some task in a lot of times faster.
WL4 have Optimization module which can contain up to 10 #OptVars. if you for example try use for each OptVars 5 different meaning you should make 5^10 runs for each stock. If you will multiple it on amount of Nasdaq stocks. You will have too much runs. And each run independent. More simplest way to parallel WL it is calculate each index in independent thread.
How i mentioned now on 8 cores (with 8 threads) for my optimization necessary around 23 hours. If I will use only one thread it will take 1 week.
Most of computers now have multicore processors and most of your users now use only one core for working with WL. It can make WL faster if you will use same thing for Backtest on dataset.
It can look like:
t= new WealtLab.Workspace(Index, Dataset, BeginingDate, EndingDate, Scale, PositionSize, StrategyName, ShowOrNotShow new window for workspace, Wait or not wait until thread will be finished);
t.start();
Or another alternative for parallel execution is:
Make possibility send all necessary parameters from command line like
c:\...\WealtLabPro.exe -i Index, -d Dataset, -s StrategyName -run
and create possibility to run simultaneously more than 1 copy WL5. You had this possibility in WL4. If I try to run second copy of WL5 I received message:"Apllication: WealthLabPro is already running".
Size:
Color:
Most of computers now have multicore processors and most of your users now use only one core for working with WL. It can make WL faster if you will use same thing for Backtest on dataset.
It was applicable to WL4 but doesn't apply to WL5 any more. By virtue of .NET it has support for multi-core CPUs.
and create possibility to run simultaneously more than 1 copy WL5. You had this possibility in WL4. If I try to run second copy of WL5 I received message:"Apllication: WealthLabPro is already running".
And this possibility still exists: just select "New Main Workspace Window" from the Workspaces menu.
Size:
Color:
>By virtue of .NET it has support for multi-core CPUs.
but WL when execute strategy use only one core if you use one thread.
> run simultaneously more than 1 copy WL5.
Sorry it was question from another area. I once had asked this. It is about 2Gb limit for WL5
>just select "New Main Workspace Window"
I am using this regularly but it is manual way.
Size:
Color:
>By virtue of .NET it has support for multi-core CPUs.
but WL when execute strategy use only one core if you use one thread.
I was under impression that WLP5 is able to load the CPU up to 100%, indicating the use of all the cores available.
Anyway, ClearPositions works somewhat different than it did in WL4. I can't elucidate that now - just keep in mind.
Size:
Color:
Probably WL5.1 can but my strategy in WL5.0 load only one core.
My strategy performed a lot of calculation and don't use integrated indicators like RSI, Roc and other. I don't know how you realize creating new series maybe by new threads and it can load 100%.
I just check my strategy on notebook with 2 core. Peak load was 57%. On 8 Core peak was around 13%. I guess that 13% is too few.
Of course, WL5 is a lot of time faster then WL4. I made some estimation of speed differences several months ago. On same strategy (same calculation) differences was at least in 5 times.
Size:
Color: