max

package
v1.16.3 Latest Latest
Warning

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

Go to latest
Published: May 28, 2021 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	All = iota
	Active
	Closed
)
View Source
const (
	OrderStateDone       = OrderState("done")
	OrderStateCancel     = OrderState("cancel")
	OrderStateWait       = OrderState("wait")
	OrderStateConvert    = OrderState("convert")
	OrderStateFinalizing = OrderState("finalizing")
	OrderStateFailed     = OrderState("failed")
)
View Source
const (
	OrderTypeMarket     = OrderType("market")
	OrderTypeLimit      = OrderType("limit")
	OrderTypePostOnly   = OrderType("post_only")
	OrderTypeStopLimit  = OrderType("stop_limit")
	OrderTypeStopMarket = OrderType("stop_market")
	OrderTypeIOCLimit   = OrderType("ioc_limit")
)

Order types that the API can return.

View Source
const (
	// ProductionAPIURL is the official MAX API v2 Endpoint
	ProductionAPIURL = "https://max-api.maicoin.com/api/v2"

	UserAgent = "bbgo/" + version.Version

	// 2018-09-01 08:00:00 +0800 CST
	TimestampSince = 1535760000
)
View Source
const (
	RewardAirdrop    = RewardType("airdrop_reward")
	RewardCommission = RewardType("commission")
	RewardHolding    = RewardType("holding_reward")
	RewardMining     = RewardType("mining_reward")
	RewardTrading    = RewardType("trading_reward")
	RewardVipRebate  = RewardType("vip_rebate")
)
View Source
const Buy = 1
View Source
const Sell = -1

Variables

View Source
var ErrIncorrectBookEntryElementLength = errors.New("incorrect book entry element length")
View Source
var ErrMessageTypeNotSupported = errors.New("message type currently not supported")
View Source
var SubscribeAction = "subscribe"
View Source
var UnsubscribeAction = "unsubscribe"
View Source
var WebSocketURL = "wss://max-stream.maicoin.com/ws"

Functions

func ParseMessage

func ParseMessage(payload []byte) (interface{}, error)

ParseMessage accepts the raw messages from max public websocket channels and parses them into market data Return types: *BookEvent, *PublicTradeEvent, *SubscriptionEvent, *ErrorEvent

func ParseUserEvent

func ParseUserEvent(v *fastjson.Value) (interface{}, error)

Types

type Account

type Account struct {
	Currency string `json:"currency"`
	Balance  string `json:"balance"`
	Locked   string `json:"locked"`
	Type     string `json:"type"`
}

Account is for max rest api v2, Balance and Type will be conflict with types.PrivateBalanceUpdate

type AccountService

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

func (*AccountService) Account

func (s *AccountService) Account(currency string) (*Account, error)

func (*AccountService) Accounts

func (s *AccountService) Accounts() ([]Account, error)

func (*AccountService) Me

func (s *AccountService) Me() (*UserInfo, error)

Me returns the current user info by the current used MAX key and secret

func (*AccountService) NewGetDepositHistoryRequest

func (s *AccountService) NewGetDepositHistoryRequest() *GetDepositHistoryRequest

func (*AccountService) NewGetWithdrawalHistoryRequest

func (s *AccountService) NewGetWithdrawalHistoryRequest() *GetWithdrawHistoryRequest

func (*AccountService) VipLevel

func (s *AccountService) VipLevel() (*VipLevel, error)

type AccountSnapshotEvent

type AccountSnapshotEvent struct {
	BaseEvent
	Balances []BalanceMessage `json:"B"`
}

type AccountUpdateEvent

type AccountUpdateEvent struct {
	BaseEvent
	Balances []BalanceMessage `json:"B"`
}

type AuthEvent

type AuthEvent struct {
	Event     string
	ID        string
	Timestamp int64
}

type AuthMessage

type AuthMessage struct {
	Action    string `json:"action"`
	APIKey    string `json:"apiKey"`
	Nonce     int64  `json:"nonce"`
	Signature string `json:"signature"`
	ID        string `json:"id"`
}

type Balance

type Balance struct {
	Currency  string
	Available int64
	Locked    int64
	Total     int64
}

Balance is for kingfisher

type BalanceMessage

type BalanceMessage struct {
	Currency  string `json:"cu"`
	Available string `json:"av"`
	Locked    string `json:"l"`
}

func (*BalanceMessage) Balance

func (m *BalanceMessage) Balance() (*types.Balance, error)

type BaseEvent

type BaseEvent struct {
	Event     string `json:"e"`
	Timestamp int64  `json:"T"`
}

type BookEntry

type BookEntry struct {
	Side   int
	Time   time.Time
	Price  string
	Volume string
}

