Greetings Quantopians,
I'm new to this, still learning the API+python, and need help selecting the properties of a security (price for example) on an arbitrary day, hour or minute.
There are several posts about using external data sources to feed into our algorithms which have motivated me to start thinking about how to relate news and events to specific securities on specific days. Since these dates and times will vary from security to security there will probably need to be some code/function/subroutine that retrieves the properties of those securities on any given date from the Back-testing data. For example, During live trading, some news is reported relevant to a security in my portfolio. It would be useful to be able to compare how prices moved on days in the past when similar news were reported about the security.
The first solution I have come with up so far:
- Set the starting date of the algorithm to the chosen date.
- Retrieve the value
- Store the value externally, import the external value on a separate algorithm
This doesn't work too well, because it would be ideal to reference the properties of the security from within handle_data() and would probably not work during live trading. The second solution I've come up with is:
- Set @batch_transform(window_length=n), where n falls on the arbitrary date.
- Drop the values that the @batch_transform() function returns, except for the day or days chosen.
This seems computationally inefficient, but it does allow for sampling the days around the arbitrary date which could turn out to be important. However, both of these solutions seem like the wrong way to go about doing this.