- ago
I am in a coded Strategy.
I want to know the name of the currently used DataSet.

(i.e. what is entered in Strategy Settings->Portfolio Backtest->Select Backtest DataSet)

How can I find out?

(I want to use this name in logging, reporting, as part of a result filename, etc...)
12
1,581
Solved
27 Replies

Reply

Bookmark

Sort
- ago
#1
Couldn't find such property, too. Dion will correct me if I'm wrong.
0
Glitch8
 ( 10.62% )
- ago
#2
You’re correct. We already have a feature request to obtain the execution mode, this can be bundled with that eventual feature.
0
- ago
#3
Here's that request just for reference:
https://www.wealth-lab.com/Discussion/Is-there-a-way-to-know-if-strategy-is-running-in-backtest-mode-SM-or-streaming-in-a-chart-6103
0
- ago
#4
I am using the construction
CODE:
         DataSet ds = DataSetFactory.FindDataSet("Test");             foreach (string symb in ds.Symbols)             {


If the feature in this post is implemented, I expect I would be able to dynamically supply the variable "Test" instead of hardcoding it. Sometimes I use the same strategy on different datasets.

While this DataSetFactory.FindDataSet("DS Name); is super useful, I will have to remember to change the "DS Name" in the code to designate a different dataset if I use one.
0
Cone8
 ( 4.98% )
- ago
#5
Only 2 votes still and I'm one of them!
0
- ago
#6
Sorry @Cone. Where can I vote on this and other features?

Robert
0
- ago
#7
@Cone
Aren't those 2 votes on the linked topic for a quite different request (strategy run mode)?

@innertrader
You can vote on this topic (and move it a step closer) since it's marked with #FeatureRequest by upvoting the title post. Currently it has zero votes. For other items in the backlog see the Wishlist - you'll get there with a characteristic button near "Ask a question".
0
- ago
#8
It's a bit circular and confusing to me.

@Eugene - in Post #3 of this thread you supplied a link to what you called the #FeatureRequest for this, which out to be Strategy Run Mode. Your post followed @Glitch Post #2 that WL already had a feature request for DataSet Name. The Strategy Run Mode post has a #FeatureRequest tag at the top. I assumed you knew that (technically) the Strategy Run mode incorporated (or could) the DataSet name feature.

At the bottom of the Strategy Run mode post, you link back to this post calling it as a "linked feature request".

This post has tag #WealthLab7 at the top. Is that a feature request tag also, or is #FeeatureRequest missing?

Which of these two posts should I be upvoting for DataSet Name?

Robert
0
- ago
#9
You're right, this is confusing. Marked this very topic with #FeatureRequest.
0
Glitch8
 ( 10.62% )
- ago
#10
Activating this item for Build 14 delivery!
2
Best Answer
- ago
#11
@Glitch - Was this actually implemented? Where can I find documentation? Where is info on new build features?
0
Glitch8
 ( 10.62% )
- ago
#12
You can find it documented in the QuickRef, it's a property called ExecutionDataSetName.

1
- ago
#13
Thank you @Glitch.
0
- ago
#14
So how do I get ExecutionDataSetName to reveal the dataset name when you're executing in single-symbol mode?

My stocks are grouped by type with the dataset name revealing that type. And I need to know what that type is in single-symbol mode. This wasn't a problem in WL6.
0
- ago
#15
This is not possible in WL7 ¯\_ (ツ)_/¯
0
Glitch8
 ( 10.62% )
- ago
#16
The symbol could be anything you type in. It could be contained in multiple, or no, DataSets.

But if you want to look for a match you could enumerate the DataSets using DataSetFactory and look at each one’s Symbols.
0
- ago
#17
Looks like we found something WL6 does better than WL7.

QUOTE:
... you could enumerate the DataSets using DataSetFactory and look at each one’s Symbols.

Well, I know the DataSet names I'm trying to avoid. Basically, any DataSet name with "screener" or "ETF" in it because I don't want to query fundamentals for stocks in those. So I need to write a procedure for doing this in WL7. Two questions:

1) Is there a better way to avoid certain stocks than placing them in taboo DataSets?

2) How do a get a listing of all stock symbols in a certain DataSet?

With WL6, this business is a simple DataSetName string test.

QUOTE:
This is not possible in WL7 ¯\_ (ツ)_/¯

And we need a thumbs down arrow. I know, that's a separate "feature" request. :)
0
- ago
#18
QUOTE:
And we need a thumbs down arrow. I know, that's a separate "feature" request. :)

Feel free to submit it. I'm gonna be a devotee of this dislike button! :)
0
Glitch8
 ( 10.62% )
- ago
#19
As a team we've decided not to implement "downvote", just a heads up to save you from wasting the effort to submit a request we'll just decline.

