Unable to Cast DataSeries error in Streaming mode
Author: DamV
Creation Date: 3/9/2017 1:15 PM
profile picture

DamV

#1
Here is the code using a daily scale. Could you please explain the issue and how to fix it?

CODE:
Please log in to see this code.


Streaming: Disable => OK

Streaming: Enable => Runtime Error: Unable to cast object of type 'WealthLab.DataSeries' to type 'WealthLab.Indicator.SMA'
profile picture

Eugene

#2
SMMA is not SMA. Either it starts with "SMA sma...", or ends with "= SMMA.Series".

But this code will not compile and work in both modes, not just streaming.
profile picture

DamV

#3
It was just a typo error in my post. I updated the previous post. My code is SMA. And the compilation is ok. It's just a runtime error.
See code and error in attachment.

I noticed it always works in Intraday (streaming or not streaming).
It works in Daily + disable streaming
Runtime error in Daily + streaming

Other info:
Data Range: 2 months (but any change has no impact)
Position Size: Override
Symbol in a Data Set via Fidelity

profile picture

DamV

#4
+ screenshot
profile picture

Eugene

#5
1. Update TASCIndicators and Community.Indicators to their latest versions (2017.03 and 2017.02) and restart WLP. Background:

Unable to cast object error

I'm sure this should fix it. Your WLP installation contains an outdated TASCIndicators (switch to "Other extensions" in the Extension Manager) affected by this issue.

2. A less likely reason is when mixing data by different providers e.g. Fidelity streaming provider, Yahoo DataSet.

If nothing helps I could offer some insight if you'll be more detailed about your setup. Like I already suggested in a ticket, full-size screenshot goes a long way - especially when it comes with the full code, symbols, bar scale (Daily as we already know), settings, involved data providers and everything related.

P.S. Although SMA is not affected, there's a pesky bug that results in yet another "Unable to cast" error. But it's so specific that I'm leaving this pointer rather for others who might stumble onto this thread by searching:

Unable to cast object of type 'WealthLab.DataSeries' to type 'WealthLab.Indicators.RSI'
profile picture

DamV

#6
Yahoo dataset removed.
TASCIndicators updated to 2017.03 (it was 2015)
Community.Indicators already up-to-date 2017.02
Restarted

Issue still present but only for SMMA (community) now. SMA is ok.
I also noticed that it occurs only when I click on Run strategy+ Streaming + Daily. If the strategy is launched clicking on the symbol (on demand) in the dataset it works.

CODE:
Please log in to see this code.



I guess a bug of an incompatibility has been fixed in TASCIndicators but not in Community.

My workaround: Use Streaming + Intraday + Scale to daily in the code => it works. Any idea about the bug?

CODE:
Please log in to see this code.
profile picture

Eugene

#7
Please use CODE tags when posting code next time and not QUOTE tags. They're neighbors. I've been fixing this for you, that's why your code blocks look pretty.

I work with neither Fidelity data nor WLP so it isn't possible to reproduce "Unable to cast" for me using Yahoo! data in WLD. Maybe it's WLP specific, I don't know.

QUOTE:
Issue still present but only for SMMA (community) now. SMA is ok.

BTW, posts #3 and #4 illustrated just the opposite idea. And updating the libraries just couldn't "fix" SMA for you: it was neither broken nor affected by this issue.

QUOTE:
I guess a bug of an incompatibility has been fixed in TASCIndicators but not in Community.

No, both extensions have been successfully fixed. Furthermore, neither SMMA nor SMA has ever been affected - they don't use the FastSMA and never had any classes to share.
profile picture

DamV

#8
post 4 (screenshot) was before the update of the lib TASCIndicators.
After this update SMA works.
I tested with Yahoo provider, same issue.
New screenshot attached.

I also noticed something interesting...
If I copy/paste the FULL script to a new script
streaming + same symbol + same conf...=> compil: ok , run strategy: ok
Then if I save it (CTR+S) with a a new name in an existing folder or a new folder => compil: ok, run strategy: error is back

After more tests, actually it's not linked to the save, the first Run Strategy will work but not the second one, not the third one...
If I run without Streaming it will work, Intraday it will work, Clicking on the intrument (On demand) it will work. So the issue just in Daily mode and the second run.

I also noticed if I close the script with this issue and open it again the first run done automatically at the opening works.Clicking on Run Strategy (no other action before) and again the issue...

And another point if I changed Close by Open - the first run will also work, but the next runs. Roll back to Close then Open...changes nothing.

Am I alone with this issue? I think there is something in cache for this function and it doesn't work well.

Note: I tried with different symbols => same issue, I displayed all values of Close[] in both cases => no difference

profile picture

DamV

#9
I confirm that there is something related to the cache when we run the strategy in daily + streaming. To fix it, I added before the call of the function.

CODE:
Please log in to see this code.


Could please check/review the code of SMMA?
profile picture

Eugene

#10
Please use CODE tags when posting code next time and not QUOTE tags. Click the # icon, NOT the "" - they're neighbors. I've been fixing this for you, that's why your code blocks look pretty.

Hopefully you made your tests on Y! data with Y! streaming provider, not Fidelity. As you already know, it's not a good idea to mix streaming and static data by different providers. I'm not sure why you click 'Run Strategy' in Streaming mode as it makes little sense. Just open a strategy, click "Stream" and let it do its job.

Cannot reproduce on AMTD on ALNY on 40-60 bars (or on other symbols). Tried many times with different Y! settings (like "Never perform on demand updates" or "Always return partial bar"). Absolutely nothing in WLD. So the error message is unreproducible for me.

Also, it doesn't make great sense to use "Position Size: Override" unless your code is suitable for this option. The one on screenshots does not conform.

QUOTE:
Could please check/review the code of SMMA?

I did check that and SMMA (open source) is free from issues. It's not the reason.
profile picture

DamV

#11
I use Override because the real script with this issue needs this option.
I tried with all modes, a lot of symbols, no impact, the issue is the same.
I tested with Fidelity datasets without any other provider datasets.
I also tested with Y! but I didn't removed all the Fidelity datasets. I will test it with only Y!.
I click on Run Strategy because I'm still working on it.

I used the default configuration after an install of WLC (done around september 2016).
The only config I changed is related to the email settings.
I also added the Community extension (last version).

Ok for SMMA code review but there is something wrong in streaming mode - clearly linked to the cache maybe not in the code of SMMA.

Thanks for your help. I will continue to use my workaround cleaning the cache at the beginning of the script.
profile picture

Eugene

#12
Try to focus on the Strategy's chart window and click the "Clear Drag and Drop Indicators" button on the Function toolbar (the Eraser icon). Chances are some dragged and dropped indicator's setting with the Strategy's XML file is corrupt.
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).