Open garygause opened 3 years ago
I took a quick look at this. It looks like it is "working", but maybe not(?). Let me try to explain a bit...
The GET Accounts API shows that we will end up with JSON like this:
{
"response": {
"accounts": {
"accountsummary": [
{
"account": ... ,
"accountbalance": { ... },
"accountholdings": { ... }
},
...
]
}
}
}
In our code, we extract the response
and accounts
keys but we do not extract the accountsummary
key. I am not a Pandas expert but I believe this leads to a Pandas DataFrame that has a single row in a single named column accountsummary
with the only cell containing an object-type. I would guess that you could then just cast the value of that cell to another Pandas DataFrame to get a Nx3 matrix where N is the number of accounts you have and the datatypes for the three columns are int, object, object (or similar).
... but wait...
I also saw that it looks like we solve for this by trying to flatten the JSON. When I did my quick investigation, it looked like this flattening was not happening(?). We should build out the unit tests for this function to verify that it is working correctly. I also found a good reference article about this type of scenario (referenced below).
Ref:
I have three ally stock accounts and when running:
a.accounts()
the json data returned by Ally is not parsed properly into a dataframe. It contains only one row/column with all the json data in it. Also, I might expect it to only return info for the account number listed when instantiating the ally object, rather than all accounts.
Works fine with accounts(dataframe=False) but then has to be parsed manually. No big deal, but thought I would point it out.