luno

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2018 License: MIT Imports: 16 Imported by: 39

README

Luno API GoDoc Build Status

This Go package provides a wrapper for the Luno API.

Documentation

Please visit godoc.org for the full package documentation.

Installation
go get github.com/luno/luno-go
Authentication

Please visit the Settings page to generate an API key.

Example usage
import luno "github.com/luno/luno-go"

lunoClient := luno.NewClient()
lunoClient.SetAuth("api_key_id", "api_key_secret")

req := luno.GetOrderBookRequest{Pair: "XBTZAR"}
res, err := lunoClient.GetOrderBook(&req)
if err != nil {
  log.Fatal(err)
}
log.Println(res)
License

MIT

Documentation

Overview

Package luno is a wrapper for the Luno API.

Index

Constants

View Source
const Version = "0.0.4"

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountBalance

type AccountBalance struct {
	AccountId   string          `json:"account_id"`
	Asset       string          `json:"asset"`
	Balance     decimal.Decimal `json:"balance"`
	Name        string          `json:"name"`
	Reserved    decimal.Decimal `json:"reserved"`
	Unconfirmed decimal.Decimal `json:"unconfirmed"`
}

type AccountCapabilities

type AccountCapabilities struct {
	CanBuy        bool `json:"can_buy"`
	CanDeposit    bool `json:"can_deposit"`
	CanReceive    bool `json:"can_receive"`
	CanSell       bool `json:"can_sell"`
	CanSend       bool `json:"can_send"`
	CanSocialSend bool `json:"can_social_send"`
	CanWithdraw   bool `json:"can_withdraw"`
}

type CancelWithdrawalRequest

type CancelWithdrawalRequest struct {
	// ID of the withdrawal to cancel.
	//
	// required: true
	Id string `json:"id" url:"id"`
}

CancelWithdrawalRequest is the request struct for CancelWithdrawal.

type CancelWithdrawalResponse

type CancelWithdrawalResponse struct {
	Amount    decimal.Decimal `json:"amount"`
	CreatedAt Time            `json:"created_at"`
	Currency  string          `json:"currency"`
	Fee       decimal.Decimal `json:"fee"`
	Id        string          `json:"id"`
	Status    string          `json:"status"`
	Type      string          `json:"type"`
}

CancelWithdrawalResponse is the response struct for CancelWithdrawal.

type Client

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

Client is a Luno API client.

func NewClient

func NewClient() *Client

NewClient creates a new Luno API client with the default base URL.

func (*Client) CancelWithdrawal

func (cl *Client) CancelWithdrawal(ctx context.Context, req *CancelWithdrawalRequest) (*CancelWithdrawalResponse, error)

CancelWithdrawal makes a call to DELETE /api/1/withdrawals/{id}.

Cancel a withdrawal request. This can only be done if the request is still in state <code>PENDING</code>.

Permissions required: <code>Perm_W_Withdrawals</code>

func (*Client) CreateAccount

func (cl *Client) CreateAccount(ctx context.Context, req *CreateAccountRequest) (*CreateAccountResponse, error)

CreateAccount makes a call to POST /api/1/accounts.

Create an additional account for the specified currency.

Permissions required: <code>Perm_W_Addresses</code>

func (*Client) CreateFundingAddress

func (cl *Client) CreateFundingAddress(ctx context.Context, req *CreateFundingAddressRequest) (*CreateFundingAddressResponse, error)

CreateFundingAddress makes a call to POST /api/1/funding_address.

Allocates a new receive address to your account. There is a rate limit of 1 address per hour, but bursts of up to 10 addresses are allowed. Only 1 Ethereum receive address can be created.

Permissions required: <code>Perm_W_Addresses</code>

func (*Client) CreateQuote

func (cl *Client) CreateQuote(ctx context.Context, req *CreateQuoteRequest) (*CreateQuoteResponse, error)

CreateQuote makes a call to POST /api/1/quotes.

Creates a new quote to buy or sell a particular amount.

You can specify either the exact amount that you want to pay or the exact amount that you want too receive.

For example, to buy exactly 0.1 Bitcoin using ZAR, you would create a quote to BUY 0.1 XBTZAR. The returned quote includes the appropriate ZAR amount. To buy Bitcoin using exactly ZAR 100, you would create a quote to SELL 100 ZARXBT. The returned quote specifies the Bitcoin as the counter amount that will be returned.

An error is returned if your account is not verified for the currency pair, or if your account would have insufficient balance to ever exercise the quote.

Permissions required: <code>Perm_W_Orders</code>

func (*Client) CreateWithdrawal

func (cl *Client) CreateWithdrawal(ctx context.Context, req *CreateWithdrawalRequest) (*CreateWithdrawalResponse, error)

CreateWithdrawal makes a call to POST /api/1/withdrawals.

Creates a new withdrawal request.

Permissions required: <code>Perm_W_Withdrawals</code>

func (*Client) DiscardQuote

func (cl *Client) DiscardQuote(ctx context.Context, req *DiscardQuoteRequest) (*DiscardQuoteResponse, error)

DiscardQuote makes a call to DELETE /api/1/quotes/{id}.

Discard a quote. Once a quote has been discarded, it cannot be exercised even if it has not expired yet.

Permissions required: <code>Perm_W_Orders</code>

