max

package
v1.61.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: AGPL-3.0 Imports: 22 Imported by: 8

Documentation

Overview

Code generated by go:generate; DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var AllMarginPrivateChannels = map[PrivateChannel]struct{}{
	PrivateChannelMWalletOrder:           {},
	PrivateChannelMWalletTrade:           {},
	PrivateChannelMWalletFastTradeUpdate: {},
	PrivateChannelMWalletAccount:         {},
	PrivateChannelMWalletAveragePrice:    {},
	PrivateChannelBorrowing:              {},
	PrivateChannelAdRatio:                {},
	PrivateChannelPoolQuota:              {},
}
View Source
var AllMiscPrivateChannels = map[PrivateChannel]struct{}{
	PrivateChannelAveragePrice:   {},
	PrivateChannelFavoriteMarket: {},
}
View Source
var AllPrivateChannels = map[PrivateChannel]struct{}{
	PrivateChannelOrder:                  {},
	PrivateChannelOrderUpdate:            {},
	PrivateChannelTrade:                  {},
	PrivateChannelTradeUpdate:            {},
	PrivateChannelFastTradeUpdate:        {},
	PrivateChannelAccount:                {},
	PrivateChannelAccountUpdate:          {},
	PrivateChannelAveragePrice:           {},
	PrivateChannelFavoriteMarket:         {},
	PrivateChannelMWalletOrder:           {},
	PrivateChannelMWalletTrade:           {},
	PrivateChannelMWalletFastTradeUpdate: {},
	PrivateChannelMWalletAccount:         {},
	PrivateChannelMWalletAveragePrice:    {},
	PrivateChannelBorrowing:              {},
	PrivateChannelAdRatio:                {},
	PrivateChannelPoolQuota:              {},
}
View Source
var SupportedIntervals = map[types.Interval]int{
	types.Interval1m:  1 * 60,
	types.Interval5m:  5 * 60,
	types.Interval15m: 15 * 60,
	types.Interval30m: 30 * 60,
	types.Interval1h:  60 * 60,
	types.Interval2h:  60 * 60 * 2,
	types.Interval4h:  60 * 60 * 4,
	types.Interval6h:  60 * 60 * 6,
	types.Interval12h: 60 * 60 * 12,
	types.Interval1d:  60 * 60 * 24,
	types.Interval3d:  60 * 60 * 24 * 3,
}

Functions

func IsMarginPrivateChannel added in v1.61.0

func IsMarginPrivateChannel(ch PrivateChannel) bool

IsMarginPrivateChannel checks if the value is in the Margin group of PrivateChannel

func IsMiscPrivateChannel added in v1.61.0

func IsMiscPrivateChannel(ch PrivateChannel) bool

IsMiscPrivateChannel checks if the value is in the Misc group of PrivateChannel

func NewClientOrderID added in v1.17.0

func NewClientOrderID(originalID string, tags ...string) (clientOrderID string)

func PrivateChannelStrings added in v1.61.0

func PrivateChannelStrings(slice []PrivateChannel) (out []string)

PrivateChannelStrings converts a slice of PrivateChannel to a slice of string

func ToLocalDepth added in v1.61.0

func ToLocalDepth(depth types.Depth) int

func ValidateMarginPrivateChannels added in v1.61.0

func ValidateMarginPrivateChannels(ch PrivateChannel) bool

ValidateMarginPrivateChannels validates if a value belongs to the Margin group of PrivateChannel

func ValidateMiscPrivateChannels added in v1.61.0

func ValidateMiscPrivateChannels(ch PrivateChannel) bool

ValidateMiscPrivateChannels validates if a value belongs to the Misc group of PrivateChannel

func ValidatePrivateChannel added in v1.61.0

func ValidatePrivateChannel(ch PrivateChannel) bool

ValidatePrivateChannel validates a value of type PrivateChannel

Types

type Exchange

type Exchange struct {
	types.MarginSettings
	// contains filtered or unexported fields
}

func New

func New(key, secret string) *Exchange

func (*Exchange) BorrowMarginAsset added in v1.33.0

func (e *Exchange) BorrowMarginAsset(ctx context.Context, asset string, amount fixedpoint.Value) error

func (*Exchange) CancelAllOrders added in v1.5.0

func (e *Exchange) CancelAllOrders(ctx context.Context) ([]types.Order, error)

func (*Exchange) CancelOrders

func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) (err2 error)

func (*Exchange) CancelOrdersByGroupID added in v1.5.0

func (e *Exchange) CancelOrdersByGroupID(ctx context.Context, groupID uint32) ([]types.Order, error)

func (*Exchange) CancelOrdersBySymbol added in v1.5.0

func (e *Exchange) CancelOrdersBySymbol(ctx context.Context, symbol string) ([]types.Order, error)

func (*Exchange) DefaultFeeRates added in v1.33.0

func (e *Exchange) DefaultFeeRates() types.ExchangeFee

DefaultFeeRates returns the MAX VIP 0 fee schedule See also https://max-vip-zh.maicoin.com/

func (*Exchange) IsSupportedInterval added in v1.38.0

func (e *Exchange) IsSupportedInterval(interval types.Interval) bool

func (*Exchange) Name

func (e *Exchange) Name() types.ExchangeName

func (*Exchange) NewStream

func (e *Exchange) NewStream() types.Stream

func (*Exchange) PlatformFeeCurrency

func (e *Exchange) PlatformFeeCurrency() string

PlatformFeeCurrency

func (*Exchange) QueryAccount

func (e *Exchange) QueryAccount(ctx context.Context) (*types.Account, error)

func (*Exchange) QueryAccountBalances

func (e *Exchange) QueryAccountBalances(ctx context.Context) (types.BalanceMap, error)

func (*Exchange) QueryAveragePrice

func (e *Exchange) QueryAveragePrice(ctx context.Context, symbol string) (fixedpoint.Value, error)

func (*Exchange) QueryClosedOrders

func (e *Exchange) QueryClosedOrders(
	ctx context.Context, symbol string, since, until time.Time, lastOrderID uint64,
) ([]types.Order, error)

func (*Exchange) QueryClosedOrdersDesc added in v1.55.0

func (e *Exchange) QueryClosedOrdersDesc(
	ctx context.Context, symbol string, since, until time.Time, lastOrderID uint64,
) ([]types.Order, error)

func (*Exchange) QueryDepositHistory

func (e *Exchange) QueryDepositHistory(
	ctx context.Context, asset string, since, until time.Time,
) (allDeposits []types.Deposit, err error)

func (*Exchange) QueryDepth added in v1.61.0

func (e *Exchange) QueryDepth(
	ctx context.Context, symbol string, limit int,
) (snapshot types.SliceOrderBook, finalUpdateID int64, err error)

func (*Exchange) QueryKLines

func (e *Exchange) QueryKLines(
	ctx context.Context, symbol string, interval types.Interval, options types.KLineQueryOptions,
) ([]types.KLine, error)

QueryKLines returns the klines from the MAX exchange API. The KLine API of the MAX exchange uses inclusive time range

https://max-api.maicoin.com/api/v2/k?market=btctwd&limit=10&period=1&timestamp=1620202440 The above query will return a kline that starts with 1620202440 (unix timestamp) without endTime. We need to calculate the endTime by ourself.

func (*Exchange) QueryMarginAssetMaxBorrowable added in v1.33.0

func (e *Exchange) QueryMarginAssetMaxBorrowable(
	ctx context.Context, asset string,
) (amount fixedpoint.Value, err error)

func (*Exchange) QueryMarkets

func (e *Exchange) QueryMarkets(ctx context.Context) (types.MarketMap, error)

func (*Exchange) QueryOpenOrders

func (e *Exchange) QueryOpenOrders(ctx context.Context, symbol string) ([]types.Order, error)

func (*Exchange) QueryOrder added in v1.28.0

func (e *Exchange) QueryOrder(ctx context.Context, q types.OrderQuery) (*types.Order, error)

func (*Exchange) QueryOrderTrades added in v1.39.0

func (e *Exchange) QueryOrderTrades(ctx context.Context, q types.OrderQuery) ([]types.Trade, error)

func (*Exchange) QueryRewards added in v1.13.0

func (e *Exchange) QueryRewards(ctx context.Context, startTime time.Time) ([]types.Reward, error)

func (*Exchange) QuerySpotAccount added in v1.52.0

func (e *Exchange) QuerySpotAccount(ctx context.Context) (*types.Account, error)

func (*Exchange) QueryTicker added in v1.11.1

func (e *Exchange) QueryTicker(ctx context.Context, symbol string) (*types.Ticker, error)

func (*Exchange) QueryTickers added in v1.11.0

func (e *Exchange) QueryTickers(ctx context.Context, symbol ...string) (map[string]types.Ticker, error)

