Versions in this module Expand all Collapse all v0 v0.1.2 Jun 25, 2026 Changes in this version + const DefaultBaseURL + const DefaultWSBaseURL + const Version + var ErrMissingCredentials = errors.New("ctgexchange: api key and secret are required for private endpoints") + var ErrStreamClosed = errors.New("ctgexchange: stream closed") + func RESTCanonicalString(ts int64, method, requestURI, body string) string + func RESTHeaders(keyID, secret, method, requestURI, body string, ts int64) map[string]string + func SHA256Hex(body string) string + func SignREST(secret string, ts int64, method, requestURI, body string) string + func SignWSAuth(secret string, ts int64) string + func WSAuthMessage(keyID, secret string, ts int64) map[string]any + type APIError struct + Code string + Message string + RequestID string + RetryAfter int + StatusCode int + func (e *APIError) Error() string + func (e *APIError) IsBadRequest() bool + func (e *APIError) IsForbidden() bool + func (e *APIError) IsNotFound() bool + func (e *APIError) IsRateLimited() bool + func (e *APIError) IsUnauthorized() bool + type Balance struct + Asset string + Available string + Reserved string + type BookLevel struct + Price string + Qty string + type Candle struct + Close string + CloseTime int64 + High string + Low string + Open string + OpenTime int64 + Trades int + Volume string + type CandleOptions struct + From int64 + Limit int + To int64 + type Client struct + func NewClient(cfg Config) *Client + func (c *Client) CancelAllOrders(ctx context.Context, symbol string) ([]Order, error) + func (c *Client) CancelOrder(ctx context.Context, symbol, orderID string) (Order, error) + func (c *Client) GetBalances(ctx context.Context) ([]Balance, error) + func (c *Client) GetCandles(ctx context.Context, symbol, interval string, opts CandleOptions) ([]Candle, error) + func (c *Client) GetFees(ctx context.Context) (UserFees, error) + func (c *Client) GetMyTrades(ctx context.Context, symbol string, q TradeQuery) ([]Trade, error) + func (c *Client) GetOpenOrders(ctx context.Context) ([]Order, error) + func (c *Client) GetOrder(ctx context.Context, symbol, orderID string) (Order, error) + func (c *Client) GetOrderBook(ctx context.Context, symbol string) (OrderBook, error) + func (c *Client) GetOrders(ctx context.Context, symbol string, q OrderQuery) ([]Order, error) + func (c *Client) GetSymbols(ctx context.Context) ([]Symbol, error) + func (c *Client) GetTicker(ctx context.Context, symbol string) (Ticker, error) + func (c *Client) GetTickers(ctx context.Context) ([]Ticker, error) + func (c *Client) GetTrades(ctx context.Context, symbol string, limit int) ([]Trade, error) + func (c *Client) ModifyOrder(ctx context.Context, symbol, orderID string, p ModifyOrderParams) (Order, error) + func (c *Client) PlaceOrder(ctx context.Context, symbol string, p PlaceOrderParams) (OrderResult, error) + type Config struct + APIKey string + APISecret string + BaseURL string + HTTPClient *http.Client + MaxRetries int + Timeout time.Duration + type FeeRebate struct + AccountID string + FractionBps int + type ModifyOrderParams struct + NewPrice string + NewQty string + type Order struct + AvgExecutionPrice string + ClientOrderID string + CreatedAt string + FeeAmount string + FeeAsset string + FilledQty string + ID string + MakerFeeBps int + Price string + Qty string + Rebate *FeeRebate + RemainingQty string + Side string + Status string + Symbol string + TakerFeeBps int + TimeInForce string + Type string + UID string + UpdatedAt string + type OrderBook struct + Asks []BookLevel + Bids []BookLevel + LastUpdateID int64 + Symbol string + type OrderQuery struct + Limit int + Offset int + Status string + type OrderResult struct + Order Order + Trades []Trade + type PlaceOrderParams struct + ClientOrderID string + Price string + Qty string + Side string + Type string + type Rebate struct + FractionBps int + ReferrerAccount string + type Stream struct + func NewMarketDataStream(cfg StreamConfig) *Stream + func NewUserStream(apiKey, apiSecret string, cfg StreamConfig) (*Stream, error) + func (s *Stream) Close() + func (s *Stream) Next(ctx context.Context) (StreamMessage, error) + func (s *Stream) Subscribe(channels ...string) + func (s *Stream) Unsubscribe(channels ...string) + type StreamConfig struct + BaseURL string + Channels []string + DisableReconnect bool + ReconnectDelay time.Duration + type StreamMessage struct + Channel string + Data json.RawMessage + Symbol string + Type string + type Symbol struct + BaseAsset string + MaxPrice string + MaxQty string + MinNotional string + MinPrice string + MinQty string + PriceScale int + QtyScale int + QuoteAsset string + QuoteAssetScale int + StepSize string + Symbol string + TickSize string + type Ticker struct + ChangeBps int + Close string + High string + Low string + Open string + Price string + Symbol string + Trades int + Ts int64 + Volume string + type Trade struct + AggressorSide string + BuyFeeAmount string + BuyFeeAsset string + BuyFeeBps int + BuyOrderID string + BuyRebate *FeeRebate + BuyUID string + CreatedAt string + ID string + MakerOrderID string + Price string + Qty string + SellFeeAmount string + SellFeeAsset string + SellFeeBps int + SellOrderID string + SellRebate *FeeRebate + SellUID string + Symbol string + TakerOrderID string + type TradeQuery struct + Limit int + Offset int + type UserFees struct + MakerFeeBps *int + Rebate *Rebate + TakerFeeBps *int