robinhood-unofficial / pyrh

Python Framework to make trades with the unofficial Robinhood API
https://pyrh.readthedocs.io/en/latest/
MIT License
1.77k stars 603 forks source link

Retirement Support #304

Open abhmul opened 1 year ago

abhmul commented 1 year ago

Checklist

Feature Request

Now that Robinhood has added retirement accounts, it would be good to be able to manage investment there as well. I can look into how to do this, but if anyone familiar with the codebase and api has pointers on how to do this, that would be helpful.

Questions I have

  1. Is there any documentation available on what API endpoints are available?
  2. I placed a test order on my retirement account for VTI of $1 through the RobinHood website. When placing the order, the website says my "Estimated Shares" were 0.005212, but the api request for the order used a quantity of 0.004577. In fact the price on the website was $191.86 but the price in the request was $218.44. Why the discrepancy?

Notes on what I've figured out

adithyabsk commented 1 year ago

Hi @abhmul, that's interesting! Right now, this project is in maintainance mode and is accepting contributions. Robinhood does not have a documented API as such and will require reverse engineering to figure out both the endpoints and the payloads.

If this feature is of interest to you please submit a PR and I'll review and merge.

jhirschibar commented 1 year ago

You can find your retirement account numbers by examining your retirement account statement. It is in the top right corner. The API endpoints in pyrh work well when substituting in the retirement account number in place of the default brokerage account number

Jamonek commented 1 year ago

I'll work on documenting changes required over the coming weeks.

jhirschibar commented 1 year ago

I'm working on some tools too that I may end up pushing. I look forward to your docs

viaConBodhi commented 1 year ago

Started playing around with it and it looks like endpoint + "?account_numbers=YOACT###sGOHERE" is returning data for those accounts. Just started testing but it's looking promising.

mw66 commented 1 year ago

how to programmatically get the retirement account number?

mw66 commented 1 year ago

@abhmul

Can you show some code snippets on how to "send requests with the account number in the payload", e.g. when placing an order?

Thanks?

jhirschibar commented 1 year ago

how to programmatically get the retirement account number?

I've not found a way as of yet, only via account statement so far

viaConBodhi commented 1 year ago

@mw66 easiest way to get your act# is to get it from the reports/statement pdf. Haven't tried submitting an order so not sure. After authenticating in the variable "rh", and making sure you've imported the request, json and pandas libraries, you can use the endpoint in the url.py file in this project to build a call like

df = pd.DataFrame(rh.session.get('https://api.robinhood.com/orders/?account_numbers=YOUR-ACT-#-HERE').json()['results'])

and this will return a DF with your info. They may use the same variable "account_numbers" for the submitting order payload but haven't tested yet. You could prob look at the traffic or just update the code and test trying to buy something for a $1 to see if it processes. Let us know your findings if you do.

joortcom commented 11 months ago

FYI: robin_stocks support multiple Retirement accounts:

https://github.com/jmfernandes/robin_stocks/pull/377 https://github.com/jmfernandes/robin_stocks/pull/387

stale[bot] commented 4 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.