Ameobea / robintrack

Scrapes the Robinhood API to retrieve + store popularity and price data.

Home Page:https://robintrack.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add ability to download popularity data for a given time frame

mutebat39 opened this issue · comments

It would be nice if the popularity_history (and I suppose popularity_history_csv) API endpoint(s) supported the ability to return only data points in a given time frame (ex., "get me popularity data for TSLA between 2020-03-01 and 2020-03-06"). Currently, as far as I can tell from the source code, this endpoint only supports fetching the entire popularity history for a ticker (which for many tickers is years worth of several-times-a-day data). That makes it impossible to politely use your API to, say, keep daily tabs on a few tickers: if you want data for today (every day), you have to also fetch a couple of years worth of data (every day). Ouch.

The way I'd envision this is to add optional start_time and end_time query parameters to the endpoint(s), which (logically, at least) default to, say, the UNIX epoch (or first time when data was available for the ticker) and now, respectively, to maintain backwards compatibility with the current implementation (i.e., fetch all history). These parameters would both take some sort of encoding of a timestamp, say ISO-8601 or whatever is easy enough to get a parser for in Ruby. It should be easy enough (I think?) to plumb these further down into the get_history_for_symbol method and the MongoDB query that actually gets the data to service the endpoint call. This query gets modified to select based on the timestamp field being between start_time and end_time (inclusive).

I don't know what your bandwidth for working on Robintrack is these days, but if you think you wouldn't be able to get this feature out any time soon yourself, I'd be willing to (try to) cook up a pull request if you'd be willing to review it. (Assuming you want this feature yourself, that is, though I suspect it might help in your eventual implementation for #43.)

Thanks for such a quick implementation of the feature!