func (*BookEntry) PriceVolumePair

func (e *BookEntry) PriceVolumePair() (pv types.PriceVolume, err error)

type BookEvent

type BookEvent struct {
	Event     string `json:"e"`
	Market    string `json:"M"`
	Channel   string `json:"c"`
	Timestamp int64  `json:"t"` // Millisecond timestamp
	Bids      []BookEntry
	Asks      []BookEntry
}

func (*BookEvent) OrderBook

func (e *BookEvent) OrderBook() (snapshot types.SliceOrderBook, err error)

func (*BookEvent) Time

func (e *BookEvent) Time() time.Time

type CreateMultiOrderRequest

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

func (*CreateMultiOrderRequest) AddOrders

func (r *CreateMultiOrderRequest) AddOrders(orders ...Order) *CreateMultiOrderRequest

func (*CreateMultiOrderRequest) Do

func (r *CreateMultiOrderRequest) Do(ctx context.Context) (multiOrderResponse *MultiOrderResponse, err error)

func (*CreateMultiOrderRequest) GroupID

func (*CreateMultiOrderRequest) Market

type CreateOrderRequest

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

func (*CreateOrderRequest) ClientOrderID

func (r *CreateOrderRequest) ClientOrderID(clientOrderID string) *CreateOrderRequest

func (*CreateOrderRequest) Do

func (r *CreateOrderRequest) Do(ctx context.Context) (order *Order, err error)

func (*CreateOrderRequest) Market

func (r *CreateOrderRequest) Market(market string) *CreateOrderRequest

func (*CreateOrderRequest) OrderType

func (r *CreateOrderRequest) OrderType(orderType string) *CreateOrderRequest

func (*CreateOrderRequest) Price

func (r *CreateOrderRequest) Price(price string) *CreateOrderRequest

func (*CreateOrderRequest) Side

func (*CreateOrderRequest) StopPrice

func (r *CreateOrderRequest) StopPrice(price string) *CreateOrderRequest

func (*CreateOrderRequest) Volume

func (r *CreateOrderRequest) Volume(volume string) *CreateOrderRequest

type Deposit

type Deposit struct {
	Currency        string `json:"currency"`
	CurrencyVersion string `json:"currency_version"` // "eth"
	Amount          string `json:"amount"`
	Fee             string `json:"fee"`
	TxID            string `json:"txid"`
	State           string `json:"state"`
	Confirmations   string `json:"confirmations"`
	CreatedAt       int64  `json:"created_at"`
	UpdatedAt       int64  `json:"updated_at"`
}

type ErrorEvent

type ErrorEvent struct {
	Timestamp int64
	Errors    []string
	CommandID string
}

func (ErrorEvent) Time

func (e ErrorEvent) Time() time.Time

type ErrorField

type ErrorField struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

ErrorResponse is the custom error type that is returned if the API returns an error.

type ErrorResponse

type ErrorResponse struct {
	*util.Response
	Err ErrorField `json:"error"`
}

func ToErrorResponse

func ToErrorResponse(response *util.Response) (errorResponse *ErrorResponse, err error)

ToErrorResponse tries to convert/parse the server response to the standard Error interface object

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type GetDepositHistoryRequest

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

func (*GetDepositHistoryRequest) Currency

func (*GetDepositHistoryRequest) Do

func (r *GetDepositHistoryRequest) Do(ctx context.Context) (deposits []Deposit, err error)

func (*GetDepositHistoryRequest) From

func (*GetDepositHistoryRequest) Limit

func (*GetDepositHistoryRequest) State

func (*GetDepositHistoryRequest) To

type GetDepositHistoryRequestParams

type GetDepositHistoryRequestParams struct {
	*PrivateRequestParams

	Currency string `json:"currency,omitempty"`
	From     int64  `json:"from,omitempty"`  // seconds
	To       int64  `json:"to,omitempty"`    // seconds
	State    string `json:"state,omitempty"` // submitting, submitted, rejected, accepted, checking, refunded, canceled, suspect
	Limit    int    `json:"limit,omitempty"`
}

type GetWithdrawHistoryRequest

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

func (*GetWithdrawHistoryRequest) Currency

func (*GetWithdrawHistoryRequest) Do

func (r *GetWithdrawHistoryRequest) Do(ctx context.Context) (withdraws []Withdraw, err error)

func (*GetWithdrawHistoryRequest) From

func (*GetWithdrawHistoryRequest) Limit

func (*GetWithdrawHistoryRequest) State

func (*GetWithdrawHistoryRequest) To

type GetWithdrawHistoryRequestParams

