r - getOptionChain with multiple expiries -
i use r download option chains, via quantmod package. goal download , export option chains in order used on other software.
if download front month expiry, able correctly export .txt file, using these lines:
library(quantmod) aapl_front <- getoptionchain ('aapl') front <- do.call('rbind', aapl_front) write.table (front, 'data_front.txt')
problems appear when download expiries. here rbind
function fails work think should, , export table useless; these lines:
aapl_total <- getoptionchain('aapl', null) total <- do.call('rbind', aapl_total) write.table(total, 'data_total.txt')
i guess in second case aapl_total
list of lists, contains expiries, , i'm not able correctly split them.
any suggestions?
you loop through each expiration , rbind
calls , puts.
lapply(aapl_total, function(x) do.call(rbind, x))
then, you'd have list do.call(rbind())
.
in 1 step:
do.call(rbind, lapply(aapl_total, function(x) do.call(rbind, x)))
Comments
Post a Comment