func (*Client) ExerciseQuote

func (cl *Client) ExerciseQuote(ctx context.Context, req *ExerciseQuoteRequest) (*ExerciseQuoteResponse, error)

ExerciseQuote makes a call to PUT /api/1/quotes/{id}.

Exercise a quote to perform the trade. If there is sufficient balance available in your account, it will be debited and the counter amount credited.

An error is returned if the quote has expired or if you have insufficient available balance.

Permissions required: <code>Perm_W_Orders</code>

func (*Client) GetBalances

func (cl *Client) GetBalances(ctx context.Context, req *GetBalancesRequest) (*GetBalancesResponse, error)

GetBalances makes a call to GET /api/1/balance.

Return the list of all accounts and their respective balances.

Permissions required: <code>Perm_R_Balance</code>

func (*Client) GetFeeInfo

func (cl *Client) GetFeeInfo(ctx context.Context, req *GetFeeInfoRequest) (*GetFeeInfoResponse, error)

GetFeeInfo makes a call to GET /api/1/fee_info.

Returns your fees and 30 day trading volume (as of midnight) for a given pair.

Permissions required: <code>Perm_R_Orders</code>

func (*Client) GetFundingAddress

func (cl *Client) GetFundingAddress(ctx context.Context, req *GetFundingAddressRequest) (*GetFundingAddressResponse, error)

GetFundingAddress makes a call to GET /api/1/funding_address.

Returns the default receive address associated with your account and the amount received via the address. You can specify an optional address parameter to return information for a non-default receive address. In the response, total_received is the total confirmed Bitcoin amount received excluding unconfirmed transactions. total_unconfirmed is the total sum of unconfirmed receive transactions.

Permissions required: <code>Perm_R_Addresses</code>

func (*Client) GetOrder

func (cl *Client) GetOrder(ctx context.Context, req *GetOrderRequest) (*GetOrderResponse, error)

GetOrder makes a call to GET /api/1/orders/{id}.

Get an order by its ID.

Permissions required: <code>Perm_R_Orders</code>

func (*Client) GetOrderBook

func (cl *Client) GetOrderBook(ctx context.Context, req *GetOrderBookRequest) (*GetOrderBookResponse, error)

GetOrderBook makes a call to GET /api/1/orderbook_top.

Returns a list of the top 100 bids and asks in the order book. Ask orders are sorted by price ascending. Bid orders are sorted by price descending. Orders of the same price are aggregated.

func (*Client) GetOrderBookFull added in v0.0.3

func (cl *Client) GetOrderBookFull(ctx context.Context, req *GetOrderBookFullRequest) (*GetOrderBookFullResponse, error)

GetOrderBookFull makes a call to GET /api/1/orderbook.

Returns a list of all bids and asks in the order book. Ask orders are sorted by price ascending. Bid orders are sorted by price descending. Multiple orders at the same price are not aggregated.

Warning: This may return a large amount of data. Generally you should rather use GetOrderBook or the Streaming API.

func (*Client) GetQuote

func (cl *Client) GetQuote(ctx context.Context, req *GetQuoteRequest) (*GetQuoteResponse, error)

GetQuote makes a call to GET /api/1/quotes/{id}.

Get the latest status of a quote.

Permissions required: <code>Perm_R_Orders</code>

func (*Client) GetTicker

func (cl *Client) GetTicker(ctx context.Context, req *GetTickerRequest) (*GetTickerResponse, error)

GetTicker makes a call to GET /api/1/ticker.

Returns the latest ticker indicators.

func (*Client) GetTickers

func (cl *Client) GetTickers(ctx context.Context, req *GetTickersRequest) (*GetTickersResponse, error)

GetTickers makes a call to GET /api/1/tickers.

Returns the latest ticker indicators from all active Luno exchanges.

func (*Client) GetWithdrawal

func (cl *Client) GetWithdrawal(ctx context.Context, req *GetWithdrawalRequest) (*GetWithdrawalResponse, error)

GetWithdrawal makes a call to GET /api/1/withdrawals/{id}.

Returns the status of a particular withdrawal request.

Permissions required: <code>Perm_R_Withdrawals</code>

func (*Client) ListOrders

func (cl *Client) ListOrders(ctx context.Context, req *ListOrdersRequest) (*ListOrdersResponse, error)

ListOrders makes a call to GET /api/1/listorders.

Returns a list of the most recently placed orders. You can specify an optional <code>state=PENDING</code> parameter to restrict the results to only open orders. You can also specify the market by using the optional pair parameter. The list is truncated after 100 items.

Permissions required: <code>Perm_R_Orders</code>

func (*Client) ListPendingTransactions

ListPendingTransactions makes a call to GET /api/1/accounts/{id}/pending.

Return a list of all pending transactions related to the account.

Unlike account entries, pending transactions are not numbered, and may be reordered, deleted or updated at any time.

Permissions required: <code>Perm_R_Transactions</code>

func (*Client) ListTrades

func (cl *Client) ListTrades(ctx context.Context, req *ListTradesRequest) (*ListTradesResponse, error)

ListTrades makes a call to GET /api/1/trades.

Returns a list of the most recent trades. At most 100 results are returned per call.

func (*Client) ListTransactions

func (cl *Client) ListTransactions(ctx context.Context, req *ListTransactionsRequest) (*ListTransactionsResponse, error)

ListTransactions makes a call to GET /api/1/accounts/{id}/transactions.

Return a list of transaction entries from an account.

Transaction entry rows are numbered sequentially starting from 1, where 1 is the oldest entry. The range of rows to return are specified with the <code>min_row</code> (inclusive) and <code>max_row</code> (exclusive) parameters. At most 1000 rows can be requested per call.

If <code>min_row</code> or <code>max_row</code> is non-positive, the range wraps around the most recent row. For example, to fetch the 100 most recent rows, use <code>min_row=-100</code> and <code>max_row=0</code>.

Permissions required: <code>Perm_R_Transactions</code>

func (*Client) ListUserTrades

func (cl *Client) ListUserTrades(ctx context.Context, req *ListUserTradesRequest) (*ListUserTradesResponse, error)

ListUserTrades makes a call to GET /api/1/listtrades.

Returns a list of your recent trades for a given pair, sorted by oldest first.

<code>type</code> in the response indicates the type of order that you placed in order to participate in the trade. Possible types: <code>BID</code>, <code>ASK</code>.

If <code>is_buy</code> in the response is true, then the order which completed the trade (market taker) was a bid order.

Results of this query may lag behind the latest data.

Permissions required: <code>Perm_R_Orders</code>

func (*Client) ListWithdrawals

func (cl *Client) ListWithdrawals(ctx context.Context, req *ListWithdrawalsRequest) (*ListWithdrawalsResponse, error)

ListWithdrawals makes a call to GET /api/1/withdrawals.

Returns a list of withdrawal requests.

Permissions required: <code>Perm_R_Withdrawals</code>

func (*Client) PostLimitOrder

func (cl *Client) PostLimitOrder(ctx context.Context, req *PostLimitOrderRequest) (*PostLimitOrderResponse, error)

PostLimitOrder makes a call to POST /api/1/postorder.

Create a new trade order.

Warning! Orders cannot be reversed once they have executed. Please ensure your program has been thoroughly tested before submitting orders.

If no <code>base_account_id</code> or <code>counter_account_id</code> are specified, your default base currency or counter currency account will be used. You can find your account IDs by calling the <a href="#operation/getBalances">Balances</a> API.

Permissions required: <code>Perm_W_Orders</code>

func (*Client) PostMarketOrder

func (cl *Client) PostMarketOrder(ctx context.Context, req *PostMarketOrderRequest) (*PostMarketOrderResponse, error)

PostMarketOrder makes a call to POST /api/1/marketorder.

Create a new market order.

A market order executes immediately, and either buys as much Bitcoin or Ethereum that can be bought for a set amount of fiat currency, or sells a set amount of Bitcoin or Ethereum for as much fiat as possible.

Warning! Orders cannot be reversed once they have executed. Please ensure your program has been thoroughly tested before submitting orders.

If no base_account_id or counter_account_id are specified, your default base currency or counter currency account will be used. You can find your account IDs by calling the <a href="#operation/getBalances">Balances</a> API.

Permissions required: <code>Perm_W_Orders</code>

func (*Client) Send

func (cl *Client) Send(ctx context.Context, req *SendRequest) (*SendResponse, error)

Send makes a call to POST /api/1/send.

Send Bitcoin from your account to a Bitcoin address or email address. Send Ethereum from your account to an Ethereum address.

If the email address is not associated with an existing Luno account, an invitation to create an account and claim the funds will be sent.

Warning! Digital currency transactions are irreversible. Please ensure your program has been thoroughly tested before using this call.

Permissions required: <code>Perm_W_Send</code>

func (*Client) SetAuth

func (cl *Client) SetAuth(apiKeyID, apiKeySecret string) error

SetAuth provides the client with an API key and secret.

func (*Client) SetBaseURL

func (cl *Client) SetBaseURL(baseURL string)

SetBaseURL overrides the default base URL. For internal use.

func (*Client) SetDebug

func (cl *Client) SetDebug(debug bool)

SetDebug enables or disables debug mode. In debug mode, HTTP requests and responses will be logged.

func (*Client) SetHTTPClient added in v0.0.3

func (cl *Client) SetHTTPClient(httpClient *http.Client)

SetHTTPClient sets the HTTP client that will be used for API calls.

func (*Client) SetTimeout

func (cl *Client) SetTimeout(timeout time.Duration)

SetTimeout sets the timeout for requests made by this client. Note: if you set a timeout and then call .SetHTTPClient(), the timeout in the new HTTP client will be used.

func (*Client) StopOrder

func (cl *Client) StopOrder(ctx context.Context, req *StopOrderRequest) (*StopOrderResponse, error)

StopOrder makes a call to POST /api/1/stoporder.

Request to stop an order.

Permissions required: <code>Perm_W_Orders</code>

type CreateAccountRequest

type CreateAccountRequest struct {
	// The currency code for the account you want to create
	//
	// You must be verified to trade currency in order to be able to create an
	// account. A user has a limit of 4 accounts per currency.
	//
	// required: true
	Currency string `json:"currency" url:"currency"`

	// The label to use for this account
	//
	// required: true
	Name string `json:"name" url:"name"`
}

CreateAccountRequest is the request struct for CreateAccount.

type CreateAccountResponse

type CreateAccountResponse struct {
	Balance          AccountBalance      `json:"balance"`
	Capabilities     AccountCapabilities `json:"capabilities"`
	Currency         string              `json:"currency"`
	Icon             string              `json:"icon"`
	Id               string              `json:"id"`
	IsDefault        bool                `json:"is_default"`
	Name             string              `json:"name"`
	Pending          []Transaction       `json:"pending"`
	ReceiveAddresses []ReceiveAddress    `json:"receive_addresses"`
	Transactions     []Transaction       `json:"transactions"`
}

CreateAccountResponse is the response struct for CreateAccount.

type CreateFundingAddressRequest

type CreateFundingAddressRequest struct {
	// Currency code of the asset.
	//
	// required: true
	Asset string `json:"asset" url:"asset"`

	// An optional name for the new address
	Name string `json:"name" url:"name"`
}

CreateFundingAddressRequest is the request struct for CreateFundingAddress.

type CreateFundingAddressResponse

type CreateFundingAddressResponse struct {
	AccountId        string          `json:"account_id"`
	Address          string          `json:"address"`
	Asset            string          `json:"asset"`
	AssignedAt       Time            `json:"assigned_at"`
	Name             string          `json:"name"`
	ReceiveFee       decimal.Decimal `json:"receive_fee"`
	TotalReceived    decimal.Decimal `json:"total_received"`
	TotalUnconfirmed decimal.Decimal `json:"total_unconfirmed"`
}

CreateFundingAddressResponse is the response struct for CreateFundingAddress.

type CreateQuoteRequest

type CreateQuoteRequest struct {
	// Amount to buy or sell in the pair base currency.
	//
	// required: true
	BaseAmount decimal.Decimal `json:"base_amount" url:"base_amount"`

	// Currency pair to trade. The pair can also be flipped if you want to buy
	// or sell the counter currency (e.g. ZARXBT).
	//
	// required: true
	Pair string `json:"pair" url:"pair"`

	// <code>BUY</code> or <code>SELL</code>.
	//
	// required: true
	Type string `json:"type" url:"type"`

	// Optional account for the pair's base currency.
	BaseAccountId string `json:"base_account_id" url:"base_account_id"`

	// Optional account for the pair's counter currency.
	CounterAccountId string `json:"counter_account_id" url:"counter_account_id"`
}

CreateQuoteRequest is the request struct for CreateQuote.

type CreateQuoteResponse

type CreateQuoteResponse struct {
	BaseAmount    decimal.Decimal `json:"base_amount"`
	CounterAmount decimal.Decimal `json:"counter_amount"`
	CreatedAt     Time            `json:"created_at"`
	Discarded     bool            `json:"discarded"`
	Exercised     bool            `json:"exercised"`
	ExpiresAt     Time            `json:"expires_at"`
	Id            string          `json:"id"`
	Pair          string          `json:"pair"`
	Type          string          `json:"type"`
}

CreateQuoteResponse is the response struct for CreateQuote.

type CreateWithdrawalRequest

type CreateWithdrawalRequest struct {
	// Amount to withdraw. The currency depends on the type.
	//
	// required: true
	Amount decimal.Decimal `json:"amount" url:"amount"`

	// Withdrawal type.
	//
	// required: true
	Type string `json:"type" url:"type"`

	// The beneficiary ID of the bank account the withdrawal will be paid out
	// to. This parameter is required if you have multiple bank accounts. Your
	// bank account beneficiary ID can be found by clicking on the beneficiary
	// name on the <a href="/wallet/beneficiaries">Beneficiaries</a> page.
	BeneficiaryId string `json:"beneficiary_id" url:"beneficiary_id"`

	// For internal use.
	Reference string `json:"reference" url:"reference"`
}

CreateWithdrawalRequest is the request struct for CreateWithdrawal.

type CreateWithdrawalResponse

type CreateWithdrawalResponse struct {
	Amount    decimal.Decimal `json:"amount"`
	CreatedAt Time            `json:"created_at"`
	Currency  string          `json:"currency"`
	Fee       decimal.Decimal `json:"fee"`
	Id        string          `json:"id"`
	Status    string          `json:"status"`
	Type      string          `json:"type"`
}

CreateWithdrawalResponse is the response struct for CreateWithdrawal.

type DiscardQuoteRequest

type DiscardQuoteRequest struct {
	// ID of the quote to discard.
	//
	// required: true
	Id string `json:"id" url:"id"`
}

DiscardQuoteRequest is the request struct for DiscardQuote.

type DiscardQuoteResponse

type DiscardQuoteResponse struct {
	BaseAmount    decimal.Decimal `json:"base_amount"`
	CounterAmount decimal.Decimal `json:"counter_amount"`
	CreatedAt     Time            `json:"created_at"`
	Discarded     bool            `json:"discarded"`
	Exercised     bool            `json:"exercised"`
	ExpiresAt     Time            `json:"expires_at"`
	Id            string          `json:"id"`
	Pair          string          `json:"pair"`
	Type          string          `json:"type"`
}

DiscardQuoteResponse is the response struct for DiscardQuote.

type Error

type Error struct {
	// Code can be used to identify errors even if the error message is
	// localised.
	Code string `json:"error_code"`

	// Message may be localised for authenticated API calls.
	Message string `json:"error"`
}