type GetWithdrawHistoryRequestParams struct {
	*PrivateRequestParams

	Currency string `json:"currency,omitempty"`
	From     int64  `json:"from,omitempty"`  // seconds
	To       int64  `json:"to,omitempty"`    // seconds
	State    string `json:"state,omitempty"` // submitting, submitted, rejected, accepted, checking, refunded, canceled, suspect
	Limit    int    `json:"limit,omitempty"`
}

type GetWithdrawalAddressesRequest

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

func (*GetWithdrawalAddressesRequest) Currency

func (*GetWithdrawalAddressesRequest) Do

type Interval

type Interval int64

func ParseInterval

func ParseInterval(a string) (Interval, error)

type KLine

type KLine struct {
	Symbol                 string
	Interval               string
	StartTime, EndTime     time.Time
	Open, High, Low, Close float64
	Volume                 float64
	Closed                 bool
}

func (KLine) KLine

func (k KLine) KLine() types.KLine

type KLineEvent

type KLineEvent struct {
	Event     string `json:"e"`
	Market    string `json:"M"`
	Channel   string `json:"c"`
	KLine     KLine  `json:"k"`
	Timestamp int64  `json:"T"`
}

type KLinePayload

type KLinePayload struct {
	StartTime   int64  `json:"ST"`
	EndTime     int64  `json:"ET"`
	Market      string `json:"M"`
	Resolution  string `json:"R"`
	Open        string `json:"O"`
	High        string `json:"H"`
	Low         string `json:"L"`
	Close       string `json:"C"`
	Volume      string `json:"v"`
	LastTradeID int    `json:"ti"`
	Closed      bool   `json:"x"`
}
{
  "c": "kline",
  "M": "btcusdt",
  "e": "update",
  "T": 1602999650179,
  "k": {
    "ST": 1602999900000,
    "ET": 1602999900000,
    "M": "btcusdt",
    "R": "5m",
    "O": "11417.21",
    "H": "11417.21",
    "L": "11417.21",
    "C": "11417.21",
    "v": "0",
    "ti": 0,
    "x": false
  }
}

func (KLinePayload) KLine

func (k KLinePayload) KLine() types.KLine

type MarkerInfo

type MarkerInfo struct {
	Fee         string `json:"fee"`
	FeeCurrency string `json:"fee_currency"`
	OrderID     int    `json:"order_id"`
}

type Market

type Market struct {
	ID                 string  `json:"id"`
	Name               string  `json:"name"`
	BaseUnit           string  `json:"base_unit"`
	BaseUnitPrecision  int     `json:"base_unit_precision"`
	QuoteUnit          string  `json:"quote_unit"`
	QuoteUnitPrecision int     `json:"quote_unit_precision"`
	MinBaseAmount      float64 `json:"min_base_amount"`
	MinQuoteAmount     float64 `json:"min_quote_amount"`
}

type MultiOrderRequestParams

type MultiOrderRequestParams struct {
	*PrivateRequestParams

	Market string  `json:"market"`
	Orders []Order `json:"orders"`
}

type MultiOrderResponse

type MultiOrderResponse []struct {
	Error string `json:"error,omitempty"`
	Order Order  `json:"order,omitempty"`
}

type Options

type Options map[string]interface{}

Options carry the option fields for REST API

type Order

type Order struct {
	ID              uint64     `json:"id,omitempty"`
	Side            string     `json:"side"`
	OrderType       OrderType  `json:"ord_type"`
	Price           string     `json:"price,omitempty"`
	StopPrice       string     `json:"stop_price,omitempty"`
	AveragePrice    string     `json:"avg_price,omitempty"`
	State           OrderState `json:"state,omitempty"`
	Market          string     `json:"market,omitempty"`
	Volume          string     `json:"volume"`
	RemainingVolume string     `json:"remaining_volume,omitempty"`
	ExecutedVolume  string     `json:"executed_volume,omitempty"`
	TradesCount     int64      `json:"trades_count,omitempty"`
	GroupID         uint32     `json:"group_id,omitempty"`
	ClientOID       string     `json:"client_oid,omitempty"`
	CreatedAt       time.Time  `json:"-" db:"created_at"`
	CreatedAtMs     int64      `json:"created_at_in_ms,omitempty"`
	InsertedAt      time.Time  `json:"-" db:"inserted_at"`
}

Order represents one returned order (POST order/GET order/GET orders) on the max platform.

type OrderCancelAllRequest

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

func (*OrderCancelAllRequest) Do

func (r *OrderCancelAllRequest) Do(ctx context.Context) (orders []Order, err error)

func (*OrderCancelAllRequest) GroupID