func (*Exchange) QueryTrades

func (e *Exchange) QueryTrades(
	ctx context.Context, symbol string, options *types.TradeQueryOptions,
) (trades []types.Trade, err error)

QueryTrades For MAX API spec give from_id -> query trades from this id and order by asc give timestamp and order is asc -> query trades after timestamp and order by asc give timestamp and order is desc -> query trades before timestamp and order by desc limit should b1 1~1000

func (*Exchange) QueryWithdrawHistory

func (e *Exchange) QueryWithdrawHistory(
	ctx context.Context, asset string, since, until time.Time,
) (allWithdraws []types.Withdraw, err error)

func (*Exchange) RepayMarginAsset added in v1.33.0

func (e *Exchange) RepayMarginAsset(ctx context.Context, asset string, amount fixedpoint.Value) error

func (*Exchange) SubmitOrder added in v1.40.3

func (e *Exchange) SubmitOrder(ctx context.Context, order types.SubmitOrder) (createdOrder *types.Order, err error)

func (*Exchange) SupportedInterval added in v1.38.0

func (e *Exchange) SupportedInterval() map[types.Interval]int

func (*Exchange) TransferMarginAccountAsset added in v1.52.0

func (e *Exchange) TransferMarginAccountAsset(ctx context.Context, asset string, amount fixedpoint.Value, io types.TransferDirection) error

TransferMarginAccountAsset transfers the asset into/out from the margin account

types.TransferIn => Spot to Margin types.TransferOut => Margin to Spot

to call this method, you must set the IsMargin = true

func (*Exchange) Withdraw added in v1.33.0

func (e *Exchange) Withdraw(
	ctx context.Context, asset string, amount fixedpoint.Value, address string, options *types.WithdrawalOptions,
) error

type PrivateChannel added in v1.61.0

type PrivateChannel string
const (
	PrivateChannelOrder           PrivateChannel = "order"
	PrivateChannelOrderUpdate     PrivateChannel = "order_update"
	PrivateChannelTrade           PrivateChannel = "trade"
	PrivateChannelTradeUpdate     PrivateChannel = "trade_update"
	PrivateChannelFastTradeUpdate PrivateChannel = "fast_trade_update"
	PrivateChannelAccount         PrivateChannel = "account"
	PrivateChannelAccountUpdate   PrivateChannel = "account_update"

	// @group Misc
	PrivateChannelAveragePrice   PrivateChannel = "average_price"
	PrivateChannelFavoriteMarket PrivateChannel = "favorite_market"

	// @group Margin
	PrivateChannelMWalletOrder           PrivateChannel = "mwallet_order"
	PrivateChannelMWalletTrade           PrivateChannel = "mwallet_trade"
	PrivateChannelMWalletFastTradeUpdate PrivateChannel = "mwallet_fast_trade_update"
	PrivateChannelMWalletAccount         PrivateChannel = "mwallet_account"
	PrivateChannelMWalletAveragePrice    PrivateChannel = "mwallet_average_price"
	PrivateChannelBorrowing              PrivateChannel = "borrowing"
	PrivateChannelAdRatio                PrivateChannel = "ad_ratio"
	PrivateChannelPoolQuota              PrivateChannel = "borrowing_pool_quota"
)

func AllMarginPrivateChannelsKeys added in v1.61.0

func AllMarginPrivateChannelsKeys() []PrivateChannel

AllMarginPrivateChannelsKeys converts the Margin group map of PrivateChannel to a slice of PrivateChannel

func AllMiscPrivateChannelsKeys added in v1.61.0

func AllMiscPrivateChannelsKeys() []PrivateChannel

AllMiscPrivateChannelsKeys converts the Misc group map of PrivateChannel to a slice of PrivateChannel

func PrivateChannelKeys added in v1.61.0

func PrivateChannelKeys(values map[PrivateChannel]struct{}) (slice []PrivateChannel)

PrivateChannelKeys converts a map of PrivateChannel to a slice of PrivateChannel

type Stream

type Stream struct {
	types.StandardStream
	types.MarginSettings
	// contains filtered or unexported fields
}

func NewStream

func NewStream(ex *Exchange, key, secret string) *Stream

func (*Stream) EmitAccountSnapshotEvent added in v1.23.0

func (s *Stream) EmitAccountSnapshotEvent(e max.AccountSnapshotEvent)

func (*Stream) EmitAccountUpdateEvent added in v1.23.0

