## Not run:
# ## define source
# # define wallets on markets
# market.sources <- list(
# list(market = 'bitstamp', currency_pair = c('BTC', 'USD'),
# client_id = '', key = '', secret = ''),
# list(market = 'btce', currency_pair = c('LTC', 'USD'),
# key = '', secret = ''),
# list(market = 'btce', currency_pair = c('LTC', 'USD'),
# key = '', secret = ''), #multiple accounts on same market possible
# list(market = 'kraken', currency_pair = c('BTC', 'EUR'),
# key = '', secret = '')
# )
# # define wallets on blockchain
# blockchain.sources <- list(
# list(address = ''),
# list(address = '')
# )
# # define wallets manually
# manual.sources <- list(
# list(location = 'while transferring',
# currency = c('BTC','LTC'),
# amount = c(0.08, 0)),
# # manually provided value as workaround for bitstamp api unavailability captcha bug
# list(location = 'bitstamp',
# location_type = 'market'
# currency = c('USD','BTC'),
# amount = c(50,0.012))
# )
#
# ## launch wallet manager with no value calculation
# wallet_dt <- wallet_manager(market.sources,
# blockchain.sources,
# manual.sources,
# value_calc = FALSE)
# print(wallet_dt)
#
# ## launch wallet manager
# wallet_dt <- wallet_manager(
# market.sources = market.sources,
# blockchain.sources = blockchain.sources,
# manual.sources = manual.sources,
# value_currency = 'GBP',
# rate_priority = c('bitstamp','kraken','bitmarket','btce')
# archive_write = TRUE
# )
# print(wallet_dt)
#
# # export to excel/google spreadsheet
# setkey(wallet_dt,wallet_id,currency) #sort
# write.table(wallet_dt, "clipboard", sep="\t", row.names=FALSE, na = "")
# # now go to excel or google spreadsheet and use "paste" from clipboard
#
# # aggregate measures by currency and type
# wallet_dt[,list(amount = sum(amount, na.rm=T),
# value = sum(value, na.rm=T)),
# by = c('wallet_id','currency','value_currency')
# ][order(wallet_id,currency,value_currency)]
# # aggregate value by location and type
# wallet_dt[,list(value = sum(value, na.rm=T)),
# by = c('wallet_id','location_type','location')
# ][order(wallet_id,location_type,location)]
#
# # send to plot
# wallet_dt <- wallet_manager(archive_write=F, archive_read=T)
# Rbitcoin.plot(wallet_dt)
#
# # discard processing batch, by id, from wallet archive (will omit on plot)
# dt <- readRDS("wallet_archive.rds")
# dt[wallet_id==1390000000,`:=`(amount = NA_real_, value = NA_real_)]
# saveRDS(dt, "wallet_archive.rds")
#
# # To track exchange rates used set option Rbitcoin.archive_exchange_rate
# options(Rbitcoin.archive_exchange_rate=0)
# wallet_dt <- wallet_manager(market.sources,
# blockchain.sources,
# manual.sources = manual.sources,
# rate_priority = c('bitstamp','kraken','bitmarket','btce')
# archive_write = TRUE)
# # all exchange rate data as dt
# dt <- readRDS("exchange_rate_archive.rds")
# # last exchange rate table as dt
# dt <- readRDS("exchange_rate_archive.rds")[value_rate_id==max(value_rate_id)]
# # save to csv
# write.table(dt, "exchange_rate_archive.csv",
# row.names=FALSE,quote=FALSE,append=FALSE,col.names=TRUE,
# sep=";", dec=",")
# ## End(Not run)
Run the code above in your browser using DataLab