func (r *OrderCancelAllRequest) GroupID(groupID uint32) *OrderCancelAllRequest

func (*OrderCancelAllRequest) Market

func (*OrderCancelAllRequest) Side

type OrderCancelAllRequestParams

type OrderCancelAllRequestParams struct {
	*PrivateRequestParams

	Side    string `json:"side,omitempty"`
	Market  string `json:"market,omitempty"`
	GroupID int64  `json:"groupID,omitempty"`
}

type OrderCancelRequest

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

func (*OrderCancelRequest) ClientOrderID

func (r *OrderCancelRequest) ClientOrderID(id string) *OrderCancelRequest

func (*OrderCancelRequest) Do

func (*OrderCancelRequest) ID

type OrderCancelRequestParams

type OrderCancelRequestParams struct {
	*PrivateRequestParams

	ID            uint64 `json:"id,omitempty"`
	ClientOrderID string `json:"client_oid,omitempty"`
}

type OrderService

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

OrderService manages the Order endpoint.

func (*OrderService) All

func (s *OrderService) All(market string, limit, page int, states ...OrderState) ([]Order, error)

All returns all orders for the authenticated account.

func (*OrderService) Cancel

func (s *OrderService) Cancel(orderID uint64, clientOrderID string) error

Cancel the order with id `orderID`.

func (*OrderService) CancelAll

func (s *OrderService) CancelAll(side string, market string) error

CancelAll active orders for the authenticated account.

func (*OrderService) Closed

func (s *OrderService) Closed(market string, options QueryOrderOptions) ([]Order, error)

Open returns open orders

func (*OrderService) Create

func (s *OrderService) Create(market string, side string, volume float64, price float64, orderType string, options Options) (*Order, error)

Create a new order.

func (*OrderService) CreateMulti

func (s *OrderService) CreateMulti(market string, orders []Order) (*MultiOrderResponse, error)

Create multiple order in a single request

func (*OrderService) Get

func (s *OrderService) Get(orderID uint64) (*Order, error)

Status retrieves the given order from the API.

func (*OrderService) NewCreateMultiOrderRequest

func (s *OrderService) NewCreateMultiOrderRequest() *CreateMultiOrderRequest

func (*OrderService) NewCreateOrderRequest

func (s *OrderService) NewCreateOrderRequest() *CreateOrderRequest

func (*OrderService) NewOrderCancelAllRequest

func (s *OrderService) NewOrderCancelAllRequest() *OrderCancelAllRequest

func (*OrderService) NewOrderCancelRequest

func (s *OrderService) NewOrderCancelRequest() *OrderCancelRequest

func (*OrderService) Open

func (s *OrderService) Open(market string, options QueryOrderOptions) ([]Order, error)

Open returns open orders

type OrderSnapshotEvent

type OrderSnapshotEvent struct {
	BaseEvent

	Orders []OrderUpdate `json:"o"`
}

type OrderState

type OrderState string

type OrderStateToQuery

type OrderStateToQuery int

type OrderType

type OrderType string

type OrderUpdate

type OrderUpdate struct {
	Event     string    `json:"e"`
	ID        uint64    `json:"i"`
	Side      string    `json:"sd"`
	OrderType OrderType `json:"ot"`

	Price     string `json:"p"`
	StopPrice string `json:"sp"`

	Volume       string     `json:"v"`
	AveragePrice string     `json:"ap"`
	State        OrderState `json:"S"`
	Market       string     `json:"M"`

	RemainingVolume string `json:"rv"`
	ExecutedVolume  string `json:"ev"`

	TradesCount int64 `json:"tc"`

	GroupID     uint32 `json:"gi"`
	ClientOID   string `json:"ci"`
	CreatedAtMs int64  `json:"T"`
}

type OrderUpdateEvent

type OrderUpdateEvent struct {
	BaseEvent

	Orders []OrderUpdate `json:"o"`
}

type PrivateRequestParams

type PrivateRequestParams struct {
	Nonce int64  `json:"nonce"`
	Path  string `json:"path"`
}

type PrivateTradeRequest

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

func (*PrivateTradeRequest) Do

func (r *PrivateTradeRequest) Do(ctx context.Context) (trades []Trade, err error)

func (*PrivateTradeRequest) From

func (*PrivateTradeRequest) Limit

func (*PrivateTradeRequest) Market

func (r *PrivateTradeRequest) Market(market string) *PrivateTradeRequest

func (*PrivateTradeRequest) Offset

func (r *PrivateTradeRequest) Offset(offset int64) *PrivateTradeRequest

func (*PrivateTradeRequest) OrderBy

func (r *PrivateTradeRequest) OrderBy(orderBy string) *PrivateTradeRequest

