Calculate yearly return for an security listed at the middle of the year

Hi there,

I bring up this topic to see if anyone suffers from the same issue when calculate yearly return.

In fact, as shown in the picture, the stock is listed on 19th Oct 2018. If i use the following script to calculate its return in 2018:

M1 = YEARNUM() == 2018;
M2 = YEARNUM() == 2017;

As the year 2017 has the value of 0, the result is -100% which is obviously not correct.

So in order to make this script work, how to do the modification here.

Thanks in advance for your reply ~~


i think maybe it’s better to create a solution include in the optuma program for this problem. Cause it’s a relatively basic and important point to estimate individual security forward performance by it’s past path.

Or maybe it’s just me with some strange idea in trading, anyway it’s better to learn things from the past from my point of view.