market.api.query: Send request to market API

Description Usage Arguments Value See Also Examples

Description

Route a request to particular market function according to dictionary query.dict.

Usage

1
2
3
4
5
market.api.query(market, url, ..., antiddos = getOption("Rbitcoin.antiddos",
  TRUE), query.dict = getOption("Rbitcoin.query.dict",
  stop("query.dict is mandatory for redirection to market query function")),
  json.debug = getOption("Rbitcoin.json.debug", FALSE),
  verbose = getOption("Rbitcoin.verbose", 0))

Arguments

market

character which identifies market on which we want to send request, e.g. kraken.

url

character url on which launch api call.

antiddos

logical default TRUE. Default to 10s. To customize read antiddos.

query.dict

data.table default built-in dictionary with market query functions, read query.dict.

json.debug

logical default FALSE. Purely technical, if set to TRUE it will allow to debug case of unknown non-json format returned by market, by saving market response in working directory as timestamped txt file in case of fromJSON error.

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.

...

objects to be passed to api: key, secret, req, client_id (used on bitstamp).

Value

R object created by fromJSON decoded response from markets API call.

See Also

market.api.process, antiddos, query.dict

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
53
54
55
56
57
58
59
60
61
62
## 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/3/ticker/ltc_usd')
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')
market.api.query(market = 'hitbtc',
                 url = 'https://api.hitbtc.com/api/1/public/BTCUSD/ticker')
market.api.query(market = 'btcchina',
                 url = 'https://data.btcchina.com/data/ticker?market=btccny')
# 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 = '')
market.api.query(market = 'hitbtc',
                 url = "https://api.hitbtc.com/api/1/trading/balance",
                 key = '', secret = '')
market.api.query(url = 'https://api.btcc.com/api_trade_v1.php',
                 req = list(method = 'getAccountInfo'),
                 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)

jangorecki/Rbitcoin documentation built on May 18, 2019, 12:24 p.m.