func (*PrivateTradeRequest) Pagination

func (r *PrivateTradeRequest) Pagination(p bool) *PrivateTradeRequest

func (*PrivateTradeRequest) Timestamp

func (*PrivateTradeRequest) To

type PublicService

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

func (*PublicService) KLines

func (s *PublicService) KLines(symbol string, resolution string, start time.Time, limit int) ([]KLine, error)

func (*PublicService) Markets

func (s *PublicService) Markets() ([]Market, error)

func (*PublicService) Ticker

func (s *PublicService) Ticker(market string) (*Ticker, error)

func (*PublicService) Tickers

func (s *PublicService) Tickers() (map[string]Ticker, error)

func (*PublicService) Timestamp

func (s *PublicService) Timestamp() (serverTimestamp int64, err error)

type PublicTradeEvent

type PublicTradeEvent struct {
	Event     string       `json:"e"`
	Market    string       `json:"M"`
	Channel   string       `json:"c"`
	Trades    []TradeEntry `json:"t"`
	Timestamp int64        `json:"T"`
}

func (*PublicTradeEvent) Time

func (e *PublicTradeEvent) Time() time.Time

type QueryOrderOptions

type QueryOrderOptions struct {
	GroupID int
	Offset  int
	Limit   int
}

type QueryTradeOptions

type QueryTradeOptions struct {
	Market    string `json:"market"`
	Timestamp int64  `json:"timestamp,omitempty"`
	From      int64  `json:"from,omitempty"`
	To        int64  `json:"to,omitempty"`
	OrderBy   string `json:"order_by,omitempty"`
	Page      int    `json:"page,omitempty"`
	Offset    int    `json:"offset,omitempty"`
	Limit     int64  `json:"limit,omitempty"`
}

func (*QueryTradeOptions) Map

func (options *QueryTradeOptions) Map() map[string]interface{}

func (*QueryTradeOptions) Params

func (options *QueryTradeOptions) Params() url.Values

type RestClient

type RestClient struct {
	BaseURL *url.URL

	// Authentication
	APIKey    string
	APISecret string

	AccountService    *AccountService
	PublicService     *PublicService
	TradeService      *TradeService
	OrderService      *OrderService
	RewardService     *RewardService
	WithdrawalService *WithdrawalService
	// contains filtered or unexported fields
}

func NewRestClient

func NewRestClient(baseURL string) *RestClient

func NewRestClientWithHttpClient

func NewRestClientWithHttpClient(baseURL string, httpClient *http.Client) *RestClient

func (*RestClient) Auth

func (c *RestClient) Auth(key string, secret string) *RestClient

Auth sets api key and secret for usage is requests that requires authentication.

func (*RestClient) Do

func (c *RestClient) Do(req *http.Request) (resp *http.Response, err error)

func (*RestClient) GetTrades

func (c *RestClient) GetTrades(market string, lastTradeID int64) ([]byte, error)

FIXME: should deprecate the polling usage from the websocket struct

type Reward

type Reward struct {
	// UUID here is more like SN, not the real UUID
	UUID     string           `json:"uuid"`
	Type     RewardType       `json:"type"`
	Currency string           `json:"currency"`
	Amount   fixedpoint.Value `json:"amount"`
	State    string           `json:"state"`
	Note     string           `json:"note"`

	// Unix timestamp in seconds
	CreatedAt Timestamp `json:"created_at"`
}

func (Reward) Reward

func (reward Reward) Reward() (*types.Reward, error)

type RewardService

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

func (*RewardService) NewRewardsByTypeRequest

func (s *RewardService) NewRewardsByTypeRequest(pathType RewardType) *RewardsRequest

func (*RewardService) NewRewardsRequest

func (s *RewardService) NewRewardsRequest() *RewardsRequest

type RewardType

type RewardType string

func ParseRewardType

func ParseRewardType(s string) (RewardType, error)

func (RewardType) RewardType

func (t RewardType) RewardType() (types.RewardType, error)

func (*RewardType) UnmarshalJSON

func (t *RewardType) UnmarshalJSON(o []byte) error

type RewardsRequest

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

func (*RewardsRequest) Currency

func (r *RewardsRequest) Currency(currency string) *RewardsRequest

func (*RewardsRequest) Do

func (r *RewardsRequest) Do(ctx context.Context) (rewards []Reward, err error)

func (*RewardsRequest) From

func (r *RewardsRequest) From(from int64) *RewardsRequest

func (*RewardsRequest) Limit

func (r *RewardsRequest) Limit(limit int) *RewardsRequest

func (*RewardsRequest) To

func (r *RewardsRequest) To(to int64) *RewardsRequest