Error is a Luno API error.

func (*Error) Error

func (e *Error) Error() string

type ExerciseQuoteRequest

type ExerciseQuoteRequest struct {
	// ID of the quote to exercise.
	//
	// required: true
	Id string `json:"id" url:"id"`
}

ExerciseQuoteRequest is the request struct for ExerciseQuote.

type ExerciseQuoteResponse

type ExerciseQuoteResponse struct {
	BaseAmount    decimal.Decimal `json:"base_amount"`
	CounterAmount decimal.Decimal `json:"counter_amount"`
	CreatedAt     Time            `json:"created_at"`
	Discarded     bool            `json:"discarded"`
	Exercised     bool            `json:"exercised"`
	ExpiresAt     Time            `json:"expires_at"`
	Id            string          `json:"id"`
	Pair          string          `json:"pair"`
	Type          string          `json:"type"`
}

ExerciseQuoteResponse is the response struct for ExerciseQuote.

type GetBalancesRequest

type GetBalancesRequest struct {
	// Only return balances for wallets with these currencies (if not provided,
	// all balances will be returned)
	Assets []string `json:"assets" url:"assets"`
}

GetBalancesRequest is the request struct for GetBalances.

type GetBalancesResponse

type GetBalancesResponse struct {
	Balance []AccountBalance `json:"balance"`
}

GetBalancesResponse is the response struct for GetBalances.

type GetFeeInfoRequest

type GetFeeInfoRequest struct {
	// Get fee information about this pair.
	//
	// required: true
	Pair string `json:"pair" url:"pair"`
}

GetFeeInfoRequest is the request struct for GetFeeInfo.

type GetFeeInfoResponse

type GetFeeInfoResponse struct {
	MakerFee        string `json:"maker_fee"`
	TakerFee        string `json:"taker_fee"`
	ThirtyDayVolume string `json:"thirty_day_volume"`
}

GetFeeInfoResponse is the response struct for GetFeeInfo.

type GetFundingAddressRequest

type GetFundingAddressRequest struct {
	// Currency code of the asset.
	//
	// required: true
	Asset string `json:"asset" url:"asset"`

	// Specific Bitcoin or Ethereum address to retrieve. If not provided, the
	// default address will be used.
	Address string `json:"address" url:"address"`
}

GetFundingAddressRequest is the request struct for GetFundingAddress.

type GetFundingAddressResponse

type GetFundingAddressResponse struct {
	AccountId        string          `json:"account_id"`
	Address          string          `json:"address"`
	Asset            string          `json:"asset"`
	AssignedAt       Time            `json:"assigned_at"`
	Name             string          `json:"name"`
	ReceiveFee       decimal.Decimal `json:"receive_fee"`
	TotalReceived    decimal.Decimal `json:"total_received"`
	TotalUnconfirmed decimal.Decimal `json:"total_unconfirmed"`
}

GetFundingAddressResponse is the response struct for GetFundingAddress.

type GetOrderBookFullRequest added in v0.0.3

type GetOrderBookFullRequest struct {
	// Currency pair
	//
	// required: true
	Pair string `json:"pair" url:"pair"`
}

GetOrderBookFullRequest is the request struct for GetOrderBookFull.

type GetOrderBookFullResponse added in v0.0.3

type GetOrderBookFullResponse struct {
	Asks      []OrderBookEntry `json:"asks"`
	Bids      []OrderBookEntry `json:"bids"`
	Timestamp int64            `json:"timestamp"`
}

GetOrderBookFullResponse is the response struct for GetOrderBookFull.

type GetOrderBookRequest

type GetOrderBookRequest struct {
	// Currency pair
	//
	// required: true
	Pair string `json:"pair" url:"pair"`
}

GetOrderBookRequest is the request struct for GetOrderBook.

type GetOrderBookResponse

type GetOrderBookResponse struct {
	Asks      []OrderBookEntry `json:"asks"`
	Bids      []OrderBookEntry `json:"bids"`
	Timestamp int64            `json:"timestamp"`
}

GetOrderBookResponse is the response struct for GetOrderBook.

type GetOrderRequest

type GetOrderRequest struct {
	// The order ID.
	//
	// required: true
	Id string `json:"id" url:"id"`
}

GetOrderRequest is the request struct for GetOrder.

type GetOrderResponse

type GetOrderResponse struct {
	Base                decimal.Decimal `json:"base"`
	CompletedTimestamp  Time            `json:"completed_timestamp"`
	Counter             decimal.Decimal `json:"counter"`
	CreationTimestamp   Time            `json:"creation_timestamp"`
	ExpirationTimestamp Time            `json:"expiration_timestamp"`
	FeeBase             decimal.Decimal `json:"fee_base"`
	FeeCounter          decimal.Decimal `json:"fee_counter"`
	LimitPrice          decimal.Decimal `json:"limit_price"`
	LimitVolume         decimal.Decimal `json:"limit_volume"`
	OrderId             string          `json:"order_id"`

	// Specifies the market.
	Pair string `json:"pair"`

	// <code>PENDING</code> The order has been placed. Some trades may have
	// taken place but the order is not filled yet.<br>
	// <code>COMPLETE</code> The order is no longer active. It has been settled
	// or has been cancelled.
	State OrderState `json:"state"`

	// <code>BID</code> bid (buy) limit order.<br>
	// <code>ASK</code> ask (sell) limit order.
	Type OrderType `json:"type"`
}

