novadax

package module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2020 License: GPL-3.0 Imports: 17 Imported by: 0

README

novadax-go

GoDoc

novadax-go is a Go client library for accessing the NovaDAX API v1.

Usage

import "github.com/artemis-tech/novadax-go"

Construct a new NovaDAX client, then use the various services on the client to access different parts of the NovaDAX API. For example:

// LISTING SYMBOLS (PUBLIC ENDPOINT)

import (
    novadax "github.com/artemis-tech/novadax-go"
)

client := novadax.Default()

// list all symbols available at NovaDAX
symbols, err := client.ListSymbols()
// LISTING ORDERS (PRIVATE ENDPOINT, THUS REQUIRE ACCESS AND SECRET KEYS)

import (
    novadax "github.com/artemis-tech/novadax-go"
)

/*
* This configuration is also possible via environment variables, eg.:
* NOVADAX_ACCESS_KEY="5388359-538583-5i9593-3596e0-6ca252484934aa4"
* NOVADAX_SECRET_KEY="nl3KVXiOp4JN74482h4nkahiu5jDKWkKhnMumMy"
*/

// novadax.New("ACCESS_KEY", "PRIVATE_KEY")
client := novadax.New("5388359-538583-5i9593-3596e0-6ca252484934aa4", "nl3KVXiOp4JN74482h4nkahiu5jDKWkKhnMumMy") // fake credentials here, just maintained a similar pattern to the actual data

// list all symbols available at NovaDAX
symbols, err := client.ListOreders()
Rate Limiting

NovaDAX imposes a rate limit on all API clients. Public endpoints are limited to 60 requests per second, while private endpoints can be invoked up to 20 requests per second.

Learn more about NovaDAX rate limiting at https://doc.novadax.com/pt-BR/#comunicacao-com-a-api.

Integration Tests

TODO: implement tests

Contributing

I would like to cover the entire NovaDAX API and contributions are of course always welcome. The calling pattern is pretty well established, so adding new methods is relatively straightforward.

TODO: Contribution doc.

License

This library is distributed under the GPLv3 license found in the LICENSE file.

Documentation

Index

Constants

View Source
const StatusCode = 0

StatusCode stands for the resp.Status code index

Variables

This section is empty.

Functions

func MD5Digest added in v0.0.3

func MD5Digest(s *string) string

MD5Digest returns a string digested MD5 hash

Types

type CancelResponse added in v0.0.3

type CancelResponse struct {
	Code    string       `json:"code"`
	Result  CancelResult `json:"data"`
	Message string       `json:"message"`
}

type CancelResult added in v0.0.3

type CancelResult struct {
	Success bool `json:"result"`
}

type Client

type Client struct {
	Config    *Config
	BaseURL   *url.URL
	UserAgent string
	// contains filtered or unexported fields
}

Client stands for the NovaDAX API HTTP client

func Default

func Default() *Client

Default returns a new default instance of NovaDAX API http client

func New

func New(accessKey string, privateKey string) *Client

New returns a new instance of NovaDAX API http client

func (*Client) AccountSubs added in v0.0.3

func (client *Client) AccountSubs() ([]*SubAccount, error)

AccountSubs returns current available sub accounts for NovaDAX

func (*Client) CancelOrder added in v0.0.3

func (client *Client) CancelOrder(ID string) (bool, error)

func (*Client) CreateMarketBuyOrder added in v0.0.4

func (client *Client) CreateMarketBuyOrder(order *MarketBuyOrder) (*OrderDetails, error)

CreateMarketBuyOrder creates a new market buy order and return it's details

func (*Client) CreateOrder added in v0.0.3

func (client *Client) CreateOrder(order *Order) (*OrderDetails, error)

CreateOrder creates a new order and return it's details

func (*Client) GetLatestTickers added in v0.0.2

func (client *Client) GetLatestTickers(filters *GetLatestMarketTickersFilters) ([]*MarketTicker, error)

GetLatestTickers returns latest market tickers for all key pairs in NovaDAX

func (*Client) GetMarketDepth added in v0.0.5

func (client *Client) GetMarketDepth(filters *GetMarketDepthFilters) (*MarketDepth, error)

GetMarketDepth returns limit orders for a key pair in NovaDAX

func (*Client) GetOrderDetails added in v0.0.3

func (client *Client) GetOrderDetails(ID string) (*OrderDetails, error)

func (*Client) ListOrders

func (client *Client) ListOrders(filters *ListOrdersFilters) ([]*OrderDetails, error)

ListOrders returns current market orders based on filters

func (*Client) ListSymbols

func (client *Client) ListSymbols() ([]*Symbol, error)

ListSymbols returns current available symbols for NovaDAX

type Config

type Config struct {
	AccessKey  string
	PrivateKey string
}

Config stands for the NovaDAX API config

type GetLatestMarketTickersFilters added in v0.0.5

type GetLatestMarketTickersFilters struct {
	Symbol string `json:"symbol"`
}

GetLatestMarketTickersFilters stands for the GetLatestTickers possible and required filters

type GetLatestMarketTickersResponse added in v0.0.2

type GetLatestMarketTickersResponse struct {
	Code          string          `json:"code"`
	MarketTickers []*MarketTicker `json:"data"`
	Message       string          `json:"message"`
}

GetLatestMarketTickersResponse stands for the response structure for latest market tickers API endpoint

type GetMarketDepthFilters added in v0.0.5

type GetMarketDepthFilters struct {
	Symbol string `json:"symbol"`
	Limit  int    `json:"limit"`
}

GetMarketDepthFilters stands for the GetLatestTickers possible and required filters

type GetMarketDepthResponse added in v0.0.5

type GetMarketDepthResponse struct {
	Code        string       `json:"code"`
	MarketDepth *MarketDepth `json:"data"`
	Message     string       `json:"message"`
}

GetMarketDepthResponse stands for the response structure for market depth API endpoint

type GetOrderDetailsFilters added in v0.0.3

type GetOrderDetailsFilters struct {
	ID string `json:"id"`
}

type ListAccountSubs added in v0.0.3

type ListAccountSubs struct {
	Code        string        `json:"code"`
	SubAccounts []*SubAccount `json:"data"`
	Message     string        `json:"message"`
}

ListAccountSubs stands for the response structure for sub accounts listing API endpoint

type ListOrdersFilters

type ListOrdersFilters struct {
	Symbol        string `json:"symbol"`
	Status        string `json:"status"`
	FromID        string `json:"fromId"`
	ToID          string `json:"toId"`
	FromTimestamp int64  `json:"fromTimestamp"`
	ToTimestamp   int64  `json:"toTimestamp"`
	Limit         int    `json:"limit"`
}

ListOrdersFilters stands for the ListOrders possible and required filters

type ListSymbolsResponse

type ListSymbolsResponse struct {
	Code    string    `json:"code"`
	Symbols []*Symbol `json:"data"`
}

ListSymbolsResponse stands for the response structure for symbol listing API endpoint

type MarketBuyOrder added in v0.0.4

type MarketBuyOrder struct {
	Symbol    string `json:"symbol"`
	Type      string `json:"type"`
	Side      string `json:"side"`
	Price     string `json:"price,omitempty"`
	AccountID string `json:"accountId,omitempty"`
	Value     string `json:"value"`
}

MarketBuyOrder stands for the market buy order to be sent to NovaDAX

type MarketDepth added in v0.0.5

type MarketDepth struct {
	Asks      [][]string `json:"asks"` // 0 for price and 1 for amount
	Bids      [][]string `json:"bids"` // 0 for price and 1 for amount
	Timestamp int64      `json:"timestamp"`
}

MarketDepth stands for the NovaDAX API market depth resource

type MarketTicker added in v0.0.2

type MarketTicker struct {
	Ask            string `json:"ask"`
	BaseVolume24h  string `json:"baseVolume24h"`
	Bid            string `json:"bid"`
	High24h        string `json:"high24h"`
	LastPrice      string `json:"lastPrice"`
	Low24h         string `json:"low24h"`
	Open24h        string `json:"open24h"`
	QuoteVolume24h string `json:"quoteVolume24h"`
	Symbol         string `json:"symbol"`
	Timestamp      int64  `json:"timestamp"`
}

MarketTicker stands for the NovaDAX API market ticker resource

type Order

type Order struct {
	Symbol    string `json:"symbol"`
	Type      string `json:"type"`
	Side      string `json:"side"`
	Price     string `json:"price,omitempty"`
	AccountID string `json:"accountId,omitempty"`
	Amount    string `json:"amount"`
}

Order stands for the common order to be sent to NovaDAX

type OrderDetails added in v0.0.3

type OrderDetails struct {
	ID           string `json:"id"`
	Symbol       string `json:"symbol"`
	Type         string `json:"type"`
	Side         string `json:"side"`
	Price        string `json:"price"`
	AveragePrice string `json:"averagePrice"`
	Amount       string `json:"amount"`
	FilledAmount string `json:"filledAmount"`
	Value        string `json:"value"`
	FilledValue  string `json:"filledValue"`
	FilledFee    string `json:"filledFee"`
	Status       string `json:"status"`
	Timestamp    int64  `json:"timestamp"`
}

OrderDetails stands for the order data returned by NovaDAX API

type OrderDetailsResponse added in v0.0.3

type OrderDetailsResponse struct {
	Code         string        `json:"code"`
	OrderDetails *OrderDetails `json:"data"`
}

OrderDetailsResponse returns current orders in NovaDAX

type OrdersDetailsResponse added in v0.0.3

type OrdersDetailsResponse struct {
	Code          string          `json:"code"`
	OrdersDetails []*OrderDetails `json:"data"`
}

OrdersDetailsResponse returns current orders in NovaDAX

type SubAccount added in v0.0.3

type SubAccount struct {
	SubID       string `json:"subId"`
	State       string `json:"state"`
	SubAccount  string `json:"subAccount"`
	SubIdentify string `json:"subIdentify"`
}

SubAccount stands for NovaDAX's sub account resource

type Symbol

type Symbol struct {
	Symbol          string `json:"symbol"`
	BaseCurrency    string `json:"baseCurrency"`
	QuoteCurrency   string `json:"quoteCurrency"`
	AmountPrecision int    `json:"amountPrecision"`
	PricePrecision  int    `json:"pricePrecision"`
	ValuePrecision  int    `json:"valuePrecision"`
	MinOrderAmount  string `json:"minOrderAmount"`
	MinOrderValue   string `json:"minOrderValue"`
}

Symbol stands for NovaDAX's available symbol

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL