[英]How to get stock rating on Robin_Stocks robin_stocks.stocks.get_ratings function
Peeps, I am using robin_stocks to get stock quotes Robinhood and interested in getting rating of stock using this function: robin_stocks.stocks.get_ratings as follow:偷看,我正在使用 robin_stocks 获取股票报价 Robinhood 并有兴趣使用此函数获取股票评级:robin_stocks.stocks.get_ratings 如下:
quotes = robin_stocks.stocks.get_ratings('AAPL', )
print(quotes)
I get a very long string as follow (cut it short to save space here) :我得到一个很长的字符串如下(把它剪短以节省空间):
{'summary': {'num_buy_ratings': 26, 'num_hold_ratings': 13, 'num_sell_ratings': 3 ....
How can I modify my code to get just the numbers ie 26, 13, and 3 so that I can run my calculations.我如何修改我的代码以获取数字,即 26、13 和 3,以便我可以运行我的计算。
if I use:如果我使用:
quotes = robin_stocks.stocks.get_ratings('AAPL', 'num_buy_ratings')
I get error as follow:我得到如下错误:
Error: The keyword "num_buy_ratings" is not a key in the dictionary.
I am not advance in python, if you can help, I very much appreciate it.我在python方面不是很先进,如果你能帮忙,我非常感谢。 Thanks,
谢谢,
You mentioned on the comment that from:您在评论中提到来自:
quotes = robin_stocks.stocks.get_ratings ('AAPL', 'summary')
you get你得到
{'num_buy_ratings': 26, 'num_hold_ratings': 13, 'num_sell_ratings': 3}
Which means that it is a dict
这意味着它是一个
dict
So if you just want the numbers than you can do:所以如果你只想要数字而不是你可以做的:
quotes = robin_stocks.stocks.get_ratings ('AAPL', 'summary').values()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.