tkxsdk

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2020 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Tokenize Public API Client

1. Overview

A client for Tokenize Public API implemented in Golang

Note: This package is under development. Current stable version is v0.2.0

2. How to use

Example usage:

  func main() {
    clientID := os.Getenv("CLIENT_ID")
    clientSecret := os.Getenv("CLIENT_SECRET")
    apiBaseURL := "https://api.tokenize-my.com/public/v1"
    
    // Initialize client
    client := tkxsdk.NewAPIClientWithCredentials(apiBaseURL, clientID, clientSecret)

    // Get account info
    info, err := client.AccountAPI.GetAccountInfo()
    if err != nil {
      t.Error(err)
    }
    fmt.Println("Account info:", info)
  }

3. Running tests

To run all test cases:

go test ./test/ -v

To run a single test case:

go test ./test/ -run TestFunctionX -v

To run test with coverage:

go test ./test/ -v --coverprofile coverage.out && go tool cover -html=coverage.out -o coverage.html

4. Contact developers/maintainers:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient struct {
	AccountAPI *AccountAPI
	MarketAPI  *MarketAPI
	OrderAPI   *OrderAPI
	// contains filtered or unexported fields
}

APIClient - APIClient struct

func NewAPIClient

func NewAPIClient(apiBaseURL string) *APIClient

NewAPIClient - APIClient constructor

func NewAPIClientWithCredentials

func NewAPIClientWithCredentials(apiBaseURL, clientID, clientSecret string) *APIClient

NewAPIClientWithCredentials - APIClient factory (create with params)

func (*APIClient) InitSubAPIs

func (c *APIClient) InitSubAPIs()

InitSubAPIs - Initialize sub APIs

type AccountAPI

type AccountAPI struct {
	// contains filtered or unexported fields
}

AccountAPI - AccountAPI struct

func NewAccountAPI

func NewAccountAPI(httpManager *HttpManager) *AccountAPI

NewAccountAPI - AccountAPI constructor

func (*AccountAPI) GetAccountBalanceByCCY

func (api *AccountAPI) GetAccountBalanceByCCY(currency string) (*AccountBalance, error)

GetAccountBalanceByCCY - Use to retrieve the balance from your account for a specified currency. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#get_currency_balances

func (*AccountAPI) GetAccountBalances

func (api *AccountAPI) GetAccountBalances() ([]AccountBalance, error)

GetAccountBalances - Use to retrieve all balances from your account. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#get_account_balances

func (*AccountAPI) GetAccountInfo

func (api *AccountAPI) GetAccountInfo() (*AccountInfo, error)

GetAccountInfo - Use to get your account information. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#get_account_information

func (*AccountAPI) GetDepositAddress

func (api *AccountAPI) GetDepositAddress(currency string) (*DepositAddress, error)

GetDepositAddress - Use to retrieve or generate an address for a specified currency. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#get_deposit_address

type AccountBalance

type AccountBalance struct {
	Currency  string
	Balance   float64
	Available float64
	Pending   float64
	Address   string
}

type AccountInfo

type AccountInfo struct {
	Email                  string
	RegId                  string
	AccountType            string
	IsMobileNumberVerified int
	RoleId                 int
	DigitalTokenTrading    bool
	FiatTrading            bool
	MarginTrading          bool
	DailyWithdrawalLimit   string
	Message                string
}

type ClientCredentials

type ClientCredentials struct {
	ClientID     string
	ClientSecret string
	Token        string
}

ClientCredentials - ClientCredentials struct

type DepositAddress

type DepositAddress struct {
	Currency string
	Address  string
}

type HttpManager

type HttpManager struct {
	// contains filtered or unexported fields
}

HttpManager - HttpManager struct

func NewHttpManager

func NewHttpManager(apiBaseURL string) *HttpManager

NewHttpManager - HttpManager constructor

func (*HttpManager) SetCredentials

func (m *HttpManager) SetCredentials(id, secret string) *HttpManager

SetCredentials - Set client's credentials (id + secret)

type HttpResponseAccountBalance

type HttpResponseAccountBalance struct {
	Message string
	Status  string
	Data    *AccountBalance
}

type HttpResponseAccountBalances

type HttpResponseAccountBalances struct {
	Message string
	Status  string
	Data    []AccountBalance
}

