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 469 forks source link

Issue with robin_stocks.get_option_historicals #19

Closed AmeliorateOr closed 4 years ago

AmeliorateOr commented 5 years ago

Trying to find an alternative way of getting the expiry day data, I figured I would try to get the historical option data and run through each strike as desired. Unfortunately, I got the following error:

Getting the option ID failed. Perhaps the expiration date is wrong format, or the strike price is wrong. 404 Client Error: Not Found for url: https://api.robinhood.com/marketdata/options/historicals/None/?span=week&interval=10minute None

Here is my code:


import robin_stocks as r

username = ""' password = ""

symbol = 'SPY' expirationDate = '2018-12-21' strike = '245.00' optionType = 'call' #I think 'both' or empty '' may yield both, but am unsure. span = 'week'

r.login(username, password)

data = r.options.get_option_historicals(symbol, expirationDate, strike, optionType, span)

print(data)


Something to do with the optionID for this request it seems.

jmfernandes commented 5 years ago

I check this out but im sure there is a better way to get the expiration date data.

AmeliorateOr commented 5 years ago

That would be great.

I do agree, I'm sure there is a better way for the expiration date data, but to acquire historical data, this method may the best route. Plus I wanted to let you know it was not working as expected and confirm that it was indeed something with the API and not something I improperly input on my end.


A quick aside, your code is amazing. So clean and readable, I especially enjoyed 'the explicit vs implicit' in your talk about how you chose to write, it really shows and shines. Really great to see the progress and learn from reading. So let me give you the proper thanks that everyone using this should! :)

nathanielrosendall commented 4 years ago

I'm running into this same issue and trying to troubleshoot.. am having a tough time finding any formal API documentation for Robinhood's private API. Thanks @jmfernandes for all the great work you've put into this

sher85 commented 4 years ago

Hi,

I attempted to use the same function for retrieving historical options data but received a similar error message (below). I tried variations of the input variables but received similar messages each time. I see that this issue was closed, was a resolution found?

Getting the option ID failed. Perhaps the expiration date is the wrong format, or the strike price is wrong. 404 Client Error: Not Found for url: https://api.robinhood.com/marketdata/options/historicals/None/?span=week&interval=hour&bounds=regular

My base code below:

import robin_stocks as rs
import os

login = rs.login(os.environ['robinhood_user'],os.environ['robinhood_pass'])
rs.options.get_option_historicals('TSLA', '2020-08-28', '500.0000', 'call')
nathanielrosendall commented 4 years ago

I haven't tested this out since it was closed, but I'm suspicious this function is only meant to return option historicals for positions that you actively hold. The documentation said it's used to pull data that's "used to make the charts", and the only place the app gives you option historical charts is for positions that you currently hold. Just a thought

Novosti1 commented 4 years ago

Hi,

I attempted to use the same function for retrieving historical options data but received a similar error message (below). I tried variations of the input variables but received similar messages each time. I see that this issue was closed, was a resolution found?

Getting the option ID failed. Perhaps the expiration date is the wrong format, or the strike price is wrong. 404 Client Error: Not Found for url: https://api.robinhood.com/marketdata/options/historicals/None/?span=week&interval=hour&bounds=regular

My base code below:

import robin_stocks as rs
import os

login = rs.login(os.environ['robinhood_user'],os.environ['robinhood_pass'])
rs.options.get_option_historicals('TSLA', '2020-08-28', '500.0000', 'call')

Did you fix your problem ? and if you do - HOW ?

samuelgoldsteinGT commented 3 years ago

I am trying to use robin_stocks. get_option_historicals to access historical TSLA option prices. Although I am able to access the history for options that have not expired yet, I cannot access data for previously expired options. This may be because the ‘span’ must not include the time after options expiration for the request to be valid.

Is there a way to access the historical time series of options that have already expired? Or, is there a way to adjust the 'span' argument to not include the time points after expiration?

Thank you!

jessie5555 commented 2 years ago

Hey did anyone end up figuring this out? Heres what I know:

GrahamboJangles commented 1 year ago

@jessie5555

It works for future expiration but not previous ones, unless theres something you can do there.

I had just spent a couple hours trying to figure out what I was doing wrong and it was just this... ughh. Anyone know a good way to get historical data, as in PAST data?