knitr::opts_chunk$set(
  warning = FALSE,
  message = FALSE,
  fig.path = "man/figures/README-",
  fig.align = "center",
  out.width = "100%",
  collapse = TRUE,
  comment = "#>"
)

rucoin

Lifecycle: experimental Travis build status

Installation

You can install the development version of rucoin using:

# install.packages("remotes")
remotes::install_github("bagasbgy/rucoin")

Getting Started

First of all, let's start by importing the library:

# import library
library(rucoin)

API Authorization

Some function in this package requires private access and need a proper API key, secret, and passphrase. If you don't have any, or need more information, please visit the Generating an API Key{target="_blank} section in the official API documentation.

Current functions that need API authorization are:

Setting-up API Key

To setup the API, the recommended way is using .Renviron file, which could be conveniently done using usethis::edit_r_environ(){target="_blank"}:

# you can also use `scope = "project"` for local environment
usethis::edit_r_environ(scope = "user")

In the .Renviron file, insert your API key details as follow:

KC-API-KEY = XXXXXXXXXX
KC-API-SECRET = XXXXXXXXXX
KC-API-PASSPHRASE = XXXXXXXXXX

Market Data

All market data is publicly accessible, and could be accessed without API authorization.

For getting historical data, you can use get_kucoin_prices():

# get one pair of symbol prices
prices <- get_kucoin_prices(
  symbols = "KCS/USDT",
  from = "2019-06-01 00:00:00",
  to = "2019-06-02 00:00:00",
  frequency = "1 hour"
)

# quick check
prices

The get_kucoin_prices() function also support for querying multiple symbols:

# get one pair of symbol prices
prices <- get_kucoin_prices(
  symbols = c("KCS/USDT", "BTC/USDT", "KCS/BTC"),
  from = "2019-06-01 00:00:00",
  to = "2019-06-02 00:00:00",
  frequency = "1 hour"
)

# quick check
prices

You can also get the most recent metadata for all symbols using get_kucoin_symbols():

# get all symbols' most recent metadata
metadata <- get_kucoin_symbols()

# quick check
metadata

Get User Information

All user information data is private, and need API authorization.

To get the balance information, you can use get_kucoin_balance():

# get user's balance details
balances <- get_kucoin_balances()

# quick check
balances

Post an Order

All order posting functions are private, and need API authorization.

Market Order

Here is an example of posting a market order:

# post a market order: buy 1 KCS
order_detail <- post_kucoin_market_order(
  symbol = "KCS/BTC",
  side = "buy",
  base_size = 1
)

# quick check
order_detail


bagasbgy/rucoin documentation built on Jan. 1, 2020, 8:34 p.m.