GetOrderResponse is the response struct for GetOrder.

type GetQuoteRequest

type GetQuoteRequest struct {
	// ID of the quote to retrieve.
	//
	// required: true
	Id string `json:"id" url:"id"`
}

GetQuoteRequest is the request struct for GetQuote.

type GetQuoteResponse

type GetQuoteResponse struct {
	BaseAmount    decimal.Decimal `json:"base_amount"`
	CounterAmount decimal.Decimal `json:"counter_amount"`
	CreatedAt     Time            `json:"created_at"`
	Discarded     bool            `json:"discarded"`
	Exercised     bool            `json:"exercised"`
	ExpiresAt     Time            `json:"expires_at"`
	Id            string          `json:"id"`
	Pair          string          `json:"pair"`
	Type          string          `json:"type"`
}

GetQuoteResponse is the response struct for GetQuote.

type GetTickerRequest

type GetTickerRequest struct {
	// Currency pair
	//
	// required: true
	Pair string `json:"pair" url:"pair"`
}

GetTickerRequest is the request struct for GetTicker.

type GetTickerResponse

type GetTickerResponse struct {
	Ask                 decimal.Decimal `json:"ask"`
	Bid                 decimal.Decimal `json:"bid"`
	LastTrade           decimal.Decimal `json:"last_trade"`
	Pair                string          `json:"pair"`
	Rolling24HourVolume decimal.Decimal `json:"rolling_24_hour_volume"`
	Timestamp           Time            `json:"timestamp"`
}

GetTickerResponse is the response struct for GetTicker.

type GetTickersRequest

type GetTickersRequest struct {
}

GetTickersRequest is the request struct for GetTickers.

type GetTickersResponse

type GetTickersResponse struct {
	Tickers []Ticker `json:"tickers"`
}

GetTickersResponse is the response struct for GetTickers.

type GetWithdrawalRequest

type GetWithdrawalRequest struct {
	// Withdrawal ID to retrieve.
	//
	// required: true
	Id string `json:"id" url:"id"`
}

GetWithdrawalRequest is the request struct for GetWithdrawal.

type GetWithdrawalResponse

type GetWithdrawalResponse struct {
	Amount    decimal.Decimal `json:"amount"`
	CreatedAt Time            `json:"created_at"`
	Currency  string          `json:"currency"`
	Fee       decimal.Decimal `json:"fee"`
	Id        string          `json:"id"`
	Status    string          `json:"status"`
	Type      string          `json:"type"`
}

GetWithdrawalResponse is the response struct for GetWithdrawal.

type ListOrdersRequest

type ListOrdersRequest struct {
	// Filter to orders created before this timestamp (Unix milliseconds)
	CreatedBefore int64 `json:"created_before" url:"created_before"`

	// Limit to this many orders
	Limit int64 `json:"limit" url:"limit"`

	// Filter to only orders of this currency pair
	Pair string `json:"pair" url:"pair"`

	// Filter to only orders of this state
	State OrderState `json:"state" url:"state"`
}

ListOrdersRequest is the request struct for ListOrders.

type ListOrdersResponse

type ListOrdersResponse struct {
	Orders []Order `json:"orders"`
}

ListOrdersResponse is the response struct for ListOrders.

type ListPendingTransactionsRequest

type ListPendingTransactionsRequest struct {
	// Account ID
	//
	// required: true
	Id string `json:"id" url:"id"`
}

ListPendingTransactionsRequest is the request struct for ListPendingTransactions.

type ListPendingTransactionsResponse

type ListPendingTransactionsResponse struct {
	Balance          AccountBalance      `json:"balance"`
	Capabilities     AccountCapabilities `json:"capabilities"`
	Currency         string              `json:"currency"`
	Icon             string              `json:"icon"`
	Id               string              `json:"id"`
	IsDefault        bool                `json:"is_default"`
	Name             string              `json:"name"`
	Pending          []Transaction       `json:"pending"`
	ReceiveAddresses []ReceiveAddress    `json:"receive_addresses"`
	Transactions     []Transaction       `json:"transactions"`
}

ListPendingTransactionsResponse is the response struct for ListPendingTransactions.

type ListTradesRequest

type ListTradesRequest struct {
	// Currency pair
	//
	// required: true
	Pair string `json:"pair" url:"pair"`

	// Fetch trades executed after this time, specified as a Unix timestamp in
	// milliseconds.
	Since Time `json:"since" url:"since"`
}

ListTradesRequest is the request struct for ListTrades.

type ListTradesResponse

type ListTradesResponse struct {
	Trades []Trade `json:"trades"`
}

ListTradesResponse is the response struct for ListTrades.

type ListTransactionsRequest

type ListTransactionsRequest struct {
	// Account ID
	//
	// required: true
	Id string `json:"id" url:"id"`

	// Maximum of the row range to return (exclusive)
	//
	// required: true
	MaxRow int64 `json:"max_row" url:"max_row"`

	// Minimum of the row range to return (inclusive)
	//
	// required: true
	MinRow int64 `json:"min_row" url:"min_row"`
}

