Documentation
¶
Overview ¶
Package mbx provides shared rate-limit tracking and error mapping for Binance-family exchanges (Binance, Aster) that use the X-Mbx-* header convention for communicating request weight and order count usage.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRateLimitMessage ¶
IsRateLimitMessage checks if the error message suggests rate limiting.
func MapAPIError ¶
func MapAPIError(exchange string, statusCode int, data []byte, unmarshalErr func([]byte) (int, string, error)) error
MapAPIError parses a Binance-family API error response and wraps rate-limit errors as exchanges.ErrRateLimited. The apiErr parameter should be a pointer to a struct with Code (int) and Message (string) fields populated from the JSON response body. Returns nil if no error mapping was needed — caller should fall through to returning apiErr directly.
Types ¶
type OrderCount ¶
OrderCount tracks the order rate as reported by the exchange via X-Mbx-Order-Count-10s and X-Mbx-Order-Count-1d headers.
func (*OrderCount) UpdateByHeader ¶
func (o *OrderCount) UpdateByHeader(header http.Header)
UpdateByHeader reads X-Mbx-Order-Count headers and atomically stores them.
type UsedWeight ¶
UsedWeight tracks the cumulative request weight as reported by the exchange via X-Mbx-Used-Weight and X-Mbx-Used-Weight-1m headers.
func (*UsedWeight) UpdateByHeader ¶
func (u *UsedWeight) UpdateByHeader(header http.Header)
UpdateByHeader reads X-Mbx-Used-Weight headers and atomically stores them.