Unified processing of API call according to API dictionary api.dict. Limited to markets and currency processing defined in api.dict, in case of currency pairs and methods not availble in dictionary use market.api.query directly. This function perform pre processing of request and post processing of API call results to unified structure across markets. It will result truncation of most (not common across the markets) attributes returned. If you need the full set of data returned by market's API you should use market.api.query.
character vector of length 2, ex. c(base = 'BTC', quote = 'EUR'). Order does matter.
action
character, defined process to get organized data.
req
list with action details (price, amount, tid, oid, etc.) unified across the markets specific per action, see examples.
...
objects to be passed to market.api.query
auth params: key, secret, client_id (last one used on bitstamp),
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.
on.market.error
expression to be evaluated on market level error. Rules specified in api.dict.
on.error
expression to be evaluated on R level error related to market.api.query. For details read market.api.query.
api.dict
data.table user custom API dictionary definition, if not provided function will use default Rbitcoin api.dict.
raw.query.res
logical skip post-processing are return results only after fromJSON processing. Useful in case of change results structure from market API. It can always be manually post-processed as a workaround till the Rbitcoin update.
Details
To do not spam market's API, use Sys.sleep(10) between API calls.
Value
Returned value depends on the action param. All actions will return market, currency pair (except wallet and open_orders which returns all currencies), R timestamp, market timestamp and below data (in case if market not provide particular data, it will result NA value):
'ticker' returns data.table with fields: last, vwap, volume, ask, bid.
'wallet' returns data.table with fields: currency, amount, fee.
'order_book' returns list with API call level attributes and sub elements [['asks']] and [['bids']] as data.table objects with order book including already calculated cumulative amount, price and value.
'open_orders' returns data.table with fields: oid, type, price, amount.
'place_limit_order' returns data.table with fields: oid, type, price, amount.
'cancel_order' returns data.table with fields: oid.
'trades' returns list with API call level attributes and sub element [['trades']] as data.table (ASC order) with fields: date, price, amount, tid, type.
Note
The api dictionary was not fully tested, please follow the examples, if you find any bugs please report. Use only api dictionary api.dict from trusted source, in case if you use other api.dict it is advised to review pre-process, post-process and catch_market_error functions for markets and currency pairs you are going to use. Market level error handling might not fully work as not all markets returns API call status information.