ListTransactionsRequest is the request struct for ListTransactions.

type ListTransactionsResponse

type ListTransactionsResponse struct {
	Balance          AccountBalance      `json:"balance"`
	Capabilities     AccountCapabilities `json:"capabilities"`
	Currency         string              `json:"currency"`
	Icon             string              `json:"icon"`
	Id               string              `json:"id"`
	IsDefault        bool                `json:"is_default"`
	Name             string              `json:"name"`
	Pending          []Transaction       `json:"pending"`
	ReceiveAddresses []ReceiveAddress    `json:"receive_addresses"`
	Transactions     []Transaction       `json:"transactions"`
}

ListTransactionsResponse is the response struct for ListTransactions.

type ListUserTradesRequest

type ListUserTradesRequest struct {
	// Filter to trades of this currency pair.
	//
	// required: true
	Pair string `json:"pair" url:"pair"`

	// Limit to this number of trades (default 100).
	Limit int64 `json:"limit" url:"limit"`

	// Filter to trades on or after this timestamp.
	Since Time `json:"since" url:"since"`
}

ListUserTradesRequest is the request struct for ListUserTrades.

type ListUserTradesResponse

type ListUserTradesResponse struct {
	Trades []Trade `json:"trades"`
}

ListUserTradesResponse is the response struct for ListUserTrades.

type ListWithdrawalsRequest

type ListWithdrawalsRequest struct {
}

ListWithdrawalsRequest is the request struct for ListWithdrawals.

type ListWithdrawalsResponse

type ListWithdrawalsResponse struct {
	Withdrawals []Withdrawal `json:"withdrawals"`
}

ListWithdrawalsResponse is the response struct for ListWithdrawals.

type Order

type Order struct {
	Base                decimal.Decimal `json:"base"`
	CompletedTimestamp  Time            `json:"completed_timestamp"`
	Counter             decimal.Decimal `json:"counter"`
	CreationTimestamp   Time            `json:"creation_timestamp"`
	ExpirationTimestamp Time            `json:"expiration_timestamp"`
	FeeBase             decimal.Decimal `json:"fee_base"`
	FeeCounter          decimal.Decimal `json:"fee_counter"`
	LimitPrice          decimal.Decimal `json:"limit_price"`
	LimitVolume         decimal.Decimal `json:"limit_volume"`
	OrderId             string          `json:"order_id"`

	// Specifies the market.
	Pair string `json:"pair"`

	// <code>PENDING</code> The order has been placed. Some trades may have
	// taken place but the order is not filled yet.<br>
	// <code>COMPLETE</code> The order is no longer active. It has been settled
	// or has been cancelled.
	State OrderState `json:"state"`

	// <code>BID</code> bid (buy) limit order.<br>
	// <code>ASK</code> ask (sell) limit order.
	Type OrderType `json:"type"`
}

type OrderBookEntry

type OrderBookEntry struct {
	Price  decimal.Decimal `json:"price"`
	Volume decimal.Decimal `json:"volume"`
}

type OrderState

type OrderState string
const (
	OrderStateComplete OrderState = "COMPLETE"
	OrderStatePending  OrderState = "PENDING"
)

type OrderType

type OrderType string
const (
	OrderTypeAsk  OrderType = "ASK"
	OrderTypeBid  OrderType = "BID"
	OrderTypeBuy  OrderType = "BUY"
	OrderTypeSell OrderType = "SELL"
)

type PostLimitOrderRequest

type PostLimitOrderRequest struct {
	// The currency pair to trade.
	//
	// required: true
	Pair string `json:"pair" url:"pair"`

	// Limit price as a decimal string in units of ZAR/BTC.
	//
	// required: true
	Price decimal.Decimal `json:"price" url:"price"`

	// <code>BID</code> for a bid (buy) limit order<br>
	// <code>ASK</code> for ab ask (sell) limit order
	//
	// required: true
	Type OrderType `json:"type" url:"type"`

	// Amount of Bitcoin or Ethereum to buy or sell as a decimal string in units
	// of the currency.
	//
	// required: true
	Volume decimal.Decimal `json:"volume" url:"volume"`

	// The base currency account to use in the trade.
	BaseAccountId string `json:"base_account_id" url:"base_account_id"`

	// The counter currency account to use in the trade.
	CounterAccountId string `json:"counter_account_id" url:"counter_account_id"`

	// Post-only orders will be cancelled if they would otherwise have traded
	// immediately. For example, if there's a bid at ZAR 100,000 and you place
	// a post-only ask at ZAR 100,000, your order will be cancelled instead of
	// trading. If the best bid is ZAR 100,000 and you place a post-only ask at
	// ZAR 101,000, your order won't trade but will go into the order book.
	PostOnly bool `json:"post_only" url:"post_only"`
}

PostLimitOrderRequest is the request struct for PostLimitOrder.

type PostLimitOrderResponse

type PostLimitOrderResponse struct {
	OrderId string `json:"order_id"`
}

PostLimitOrderResponse is the response struct for PostLimitOrder.

type PostMarketOrderRequest

