You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Have you considered adding the ability to trade your retirement accounts? Your current account API pull only returns the main account, but if you use https://api.robinhood.com/accounts/?default_to_all_accounts=true then you can see all the accounts. It shows the URL and account number for all three.
You could add an optional argument in the RobinHood login function for account type to specify which account to use and then feed this into other functions. It looks like RH will use the account URL in things like place_order, but then others do a base pull which always defaults to the main account.
The following code will return different results if you look at the outputs. The problem is that you are repulling the account number for most of your functions instead of relying on the RobinHood class function so you would need to rebuild a lot of functions.
New_Robinhood = function(username, password, mfa_code, account_type = 'individual'){
RH <- RobinHood::api_login(username,password,mfa_code)
url = 'https://api.robinhood.com/accounts/?default_to_all_accounts=true'
token <- paste("Bearer", RH$api_response.access_token)
dta <- GET(url, add_headers(Accept = "application/json",
`Content-Type` = "application/json", Authorization = token))
httr::stop_for_status(dta)
dta <- RobinHood::mod_json(dta, "fromJSON")
url_account_id = dta$results$url[dta$results$brokerage_account_type==account_type]
act_number = dta$results$account_number[dta$results$brokerage_account_type==account_type]
RH <- c(RH, url = list(account_id = url_account_id, account_number = act_number))
if (is.null(RH$api_response.access_token)) {
cat("Login not successful, check username and password.")
}
class(RH) <- "RobinHood"
return(RH)
}
### Produces three different outputs
RH1 = New_Robinhood(username,password,mfa_code)
RH2 = New_Robinhood(username,password,mfa_code, account_type = 'ira_roth')
RH3 = New_Robinhood(username,password,mfa_code, account_type = 'ira_traditional')
### This produces same output because of how the helper functions exist
get_accounts(RH1)
get_accounts(RH2)
### place order works naturally because it uses the RH URL, account and positions require the following APIs:
url = 'https://api.robinhood.com/positions/?account_number=XXXXXXXX'
url = 'https://bonfire.robinhood.com/accounts/XXXXXXXX/unified/'
The text was updated successfully, but these errors were encountered:
Have you considered adding the ability to trade your retirement accounts? Your current account API pull only returns the main account, but if you use
https://api.robinhood.com/accounts/?default_to_all_accounts=true
then you can see all the accounts. It shows the URL and account number for all three.You could add an optional argument in the RobinHood login function for account type to specify which account to use and then feed this into other functions. It looks like RH will use the account URL in things like place_order, but then others do a base pull which always defaults to the main account.
The following code will return different results if you look at the outputs. The problem is that you are repulling the account number for most of your functions instead of relying on the RobinHood class function so you would need to rebuild a lot of functions.
The text was updated successfully, but these errors were encountered: