Documentation
¶
Index ¶
- Constants
- Variables
- func NewClient(opts ...ClientOption) *client
- func NewWSClient(opts ...WebsocketClientOption) (*wsClient, error)
- type API
- type AccountSubscription
- type CallOption
- func AsksLimit(limit int32) CallOption
- func BidsLimit(limit int32) CallOption
- func Currency(currency string) CallOption
- func DepositState(state types.DepositState) CallOption
- func From(from int32) CallOption
- func FromTime(from time.Time) CallOption
- func Limit(limit int32) CallOption
- func Market(market string) CallOption
- func Offset(offset int32) CallOption
- func OrderAsc() CallOption
- func OrderDesc() CallOption
- func OrderSide(t types.OrderSide) CallOption
- func OrderType(t types.OrderType) CallOption
- func OrderTypes(t []types.OrderType) CallOption
- func Page(page int32) CallOption
- func Pagination(pagination bool) CallOption
- func Period(period int32) CallOption
- func PeriodDuration(period time.Duration) CallOption
- func Price(price types.Price) CallOption
- func Prices(prices []types.Price) CallOption
- func StopPrice(price types.Price) CallOption
- func StopPrices(prices []types.Price) CallOption
- func Time(t time.Time) CallOption
- func Timestamp(timestamp int32) CallOption
- func To(to int32) CallOption
- func ToTime(to time.Time) CallOption
- func WithdrawalState(state types.WithdrawalState) CallOption
- type ClientOption
- type Options
- type OrderBookSubscription
- type PrivateAPI
- type PublicAPI
- type TickerSubscription
- type TradeSubscription
- type WebsocketClientOption
Constants ¶
const ( HeaderAccessKey = "X-MAX-ACCESSKEY" HeaderPayloadKey = "X-MAX-PAYLOAD" HeaderSignature = "X-MAX-SIGNATURE" )
Variables ¶
var ( DepositStateSubmitting types.DepositState = "submitting" DepositStateCancelled types.DepositState = "cancelled" DepositStateSubmitted types.DepositState = "submitted" DepositStateSuspended types.DepositState = "suspended" DepositStateRejected types.DepositState = "rejected" DepositStateAccepted types.DepositState = "accepted" DepositStateRefunded types.DepositState = "refunded" DepositStateSuspect types.DepositState = "suspect" DepositStateRefundCancelled types.DepositState = "refund_cancelled" )
var ( WithdrawalStateSubmitting types.WithdrawalState = "submitting" WithdrawalStateSubmitted types.WithdrawalState = "submitted" WithdrawalStateRejected types.WithdrawalState = "rejected" WithdrawalStateAccepted types.WithdrawalState = "accepted" WithdrawalStateSuspect types.WithdrawalState = "suspect" WithdrawalStateApproved types.WithdrawalState = "approved" WithdrawalStateProcessing types.WithdrawalState = "processing" WithdrawalStateRetryable types.WithdrawalState = "retryable" WithdrawalStateSent types.WithdrawalState = "sent" WithdrawalStateCancelled types.WithdrawalState = "cancelled" WithdrawalStateFailed types.WithdrawalState = "failed" WithdrawalStatePending types.WithdrawalState = "pending" WithdrawalStateConfirmed types.WithdrawalState = "confirmed" )
var ( OrderTypeLimit types.OrderType = "limit" OrderTypeMarket types.OrderType = "market" OrderTypeStopLimit types.OrderType = "stop_limit" OrderTypeStopMarket types.OrderType = "stop_market" )
var ( OrderSideSell types.OrderSide = "sell" OrderSideBuy types.OrderSide = "buy" )
var ( OrderStateWait types.OrderState = "wait" OrderStateDone types.OrderState = "done" OrderStateConvert types.OrderState = "convert" OrderStateCancel types.OrderState = "cancel" )
Functions ¶
func NewClient ¶
func NewClient(opts ...ClientOption) *client
func NewWSClient ¶
func NewWSClient(opts ...WebsocketClientOption) (*wsClient, error)
NewWSClient returns a websocket client.
Types ¶
type AccountSubscription ¶
type AccountSubscription interface { Chan() <-chan models.AccountEvent Close() }
type CallOption ¶
type CallOption func(opt map[string]interface{})
CallOption represents the API parameters
func AsksLimit ¶
func AsksLimit(limit int32) CallOption
AsksLimit represents the asks_limit parameter
func BidsLimit ¶
func BidsLimit(limit int32) CallOption
BidsLimit represents the bids_limit parameter
func Currency ¶
func Currency(currency string) CallOption
Currency represents the currency parameter
func DepositState ¶
func DepositState(state types.DepositState) CallOption
DepositState represents the state parameter for deposit
func FromTime ¶
func FromTime(from time.Time) CallOption
FromTime represents the from parameter in Go time.Time format
func OrderSide ¶
func OrderSide(t types.OrderSide) CallOption
OrderSide represents the side parameter
func OrderType ¶
func OrderType(t types.OrderType) CallOption
OrderType represents the ord_type parameter
func OrderTypes ¶
func OrderTypes(t []types.OrderType) CallOption
OrderTypes represents the orders[ord_type] parameter
func Pagination ¶
func Pagination(pagination bool) CallOption
Pagination represents the pagination parameter
func PeriodDuration ¶
func PeriodDuration(period time.Duration) CallOption
PeriodDuration represents the period parameter in Go time.Duration format
func Prices ¶
func Prices(prices []types.Price) CallOption
Prices represents the orders[price] parameter
func StopPrice ¶
func StopPrice(price types.Price) CallOption
StopPrice represents the stop_price parameter
func StopPrices ¶
func StopPrices(prices []types.Price) CallOption
StopPrices represents the orders[stop_price] parameter
func Time ¶
func Time(t time.Time) CallOption
Time represents the timestamp parameter in Go time.Time format
func Timestamp ¶
func Timestamp(timestamp int32) CallOption
Timestamp represents the timestamp parameter
func WithdrawalState ¶
func WithdrawalState(state types.WithdrawalState) CallOption
WithdrawalState represents the state parameter for withdrawal
type ClientOption ¶
type ClientOption func(*client)
func AuthToken ¶
func AuthToken(accessKey, secretKey string) ClientOption
AuthToken passess the access key and secret key to the API client.
func UserAgent ¶
func UserAgent(agent string) ClientOption
UserAgent sets the User-Agent in HTTP header.
type OrderBookSubscription ¶
type OrderBookSubscription interface { Chan() <-chan *models.OrderBookEvent Close() }
type PrivateAPI ¶
type PrivateAPI interface { // Me returns user profile and accounts information // // Available `CallOption`: // // Note: // Use AuthToken() to pass your auth tokens. Me(context.Context, ...CallOption) (*models.Member, error) // Deposit returns details of the deposit with specific transaction ID. // // Available `CallOption`: // // Note: // Use AuthToken() to pass your auth tokens. Deposit(context.Context, string, ...CallOption) (*models.Deposit, error) // Deposits returns the history of your deposits. // // Available `CallOption`: // Currency(): unique currency id, use Currencies() for available currencies. // From(): target period start (Epoch time in seconds) // FromTime(): target period start // To(): target period end (Epoch time in seconds) // ToTime(): target period end // State(): the state of deposit // Pagination(): do pagination & return metadata in header (default false) // Page(): page number, applied for pagination (default 1) // Limit(): returned limit (1~1000, default 50) // Offset(): records to skip, not applied for pagination (default 0) // // Note: // Use AuthToken() to pass your auth tokens. Deposits(context.Context, ...CallOption) ([]*models.Deposit, error) // Deprecated: Use DepositAddresses instead. // // DepositAddress returns the addresses which are able to deposit. // // Available `CallOption`: // Currency(): unique currency id, use Currencies() for available currencies. // // The address could be empty when a new one is generating, try again later in that case. // // Note: // Use AuthToken() to pass your auth tokens. DepositAddress(context.Context, ...CallOption) ([]*models.PaymentAddress, error) // DepositAddress returns the addresses that users are able to deposit. // // The address could be empty when a new one is generating, try again later in that case. // // Available `CallOption`: // // Note: // Use AuthToken() to pass your auth tokens. DepositAddresses(context.Context, ...CallOption) ([]*models.PaymentAddress, error) // CreateDepositAddresses creates new addresses for deposit. // // Address creation is asynchronous, please call DepositAddresses later to get generated addresses // // Available `CallOption`: // // Note: // Use AuthToken() to pass your auth tokens. CreateDepositAddresses(context.Context, string, ...CallOption) ([]*models.PaymentAddress, error) // Withdrawal returns the details of specific withdrawal. // // Available `CallOption`: // // Note: // Use AuthToken() to pass your auth tokens. Withdrawal(context.Context, string, ...CallOption) (*models.Withdrawal, error) // Withdrawals returns the withdrawals history. // // Available `CallOption`: // Currency(): unique currency id, check Currencies() for available currencies // From(): target period start (Epoch time in seconds) // FromTime(): target period start // To(): target period end (Epoch time in seconds) // ToTime(): target period end // State(): the state of withdrawals // Pagniation(): do pagination & return metadata in header (default false) // Page(): page number, applied for pagination (default 1) // Limit(): returned limit (1~1000, default 50) // Offset(): records to skip, not applied for pagination (default 0) // // Note: // Use AuthToken() to pass your auth tokens. Withdrawals(context.Context, ...CallOption) ([]*models.Withdrawal, error) // CreateOrder creates a sell/buy order. // // markets: unique market id, check Markets() for available markets // side: 'sell' or 'buy' // volume: total amount to sell/buy, an order could be partially executed // // Available `CallOption`: // Price(): price per unit // StopPrice(): price per unit to trigger a stop order // OrderType(): `OrderTypeLimit`, `OrderTypeMarket`, `OrderTypeStopLimit`, or `OrderTypeStopMarket` // // Note: // Use AuthToken() to pass your auth tokens. CreateOrder(context.Context, string, string, types.Volume, ...CallOption) (*models.Order, error) // CreateOrders creates multiple sell/buy orders. // // Available `CallOption`: // // Note: // Use AuthToken() to pass your auth tokens. CreateOrders(context.Context, string, []*models.OrderRequest, ...CallOption) ([]*models.Order, error) // CancelOrder cancels a sell/buy order. // // Available `CallOption`: // // Note: // Use AuthToken() to pass your auth tokens. CancelOrder(context.Context, int32, ...CallOption) (*models.Order, error) // CancelOrders cancels a series of sell/buy orders. // // Available `CallOption`: // OrderSide(): set tp cancel only sell (asks) or buy (bids) orders // Market(): specify market like btctwd / ethbtc // // Note: // Use AuthToken() to pass your auth tokens. CancelOrders(context.Context, ...CallOption) ([]*models.Order, error) // Order returns details of a specific order. // // Available `CallOption`: // // Note: // Use AuthToken() to pass your auth tokens. Order(context.Context, int32, ...CallOption) (*models.Order, error) // Orders returns your orders. // // Available `CallOption`: // State(): filter by state, default to 'OrderStateWait' // OrderDesc(): use descending order by created time // OrderAsc(): use ascending order by created time, default value // Pagination(): do pagination & return metadata in header (default true) // Page(): page number, applied for pagination (default 1) // Limit(): returned limit (1~1000, default 100) // Offset(): records to skip, not applied for pagination (default 0) // // Note: // Use AuthToken() to pass your auth tokens. Orders(context.Context, string, ...CallOption) ([]*models.Order, error) // MyTrades returns the executed trades which are sorted in reverse creation order. // // Available `CallOption`: // Timestamp(): the seconds elapsed since Unix epoch, set to return trades executed before the time only // Time(): the time in Go format, set to return trades executed before the time only // From(): trade id, set ot return trades created after the trade // To(): trade id, set to return trades created before the trade // OrderDesc(): use descending order by created time, default value // OrderAsc(): use ascending order by created time // Pagination(): do pagination & return metadata in header (default true) // Page(): page number, applied for pagination (default 1) // Limit(): returned limit (1~1000, default 50) // Offset(): records to skip, not applied for pagination (default 0) // // Note: // Use AuthToken() to pass your auth tokens. MyTrades(context.Context, string, ...CallOption) ([]*models.Trade, error) }
PrivateAPI provides an interface the private MAX APIs which has authtication requirements and rate limits.
type PublicAPI ¶
type PublicAPI interface { // Markets returns available markets on MAX. // // Available `CallOption`: // Markets(context.Context, ...CallOption) ([]*models.Market, error) // Markets returns available currencies on MAX. // // Available `CallOption`: // Currencies(context.Context, ...CallOption) ([]*models.Currency, error) // Ticker returns a ticker of specific market. // // Available `CallOption`: // Ticker(context.Context, string, ...CallOption) (*models.Ticker, error) // Tickers returns tickers of all markets. // // Available `CallOption`: // Tickers(context.Context, ...CallOption) (models.Tickers, error) // OrderBook returns order books of specific market. // // Available `CallOption`: // AsksLimit(): returned sell orders limit, default to 20 // BidsLimit(): returned buy orders limit, default to 20 OrderBook(context.Context, string, ...CallOption) (*models.OrderBook, error) // Depth returns depth of specific market. // // Available `CallOption`: // Limit(): returned price levels limit, default to 300 Depth(context.Context, string, ...CallOption) (*models.Depth, error) // Trades returns recent trades on market. // // Available `CallOption`: // Timestamp(): the seconds elapsed since Unix epoch, set to return trades executed before the time only // Time(): the time in Go format, set to return trades executed before the time only // From(): trade id, set ot return trades created after the trade // To(): trade id, set to return trades created before the trade // OrderDesc(): use descending order by created time, default value // OrderAsc(): use ascending order by created time // Pagination(): do pagination & return metadata in header (default true) // Page(): page number, applied for pagination (default 1) // Limit(): returned limit (1~1000, default 50) // Offset(): records to skip, not applied for pagination (default 0) Trades(context.Context, string, ...CallOption) ([]*models.Trade, error) // K returns OHLC chart of specific market. // // Available `CallOption`: // Timestamp(): the seconds elapsed since Unix epoch, set to return data after the timestamp only // Time(): the time in Go format, set to return data after the time only // Period(): time period of K line in minute, default to 1 // PeriodDuration(): time period of K line in time.Duration format, default to 1*time.Minute // Limit(): returned data points limit, default to 30 K(context.Context, string, ...CallOption) ([]*models.Candle, error) // Time returns current sever time. // // Available `CallOption`: // Time(context.Context, ...CallOption) (time.Time, error) }
PublicAPI provides an interface to the public MAX APIs. Public APIs can be invoked without authentication and rate limits.
type TickerSubscription ¶
type TickerSubscription interface { Chan() <-chan *models.TickerEvent Close() }
type TradeSubscription ¶
type TradeSubscription interface { Chan() <-chan *models.TradeEvent Close() }
type WebsocketClientOption ¶
type WebsocketClientOption func(*wsClient)
func WSAuthToken ¶
func WSAuthToken(accessKey, secretKey string) WebsocketClientOption
WSAuthToken passes API tokens to the websocket client
func WSLogging ¶
func WSLogging(logger *log.Logger) WebsocketClientOption
WSLogging sets logger of the websocket client
func WSURL ¶
func WSURL(url string) WebsocketClientOption
WSURL sets the websocket URL to connect to