knitr::opts_chunk$set( warning = FALSE, message = FALSE, fig.path = "man/figures/README-", fig.align = "center", out.width = "100%", collapse = TRUE, comment = "#>" )
You can install the development version of rucoin
using:
# install.packages("remotes") remotes::install_github("bagasbgy/rucoin")
First of all, let's start by importing the library:
# import library library(rucoin)
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:
post_kucoin_market_order()
get_kucoin_balances()
get_kucoin_order()
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
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
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
All order posting functions are private, and need API authorization.
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.