type PostMarketOrderRequest struct {
	// The currency pair to trade.
	//
	// required: true
	Pair string `json:"pair" url:"pair"`

	// <code>BUY</code> to buy Bitcoin or Ethereum<br>
	// <code>SELL</code> to sell Bitcoin or Ethereum
	//
	// required: true
	Type OrderType `json:"type" url:"type"`

	// The base currency account to use in the trade.
	BaseAccountId string `json:"base_account_id" url:"base_account_id"`

	// For a <code>SELL</code> order: amount of Bitcoin to sell as a decimal
	// string in units of BTC or ETH.
	BaseVolume decimal.Decimal `json:"base_volume" url:"base_volume"`

	// The counter currency account to use in the trade.
	CounterAccountId string `json:"counter_account_id" url:"counter_account_id"`

	// For a <code>BUY</code> order: amount of local currency (e.g. ZAR, MYR) to
	// spend as a decimal string in units of the local currency.
	CounterVolume decimal.Decimal `json:"counter_volume" url:"counter_volume"`
}

PostMarketOrderRequest is the request struct for PostMarketOrder.

type PostMarketOrderResponse

type PostMarketOrderResponse struct {
	OrderId string `json:"order_id"`
}

PostMarketOrderResponse is the response struct for PostMarketOrder.

type ReceiveAddress

type ReceiveAddress struct {
	AccountId        string          `json:"account_id"`
	Address          string          `json:"address"`
	Asset            string          `json:"asset"`
	AssignedAt       Time            `json:"assigned_at"`
	Name             string          `json:"name"`
	ReceiveFee       decimal.Decimal `json:"receive_fee"`
	TotalReceived    decimal.Decimal `json:"total_received"`
	TotalUnconfirmed decimal.Decimal `json:"total_unconfirmed"`
}

type SendRequest

type SendRequest struct {
	// Destination Bitcoin address or email address, or Ethereum address to send
	// to.
	//
	// Note:
	// <ul>
	// <li>Ethereum addresses must be
	// <a href="https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md" target="_blank" rel="nofollow">checksummed</a>.</li>
	// <li>Ethereum sends to email addresses are not supported.</li>
	// </ul>
	//
	// required: true
	Address string `json:"address" url:"address"`

	// Amount to send as a decimal string.
	//
	// required: true
	Amount decimal.Decimal `json:"amount" url:"amount"`

	// Currency to send.
	//
	// required: true
	Currency string `json:"currency" url:"currency"`

	// Description for the transaction to record on the account statement.
	Description string `json:"description" url:"description"`

	// Message to send to the recipient. This is only relevant when sending to
	// an email address.
	Message string `json:"message" url:"message"`
}

SendRequest is the request struct for Send.

type SendResponse

type SendResponse struct {
	Success      bool   `json:"success"`
	WithdrawalId string `json:"withdrawal_id"`
}

SendResponse is the response struct for Send.

type StopOrderRequest

type StopOrderRequest struct {
	// The order reference as a string.
	//
	// required: true
	OrderId string `json:"order_id" url:"order_id"`
}

StopOrderRequest is the request struct for StopOrder.

type StopOrderResponse

type StopOrderResponse struct {
	Success bool `json:"success"`
}

StopOrderResponse is the response struct for StopOrder.

type Ticker

type Ticker struct {
	Ask                 decimal.Decimal `json:"ask"`
	Bid                 decimal.Decimal `json:"bid"`
	LastTrade           decimal.Decimal `json:"last_trade"`
	Pair                string          `json:"pair"`
	Rolling24HourVolume decimal.Decimal `json:"rolling_24_hour_volume"`
	Timestamp           Time            `json:"timestamp"`
}

type Time

type Time time.Time

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (Time) String

func (t Time) String() string

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

type Trade

type Trade struct {
	Base       decimal.Decimal `json:"base"`
	Counter    decimal.Decimal `json:"counter"`
	FeeBase    decimal.Decimal `json:"fee_base"`
	FeeCounter decimal.Decimal `json:"fee_counter"`
	IsBuy      bool            `json:"is_buy"`
	OrderId    string          `json:"order_id"`
	Pair       string          `json:"pair"`
	Price      decimal.Decimal `json:"price"`
	Timestamp  Time            `json:"timestamp"`
	Type       OrderType       `json:"type"`
	Volume     decimal.Decimal `json:"volume"`
}

type Transaction

type Transaction struct {
	AccountId      string          `json:"account_id"`
	Available      decimal.Decimal `json:"available"`
	AvailableDelta decimal.Decimal `json:"available_delta"`
	Balance        decimal.Decimal `json:"balance"`

	// Transaction amounts computed for convenience.
	BalanceDelta decimal.Decimal `json:"balance_delta"`
	Currency     string          `json:"currency"`

	// Human-readable description of the transaction.
	Description string `json:"description"`
	RowIndex    int64  `json:"row_index"`
	Timestamp   Time   `json:"timestamp"`
}

type Withdrawal

type Withdrawal struct {
	Amount    decimal.Decimal `json:"amount"`
	CreatedAt Time            `json:"created_at"`
	Currency  string          `json:"currency"`
	Fee       decimal.Decimal `json:"fee"`
	Id        string          `json:"id"`
	Status    string          `json:"status"`
	Type      string          `json:"type"`
}

Directories

Path Synopsis
examples
Package streaming implements a client for the Luno Streaming API.
Package streaming implements a client for the Luno Streaming API.

Jump to

Keyboard shortcuts

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