type SubscribeOptions

type SubscribeOptions struct {
	Depth      int    `json:"depth,omitempty"`
	Resolution string `json:"resolution,omitempty"`
}

type Subscription

type Subscription struct {
	Channel    string `json:"channel"`
	Market     string `json:"market"`
	Depth      int    `json:"depth,omitempty"`
	Resolution string `json:"resolution,omitempty"`
}

Subscription is used for presenting the subscription metadata. This is used for sending subscribe and unsubscribe requests

type SubscriptionEvent

type SubscriptionEvent struct {
	Event         string         `json:"e"`
	Timestamp     int64          `json:"T"`
	CommandID     string         `json:"i"`
	Subscriptions []Subscription `json:"s"`
}

func (SubscriptionEvent) Time

func (e SubscriptionEvent) Time() time.Time

type Ticker

type Ticker struct {
	Time time.Time

	At          int64  `json:"at"`
	Buy         string `json:"buy"`
	Sell        string `json:"sell"`
	Open        string `json:"open"`
	High        string `json:"high"`
	Low         string `json:"low"`
	Last        string `json:"last"`
	Volume      string `json:"vol"`
	VolumeInBTC string `json:"vol_in_btc"`
}

type Timestamp

type Timestamp time.Time

func (Timestamp) String

func (t Timestamp) String() string

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(o []byte) error

type Trade

type Trade struct {
	ID                    uint64    `json:"id" db:"exchange_id"`
	Price                 string    `json:"price" db:"price"`
	Volume                string    `json:"volume" db:"volume"`
	Funds                 string    `json:"funds"`
	Market                string    `json:"market" db:"market"`
	MarketName            string    `json:"market_name"`
	CreatedAt             int64     `json:"created_at"`
	CreatedAtMilliSeconds int64     `json:"created_at_in_ms"`
	Side                  string    `json:"side" db:"side"`
	OrderID               uint64    `json:"order_id"`
	Fee                   string    `json:"fee" db:"fee"` // float number as string
	FeeCurrency           string    `json:"fee_currency" db:"fee_currency"`
	Info                  TradeInfo `json:"info,omitempty"`
}

Trade represents one returned trade on the max platform.

func (Trade) IsBuyer

func (t Trade) IsBuyer() bool

func (Trade) IsMaker

func (t Trade) IsMaker() bool

type TradeEntry

type TradeEntry struct {
	Trend     string `json:"tr"`
	Price     string `json:"p"`
	Volume    string `json:"v"`
	Timestamp int64  `json:"T"`
}

func (TradeEntry) Time

func (e TradeEntry) Time() time.Time

type TradeInfo

type TradeInfo struct {
	// Maker tells you the maker trade side
	Maker string      `json:"maker,omitempty"`
	Bid   *MarkerInfo `json:"bid,omitempty"`
	Ask   *MarkerInfo `json:"ask,omitempty"`
}

type TradeService

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

func (*TradeService) NewPrivateTradeRequest

func (s *TradeService) NewPrivateTradeRequest() *PrivateTradeRequest

type TradeSnapshot

type TradeSnapshot []TradeUpdate

type TradeSnapshotEvent

type TradeSnapshotEvent struct {
	BaseEvent

	Trades []TradeUpdate `json:"t"`
}

type TradeUpdate

type TradeUpdate struct {
	ID     uint64 `json:"i"`
	Side   string `json:"sd"`
	Price  string `json:"p"`
	Volume string `json:"v"`
	Market string `json:"M"`

	Fee         string `json:"f"`
	FeeCurrency string `json:"fc"`
	Timestamp   int64  `json:"T"`

	OrderID uint64 `json:"oi"`

	Maker bool `json:"m"`
}

type TradeUpdateEvent

type TradeUpdateEvent struct {
	BaseEvent

	Trades []TradeUpdate `json:"t"`
}

type UserBank

type UserBank struct {
	Branch  string `json:"branch"`
	Name    string `json:"name"`
	Account string `json:"account"`
	State   string `json:"state"`
}

type UserInfo

type UserInfo struct {
	Sn              string    `json:"sn"`
	Name            string    `json:"name"`
	Type            string    `json:"member_type"`
	Level           int       `json:"level"`
	VipLevel        int       `json:"vip_level"`
	Email           string    `json:"email"`
	Accounts        []Account `json:"accounts"`
	Bank            *UserBank `json:"bank,omitempty"`
	IsFrozen        bool      `json:"is_frozen"`
	IsActivated     bool      `json:"is_activated"`
	KycApproved     bool      `json:"kyc_approved"`
	KycState        string    `json:"kyc_state"`
	PhoneSet        bool      `json:"phone_set"`
	PhoneNumber     string    `json:"phone_number"`
	ProfileVerified bool      `json:"profile_verified"`
	CountryCode     string    `json:"country_code"`
	IdentityNumber  string    `json:"identity_number"`
	WithDrawable    bool      `json:"withdrawable"`
	ReferralCode    string    `json:"referral_code"`
}

