Rbitcoin.plot: Plot Rbitcoin objects

Description Usage Arguments Value Export input trades, order_book input wallet manager See Also Examples

Description

Generic function to plot different objects returned by some Rbitcoin functions. The plot produce basic visualization of the data. The plots will likely be subject to change in future versions.

Usage

1
2
3
Rbitcoin.plot(x, mask = FALSE, ..., export = FALSE,
  export.args = list(format = "svg", filename = NULL),
  verbose = getOption("Rbitcoin.verbose", 0))

Arguments

x

object to be plotted, result of Rbitcoin function, currently supported: market.api.process with action in c("trades","order_book"), wallet_manager with archive_read = TRUE.

mask

logical, default FALSE, setting TRUE will mask values on wallet manager plot with the ratio of value to the initial value. Use this when you want to share the plot. See examples to mask the bitcoin address.

export

logical default FALSE, if TRUE the plot will be exported to file instead of plot to ploting device.

export.args

list of arguments to be passed to target graphic device function, ex. svg() or png(), list gives the control over width and height which by default for png are quite small. Element export.args[['format']] will be mapped to the function name, by default svg(), any others as its args.

...

additional params to be passed to plot function.

verbose

integer. Rbitcoin processing messages, print to console if verbose > 0, each subfunction reduce verbose by 1. If missing then getOption("Rbitcoin.verbose",0) is used, by default 0.

Value

TRUE

Export

Element format in the export.args list defines the export format, default "svg", tested and supported formats are "svg" and "png", other might work also. To use custom export filename just pass the filename arg to export.args list. By default NULL results timestamped by last wallet_id filename. Use custom export.args[['filename']] with no file extension while declaring. You may notice the legend is different on exported files. The same legend was not scalling well between export to file and plot to interactive device.

input trades, order_book

The plot function for trades, order_book do not process the data, it plot the data as is, so it may result poor visibility due to the data itself (ex. order_book containing asks with enormously high price). See examples how this can be handled.

input wallet manager

To be able to track wallet assets value over time user needs to use archive_write=TRUE at least twice in wallet manager processing (with non-NA measures). Using the cryptocurrency which do not have any exchange path to transfer_currency_pair and/or value_currency will result NA as value. Error on data downloading from external sources (wallets or exchange rates) will also result NA. Any wallet processing batch which will contain at least one NA measure will be omitted from plot. If you have some crypto not currenctly supported you may extend dictionary for more currencies or provide its value as manual source to wallet_manager already calculated in common value currency, remember to comment out the previous source which returns the NA measure.
To plot wallet manager data load wallet archive data, see examples.
Plotting function will produce dashboard panel to track different measures of your assets and its value. Use mask if you want to share the results to somebody, it will overwrite value with value ratio. Target value currency is taken from the last execution of wallet_manager.

See Also

market.api.process, wallet_manager

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
## Not run: 
# plot trades data from kraken's api
trades <- market.api.process('kraken',c('BTC','EUR'),'trades')
Rbitcoin.plot(trades)
Rbitcoin.plot(trades,export=TRUE,col='blue') #export to file, plot trades line in blue

# plot order book data from kraken's api
order_book <- market.api.process('kraken',c('BTC','EUR'),'order_book')
Rbitcoin.plot(order_book)

# plot order book with filtering margins based on order price
order_book <- market.api.process('bitmarket',c('BTC','PLN'),'order_book')
pct <- 0.75
mid <- ((order_book[["asks"]][1,price] + order_book[["bids"]][1,price]) / 2)
order_book[["asks"]] <- order_book[["asks"]][price <= mid * (1+pct)]
order_book[["bids"]] <- order_book[["bids"]][price >= mid * (1-pct)]
Rbitcoin.plot(order_book)

# plot wallet manager data (from local archive) - for details read ?waller_manager
wallet_dt <- wallet_manager(archive_write=F, archive_read=T) #readRDS("wallet_archive.rds")
Rbitcoin.plot(wallet_dt) # plot in R
Rbitcoin.plot(wallet_dt[value>=100 | is.na(value)]) # filter out low value from plot
Rbitcoin.plot(wallet_dt, export=T) # export to svg
# mask value with ratio value and save to png
Rbitcoin.plot(wallet_dt,mask=T,export=T,
              export.args=list(format="png",
                               width = 2*480,
                               height = 2*480,
                               units = "px",
                               pointsize = 18))
# mask value with ratio and mask bitcoin addresses
Rbitcoin.plot(wallet_dt[,.SD][location_type=="blockchain",location := "*address*"],
              mask=T, export=T)

## End(Not run)

Rbitcoin documentation built on May 2, 2019, 3:41 p.m.