Documentation
¶
Index ¶
- Variables
- func EncodeURLValues(urlPath string, values url.Values) string
- func Query(params []string) string
- func SignSHA256HMAC(message string, secret string) (string, error)
- type Auth
- type Candle
- type Client
- func (c *Client) Delete(ctx context.Context, path string, payload interface{}, v interface{}) error
- func (c *Client) Get(ctx context.Context, path string, v interface{}) error
- func (c *Client) Post(ctx context.Context, path string, payload interface{}, v interface{}) error
- func (c *Client) Put(ctx context.Context, path string, payload interface{}, v interface{}) error
- type Config
- type Dialer
- type Exchange
- type ExchangeFeatures
- type HTTPClient
- type IExchange
- type Name
- type Options
- type Product
- type RequestError
- type Websocket
Constants ¶
This section is empty.
Variables ¶
var ( ErrUserAccessDenied = errors.New("you do not have access to the requested resource") ErrNotFound = errors.New("the requested resource not found") ErrTooManyRequests = errors.New("you have exceeded throttle") )
var SupportedExchanges = []Name{ CoinbasePro, }
SupportedExchanges is a list of all supported exchange connections
Functions ¶
func SignSHA256HMAC ¶
SignSHA256HMAC creates a sha256 HMAC using the base64-decoded Secret key on the pre-hash string:
`timestamp + method + requestPath + body`
where + represents string concatenation, and then base64 encoding the output
Types ¶
type Auth ¶
Auth is the type for storing all authentication information for exchanges that support it Please take notice that not all fields are required for every exchange
type Candle ¶
type Candle struct {
Open float64 `json:"open"`
High float64 `json:"high"`
Low float64 `json:"low"`
Close float64 `json:"close"`
Volume float64 `json:"volume"`
Time time.Time `json:"time"`
}
Candle is the main type to represent candlestick data
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
type Exchange ¶
type Exchange struct {
// Name is the unique name of the exchange/marketplace
Name Name
// Features holds information about the supported features of the exchange
Features *ExchangeFeatures
// Auth is for authentication information (keys, tokens etc.)
Auth *Auth
// API is http(s) client connection and routes to the vendors' service
API *Client
// Websocket is the ws(s) client connection to the vendors' service
Websocket Websocket
}
Exchange is the base type that all supported exchanges must include It implements common methods of the IExchange interface
func (*Exchange) GetFeatures ¶
func (base *Exchange) GetFeatures() *ExchangeFeatures
GetFeatures implements the IExchange interface, and returns if the exchange's supported features
type ExchangeFeatures ¶
type ExchangeFeatures struct {
// HasCrypto returns true if the exchange has cryptocurrency support
HasCrypto bool
// HasWebsocket returns true if the exchange has websocket streaming support
HasWebsocket bool
// HasOptions returns true if the exchange has support for options data
HasOptions bool
}
ExchangeFeatures holds information about what services/features the exchange provides
type HTTPClient ¶
type HTTPClient interface {
Get(ctx context.Context, path string, v interface{}) error
Post(ctx context.Context, path string, payload interface{}, v interface{}) error
Put(ctx context.Context, path string, payload interface{}, v interface{}) error
Delete(ctx context.Context, path string, payload interface{}, v interface{}) error
}
type IExchange ¶
type IExchange interface {
// GetName returns the exchanges unique name
GetName() Name
// GetFeatures returns the exchanges supported features
GetFeatures() *ExchangeFeatures
// ListProducts returns an array of Product's
// A Product is a crypto market trading pair such as BTC-USD or stock such as AAPL
ListProducts(ctx context.Context) ([]Product, error)
// GetHistoricalCandles returns and array of Candle's in the normal format for candlestick data
GetHistoricalCandles(ctx context.Context, productID string, granularity string) ([]Candle, error)
// WatchFeed is the function to start watching a websocket feed for a specific product
WatchFeed(shutdown chan struct{}, wg *sync.WaitGroup, product string, feed interface{}) (*orderbook.Orderbook, error)
}
IExchange is the interface which all supported exchanges must implement
type Product ¶
type Product struct {
ID string `json:"id"`
// BaseCurrency is the base in the pair of currencies that comprise the Product
BaseCurrency string `json:"base_currency"`
// QuoteCurrency
QuoteCurrency string `json:"quote_currency"`
// BaseMinSize defines the minimum order size
BaseMinSize string `json:"base_min_size"`
// BaseMaxSize defines the maximum order size
BaseMaxSize string `json:"base_max_size"`
// QuoteIncrement
QuoteIncrement string `json:"quote_increment"`
// BaseIncrement specifies the minimum increment for the BaseCurrency
BaseIncrement string `json:"base_increment"`
// DisplayName
DisplayName string `json:"display_name"`
// MinMarketFunds defines the minimum funds allowed
MinMarketFunds string `json:"min_market_funds"`
// MaxMarketFunds defines the maximum funds allowed
MaxMarketFunds string `json:"max_market_funds"`
// MarginEnabled
MarginEnabled bool `json:"margin_enabled"`
// PostOnly indicates whether only maker orders can be placed. No orders will be matched when post_only mode is active.
PostOnly bool `json:"post_only"`
// LimitOnly indicates whether this product only accepts limit orders.
LimitOnly bool `json:"limit_only"`
// CancelOnly indicates whether this product only accepts cancel requests for orders.
CancelOnly bool `json:"cancel_only"`
// Status
Status string `json:"status"`
// StatusMessage provides any extra information regarding the status, if available
StatusMessage string `json:"status_message"`
// AuctionMode
AuctionMode bool `json:"auction_mode"`
}
Product Only a maximum of one of trading_disabled, cancel_only, post_only, limit_only can be true at once. If none are true, the product is trading normally. !! When limit_only is true, matching can occur if a limit order crosses the book. !! Product ID will not change once assigned to a Product but all other fields are subject to change.
type RequestError ¶
type RequestError struct {
}