Golang library for Kuna.io cryptocurrency market.
Also there is a command line tool (under the cli
directory) which
can be useful to make requests to the Kuna.io API from scripts. Read the
tool documentation at cli/README.md
file.
The Golang client and command line tool are published under the BSD 2 Clause Licence. You can find full license text at https://opensource.org/licenses/BSD-2-Clause or in LICENSE file in the sources tree.
Bitcoin: 1PtgmrQzYNqTCLzGwVc9wVvYFpUU9Esftu
Read the source or use documentation generated by godoc
. Also there is a few
examples below.
make
make test
Before you start, import the library:
import (
"kunaio"
)
List market types supported by the library:
markets := kunaio.SupportedMarkets()
Get kuna.io server time:
t, err := kunaio.GetServerTime()
Get latest market stats:
market := "btcuah"
stats, err := kunaio.GetLatestStats(market)
Get order book:
market := "btcuah"
obook, err := kunaio.GetOrderBook(market)
for _, order := range obook.Bids {
...
}
for _, order := range obook.Asks {
...
}
Get trade history:
market := "btcuah"
history, err := kunaio.GetTradeHistory(market)
for _, hEntry := range history {
...
}
Methods below require authentication tokens.
Get user info and assets:
access_key := "nkfjhwkfhwkrughrekguhekug"
secret_key := "eo328u3bkfbgfu6gdugsyu36t"
userInfo, err := kunaio.GetUserInfo(access_key, secret_key)
for _, account := range userInfo.Accounts {
fmt.Printf("Currency: %s; Balance: %f; Locked: %f\n",
account.Currency, account.Balance, account.Locked)
}
Get list of currently opened user orders:
access_key := "nkfjhwkfhwkrughrekguhekug"
secret_key := "eo328u3bkfbgfu6gdugsyu36t"
market := "btcuah"
orders, err := kunaio.GetUserOrders(access_key, secret_key, market)
for _, order := range orders {
...
}
Get history of user trades:
access_key := "nkfjhwkfhwkrughrekguhekug"
secret_key := "eo328u3bkfbgfu6gdugsyu36t"
market := "btcuah"
orders, err := kunaio.GetUserTrades(access_key, secret_key, market)
for _, deal := range trades {
...
}
Create new order:
access_key := "nkfjhwkfhwkrughrekguhekug"
secret_key := "eo328u3bkfbgfu6gdugsyu36t"
market := "btcuah"
side := "buy"
volume := 0.12345 // bitcoins
price := 100000 // UAH per 1 bitcoin
order, err := kunaio.NewOrder(access_key, secret_key, side, volume, price)
fmt.Printf("Order created: %+v\n", order)
Delete existing order:
access_key := "nkfjhwkfhwkrughrekguhekug"
secret_key := "eo328u3bkfbgfu6gdugsyu36t"
orderID := 555111
order, err := kunaio.CancelOrder(access_key, secret_key, orderID)
fmt.Printf("Order removed: %+v\n", order)
Aleksey Morarash tuxofil@gmail.com, 2017