type VipLevel

type VipLevel struct {
	Current VipLevelSettings `json:"current_vip_level"`
	Next    VipLevelSettings `json:"next_vip_level"`
}

type VipLevelSettings

type VipLevelSettings struct {
	Level                int     `json:"level"`
	MinimumTradingVolume float64 `json:"minimum_trading_volume"`
	MinimumStakingVolume float64 `json:"minimum_staking_volume"`
	MakerFee             float64 `json:"maker_fee"`
	TakerFee             float64 `json:"taker_fee"`
}

type WebSocketService

type WebSocketService struct {

	// Subscriptions is the subscription request payloads that will be used for sending subscription request
	Subscriptions []Subscription
	// contains filtered or unexported fields
}

func NewWebSocketService

func NewWebSocketService(wsURL string, key, secret string) *WebSocketService

func (*WebSocketService) AddSubscription

func (s *WebSocketService) AddSubscription(subscription Subscription)

AddSubscription adds the subscription request to the buffer, these requests will be sent to the server right after connecting to the endpoint.

func (*WebSocketService) Auth

func (s *WebSocketService) Auth() error

func (*WebSocketService) ClearSubscriptions

func (s *WebSocketService) ClearSubscriptions()

func (*WebSocketService) Close

func (s *WebSocketService) Close() error

Close web socket connection

func (*WebSocketService) Connect

func (s *WebSocketService) Connect(ctx context.Context) error

func (*WebSocketService) EmitAccountSnapshotEvent

func (s *WebSocketService) EmitAccountSnapshotEvent(e AccountSnapshotEvent)

func (*WebSocketService) EmitAccountUpdateEvent

func (s *WebSocketService) EmitAccountUpdateEvent(e AccountUpdateEvent)

func (*WebSocketService) EmitBookEvent

func (s *WebSocketService) EmitBookEvent(e BookEvent)

func (*WebSocketService) EmitConnect

func (s *WebSocketService) EmitConnect(conn *websocket.Conn)

func (*WebSocketService) EmitDisconnect

func (s *WebSocketService) EmitDisconnect()

func (*WebSocketService) EmitError

func (s *WebSocketService) EmitError(err error)

func (*WebSocketService) EmitErrorEvent

func (s *WebSocketService) EmitErrorEvent(e ErrorEvent)

func (*WebSocketService) EmitKLineEvent

func (s *WebSocketService) EmitKLineEvent(e KLineEvent)

func (*WebSocketService) EmitMessage

func (s *WebSocketService) EmitMessage(message []byte)

func (*WebSocketService) EmitOrderSnapshotEvent

func (s *WebSocketService) EmitOrderSnapshotEvent(e OrderSnapshotEvent)

func (*WebSocketService) EmitOrderUpdateEvent

func (s *WebSocketService) EmitOrderUpdateEvent(e OrderUpdateEvent)

func (*WebSocketService) EmitSubscriptionEvent

func (s *WebSocketService) EmitSubscriptionEvent(e SubscriptionEvent)

func (*WebSocketService) EmitTradeEvent

func (s *WebSocketService) EmitTradeEvent(e PublicTradeEvent)

func (*WebSocketService) EmitTradeSnapshotEvent

func (s *WebSocketService) EmitTradeSnapshotEvent(e TradeSnapshotEvent)

func (*WebSocketService) EmitTradeUpdateEvent

func (s *WebSocketService) EmitTradeUpdateEvent(e TradeUpdateEvent)

func (*WebSocketService) OnAccountSnapshotEvent

func (s *WebSocketService) OnAccountSnapshotEvent(cb func(e AccountSnapshotEvent))

func (*WebSocketService) OnAccountUpdateEvent

func (s *WebSocketService) OnAccountUpdateEvent(cb func(e AccountUpdateEvent))

func (*WebSocketService) OnBookEvent

func (s *WebSocketService) OnBookEvent(cb func(e BookEvent))

func (*WebSocketService) OnConnect

func (s *WebSocketService) OnConnect(cb func(conn *websocket.Conn))

func (*WebSocketService) OnDisconnect

func (s *WebSocketService) OnDisconnect(cb func())

func (*WebSocketService) OnError

func (s *WebSocketService) OnError(cb func(err error))

func (*WebSocketService) OnErrorEvent

func (s *WebSocketService) OnErrorEvent(cb func(e ErrorEvent))

func (*WebSocketService) OnKLineEvent

func (s *WebSocketService) OnKLineEvent(cb func(e KLineEvent))

func (*WebSocketService) OnMessage

func (s *WebSocketService) OnMessage(cb func(message []byte))

func (*WebSocketService) OnOrderSnapshotEvent

func (s *WebSocketService) OnOrderSnapshotEvent(cb func(e OrderSnapshotEvent))

func (*WebSocketService) OnOrderUpdateEvent

func (s *WebSocketService) OnOrderUpdateEvent(cb func(e OrderUpdateEvent))

func (*WebSocketService) OnSubscriptionEvent

func (s *WebSocketService) OnSubscriptionEvent(cb func(e SubscriptionEvent))

func (*WebSocketService) OnTradeEvent

func (s *WebSocketService) OnTradeEvent(cb func(e PublicTradeEvent))

func (*WebSocketService) OnTradeSnapshotEvent

func (s *WebSocketService) OnTradeSnapshotEvent(cb func(e TradeSnapshotEvent))

func (*WebSocketService) OnTradeUpdateEvent

func (s *WebSocketService) OnTradeUpdateEvent(cb func(e TradeUpdateEvent))

func (*WebSocketService) Reconnect

func (s *WebSocketService) Reconnect()

func (*WebSocketService) Resubscribe

func (s *WebSocketService) Resubscribe()

func (*WebSocketService) SendSubscriptionRequest

func (s *WebSocketService) SendSubscriptionRequest(action string) error

func (*WebSocketService) Subscribe

func (s *WebSocketService) Subscribe(channel, market string, options SubscribeOptions)

Subscribe is a helper method for building subscription request from the internal mapping types. (Internal public method)

type WebsocketCommand

type WebsocketCommand struct {
	// Action is used for specify the action of the websocket session.
	// Valid values are "subscribe", "unsubscribe" and "auth"
	Action        string         `json:"action"`
	Subscriptions []Subscription `json:"subscriptions,omitempty"`
}

type Withdraw

type Withdraw struct {
	UUID            string `json:"uuid"`
	Currency        string `json:"currency"`
	CurrencyVersion string `json:"currency_version"` // "eth"
	Amount          string `json:"amount"`
	Fee             string `json:"fee"`
	FeeCurrency     string `json:"fee_currency"`
	TxID            string `json:"txid"`

	// State can be "submitting", "submitted",
	//     "rejected", "accepted", "suspect", "approved", "delisted_processing",
	//     "processing", "retryable", "sent", "canceled",
	//     "failed", "pending", "confirmed",
	//     "kgi_manually_processing", "kgi_manually_confirmed", "kgi_possible_failed",
	//     "sygna_verifying"
	State         string `json:"state"`
	Confirmations int    `json:"confirmations"`
	CreatedAt     int64  `json:"created_at"`
	UpdatedAt     int64  `json:"updated_at"`
	Notes         string `json:"notes"`
}

type WithdrawalAddress

type WithdrawalAddress struct {
	UUID            string `json:"uuid"`
	Currency        string `json:"currency"`
	CurrencyVersion string `json:"currency_version"`
	Address         string `json:"address"`
	ExtraLabel      string `json:"extra_label"`
	State           string `json:"state"`
	SygnaVaspCode   string `json:"sygna_vasp_code"`
	SygnaUserType   string `json:"sygna_user_type"`
	SygnaUserCode   string `json:"sygna_user_code"`
	IsInternal      bool   `json:"is_internal"`
}

type WithdrawalRequest

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

func (*WithdrawalRequest) AddressUUID

func (r *WithdrawalRequest) AddressUUID(uuid string) *WithdrawalRequest

func (*WithdrawalRequest) Amount

func (r *WithdrawalRequest) Amount(amount float64) *WithdrawalRequest

func (*WithdrawalRequest) Currency

func (r *WithdrawalRequest) Currency(currency string) *WithdrawalRequest

func (*WithdrawalRequest) Do

type WithdrawalService

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

func (*WithdrawalService) NewGetWithdrawalAddressesRequest

func (s *WithdrawalService) NewGetWithdrawalAddressesRequest() *GetWithdrawalAddressesRequest

func (*WithdrawalService) NewGetWithdrawalHistoryRequest

func (s *WithdrawalService) NewGetWithdrawalHistoryRequest() *GetWithdrawHistoryRequest

func (*WithdrawalService) NewWithdrawalRequest

func (s *WithdrawalService) NewWithdrawalRequest() *WithdrawalRequest

Jump to

Keyboard shortcuts

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