jmfernandes / robin_stocks

This is a library to use with Robinhood Financial App. It currently supports trading crypto-currencies, options, and stocks. In addition, it can be used to get real time ticker information, assess the performance of your portfolio, and can also get tax documents, total dividends paid, and more. More info at
http://www.robin-stocks.com
MIT License
1.74k stars 468 forks source link

Allow caller specified interval in get_historicals #126

Closed ghost closed 4 years ago

ghost commented 4 years ago

Currently get_historicals determines a specific interval based on the span requested. It would be extremely helpful if the developer could specify the interval they are interested in. For instance there are many cases where I need the last month or 3 of data, but I only need daily ranges and not hourly/10min intervals.

IE

def get_historicals(inputSymbols, span='week', bounds='regular', interval='notset'):

If it is the default notset value the existing functionality is maintained. If the interval is set to a valid value use that instead.

ghost commented 4 years ago

Some have raised concerns that not all intervals are accepted by the Robinhood API for all span values. I'm going to need to do further testing on my end to address this. I do have an idea though...

If RobinHood does not except the interval, but it is a valid step up (IE for a given span RobinHood returns 1hr intervals and the user requested 1 day intervals) we have all the data to step up and deduce the open/close/min/max/volumes for the entire day based on the hourly intervals.

I will be doing some testing and coding something up. Consider the PR a draft until I have time to get this done.

ghost commented 4 years ago

Follow up: It appears that a lot of combinations are allowed. For those not allowed the system simply returns a 400 error.

I would propose we let uses make requests for whatever intervals they want - and leave it up to Robinhood to determine if the span/interval range is valid. At the very least it appears the acceptable combinations are for more lenient than what robin_stocks is currently allowing.

jmfernandes commented 4 years ago

Fixed in v1.1.0