-
Notifications
You must be signed in to change notification settings - Fork 602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request Crypto #73
Comments
Until RH releases the API endpoints, it will be pretty hard to add the functionality. Looks like feature will launch in Feb. We're also still waiting for options trading to release properly ¯\_(ツ)_/¯ |
@lockefox Ya, I understand. I am kind of confused though: since the mobile app accesses the price, does that mean it is using part of the API for that? |
I'm expecting drop-in coverage once the feature releases; quotes should still come from But I can't find the tickers after a quick search through the available |
@lockefox So you think the current code would cover it and they would just a new ticker for it? |
🤞 that's the hope. No new endpoints have been added to the top-level of the REST API, and quoting like any other stock would be the easiest route. If not, extending searches to a second endpoint shouldn't be difficult. And if you can't wait, services like CryptoCompare give you quoting ability today |
Just tested on |
@lockefox I submitted a ticket to RH, we'll see what they say, saw your tweet at them also. |
Looks like the endpoint for crypto currency is /marketdata/forex/quotes/ but I haven't been able to get anything to return outside of Robinhood web. Might be protected via CORS or something. Here's the endpoint that the network is using for Bitcoin for example: And its corresponding response:
|
Just noticed that there is a bunch of instrument information available at this endpoint that I was able to hit and return data from outside robin hood web: https://nummus.robinhood.com/currency_pairs/ And it returns this:
That is at least a start on getting data that can be potentially used to make other calls. |
Here are the APIs for cryptocurrency (you can walk through the crypto scripts): https://github.com/mstrum/robinhood-python#cryptocurrency |
This is on the roadmap |
Really looking forward to this myself. I hope this feature will be added at some point as I've recently taken an interest. |
Hi, I have a working version of crypto-trading on my fork. I could make a pull request if you enjoy the different design choices I made, but if you want to just borrow the relevant crypto-code thats fine as well. |
@josephjaspers I'd love to get more activity and support on that. I'm looking to overhaul the way the project is structured to use marshmallow and proper OO design to make it easier to contribute to. I'll ping you as soon as that structure is done as contributions are most definitely welcome. |
Awesome, sounds good. I do have Quote/Order objects for a little bit of OO-style. |
@jasonleehodges I'm able to get the data using GET on postman but I did have to call the POST endpoint to update my bearer token and then change my request to include the /marketdata/forex/quotes/{id} to include headers. Once that's done, I can access from both Postman and command line/terminal. Here's a snippet of the code although not sure how useful as straight GET request here is since the data is streaming (from polygon.io I believe). Would be better to build this out with a web socket server and treat the request as client to internal server session off of the RH class object (or maybe a new class altogether so we're not instantiating off of the root when not needed; i digress...) #first get your bearer token:
import requests, json
url = 'https://api.robinhood.com/oauth2/token/'
payload = {
"username": "{your_username}",
"password": "{your_password}",
"grant_type": "password",
"client_id": "{your_client_id}",
"expires_in": "86400",
"scope": "internal",
"device_token": "{your_device_token}",
"challenge_type": "411313"
}
headers = {
'Content-Type': 'application/json',
'Content-Type': 'text/plain'
}
p = requests.post(url, headers=headers, data=payload)
'''
sample response from printing p.json() is:
{
"access_token": "{your_access_token}",
"expires_in": 742914,
"token_type": "Bearer",
"scope": "internal",
"refresh_token": "{your_refresh_token}",
"mfa_code": null,
"backup_code": null
}
''' Now that we have the new bearer token, we can call the crypto endpoint as follows: url = "https://api.robinhood.com/marketdata/forex/quotes/3d961844-d360-45fc-989b-f6fca761d511/"
headers = {'Authorization': 'Bearer {your_bearer_token_here}'}
r = requests.get(url, headers=headers)
'''
r.json() in command line/terminal will now return the price:
{
"ask_price": "8665.410000",
"bid_price": "8655.039963",
"mark_price": "8660.224981",
"high_price": "9208.952894",
"low_price": "8037.466209",
"open_price": "8712.055000",
"symbol": "BTCUSD",
"id": "3d961844-d360-45fc-989b-f6fca761d511",
"volume": "0.000000"
}
''' Note: when reverse engineering everything on the front end of the site, the response does include a max lifespan value of "Strict-Transport-Security: max-age=31536000". If anyone ends up wrapping the above in a socket, would need to monitor alive time and reset the conn() accordingly. Just thinking out loud. |
Thank you for creating this! |
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. |
Closing this issue automatically because it has not had any activity since it has been marked as stale. If you think it is still relevant and should be addressed, feel free to open a new one. |
This isn't really an issue, but any chance that crypto will be implemented? I though that maybe getting the price by treating it like a quote ( something like https://api.robinhood.com/quotes/BTC-USD/ ) would work but it doesn't seem to. I tried finding the appropriate API endpoint but can't seem to figure it out. The mobile app must be accessing it somehow though.
I know that trading is not yet allowed for crypto, but even just getting the price right now would be awesome to get a head start on building a bot! Thanks
The text was updated successfully, but these errors were encountered: