Learn R Programming

Rbitcoin (version 0.9.2)

market.api.query: Send request to market API

Description

Route a request to particular market function.

Usage

market.api.query(market, ..., verbose = getOption("Rbitcoin.verbose", 0), on.error = expression(stop(e[["message"]], call. = FALSE)))

Arguments

market
character which identifies market on which we want to send request: bitstamp, btce, kraken, bitmarket.
...
objects to be passed to API: url, key, secret, req, client_id (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.error
expression to be evaluated on R level error of market specific function. It does not catch internal market's error returned as valid object.

Value

R object created by fromJSON decoded result from market's API call.

Details

To do not spam market's API, use Sys.sleep(10) between API calls.

References

API documentation: https://bitbucket.org/nitrous/mtgox-api, https://www.bitstamp.net/api/, https://btc-e.com/api/documentation, https://www.kraken.com/help/api

See Also

market.api.process, market.api.query.bitstamp, market.api.query.btce, market.api.query.kraken, market.api.query.bitmarket, market.api.query.mtgox

Examples

Run this code
## Not run: 
# # ticker
# market.api.query(market = 'bitstamp',
#                  url = 'https://www.bitstamp.net/api/ticker/')
# market.api.query(market = 'btce',
#                  url = 'https://btc-e.com/api/2/btc_usd/ticker')
# market.api.query(market = 'kraken',
#                  url = 'https://api.kraken.com/0/public/Ticker?pair=XXBTZEUR')
# market.api.query(market = 'bitmarket',
#                  url = 'https://www.bitmarket.pl/json/LTCPLN/ticker.json')
# # wallet
# market.api.query(market = 'bitstamp',
#                  url = 'https://www.bitstamp.net/api/balance/',
#                  client_id = '', # bitstamp specific
#                  key = '', secret = '')
# market.api.query(market = 'btce',
#                  url = 'https://btc-e.com/tapi',
#                  req = list(method = 'getInfo'),
#                  key = '', secret = '')
# market.api.query(market = 'kraken',
#                  url = 'https://api.kraken.com/0/private/Balance',
#                  key = '', secret = '')
# market.api.query(market = 'bitmarket',
#                  url = 'https://www.bitmarket.pl/api2/',
#                  req = list(method = 'info'),
#                  key = '', secret = '')
# # order book
# market.api.query(market = 'kraken',
#                  url = 'https://api.kraken.com/0/public/Depth?pair=XXBTZEUR')
# # open orders
# market.api.query(market = 'kraken',
#                  url = 'https://api.kraken.com/0/private/OpenOrders',
#                  key = '', secret = '')
# # place order
# market.api.query(market = 'kraken',
#                  url = 'https://api.kraken.com/0/private/AddOrder',
#                  key = '', secret = '',
#                  req = list(pair = 'XXBTZEUR',
#                             type = 'sell',
#                             ordertype = 'limit',
#                             price = 1200, # 1200 eur
#                             volume = 0.1)) # 0.1 btc
# # cancel order
# market.api.query(market = 'kraken',
#                  url = 'https://api.kraken.com/0/private/CancelOrder',
#                  key = '', secret = '',
#                  req = list(txid = 'id_from_open_orders'))
# # trades
# market.api.query(market = 'kraken',
#                  url = 'https://api.kraken.com/0/public/Trades?pair=XXBTZEUR')
# ## End(Not run)

Run the code above in your browser using DataLab