Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, TipmyPip, 7th_zorro), 877 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Handling assets with different history lengths #484015
08/28/21 17:37
08/28/21 17:37
Joined: Aug 2021
Posts: 101
M
MegaTanker Offline OP
Member
MegaTanker  Offline OP
Member
M

Joined: Aug 2021
Posts: 101
Working on a script that filters through a large list of assets, some of which are much younger than the backtest length. The history can be as short as a year but since I'm working with daily bars, I can't cut the backtest length short to just one year.
I have plotted one such histories and have noticed that it propagates the earliest value in the history all the way to the earliest day of the backtest. This means I probably can't check if price() returns something valid, because it does no matter what.

I have found AssetFrame in the manual which states: "Asset specific time frame, automatically set by AssetZone or AssetMarket. 0 when the current asset had no price quotes in the current bar or when its market is closed".
I haven't tested if that works for my intended purposes, it seems to be designed for some other purpose. Is there a recommended way to check if an asset already has a history at the current bar? I also need to consider that each asset will need some lookback period to calculate indicators and such. I could run an int array that counts up each encountered bar of an asset, and then only start considering assets once the counter is greater than the lookback. But maybe there's some built-in solution to this problem?

Last edited by MegaTanker; 08/28/21 17:38.
Re: Handling assets with different history lengths [Re: MegaTanker] #484018
08/29/21 13:17
08/29/21 13:17
Joined: Mar 2019
Posts: 357
D
danatrader Offline
Senior Member
danatrader  Offline
Senior Member
D

Joined: Mar 2019
Posts: 357
Sorry, but totally unclear for any reader what your question is.

Re: Handling assets with different history lengths [Re: MegaTanker] #484019
08/29/21 14:51
08/29/21 14:51
Joined: Aug 2021
Posts: 101
M
MegaTanker Offline OP
Member
MegaTanker  Offline OP
Member
M

Joined: Aug 2021
Posts: 101
Ok, I'll try differently: I want the backtest to be 5 years long but the asset list includes assets that haven't existed 5 years ago because they're new companies, so the historical data for those doesn't go back 5 years. I need to find out at each bar if an asset already has valid price data at this current bar or not.

Re: Handling assets with different history lengths [Re: MegaTanker] #484023
08/30/21 08:25
08/30/21 08:25
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Compare the current price with the first price. If both are identical, the history has not yet begun.

Normally it doesn't matter because trades are usually not triggered anyway when the price curve is flat.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1