You still haven't answered my question about how to return a DataSet name for a symbol that you type in that is not in ANY DataSet, or even in MULTIPLE DataSets? Maybe WL7 is doing things better than WL6 after all here. The fact is when you test using a single symbol, you DON'T HAVE a DataSet specified, so it's behaving correctly.

>>2) How do a get a listing of all stock symbols in a certain DataSet?<<

Use its Symbols property.
0
- ago
#20
QUOTE:
You still haven't answered my question about how to return a DataSet name for a symbol that you type in that is not in ANY DataSet, or even in MULTIPLE DataSets?

Well, the DataSetName query is being processed by a strategy in single-symbol mode, so it's a valid stock. What I want to do is a next-earnings-date lookup for that stock if it's:

1) not an EFT and ...
2) not in one of several screener DataSets.

If it's contained in neither, then I want to do a next-earnings-date lookup. And that's true even if the stock doesn't exists in any DataSet. Bottom line, I want to avoid the earnings lookup if the stock is contained in a taboo DataSet.

I suppose special DataSet state attributes (one for "ETF" and another for "screener") could be created that the strategy could test against. But that's an awkward solution. I'm trying to think of something simple and straightforward for this solution. Any ideas?
0
Glitch8
 ( 10.62% )
- ago
#21
It depends on how you have your DataSets organized. If there is just one DataSet of ETFs, for example, you can use DataSetFactory.FindDataSet, then use the DataSet.Symbols property to see if that symbol is in that DataSet.
0
- ago
#22
There are several ETF DataSets and several screener DataSets, and "ETF" or "screener" appears in their dataset name. The procedure I was thinking of writing would grab the contents of all taboo datasets in the constructor of the strategy (storing them in a sorted set that would then be converted to a "taboo" string array), then that sorted string array would be searched as needed.

I find this an awkward solution too. But I'm open to other suggestions.
0
Glitch8
 ( 10.62% )
- ago
#23
Maybe create a reusable method like:

CODE:
public bool IsSymbolInDataSet(string symbol, string dsNameSubstring)


to do the heavy lifting for you?
0
- ago
#24
No, I don't want to test each taboo dataset independently. That's even more awkward. I like my approach above better where I combine all taboo datasets (eliminating duplicates) into one big taboo string array (strategy constructor) and test against that.

But if you can think of a better way, let me know. Could BacktestBegin() sample the "current" DataSet name and set a taboo logical? UPDATE: This doesn't work in single-symbol mode.
0
Glitch8
 ( 10.62% )
- ago
#25
It’s already called. And, I’m not sure what you mean by “current” DataSet?
0
- ago
#26
QUOTE:
It’s already called.

I mean I'm doing this batch in the constructor of the strategy, building a taboo string array. Then in Initialize I can test against each stock (using the taboo string array) as the strategy encounters them over the day.

QUOTE:
what you mean by “current” DataSet?

Well, the strategy will be hopping between different datasets over the course of the day. Some will be from ETF datasets, some from screener datasets, and most from none of the above. I just want next earnings dates from the latter (which is most of the datasets). This strategy samples all the datasets.
0
- ago
#27
I implemented my proposed solution with the tabooSymbols array, and it works. The calling sequence is

CODE:
public class MyStrategy : UserStrategyBase {       readonly string[] tabooSymbols = WLUtil.ExcludeSymbolsByDataSetName(new String[] { "screener", "ETF" });              public override void Initialize(BarHistory bars) {          . . .          if (Array.BinarySearch(tabooSymbols, bars.Symbol) < 0) //exec below if not a taboo symbol             WLTradingExtras.ShowBarsUntilEarnings(bars,decorrelated,decorrelated.Description,100);       }

And the WL utility class (WLUtil.) method being called is
CODE:
      public static string[] ExcludeSymbolsByDataSetName(string[] tabooDataSetNameParts) {          SortedSet<string> tabooSymbols = new SortedSet<string>();          foreach (DataSet dataSet in WLHost.Instance.DataSets)          {             foreach (string tabooNameSnippet in tabooDataSetNameParts)             {                if (dataSet.Name.Contains(tabooNameSnippet))                   tabooSymbols.UnionWith(dataSet.Symbols);             }          }          string[] tabooSymbolsArray = new string[tabooSymbols.Count];          tabooSymbols.CopyTo(tabooSymbolsArray);          return tabooSymbolsArray;       }
The binary array search requires a sorted array, but the SortedSet datatype takes care of that. I don't like all the Unions it does, but that happens only in the MyStrategy constructor, so it's not too bad.

If you can think of a less messy way, let me know. I simply want to exclude some symbols for future earnings date lookups based on the dataset name they reside in.
0

Reply

Bookmark

Sort