Documentation ¶
Index ¶
- Constants
- Variables
- func ParseMessage(payload []byte) (interface{}, error)
- func ParseUserEvent(v *fastjson.Value) (interface{}, error)
- type Account
- type AccountService
- func (s *AccountService) Account(currency string) (*Account, error)
- func (s *AccountService) Accounts() ([]Account, error)
- func (s *AccountService) Me() (*UserInfo, error)
- func (s *AccountService) NewGetDepositHistoryRequest() *GetDepositHistoryRequest
- func (s *AccountService) NewGetWithdrawalHistoryRequest() *GetWithdrawHistoryRequest
- func (s *AccountService) VipLevel() (*VipLevel, error)
- type AccountSnapshotEvent
- type AccountUpdateEvent
- type AuthEvent
- type AuthMessage
- type Balance
- type BalanceMessage
- type BaseEvent
- type BookEntry
- type BookEvent
- type CreateMultiOrderRequest
- func (r *CreateMultiOrderRequest) AddOrders(orders ...Order) *CreateMultiOrderRequest
- func (r *CreateMultiOrderRequest) Do(ctx context.Context) (multiOrderResponse *MultiOrderResponse, err error)
- func (r *CreateMultiOrderRequest) GroupID(groupID uint32) *CreateMultiOrderRequest
- func (r *CreateMultiOrderRequest) Market(market string) *CreateMultiOrderRequest
- type CreateOrderRequest
- func (r *CreateOrderRequest) ClientOrderID(clientOrderID string) *CreateOrderRequest
- func (r *CreateOrderRequest) Do(ctx context.Context) (order *Order, err error)
- func (r *CreateOrderRequest) Market(market string) *CreateOrderRequest
- func (r *CreateOrderRequest) OrderType(orderType string) *CreateOrderRequest
- func (r *CreateOrderRequest) Price(price string) *CreateOrderRequest
- func (r *CreateOrderRequest) Side(side string) *CreateOrderRequest
- func (r *CreateOrderRequest) StopPrice(price string) *CreateOrderRequest
- func (r *CreateOrderRequest) Volume(volume string) *CreateOrderRequest
- type Deposit
- type ErrorEvent
- type ErrorField
- type ErrorResponse
- type GetDepositHistoryRequest
- func (r *GetDepositHistoryRequest) Currency(currency string) *GetDepositHistoryRequest
- func (r *GetDepositHistoryRequest) Do(ctx context.Context) (deposits []Deposit, err error)
- func (r *GetDepositHistoryRequest) From(from int64) *GetDepositHistoryRequest
- func (r *GetDepositHistoryRequest) Limit(limit int) *GetDepositHistoryRequest
- func (r *GetDepositHistoryRequest) State(state string) *GetDepositHistoryRequest
- func (r *GetDepositHistoryRequest) To(to int64) *GetDepositHistoryRequest
- type GetDepositHistoryRequestParams
- type GetWithdrawHistoryRequest
- func (r *GetWithdrawHistoryRequest) Currency(currency string) *GetWithdrawHistoryRequest
- func (r *GetWithdrawHistoryRequest) Do(ctx context.Context) (withdraws []Withdraw, err error)
- func (r *GetWithdrawHistoryRequest) From(from int64) *GetWithdrawHistoryRequest
- func (r *GetWithdrawHistoryRequest) Limit(limit int) *GetWithdrawHistoryRequest
- func (r *GetWithdrawHistoryRequest) State(state string) *GetWithdrawHistoryRequest
- func (r *GetWithdrawHistoryRequest) To(to int64) *GetWithdrawHistoryRequest
- type GetWithdrawHistoryRequestParams
- type Interval
- type KLine
- type KLineEvent
- type KLinePayload
- type MarkerInfo
- type Market
- type MultiOrderRequestParams
- type MultiOrderResponse
- type Options
- type Order
- type OrderCancelAllRequest
- func (r *OrderCancelAllRequest) Do(ctx context.Context) (orders []Order, err error)
- func (r *OrderCancelAllRequest) GroupID(groupID uint32) *OrderCancelAllRequest
- func (r *OrderCancelAllRequest) Market(market string) *OrderCancelAllRequest
- func (r *OrderCancelAllRequest) Side(side string) *OrderCancelAllRequest
- type OrderCancelAllRequestParams
- type OrderCancelRequest
- type OrderCancelRequestParams
- type OrderService
- func (s *OrderService) All(market string, limit, page int, states ...OrderState) ([]Order, error)
- func (s *OrderService) Cancel(orderID uint64, clientOrderID string) error
- func (s *OrderService) CancelAll(side string, market string) error
- func (s *OrderService) Closed(market string, options QueryOrderOptions) ([]Order, error)
- func (s *OrderService) Create(market string, side string, volume float64, price float64, orderType string, ...) (*Order, error)
- func (s *OrderService) CreateMulti(market string, orders []Order) (*MultiOrderResponse, error)
- func (s *OrderService) Get(orderID uint64) (*Order, error)
- func (s *OrderService) NewCreateMultiOrderRequest() *CreateMultiOrderRequest
- func (s *OrderService) NewCreateOrderRequest() *CreateOrderRequest
- func (s *OrderService) NewOrderCancelAllRequest() *OrderCancelAllRequest
- func (s *OrderService) NewOrderCancelRequest() *OrderCancelRequest
- func (s *OrderService) Open(market string, options QueryOrderOptions) ([]Order, error)
- type OrderSnapshotEvent
- type OrderState
- type OrderStateToQuery
- type OrderType
- type OrderUpdate
- type OrderUpdateEvent
- type PrivateRequestParams
- type PrivateTradeRequest
- func (r *PrivateTradeRequest) Do(ctx context.Context) (trades []Trade, err error)
- func (r *PrivateTradeRequest) From(from int64) *PrivateTradeRequest
- func (r *PrivateTradeRequest) Limit(limit int64) *PrivateTradeRequest
- func (r *PrivateTradeRequest) Market(market string) *PrivateTradeRequest
- func (r *PrivateTradeRequest) Offset(offset int64) *PrivateTradeRequest
- func (r *PrivateTradeRequest) OrderBy(orderBy string) *PrivateTradeRequest
- func (r *PrivateTradeRequest) Pagination(p bool) *PrivateTradeRequest
- func (r *PrivateTradeRequest) Timestamp(t int64) *PrivateTradeRequest
- func (r *PrivateTradeRequest) To(to int64) *PrivateTradeRequest
- type PublicService
- func (s *PublicService) KLines(symbol string, resolution string, start time.Time, limit int) ([]KLine, error)
- func (s *PublicService) Markets() ([]Market, error)
- func (s *PublicService) Ticker(market string) (*Ticker, error)
- func (s *PublicService) Tickers() (map[string]Ticker, error)
- func (s *PublicService) Timestamp() (serverTimestamp int64, err error)
- type PublicTradeEvent
- type QueryOrderOptions
- type QueryTradeOptions
- type RestClient
- type Reward
- type RewardService
- type RewardType
- type RewardsRequest
- func (r *RewardsRequest) Currency(currency string) *RewardsRequest
- func (r *RewardsRequest) Do(ctx context.Context) (rewards []Reward, err error)
- func (r *RewardsRequest) From(from int64) *RewardsRequest
- func (r *RewardsRequest) Limit(limit int) *RewardsRequest
- func (r *RewardsRequest) To(to int64) *RewardsRequest
- type SubscribeOptions
- type Subscription
- type SubscriptionEvent
- type Ticker
- type Timestamp
- type Trade
- type TradeEntry
- type TradeInfo
- type TradeService
- type TradeSnapshot
- type TradeSnapshotEvent
- type TradeUpdate
- type TradeUpdateEvent
- type UserBank
- type UserInfo
- type VipLevel
- type VipLevelSettings
- type WebSocketService
- func (s *WebSocketService) AddSubscription(subscription Subscription)
- func (s *WebSocketService) Auth() error
- func (s *WebSocketService) ClearSubscriptions()
- func (s *WebSocketService) Close() error
- func (s *WebSocketService) Connect(ctx context.Context) error
- func (s *WebSocketService) EmitAccountSnapshotEvent(e AccountSnapshotEvent)
- func (s *WebSocketService) EmitAccountUpdateEvent(e AccountUpdateEvent)
- func (s *WebSocketService) EmitBookEvent(e BookEvent)
- func (s *WebSocketService) EmitConnect(conn *websocket.Conn)
- func (s *WebSocketService) EmitDisconnect()
- func (s *WebSocketService) EmitError(err error)
- func (s *WebSocketService) EmitErrorEvent(e ErrorEvent)
- func (s *WebSocketService) EmitKLineEvent(e KLineEvent)
- func (s *WebSocketService) EmitMessage(message []byte)
- func (s *WebSocketService) EmitOrderSnapshotEvent(e OrderSnapshotEvent)
- func (s *WebSocketService) EmitOrderUpdateEvent(e OrderUpdateEvent)
- func (s *WebSocketService) EmitSubscriptionEvent(e SubscriptionEvent)
- func (s *WebSocketService) EmitTradeEvent(e PublicTradeEvent)
- func (s *WebSocketService) EmitTradeSnapshotEvent(e TradeSnapshotEvent)
- func (s *WebSocketService) EmitTradeUpdateEvent(e TradeUpdateEvent)
- func (s *WebSocketService) OnAccountSnapshotEvent(cb func(e AccountSnapshotEvent))
- func (s *WebSocketService) OnAccountUpdateEvent(cb func(e AccountUpdateEvent))
- func (s *WebSocketService) OnBookEvent(cb func(e BookEvent))
- func (s *WebSocketService) OnConnect(cb func(conn *websocket.Conn))
- func (s *WebSocketService) OnDisconnect(cb func())
- func (s *WebSocketService) OnError(cb func(err error))
- func (s *WebSocketService) OnErrorEvent(cb func(e ErrorEvent))
- func (s *WebSocketService) OnKLineEvent(cb func(e KLineEvent))
- func (s *WebSocketService) OnMessage(cb func(message []byte))
- func (s *WebSocketService) OnOrderSnapshotEvent(cb func(e OrderSnapshotEvent))
- func (s *WebSocketService) OnOrderUpdateEvent(cb func(e OrderUpdateEvent))
- func (s *WebSocketService) OnSubscriptionEvent(cb func(e SubscriptionEvent))
- func (s *WebSocketService) OnTradeEvent(cb func(e PublicTradeEvent))
- func (s *WebSocketService) OnTradeSnapshotEvent(cb func(e TradeSnapshotEvent))
- func (s *WebSocketService) OnTradeUpdateEvent(cb func(e TradeUpdateEvent))
- func (s *WebSocketService) Reconnect()
- func (s *WebSocketService) Resubscribe()
- func (s *WebSocketService) SendSubscriptionRequest(action string) error
- func (s *WebSocketService) Subscribe(channel, market string, options SubscribeOptions)
- type WebsocketCommand
- type Withdraw
Constants ¶
const ( All = iota Active Closed )
const ( OrderStateDone = OrderState("done") OrderStateCancel = OrderState("cancel") OrderStateWait = OrderState("wait") OrderStateConvert = OrderState("convert") OrderStateFinalizing = OrderState("finalizing") OrderStateFailed = OrderState("failed") )
const ( OrderTypeMarket = OrderType("market") OrderTypeLimit = OrderType("limit") OrderTypePostOnly = OrderType("post_only") OrderTypeStopLimit = OrderType("stop_limit") OrderTypeStopMarket = OrderType("stop_market") )
Order types that the API can return.
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 )
const ( RewardAirdrop = RewardType("airdrop_reward") RewardCommission = RewardType("commission") RewardHolding = RewardType("holding_reward") RewardMining = RewardType("mining_reward") RewardTrading = RewardType("trading_reward") RewardVipRebate = RewardType("vip_rebate") )
const Buy = 1
const Sell = -1
Variables ¶
var ErrIncorrectBookEntryElementLength = errors.New("incorrect book entry element length")
var ErrMessageTypeNotSupported = errors.New("message type currently not supported")
var SubscribeAction = "subscribe"
var UnsubscribeAction = "unsubscribe"
var WebSocketURL = "wss://max-stream.maicoin.com/ws"
Functions ¶
func ParseMessage ¶
ParseMessage accepts the raw messages from max public websocket channels and parses them into market data Return types: *BookEvent, *PublicTradeEvent, *SubscriptionEvent, *ErrorEvent
func ParseUserEvent ¶
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 ¶ added in v1.14.1
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 AuthMessage ¶
type BalanceMessage ¶
type BookEntry ¶
func (*BookEntry) PriceVolumePair ¶
func (e *BookEntry) PriceVolumePair() (pv types.PriceVolume, err error)
type BookEvent ¶
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 ¶ added in v1.15.0
func (r *CreateMultiOrderRequest) GroupID(groupID uint32) *CreateMultiOrderRequest
func (*CreateMultiOrderRequest) Market ¶
func (r *CreateMultiOrderRequest) Market(market string) *CreateMultiOrderRequest
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 (r *CreateOrderRequest) Side(side string) *CreateOrderRequest
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 ¶
func (ErrorEvent) Time ¶
func (e ErrorEvent) Time() time.Time
type ErrorField ¶
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 (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type GetDepositHistoryRequest ¶
type GetDepositHistoryRequest struct {
// contains filtered or unexported fields
}
func (*GetDepositHistoryRequest) Currency ¶
func (r *GetDepositHistoryRequest) Currency(currency string) *GetDepositHistoryRequest
func (*GetDepositHistoryRequest) Do ¶
func (r *GetDepositHistoryRequest) Do(ctx context.Context) (deposits []Deposit, err error)
func (*GetDepositHistoryRequest) From ¶
func (r *GetDepositHistoryRequest) From(from int64) *GetDepositHistoryRequest
func (*GetDepositHistoryRequest) Limit ¶
func (r *GetDepositHistoryRequest) Limit(limit int) *GetDepositHistoryRequest
func (*GetDepositHistoryRequest) State ¶
func (r *GetDepositHistoryRequest) State(state string) *GetDepositHistoryRequest
func (*GetDepositHistoryRequest) To ¶
func (r *GetDepositHistoryRequest) To(to int64) *GetDepositHistoryRequest
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 (r *GetWithdrawHistoryRequest) Currency(currency string) *GetWithdrawHistoryRequest
func (*GetWithdrawHistoryRequest) Do ¶
func (r *GetWithdrawHistoryRequest) Do(ctx context.Context) (withdraws []Withdraw, err error)
func (*GetWithdrawHistoryRequest) From ¶
func (r *GetWithdrawHistoryRequest) From(from int64) *GetWithdrawHistoryRequest
func (*GetWithdrawHistoryRequest) Limit ¶
func (r *GetWithdrawHistoryRequest) Limit(limit int) *GetWithdrawHistoryRequest
func (*GetWithdrawHistoryRequest) State ¶
func (r *GetWithdrawHistoryRequest) State(state string) *GetWithdrawHistoryRequest
func (*GetWithdrawHistoryRequest) To ¶
func (r *GetWithdrawHistoryRequest) To(to int64) *GetWithdrawHistoryRequest
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 KLine ¶
type KLineEvent ¶
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 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 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 ¶ added in v1.5.0
type OrderCancelAllRequest struct {
// contains filtered or unexported fields
}
func (*OrderCancelAllRequest) Do ¶ added in v1.5.0
func (r *OrderCancelAllRequest) Do(ctx context.Context) (orders []Order, err error)
func (*OrderCancelAllRequest) GroupID ¶ added in v1.5.0
func (r *OrderCancelAllRequest) GroupID(groupID uint32) *OrderCancelAllRequest
func (*OrderCancelAllRequest) Market ¶ added in v1.5.0
func (r *OrderCancelAllRequest) Market(market string) *OrderCancelAllRequest
func (*OrderCancelAllRequest) Side ¶ added in v1.5.0
func (r *OrderCancelAllRequest) Side(side string) *OrderCancelAllRequest
type OrderCancelAllRequestParams ¶ added in v1.5.0
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) ID ¶
func (r *OrderCancelRequest) ID(id uint64) *OrderCancelRequest
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 ¶ added in v1.5.0
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 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 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 (r *PrivateTradeRequest) From(from int64) *PrivateTradeRequest
func (*PrivateTradeRequest) Limit ¶
func (r *PrivateTradeRequest) Limit(limit int64) *PrivateTradeRequest
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 ¶ added in v1.11.1
func (r *PrivateTradeRequest) Timestamp(t int64) *PrivateTradeRequest
func (*PrivateTradeRequest) To ¶
func (r *PrivateTradeRequest) To(to int64) *PrivateTradeRequest
type PublicService ¶
type PublicService struct {
// contains filtered or unexported fields
}
func (*PublicService) Markets ¶
func (s *PublicService) Markets() ([]Market, 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 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 // 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.
type Reward ¶ added in v1.13.0
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"` }
type RewardService ¶ added in v1.13.0
type RewardService struct {
// contains filtered or unexported fields
}
func (*RewardService) NewRewardsByTypeRequest ¶ added in v1.13.0
func (s *RewardService) NewRewardsByTypeRequest(pathType RewardType) *RewardsRequest
func (*RewardService) NewRewardsRequest ¶ added in v1.13.0
func (s *RewardService) NewRewardsRequest() *RewardsRequest
type RewardType ¶ added in v1.13.0
type RewardType string
func ParseRewardType ¶ added in v1.13.0
func ParseRewardType(s string) (RewardType, error)
func (RewardType) RewardType ¶ added in v1.13.0
func (t RewardType) RewardType() (types.RewardType, error)
func (*RewardType) UnmarshalJSON ¶ added in v1.13.0
func (t *RewardType) UnmarshalJSON(o []byte) error
type RewardsRequest ¶ added in v1.13.0
type RewardsRequest struct {
// contains filtered or unexported fields
}
func (*RewardsRequest) Currency ¶ added in v1.13.0
func (r *RewardsRequest) Currency(currency string) *RewardsRequest
func (*RewardsRequest) Do ¶ added in v1.13.0
func (r *RewardsRequest) Do(ctx context.Context) (rewards []Reward, err error)
func (*RewardsRequest) From ¶ added in v1.13.0
func (r *RewardsRequest) From(from int64) *RewardsRequest
func (*RewardsRequest) Limit ¶ added in v1.13.0
func (r *RewardsRequest) Limit(limit int) *RewardsRequest
func (*RewardsRequest) To ¶ added in v1.13.0
func (r *RewardsRequest) To(to int64) *RewardsRequest
type SubscribeOptions ¶ added in v1.13.0
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 Timestamp ¶ added in v1.13.0
func (*Timestamp) UnmarshalJSON ¶ added in v1.13.0
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.
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 TradeUpdateEvent ¶
type TradeUpdateEvent struct { BaseEvent Trades []TradeUpdate `json:"t"` }
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 ¶ added in v1.14.1
type VipLevel struct { Current VipLevelSettings `json:"current_vip_level"` Next VipLevelSettings `json:"next_vip_level"` }
type VipLevelSettings ¶ added in v1.14.1
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) 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"` }