robinhood-unofficial / pyrh

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

How can I see how much buying power I have? #70

Closed Njreardo closed 6 years ago

Njreardo commented 6 years ago

Is there a way to do this with this API?

bdowling commented 6 years ago

It is available as buying_power in rh.get_account(), with more details in margin_balances

#!/usr/bin/env python3

from Robinhood import Robinhood
import json

# load username and password
from userInfo import username,password

#Setup
rh = Robinhood();
#login
rh.login(username=username, password=password)

account = rh.get_account()
portfolio = rh.portfolios()
positoons = rh.positions()

print("Account", json.dumps(account,indent=3))
print("Portfolio", json.dumps(portfolio,indent=3))
print("Positions", json.dumps(positions,indent=3))
justin-pierce commented 6 years ago

Just wanted to note that, at least when I compared the numbers provided in my own account, "Buying power" in the RH app is actually "unallocated_margin_cash" under "margin_balances" in get_account() response. At least for a margin account (might be different for cash account). I'm actually not sure what the "buying_power" value is yet.

edit: to clarify, "buying_power" overstated my buying power relative to what the app says.