When subsetting my Account Data form the return of
reqAccountUpdates(tws)
to get my Account Details, I get a nice print on the console. But storing in a CSV yields the following error message:
acct_saved <- saveDataToDirectory(accountNumber, tag_acct, acctData) Generated Filename: U7XXXXX9_11062023_acct.csv
Fehler in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) : kann Klasse ‘"eventAccountValue"’ nicht in data.frame umwandeln
This translates to: "Error ... could not convert class 'eventAccountValue
' in a data.frame, hence storing into CSV in a usual way does not work. Is there a workaround to achieve this?
The twsPortfolioValue(tws)
can be stored in CSV easily
The Function
reqAccountDetails()
returns a bunch of data. Applying twsPortfolioValues()
returns my positions which I can store as a .csv.
acctInfo = reqAccountUpdates(tws)
#print(head(acctInfo))
twsPortfolioValue(acctInfo)
When subsetting like
acctData <- acctInfo[[1]]
The console prints a nice table, also typeof(acctData)
reveals it is a list.
> acctData
value currency
AccountCode U7XXXXX9
AccountOrGroup U7XXXXX9 USD
AccountReady true
AccountType INDIVIDUAL
AccruedCash x USD
AccruedDividend x. EUR
AvailableFunds x.xx. EUR
AvailableFunds.S x.xx. EUR
Billable x.xx EUR
BuyingPower x.xx EUR
CashBalance x.xx. USD
...
The conversion to a data frame is an issue
Is there any workaround to get this job done for my account details?
ok, I found a solution. Subsetting like this
instead of
allows to convert into a data frame.
Thanks to @Limey pointing me to check the output of
Showing nested structure of lists.