Open Chaneriel opened 2 years ago
New issue to add to this. When retrieving the price of a normal stock (cryptos still aren't working) it is formatted as such 'price'. These apostrophes mean that I cant do addition or multiplication to that number. any way around this
As for your second comment, this is expected behavior. Take a look at the docs at https://robin-stocks.readthedocs.io/en/latest/robinhood.html
price_as_float = float(price_as_string)
@lglista Thx for the help but I still dont know how to get crypto price. rs.stocks.get_latest_price("ETC") does not work. Is there supposed to be a specific command for crypto because I cant find one
Reading through the docs and the source code, there is no one single function to find the latest_price
for a crypto using Robinhood. There is however, one through Gemini that you might be able to use to find a sell price through Robinhood
robin_stocks.robinhood.stocks
does not contain any information on crypto since that module is only for stocks. The module that you want is robin_stocks.robinhood.crypto
crypto_info = robin_stocks.robinhood.crypto.get_crypto_quote('ETH')
should lend you enough information to make a reasonable bid or a reasonable sell. crypto_info
will be a dictionary with the information that you need, I recommend taking a look at the documentation to see what you have, or printing out crypto_info
to see the data that you have.
I cannot help you with finding out what is a reasonable bid or a reasonable sell. However, crypto_info['mark_price']
would be a pretty good bet.
Make sure you take a look at the value that this returns and reference it with the 'price' of the crypto you want to trade.
But if you want to get the price from Gemini, you can use robin_stocks.gemini.crypto.get_price('ETH')
. You will probably need to login to Gemini to access this. There is nothing wrong with using prices from Gemini to sell on Robinhood, cross referencing prices will not hurt you.
@lglista Sorry to ask again but my issue is that the robin_stocks.robinhood.crypto.get_crypto_quote('ETH') returns several numbers. The way I'm using my program requires what that command returns to be a single number, rather than multiple numbers, as the answer is put through an equation. Also when I pull up Gemini and Robinhood at the same time the prices dont line up
Yes, robin_stocks.crypto.get_crypto_quote('ETH')
will return a dictionary of values that correspond to useful information about that crypto. Here is a screenshot of the documentation:
It would benefit you to do some research on crypto markets to figure out what keys would be relevant to your cause. Most likely the keys mark_price
, bid_price
, and ask_price
. Looking at the source code, robin_stocks.crypto does not have a way to get the latest crypto price. So using these values will be your best bet unless you want to trade on gemini.
The prices on Robinhood and Gemini don't line up because they are different exchanges and have different people buying and selling on them. This is different than conventional stock trading since practically all stock trading is all done through the NYSE. However, you would find the same to be true if you looked at the price of GME or another stock in different exchanges.
So when I run current_price = rs.stocks.get_latest_price("ETC") i get the following error; 404 Client Error: Not Found for url: https://api.robinhood.com/quotes/?symbols=ETC. The only other thing I can find that I'm supposed to do is robin_stocks.gemini.crypto.get_price but wtf is gemini