type HttpResponseAccountInfo

type HttpResponseAccountInfo struct {
	Message string
	Status  string
	Data    *AccountInfo
}

type HttpResponseCancelOrder

type HttpResponseCancelOrder struct {
	Message string
	Status  string
	Data    bool
}

type HttpResponseGetCandles

type HttpResponseGetCandles struct {
	Message string
	Status  string
	Data    []MarketCandleRaw
}

type HttpResponseGetDepositAddress

type HttpResponseGetDepositAddress struct {
	Message string
	Status  string
	Data    *DepositAddress
}

type HttpResponseGetLastMarketPrice

type HttpResponseGetLastMarketPrice struct {
	Message string
	Status  string
	Data    *MarketPrice
}

type HttpResponseGetMarketAvgPrice

type HttpResponseGetMarketAvgPrice struct {
	Message string
	Status  string
	Data    *MarketAvgPrice
}

type HttpResponseGetMarketHistory

type HttpResponseGetMarketHistory struct {
	Message string
	Status  string
	Data    []MarketHistoryRecord
}

type HttpResponseGetMarketSummaries

type HttpResponseGetMarketSummaries struct {
	Message string
	Status  string
	Data    []MarketSummary
}

type HttpResponseGetMarketTicker

type HttpResponseGetMarketTicker struct {
	Message string
	Status  string
	Data    *MarketTicker
}

type HttpResponseGetMarketTicker24h

type HttpResponseGetMarketTicker24h struct {
	Message string
	Status  string
	Data    *MarketTicker24h
}

type HttpResponseGetMarkets

type HttpResponseGetMarkets struct {
	Message string
	Status  string
	Data    []MarketInfo
}

type HttpResponseGetOrderDetail

type HttpResponseGetOrderDetail struct {
	Message string
	Status  string
	Data    *OrderDetail
}

type HttpResponseMarketOrders

type HttpResponseMarketOrders struct {
	Message string
	Status  string
	Data    *MarketOrderData
}

type HttpResponseMyOrders

type HttpResponseMyOrders struct {
	Message string
	Status  string
	Data    []MyOrder
}

type HttpResponseOrderBook

type HttpResponseOrderBook struct {
	Message string
	Status  string
	Data    *OrderBookData
}

type HttpResponsePlaceOrder

type HttpResponsePlaceOrder struct {
	Message string
	Status  string
	Data    *PlacedOrder
}

type MarketAPI

type MarketAPI struct {
	// contains filtered or unexported fields
}

MarketAPI - MarketAPI struct

func NewMarketAPI

func NewMarketAPI(httpManager *HttpManager) *MarketAPI

NewMarketAPI - MarketAPI constructor

func (*MarketAPI) GetCandles

func (api *MarketAPI) GetCandles(market string, resolution string, from, to int) ([]MarketCandle, error)

GetCandles - The Candles endpoint provides chart candles for a specified time frame and period. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#get_candlestick

func (*MarketAPI) GetLastMarketPrice

func (api *MarketAPI) GetLastMarketPrice(market string) (*MarketPrice, error)

GetLastMarketPrice - Get last price of the given market. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#get_last_market_price

func (*MarketAPI) GetMarketBuyOrders

func (api *MarketAPI) GetMarketBuyOrders(market string) ([]MarketOrder, error)

GetMarketBuyOrders - Get all currently buy orders in Tokenize specified by market. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#get_market_buy_orders

func (*MarketAPI) GetMarketCurrentAveragePrice

func (api *MarketAPI) GetMarketCurrentAveragePrice(market string) (*MarketAvgPrice, error)

GetMarketCurrentAveragePrice - Get the current average price for specified market. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#get_current_average_price

func (*MarketAPI) GetMarketOrderBook

func (api *MarketAPI) GetMarketOrderBook(market string, orderType string, limit int) (*OrderBookData, error)

GetMarketOrderBook - Allow you to keep track of the state of Tokenize order books on a price aggregated basis with customizable precision. @params: - market [string] (required): The market, eg: "MYR-BTC"; - orderType [string] (optional): "buy" | "sell" | "both" | ""; - limit [int]: Limit numbers of order book to return. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#get_order_book

func (*MarketAPI) GetMarketSellOrders

func (api *MarketAPI) GetMarketSellOrders(market string) ([]MarketOrder, error)

GetMarketSellOrders - Get all currently sell orders in Tokenize specified by market. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#get_market_sell_orders

func (*MarketAPI) GetMarketSummaries

func (api *MarketAPI) GetMarketSummaries() ([]MarketSummary, error)

GetMarketSummaries - Used to get the last 24 hour summary of all active markets. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#get_market_summaries

func (*MarketAPI) GetMarketTicker

func (api *MarketAPI) GetMarketTicker(market string) (*MarketTicker, error)

GetMarketTicker - Get ticker for specified market. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#get_ticker_market

func (*MarketAPI) GetMarketTicker24h

func (api *MarketAPI) GetMarketTicker24h(market string) (*MarketTicker24h, error)

GetMarketTicker24h - Get statistics change price of a market. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#get_24h_change_price

func (*MarketAPI) GetMarkets

func (api *MarketAPI) GetMarkets() ([]MarketInfo, error)

GetMarkets - Used to get the open and available trading markets at Tokenize along with other meta data. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#market_information

func (*MarketAPI) GetRawCandles

func (api *MarketAPI) GetRawCandles(market string, resolution string, from, to int) ([]MarketCandleRaw, error)

GetRawCandles - Get raw candle data returned from API. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#get_candlestick

func (*MarketAPI) GetTradeHistory

func (api *MarketAPI) GetTradeHistory(market string, limit int) ([]MarketHistoryRecord, error)

GetTradeHistory - Allows the retrieval of past public trades and includes details such as price, size, and time. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#get_trades_histories

type MarketAvgPrice

type MarketAvgPrice struct {
	Market   string
	AvgPrice float64
}

type MarketCandle

type MarketCandle struct {
	OpenTime int
	Open     float64
	Close    float64
	High     float64
	Low      float64
	Volume   float64
}

type MarketCandleRaw

type MarketCandleRaw = [6]interface{}

type MarketDetail

type MarketDetail struct {
	MarketID           string
	MarketName         string
	BaseCurrency       string
	MarketCurrency     string
	MarketCurrencyLong string
	Status             string
	Ceiling            string
	Floor              string
}

type MarketHistoryRecord

type MarketHistoryRecord struct {
	Timestamp int
	Type      string
	Amount    float64
	Price     float64
	Total     float64
}

type MarketInfo

type MarketInfo struct {
	Title string
	List  []MarketDetail
}

type MarketOrder

type MarketOrder struct {
	Quantity float64
	Rate     float64
	Total    float64
	Sum      float64
}

type MarketOrderData

type MarketOrderData struct {
	Market string
	Orders []MarketOrder
}

type MarketPrice

type MarketPrice struct {
	Market     string
	BaseAsset  string
	QuoteAsset string
	LastPrice  string
	PrevPrice  string
}

type MarketSummary

type MarketSummary struct {
	MarketID  int
	Market    string
	Status    string
	AskPrice  float64
	BidPrice  float64
	LastPrice float64
	OpenPrice float64
	PrevPrice float64
	High      float64
	Low       float64
	Volume    float64
}

type MarketTicker

type MarketTicker struct {
	Market     string
	BaseAsset  string
	QuoteAsset string
	LastPrice  string
	BidPrice   float64
	BidQty     float64
	AskPrice   float64
	AskQty     float64
}

type MarketTicker24h

type MarketTicker24h struct {
	Market    string
	HighPrice float64
	LowPrice  float64
	LastPrice float64
	BidPrice  float64
	AskPrice  float64
	Volume    float64
}

type MyOrder

type MyOrder struct {
	OrderID        int
	Market         string
	Price          float64
	OriginUnits    float64
	FilledUnits    float64
	CommissionPaid float64
	Type           string
	Status         string
}

type OrderAPI

type OrderAPI struct {
	// contains filtered or unexported fields
}

OrderAPI - OrderAPI struct

func NewOrderAPI

func NewOrderAPI(httpManager *HttpManager) *OrderAPI

NewOrderAPI - OrderAPI constructor

func (*OrderAPI) CancelOrder

func (api *OrderAPI) CancelOrder(id int) (bool, error)

CancelOrder - Cancel one order Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#cancel_buy_order

func (*OrderAPI) GetBuyOrderDetail

func (api *OrderAPI) GetBuyOrderDetail(id int) (*OrderDetail, error)

GetBuyOrderDetail - Check your buy order by specified id. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#check_buy_order

func (*OrderAPI) GetMyBuyOrders

func (api *OrderAPI) GetMyBuyOrders(market string) ([]MyOrder, error)

GetMyBuyOrders - Gets all buy orders of this account Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#get_all_your_buy_orders

func (*OrderAPI) GetMyOrders

func (api *OrderAPI) GetMyOrders(market string) ([]MyOrder, error)

GetMyOrders - Get all orders of this account

func (*OrderAPI) GetMyPendingBuyOrders

func (api *OrderAPI) GetMyPendingBuyOrders(market string) ([]MyOrder, error)

GetMyPendingBuyOrders - Gets all PENDING buy orders of this account Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#current_open_your_buy

func (*OrderAPI) GetMyPendingSellOrders

func (api *OrderAPI) GetMyPendingSellOrders(market string) ([]MyOrder, error)

GetMyPendingSellOrders - Gets all PENDING sell orders of this account Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#current_open_your_sell

func (*OrderAPI) GetMySellOrders

func (api *OrderAPI) GetMySellOrders(market string) ([]MyOrder, error)

GetMySellOrders - Gets all sell orders of this account Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#get_all_your_sell_orders

func (*OrderAPI) GetSellOrderDetail

func (api *OrderAPI) GetSellOrderDetail(id int) (*OrderDetail, error)

GetSellOrderDetail - Check your sell order by specified id. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#check_sell_order

func (*OrderAPI) PlaceLimitBuyOrder

func (api *OrderAPI) PlaceLimitBuyOrder(market string, units, price float64) (*PlacedOrder, error)

PlaceLimitBuyOrder - Place a new limit buy order @params: - market [string] (required): The market, eg: "MYR-BTC"; - units [float64] (required): The amount of this order; - price [float64] (required): The price of this order. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#place_buy_order

func (*OrderAPI) PlaceLimitSellOrder

func (api *OrderAPI) PlaceLimitSellOrder(market string, units, price float64) (*PlacedOrder, error)

PlaceLimitSellOrder - Place a new limit sell order @params: - market [string] (required): The market, eg: "MYR-BTC"; - units [float64] (required): The amount of this order; - price [float64] (required): The price of this order. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#place_sell_order

func (*OrderAPI) PlaceMarketBuyOrder

func (api *OrderAPI) PlaceMarketBuyOrder(market string, units float64) (*PlacedOrder, error)

PlaceMarketBuyOrder - Place a new limit buy order @params: - market [string] (required): The market, eg: "MYR-BTC"; - units [float64] (required): The amount of this order. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#place_buy_order

func (*OrderAPI) PlaceMarketSellOrder

func (api *OrderAPI) PlaceMarketSellOrder(market string, units float64) (*PlacedOrder, error)

PlaceMarketSellOrder - Place a new limit sell order @params: - market [string] (required): The market, eg: "MYR-BTC"; - units [float64] (required): The amount of this order. Reference: https://tokenizexchange.zendesk.com/hc/en-gb/articles/360022521593-Developer-s-Guide-API#place_sell_order

type OrderBookData

type OrderBookData struct {
	Buy  []MarketOrder
	Sell []MarketOrder
}

type OrderDetail

type OrderDetail struct {
	OrderID         int
	Side            string
	Market          string
	Status          string
	Type            string
	TransactionTime int
	OriginUnits     float64
	Price           float64
	FilledUnits     float64
	CommissionPaid  float64
	Fills           []OrderFill
}

type OrderFill

type OrderFill struct {
	Price           float64
	Units           float64
	Commission      float64
	CommissionAsset string
}

type PlacedOrder

type PlacedOrder struct {
	OrderID         int
	Market          string
	TransactionTime int
	Price           float64
	OriginUnits     float64
	CommissionPaid  float64
	Type            string
	Status          string
}

type TokenGenerator

type TokenGenerator struct {
}

TokenGenerator - TokenGenerator struct

func (*TokenGenerator) Generate

func (generator *TokenGenerator) Generate(clientID, clientSecret string) (string, error)

Generate - Generate a jwt token

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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