Documentation
¶
Index ¶
- Constants
- Variables
- func IsFilledOrderState(state OrderState) bool
- func ParseMessage(payload []byte) (interface{}, error)
- func ParseUserEvent(v *fastjson.Value) (interface{}, error)
- func SignPayload(payload string, secret string) string
- type ADRatio
- type ADRatioEvent
- type Account
- type AccountSnapshotEvent
- type AccountUpdateEvent
- type AuthEvent
- type AuthMessage
- type BalanceMessage
- type BaseEvent
- type BookEvent
- type Debt
- type DebtEvent
- type ErrorEvent
- type ErrorField
- type ErrorResponse
- type KLine
- type KLineEvent
- type KLinePayload
- type Order
- type OrderByType
- type OrderSnapshotEvent
- type OrderState
- type OrderStateToQuery
- type OrderType
- type OrderUpdate
- type OrderUpdateEvent
- type PublicTradeEvent
- type SubscribeOptions
- type Subscription
- type SubscriptionEvent
- type TradeEntry
- type TradeSnapshotEvent
- type TradeUpdate
- type TradeUpdateEvent
- type UserBank
- type UserInfo
- type VipLevel
- type VipLevelSettings
- type WalletType
- type WebsocketCommand
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") OrderTypeIOCLimit = OrderType("ioc_limit") )
Order types that the API can return.
const ( Buy = 1 Sell = -1 )
const ( BookEventSnapshot string = "snapshot" BookEventUpdate string = "update" )
Variables ¶
var ErrIncorrectBookEntryElementLength = errors.New("incorrect book entry element length")
var ErrMessageTypeNotSupported = errors.New("message type currently not supported")
var WebSocketURL = "wss://max-stream.maicoin.com/ws"
Functions ¶
func IsFilledOrderState ¶ added in v1.58.0
func IsFilledOrderState(state OrderState) bool
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 ¶
func SignPayload ¶ added in v1.64.0
Types ¶
type ADRatio ¶ added in v1.33.0
type ADRatio struct {
ADRatio fixedpoint.Value `json:"ad"`
AssetInUSDT fixedpoint.Value `json:"as"`
DebtInUSDT fixedpoint.Value `json:"db"`
IndexPrices []struct {
Market string `json:"M"`
Price fixedpoint.Value `json:"p"`
} `json:"idxp"`
TU types.MillisecondTimestamp `json:"TU"`
}
type ADRatioEvent ¶ added in v1.33.0
type ADRatioEvent struct {
ADRatio ADRatio `json:"ad"`
}
type Account ¶
type Account struct {
Type string `json:"type"`
Currency string `json:"currency"`
Balance fixedpoint.Value `json:"balance"`
Locked fixedpoint.Value `json:"locked"`
// v3 fields for M wallet
Principal fixedpoint.Value `json:"principal"`
Interest fixedpoint.Value `json:"interest"`
// v2 fields
FiatCurrency string `json:"fiat_currency"`
FiatBalance fixedpoint.Value `json:"fiat_balance"`
}
Account is for max rest api v2, Balance and Type will be conflict with types.PrivateBalanceUpdate
type AccountSnapshotEvent ¶
type AccountSnapshotEvent struct {
BaseEvent
Balances []BalanceMessage `json:"B"`
}
type AccountUpdateEvent ¶
type AccountUpdateEvent struct {
BaseEvent
Balances []BalanceMessage `json:"B"`
}
type AuthMessage ¶
type AuthMessage struct {
Action string `json:"action,omitempty"`
APIKey string `json:"apiKey,omitempty"`
Nonce int64 `json:"nonce,omitempty"`
Signature string `json:"signature,omitempty"`
ID string `json:"id,omitempty"`
Filters []string `json:"filters,omitempty"`
// SubAccount is the SN of the sub-account to access, this is only for master account.
SubAccount string `json:"subAccount,omitempty"`
}
type BalanceMessage ¶
type BalanceMessage struct {
Currency string `json:"cu"`
Available fixedpoint.Value `json:"av"`
Locked fixedpoint.Value `json:"l"`
SubAccount string `json:"sa,omitempty"`
}
type BookEvent ¶
type BookEvent struct {
Event string `json:"e"`
Market string `json:"M"`
Channel string `json:"c"`
Timestamp int64 `json:"t"` // Millisecond timestamp
Bids types.PriceVolumeSlice
Asks types.PriceVolumeSlice
FirstUpdateID int64 `json:"fi"`
LastUpdateID int64 `json:"li"`
Version int64 `json:"v"`
}
type Debt ¶ added in v1.33.0
type Debt struct {
Currency string `json:"cu"`
DebtPrincipal fixedpoint.Value `json:"dbp"`
DebtInterest fixedpoint.Value `json:"dbi"`
TU types.MillisecondTimestamp `json:"TU"`
}
type ErrorEvent ¶
func (ErrorEvent) Time ¶
func (e ErrorEvent) Time() time.Time
type ErrorField ¶
type ErrorResponse ¶
type ErrorResponse struct {
*requestgen.Response
Err ErrorField `json:"error"`
}
ErrorResponse is the custom error type that is returned if the API returns an error.
func ToErrorResponse ¶ added in v1.17.0
func ToErrorResponse(response *requestgen.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 KLine ¶
type KLine struct {
Symbol string
Interval string
StartTime, EndTime time.Time
Open, High, Low, Close fixedpoint.Value
Volume fixedpoint.Value
Closed bool
}
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 Order ¶
type Order struct {
ID uint64 `json:"id,omitempty"`
WalletType WalletType `json:"wallet_type,omitempty"`
Side string `json:"side"`
OrderType OrderType `json:"ord_type"`
Price fixedpoint.Value `json:"price,omitempty"`
StopPrice fixedpoint.Value `json:"stop_price,omitempty"`
AveragePrice fixedpoint.Value `json:"avg_price,omitempty"`
State OrderState `json:"state,omitempty"`
Market string `json:"market,omitempty"`
Volume fixedpoint.Value `json:"volume"`
RemainingVolume fixedpoint.Value `json:"remaining_volume,omitempty"`
ExecutedVolume fixedpoint.Value `json:"executed_volume,omitempty"`
TradesCount int64 `json:"trades_count,omitempty"`
GroupID uint32 `json:"group_id,omitempty"`
ClientOID string `json:"client_oid,omitempty"`
CreatedAt types.MillisecondTimestamp `json:"created_at"`
UpdatedAt types.MillisecondTimestamp `json:"updated_at"`
}
Order represents one returned order (POST order/GET order/GET orders) on the max platform.
type OrderByType ¶ added in v1.55.0
type OrderByType string
const ( OrderByAsc OrderByType = "asc" OrderByDesc OrderByType = "desc" OrderByAscUpdatedAt OrderByType = "asc_updated_at" OrderByDescUpdatedAt OrderByType = "desc_updated_at" )
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 fixedpoint.Value `json:"p"`
StopPrice fixedpoint.Value `json:"sp"`
Volume fixedpoint.Value `json:"v"`
AveragePrice fixedpoint.Value `json:"ap"`
State OrderState `json:"S"`
Market string `json:"M"`
RemainingVolume fixedpoint.Value `json:"rv"`
ExecutedVolume fixedpoint.Value `json:"ev"`
TradesCount int64 `json:"tc"`
GroupID uint32 `json:"gi"`
ClientOID string `json:"ci"`
CreatedAtMs int64 `json:"T"`
UpdateTime int64 `json:"TU"`
}
type OrderUpdateEvent ¶
type OrderUpdateEvent struct {
BaseEvent
Orders []OrderUpdate `json:"o"`
}
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 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 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 TradeSnapshotEvent ¶
type TradeSnapshotEvent struct {
BaseEvent
Trades []TradeUpdate `json:"t"`
}
type TradeUpdate ¶
type TradeUpdate struct {
ID uint64 `json:"i"`
Side string `json:"sd"`
Price fixedpoint.Value `json:"p"`
Volume fixedpoint.Value `json:"v"`
Funds fixedpoint.Value `json:"fn"`
Market string `json:"M"`
Fee fixedpoint.Value `json:"f"`
FeeCurrency string `json:"fc"`
FeeDiscounted bool `json:"fd"`
Timestamp types.MillisecondTimestamp `json:"T"`
UpdateTime types.MillisecondTimestamp `json:"TU"`
OrderID uint64 `json:"oi"`
Maker bool `json:"m"`
}
type TradeUpdateEvent ¶
type TradeUpdateEvent struct {
BaseEvent
Trades []TradeUpdate `json:"t"`
}
type UserInfo ¶
type UserInfo struct {
Email string `json:"email"`
Level int `json:"level"`
MWalletEnabled bool `json:"m_wallet_enabled"`
Current VipLevelSettings `json:"current_vip_level"`
Next VipLevelSettings `json:"next_vip_level"`
}
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 WalletType ¶ added in v1.33.0
type WalletType string
const ( WalletTypeSpot WalletType = "spot" WalletTypeMargin WalletType = "m" )
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"`
}