how to find out the performance of a few stocks on specified dates
Author: BostonFern123
Creation Date: 3/26/2010 7:45 PM
profile picture

BostonFern123

#1
I have a list of stocks and the associated dates to which I need to find out the performance for the next few days. For example, I need to find out the performance of gld on 2-5, 3-3, 3-15, 3-20 and the next 1 , 2,and 3 days, and generate a report. For spy, it will be a different set of dates.

Currently I can do this by testing one security at a time, have the dates in beded in the codes, and have the program cycles through all the bars until it hits the specified dates. This is a laborious process. I'm wondering whether there is a much more direct process, which is fetching stock price for a security on a specified date directly. Can this be done with wealth Lab pro? If not, are there other things I can use?

Thank you for answering.

profile picture

Cone

#2
QUOTE:
and have the program cycles through all the bars until it hits the specified dates. This is a laborious process.
What's laborious about putting a computer in a loop? They're very good at doing that and it only takes milliseconds.

The laborious part is your need to define specific dates for specific securities. If you can put that in a single file that can be read in by a script, it makes the task [almost] child's play:

1. Your code should read the data file containing "symbol,date" records into a list (or global memory).
2. The code cycles through the list until it finds a symbol that matches Bars.Symbol.
3. Use the DateTimeToBar function to find the bar that corresponds to the date.
4. Output the gain to your report for the next 1, 2, and 3 bars.
5. Set up all of your symbols of interest in a single DataSet, select the DataSet and run.
>> Report created

After the script is done, the labor is confined to creating your symbol,date list file.
profile picture

BostonFern123

#3
You are right. I didn't know I can get the current symbol from the Bars.symbol.

Thank you so much for a great answer,

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).