market.api.query: Send request to market API

Description Usage Arguments Details Value Note References See Also Examples

Description

Route a request to particular market function.

Usage

1
2
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.

Details

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

Value

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

Note

It is advised to use this function instead of calling market's function directly. If calling directly one should ensure to send any numeric values in non-exponential notation: options(scipen=100).

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

 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
## 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)

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