I'm a new member of our forum. I would like to know how much trading value in a day of tickers in a specific watchlist is. Then I will add that value to the volume of a customized index.
The first step is calculating cumulative sum of trading value in that watchlist in one day, and my code is as below. For some reason which I don't know, the displayed result is not consistent as attached photo.
The correct result is 3021, but somehow some weird results (likes 3060, 3024) randomly occur.
In addition, my poor code seems not effective due to a long time of respond. I will add the result to the volume of a customized index for all days which means my code will take much longer.
Could you please tell me what wrong with my code? and how to improve it?
I have no ideas why the attached image could not appear properly.
It was uploaded from my computer. I will try to upload it again through a free website.