How to recognize if last Date of a DataSeries is the end date of the "Data Range"?
Author: odeedo
Creation Date: 10/24/2011 12:05 PM
profile picture

odeedo

#1
When i do backtesting i use the "Data Range" f.e. from 05/24/2006 to 05/24/2011.

In my watchlist are many delisted data series which an end date before the last date of the defined data range.

In my skript i need to know if the data series end date at the last date.


CODE:
Please log in to see this code.


But when i call the script for a symbol with end date 05/13/2010 and SP500 with end date 10/21/2011 the data range above
this results in

SP500_nosync 10/21/2011
SP500 05/13/2010

but i rather would expect

SP500_nosync 05/24/2011
SP500 05/13/2010

Do i have a chance to recognize, if last date of a symbol is not the end date of the data range?

Thanks
Frank

profile picture

Eugene

#2
QUOTE:
but i rather would expect

No, you can't expect that. What you expect is one of the aspects of the synchronization process that you purposefully disabled - and thereby are getting raw unsync'd data.
QUOTE:
Do i have a chance to recognize, if last date of a symbol is not the end date of the data range?

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

odeedo

#3


QUOTE:
CODE:
Please log in to see this code.


Sorry this didn't work

It is always true independent if my main (not SP500) data series end's before or after the end of the data range

I used only a second data series like SP500 series because i thougth i can recognize the end date of the data range.

Regards Frank


profile picture

Cone

#4
I'm not following your argument. If you pull in a DataSeries with Synch set to false, you get an unsynched DataSeries will all of the dates available. You can see the dates just as the snippet shows. You know the relation of those dates to the dates in the primary chart.

What "didn't work"?
profile picture

odeedo

#5
sorry for my bad english

My question was:
Do i have a chance to recognize, if last date of a [synchronized] symbol is not the end date of the data range?

I.e.:
My data series symbol nnn has data from 1/1/2005 to 12/31/2010

I set my backtesting "data range" from 1/1/2006 to 5/1/2010
So my data series do have data for the last date of the date range (-> 5/1/2010)

The function should result TRUE


I set my backtesting "data range" from 1/1/2006 to 5/1/2011
So my data series ends (-> 12/31/2010) before last date of the date range (-> 5/1/2011)

The function should result FALSE

=====================================
In other words: Is there a statement to ask for the end date of the backtesting "data range"?


Regards
Frank

profile picture

Cone

#6
QUOTE:
Is there a statement to ask for the end date of the backtesting "data range"?
You're looking for the equivalent of Bars.FirstActualBar for the end of the series. Although we have asked for a Bars.LastActualBar function, it hasn't found its way into WealthScript yet, so you (or we) have to make one...

I just thought about it for 5 minutes, and I don't see a trivial solution for LastActualBar (which doesn't mean one does not exist). If all you need to know is if the secondary series ends before the primary, then you pretty much have the solution above - first access the secondary unsynched, determine the last date, and then synch it later.
profile picture

Cone

#7
Here's a shot at it. The script contains a class called SelfSynch that will synchronize a non-synchronized Bars object that you pass to its SynchBars method.

SelfSynch also has 2 properties: FirstActualBar and LastActualBar that you can access after performing the synch. I think it should work for all timeframes, but I've only tested with Daily data. Give a try -

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

KGo

#8
QUOTE:
Although we have asked for a Bars.LastActualBar function, it hasn't found its way into WealthScript yet, so you (or we) have to make one...


This post is quite old so if this has been done please point me to it. Meanwhile, here are 2 functions that accept either synced or unsynced bars and do not create additional bars objects for comparison. Use LastActualBar() to simply return the last actual bar and IsBarDataUpdated(period) to to know if the bar data is current. For example if IsBarDataUpdated(1)= false then it's best to close out any open trades so the position sizer has access to that cash on later bars.

CODE:
Please log in to see this code.
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).