Skip to content
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

Closed
AustinScola opened this issue Jan 31, 2018 · 19 comments
Closed

Request Crypto #73

AustinScola opened this issue Jan 31, 2018 · 19 comments

Comments

@AustinScola
Copy link

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

@lockefox
Copy link
Contributor

lockefox commented Jan 31, 2018

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 ¯\_(ツ)_/¯

@AustinScola
Copy link
Author

@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?

@lockefox
Copy link
Contributor

I'm expecting drop-in coverage once the feature releases; quotes should still come from instruments.

But I can't find the tickers after a quick search through the available instruments endpoint at this moment

@AustinScola
Copy link
Author

@lockefox So you think the current code would cover it and they would just a new ticker for it?

@lockefox
Copy link
Contributor

🤞 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

@lockefox
Copy link
Contributor

lockefox commented Jan 31, 2018

Just tested on https://api.robinhood.com/quotes/?symbols=ZEC (after seeing this tweet). Also checked through the instruments endpoint and couldn't find anything. And with that UI, we may need to add special crypto logic afterall

@AustinScola
Copy link
Author

@lockefox I submitted a ticket to RH, we'll see what they say, saw your tweet at them also.

@jasonleehodges
Copy link
Collaborator

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:
https://api.robinhood.com/marketdata/forex/quotes/3d961844-d360-45fc-989b-f6fca761d511/

And its corresponding response:

{"ask_price":"7997.0500", "bid_price":"7969.1000", "mark_price":"7983.0750", "high_price":"8130.1600", "low_price":"7752.5200", "open_price":"7988.9100", "symbol":"BTCUSD", "id":"3d961844-d360-45fc-989b-f6fca761d511", "volume":"436655.6481"}

@jasonleehodges
Copy link
Collaborator

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:

{ "asset_currency": { "code": "BTC", "id": "d674efea-e623-4396-9026-39574b92b093", "increment": "0.000000010000000000", "name": "Bitcoin", "type": "cryptocurrency" }, "display_only": false, "id": "3d961844-d360-45fc-989b-f6fca761d511", "max_order_size": "5.0000000000000000", "min_order_size": "0.000010000000000000", "min_order_price_increment": "0.010000000000000000", "min_order_quantity_increment": "0.000000010000000000", "name": "Bitcoin to US Dollar", "quote_currency": { "code": "USD", "id": "1072fc76-1862-41ab-82c2-485837590762", "increment": "0.010000000000000000", "name": "US Dollar", "type": "fiat" }, "symbol": "BTC-USD", "tradability": "tradable" }

That is at least a start on getting data that can be potentially used to make other calls.

@mstrum
Copy link

mstrum commented Apr 11, 2018

Here are the APIs for cryptocurrency (you can walk through the crypto scripts): https://github.com/mstrum/robinhood-python#cryptocurrency

@adithyabsk
Copy link
Member

This is on the roadmap

@emmeowzing
Copy link

emmeowzing commented Apr 6, 2020

Really looking forward to this myself. I hope this feature will be added at some point as I've recently taken an interest.

@josephjaspers
Copy link

Hi, I have a working version of crypto-trading on my fork.
https://github.com/josephjaspers/Robinhood

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.

@adithyabsk
Copy link
Member

@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.

@josephjaspers
Copy link

Awesome, sounds good. I do have Quote/Order objects for a little bit of OO-style.
Excited to see which direction you'll take yours with marshmellow!

@FergusClare
Copy link

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:
https://api.robinhood.com/marketdata/forex/quotes/3d961844-d360-45fc-989b-f6fca761d511/

And its corresponding response:

{"ask_price":"7997.0500", "bid_price":"7969.1000", "mark_price":"7983.0750", "high_price":"8130.1600", "low_price":"7752.5200", "open_price":"7988.9100", "symbol":"BTCUSD", "id":"3d961844-d360-45fc-989b-f6fca761d511", "volume":"436655.6481"}

@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.

@JohnXReed
Copy link

Hi, I have a working version of crypto-trading on my fork.
https://github.com/josephjaspers/Robinhood

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.

Thank you for creating this!

@adithyabsk adithyabsk removed the roadmap label Jan 4, 2023
@stale
Copy link

stale bot commented Mar 18, 2023

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.

@stale stale bot added the stale label Mar 18, 2023
@stale
Copy link

stale bot commented Apr 2, 2023

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.

@stale stale bot closed this as completed Apr 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants