Where is DataSource inside StaticDataProvider for some methods?
Author: skaarr
Creation Date: 2/22/2013 11:19 AM
profile picture

skaarr

#1
Hello,
I store my database settings (like connection string and symbols) in dataSource.DSString.

So question is: how can I get current active DataSource to read database settings inside this methods:
CODE:
Please log in to see this code.

profile picture

skaarr

#2
Also in this method I need to get current active DataSource to read supported timeframes:
CODE:
Please log in to see this code.
profile picture

Eugene

#3
QUOTE:
So question is: how can I get current active DataSource to read database settings inside this methods:

There is no access to DSString in these methods. In GetMarketInfo and RequestUpdates, you can look up the current symbol name against a global collection of symbols. It's easier when your provider supports BarDataStore (which isn't necessarily the case with a provider like yours that deals with databases). If not, there is the IDataHost.DataSources property that provides access to all DataSets existing in Wealth-Lab.

QUOTE:
Also in this method I need to get current active DataSource to read supported timeframes:
public abstract bool SupportsDynamicUpdate(BarScale scale)

SupportsDynamicUpdate has no knowledge of the "current active DataSource". You'll have to think of a workaround - like maintaining a dictionary of symbol/BarScale pairs.
profile picture

skaarr

#4
QUOTE:
SupportsDynamicUpdate has no knowledge of the "current active DataSource". You'll have to think of a workaround - like maintaining a dictionary of symbol/BarScale pairs.

Okay, for example I create such type cache. This method does not have arguments like symbol or DataSource, so how I know which symbol or dataset means inside this method to read it from cache?
profile picture

Eugene

#5
That should not matter for SupportsDynamicUpdate for it's a provider-wide property, not symbol-based. It indicates that your provider is capable of returning on demand data in the specified data scale. For explanation, check out the static API guide. If your data provider can handle all possible bar scales, you might want to return true.
profile picture

skaarr

#6
QUOTE:
For example, if your adapter can return ad-hoc minute-based data and the user is on a Daily DataSet, the Minute scale button will remain enabled. If pressed, Wealth-Lab will produce a new DataSource object on the fly that contains the desired scale, and pass this to you in the RequestData method.

If I'm right:
1. I create DataSet with BarScale 15 min
2. Create chart 15 min chart
3. DataSource in this method (Bars RequestData(DataSource dataSource, ..)) has BarScale 15 min
4. I change chart timeframe to 60 min
5. But DataSrouce in this method (Bars RequestData(DataSource dataSource, ..)) again has BarScale 15 min
Based on your wiki, it should have 60 min barscale. This is a bug?
profile picture

Eugene

#7
The documentation example you're referring to applies to situation when the currently selected DataSet cannot be compressed down to a different scale.
profile picture

skaarr

#8
Do you have some wiki page about way how WealthLab compress custom named series in this case? Now I see unusable data in custom series. Or I should create DataSet with monthly barscale to use correct DOWN compress?
profile picture

Eugene

#9
As can be seen in the Wealth-Lab QuickRef, SetScaleCompressed() operates only on the OHLCV DataSeries and does not apply to manually created and/or Named DataSeries.
profile picture

skaarr

#10
So creating montly/yearly barscale for dataset is only way to get correct barscale in public override Bars RequestData?
profile picture

Eugene

#11
I don't know what you're after, and I don't follow you on this monthly/yearly thing. Everyone gets a correct BarScale in RequestData anyway, so if you have a problem, please rephrase/clarify your question so that I could understand it.

P.S. Make sure you've studied the open source code of the Google static/streaming provider which supports several bar scales.
profile picture

skaarr

#12
I need correct BarScale inside my static provider, to get correct custom data which I store in named series. Now I found no way to use Wealth-Lab to do this simple task.

I use Google static provider as example, but I get more details from other decompiled providers. Now I can't find the way how to make wealth-lab work with my database in all timeframes to get custom data correct for every timeframe.
profile picture

Eugene

#13
QUOTE:
Now I can't find the way how to make wealth-lab work with my database in all timeframes to get custom data correct for every timeframe.

To confirm/rephrase, in each BarScale you have a different Named DataSeries (what's the point)? Or you need to have them compressed in Wealth-Lab? The latter is pretty easy: simply use the WealthLab.BarScaleConverter class.
profile picture

skaarr

#14
Okay, I try explain step by step:
1. When I create new dataset and set default BarScale to 15 min, in RequestData I get correct lower timeframes when change current timeframe in wealth-lab.
2. When I change timeframes to upper than 15 min, I always get barscale 15 min and can't read correct custom named series data.

I can create dataset with yearly default timeframe and always get correct lower timeframes (because all timeframes is lower than year). But I cant create correct cache dictionary for datasources, because if I have two datasource with same symbols list to same database, settings string (DSString) for this different datasources should be identical and can't be used as cache dictionary key.

Other try was using dataSource.Name as cache key, but again all non default barscales pass datasource with correct DSString but with empty name.

I trying attach dataSource name to DSString, but again fail - CreateDataSource not pass name as argument, so I cant add name to DSString and use it as correct cache key and get additional data.

I just need dataSource argument in RequestData method always have same BarScale as selected in Wealth-Lab chart or strategy to read custom data exactly for this timeframe. Because Wealth-Lab can't compress or expand it correctly. And same name for dataSource clones for nonstandard barScale as in original dataSource. Is it possible?
profile picture

Eugene

#15
Thank you for the detailed explanation, it helps.

Wealth-Lab takes care of bar scale compression on its own, and so it does not pass control to the provider. Using your example, when the chart is compressed, the BarScale thereby has to remain 15-minute because the data are requested by Wealth-Lab in the native scale. This is by design, you can't overcome it: your provider's work is finished at this point.

If the ability to retrieve named series on a per scale basis is important, I'd let your provider's users know that it's important to operate on the native bar scale.
profile picture

skaarr

#16
I see. But second question is unanswered: is it possible use original dataSource name for dataSource clones for nondefault barScale in RequestData method?
profile picture

Eugene

#17
What on earth is "dataSource clone"? Please clarify.
profile picture

skaarr

#18
When I create chart in Wealth-Lab for non default dataset timeframe, you pass original DataSource object copy with DSString but WITHOUT Name (inside method RequestData).
profile picture

Eugene

#19
The ds.Name property isn't being assigned when requesting data for an arbitrary bar scale - lower than the current bar scale. I believe an explanation lies in the fact that Wealth-Lab creates a DataSet on-the-fly.

On the other hand, when requesting data for a compressed bar scale the ds.Name isn't null because Wealth-Lab requests the data from an existing DataSet AND then compresses it on its own.
profile picture

skaarr

#20
QUOTE:
The ds.Name property isn't being assigned when requesting data for an arbitrary bar scale - lower than the current bar scale. I believe an explanation lies in the fact that Wealth-Lab creates a DataSet on-the-fly.

So you can assign DSString to new dataset and can't add new code line to assign Name? This is "by-design" buggy api?
profile picture

Eugene

#21
QUOTE:
This is "by-design" buggy api?

I appreciate the friendly tone of your reply Ilia.

To close the question and at the risk of repeating myself, the ds.Name is not being assigned purposefully because in this case Wealth-Lab creates a DataSet on-the-fly, so it can not have a name.
profile picture

skaarr

#22
Look, you create public api, but a lot items have exceptions for different usage case. This is bad designed api created just for your simple OHLCV world. And I think assign Name to temporary datasource is simple thing to fix.
profile picture

Eugene

#23
If it ain't broken, don't fix it. Temporary data sources do not have names. Period.

Regardless of what you think, there are dozens of data providers in the wild - and what someone thinks to be a simple change may return a mighty echo.
profile picture

skaarr

#24
you never pass Name to dataSource, so any of this "dozens" providers never use it inside. Why you think this should broke this providers somehow? I do not see any logic in your answer.
profile picture

Eugene

#25
Since you're an expert, here's just my 2 cents: at least 16 of the static data providers I've created rely on the ds.Name property being filled or IsNullOrEmpty one way or another. Wealth-Lab builds temporary datasources for several purposes, such as requesting a symbol's data in a lower BarScale on-the-fly, SM updates and updating all data by provider. That's why your hypothetic change would be short-sighted and harmful.

At any rate, this is my final reply to you here as you keep ignoring my argument: for a virtual DataSource created on-the-fly, name simply does not exist, so the only properties that should be filled are BarDataScale and symbol (and DSString in some use cases). Good luck with your venture Ilia.
profile picture

skaarr

#26
QUOTE:
(and DSString in some use cases)

Can you explain in which cases you not fill this settings?
May be wealth lab is not right tool for my needs and I should search other tool.
profile picture

Eugene

#27
To anyone interested out there, for continuation and workaround visit this thread:

Features request
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).