{"modulePath":"github.com/QuantProcessing/exchanges","version":"v1.0.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package mbx\n\nPackage 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.\n\n## Functions\n\n```go\nfunc IsRateLimitMessage(message string) bool\n```\nIsRateLimitMessage checks if the error message suggests rate limiting.\n\n```go\nfunc MapAPIError(exchange string, statusCode int, data []byte, unmarshalErr func([]byte) (int, string, error)) error\n```\nMapAPIError 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.\n\n```go\nfunc UnmarshalAPIError(data []byte) (code int, message string, err error)\n```\nAPIErrorFields is a helper that extracts Code and Message from a standard Binance-family JSON error response: {\"code\": -1003, \"msg\": \"...\"}.\n\n## Types\n\n```go\ntype OrderCount struct {\n\tCount10s int64\n\tCount1d  int64\n}\n```\nOrderCount tracks the order rate as reported by the exchange via X-Mbx-Order-Count-10s and X-Mbx-Order-Count-1d headers.\n\n```go\nfunc (o *OrderCount) UpdateByHeader(header http.Header)\n```\nUpdateByHeader reads X-Mbx-Order-Count headers and atomically stores them.\n\n```go\ntype UsedWeight struct {\n\tUsed   int64\n\tUsed1M int64\n}\n```\nUsedWeight tracks the cumulative request weight as reported by the exchange via X-Mbx-Used-Weight and X-Mbx-Used-Weight-1m headers.\n\n```go\nfunc (u *UsedWeight) UpdateByHeader(header http.Header)\n```\nUpdateByHeader reads X-Mbx-Used-Weight headers and atomically stores them.\n\n","path":"github.com/QuantProcessing/exchanges/internal/mbx","name":"mbx","synopsis":"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.","isRedistributable":true}