func (s *Stream) EmitAccountUpdateEvent(e max.AccountUpdateEvent)

func (*Stream) EmitAdRatioEvent added in v1.33.0

func (s *Stream) EmitAdRatioEvent(e max.ADRatioEvent)

func (*Stream) EmitAuthEvent added in v1.23.0

func (s *Stream) EmitAuthEvent(e max.AuthEvent)

func (*Stream) EmitBookEvent added in v1.23.0

func (s *Stream) EmitBookEvent(e max.BookEvent)

func (*Stream) EmitDebtEvent added in v1.33.0

func (s *Stream) EmitDebtEvent(e max.DebtEvent)

func (*Stream) EmitErrorEvent added in v1.23.0

func (s *Stream) EmitErrorEvent(e max.ErrorEvent)

func (*Stream) EmitKLineEvent added in v1.23.0

func (s *Stream) EmitKLineEvent(e max.KLineEvent)

func (*Stream) EmitOrderSnapshotEvent added in v1.23.0

func (s *Stream) EmitOrderSnapshotEvent(e max.OrderSnapshotEvent)

func (*Stream) EmitOrderUpdateEvent added in v1.23.0

func (s *Stream) EmitOrderUpdateEvent(e max.OrderUpdateEvent)

func (*Stream) EmitSubscriptionEvent added in v1.23.0

func (s *Stream) EmitSubscriptionEvent(e max.SubscriptionEvent)

func (*Stream) EmitTradeEvent added in v1.23.0

func (s *Stream) EmitTradeEvent(e max.PublicTradeEvent)

func (*Stream) EmitTradeSnapshotEvent added in v1.23.0

func (s *Stream) EmitTradeSnapshotEvent(e max.TradeSnapshotEvent)

func (*Stream) EmitTradeUpdateEvent added in v1.23.0

func (s *Stream) EmitTradeUpdateEvent(e max.TradeUpdateEvent)

func (*Stream) OnAccountSnapshotEvent added in v1.23.0

func (s *Stream) OnAccountSnapshotEvent(cb func(e max.AccountSnapshotEvent))

func (*Stream) OnAccountUpdateEvent added in v1.23.0

func (s *Stream) OnAccountUpdateEvent(cb func(e max.AccountUpdateEvent))

func (*Stream) OnAdRatioEvent added in v1.33.0

func (s *Stream) OnAdRatioEvent(cb func(e max.ADRatioEvent))

func (*Stream) OnAuthEvent added in v1.23.0

func (s *Stream) OnAuthEvent(cb func(e max.AuthEvent))

func (*Stream) OnBookEvent added in v1.23.0

func (s *Stream) OnBookEvent(cb func(e max.BookEvent))

func (*Stream) OnDebtEvent added in v1.33.0

func (s *Stream) OnDebtEvent(cb func(e max.DebtEvent))

func (*Stream) OnErrorEvent added in v1.23.0

func (s *Stream) OnErrorEvent(cb func(e max.ErrorEvent))

func (*Stream) OnKLineEvent added in v1.23.0

func (s *Stream) OnKLineEvent(cb func(e max.KLineEvent))

func (*Stream) OnOrderSnapshotEvent added in v1.23.0

func (s *Stream) OnOrderSnapshotEvent(cb func(e max.OrderSnapshotEvent))

func (*Stream) OnOrderUpdateEvent added in v1.23.0

func (s *Stream) OnOrderUpdateEvent(cb func(e max.OrderUpdateEvent))

func (*Stream) OnSubscriptionEvent added in v1.23.0

func (s *Stream) OnSubscriptionEvent(cb func(e max.SubscriptionEvent))

func (*Stream) OnTradeEvent added in v1.23.0

func (s *Stream) OnTradeEvent(cb func(e max.PublicTradeEvent))

func (*Stream) OnTradeSnapshotEvent added in v1.23.0

func (s *Stream) OnTradeSnapshotEvent(cb func(e max.TradeSnapshotEvent))

func (*Stream) OnTradeUpdateEvent added in v1.23.0

func (s *Stream) OnTradeUpdateEvent(cb func(e max.TradeUpdateEvent))

func (*Stream) SetPrivateChannels added in v1.53.0

func (s *Stream) SetPrivateChannels(channels []string)

func (*Stream) String added in v1.61.0

func (s *Stream) String() string

Directories

Path Synopsis
v3

Jump to

Keyboard shortcuts

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