Documentation ¶
Index ¶
- Constants
- type Client
- func (c *Client) AddSessionHeader(k string, v string)
- func (c *Client) CancelOrders(ctx context.Context, ids []string) (*model.CancelOrderResponse, error)
- func (c *Client) CheckAuthentication(req *http.Request, body []byte)
- func (c *Client) CreateOrder(ctx context.Context, p *model.CreateOrderRequest) (*model.CreateOrderResponse, error)
- func (c *Client) DoAndDecode(req *http.Request, dest interface{}) (err error)
- func (c *Client) GetAccount(ctx context.Context, uuid string) (*model.Account, error)
- func (c *Client) GetAndDecode(ctx context.Context, URL url.URL, dest interface{}, headers *map[string]string, ...) error
- func (c *Client) GetExchangeRate(ctx context.Context, currency string) (*model.GetExchangeRateResponseData, error)
- func (c *Client) GetOrder(ctx context.Context, id string) (*model.GetOrderResponse, error)
- func (c *Client) GetPrice(ctx context.Context, currency string, side string) (*float64, error)
- func (c *Client) GetProduct(ctx context.Context, productId string) (*model.GetProductResponse, error)
- func (c *Client) GetQuote(ctx context.Context, currency string) (*Quote, error)
- func (c *Client) HttpClient() *http.Client
- func (c *Client) IsTokenValid(_ int64) bool
- func (c *Client) ListAccounts(ctx context.Context, p *ListAccountsParams) (*model.ListAccountsResponse, error)
- func (c *Client) ListFills(ctx context.Context, p *ListFillsParams) (*model.ListFillsResponse, error)
- func (c *Client) ListOrders(ctx context.Context, p *ListOrdersParams) (*model.ListOrdersResponse, error)
- func (c *Client) PostAndDecode(ctx context.Context, URL url.URL, dest interface{}, headers *map[string]string, ...) error
- func (c *Client) SetRateLimit(ms int64)
- type CoinbaseClient
- type Credentials
- type GetAccountResponse
- type ListAccountsParams
- type ListFillsParams
- type ListOrdersParams
- type Quote
Constants ¶
const ( CoinbaseAdvV3endpoint = "https://api.coinbase.com/api/v3" CoinbaseAdvV2endpoint = "https://api.coinbase.com/v2" DefaultAPIRateLimit = 100 // (ms) throttled below )
const (
DefaultLimit = 50
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) AddSessionHeader ¶
func (*Client) CancelOrders ¶
func (c *Client) CancelOrders(ctx context.Context, ids []string) (*model.CancelOrderResponse, error)
CancelOrders -- cancel orders
func (*Client) CheckAuthentication ¶
func (*Client) CreateOrder ¶
func (c *Client) CreateOrder(ctx context.Context, p *model.CreateOrderRequest) (*model.CreateOrderResponse, error)
CreateOrder -- create order
func (*Client) DoAndDecode ¶
DoAndDecode provides useful abstractions around common errors and decoding issues. Ideally unmarshals into `dest`. On error, it'll use the Webull `ErrorBody` model. Last fallback is a plain interface.
func (*Client) GetAccount ¶
GetAccount -- get account details
func (*Client) GetAndDecode ¶
func (c *Client) GetAndDecode(ctx context.Context, URL url.URL, dest interface{}, headers *map[string]string, urlValues *map[string]string) error
GetAndDecode retrieves from the endpoint and unmarshals resulting json into the provided destination interface, which must be a pointer.
func (*Client) GetExchangeRate ¶
func (c *Client) GetExchangeRate(ctx context.Context, currency string) (*model.GetExchangeRateResponseData, error)
GetExchangeRate -- get exchange rate
func (*Client) GetProduct ¶
func (c *Client) GetProduct(ctx context.Context, productId string) (*model.GetProductResponse, error)
GetProduct -- get product
func (*Client) HttpClient ¶
func (*Client) IsTokenValid ¶
func (*Client) ListAccounts ¶
func (c *Client) ListAccounts(ctx context.Context, p *ListAccountsParams) (*model.ListAccountsResponse, error)
ListAccounts -- list user's accounts
func (*Client) ListFills ¶
func (c *Client) ListFills(ctx context.Context, p *ListFillsParams) (*model.ListFillsResponse, error)
ListFills -- list fills
func (*Client) ListOrders ¶
func (c *Client) ListOrders(ctx context.Context, p *ListOrdersParams) (*model.ListOrdersResponse, error)
ListOrders -- list orders
func (*Client) PostAndDecode ¶
func (c *Client) PostAndDecode(ctx context.Context, URL url.URL, dest interface{}, headers *map[string]string, urlValues *map[string]string, payload []byte) error
PostAndDecode retrieves from the endpoint and unmarshals resulting json into the provided destination interface, which must be a pointer.
func (*Client) SetRateLimit ¶
Rate limit the client since Coinbase only allows API calls / second. Default is 100ms - DefaultAPIRateLimit
type CoinbaseClient ¶
type CoinbaseClient interface { // coinbase adv api funcs ListAccounts(ctx context.Context, p *ListAccountsParams) (*model.ListAccountsResponse, error) GetAccount(ctx context.Context, uuid string) (*model.Account, error) ListFills(ctx context.Context, p *ListFillsParams) (*model.ListFillsResponse, error) GetOrder(ctx context.Context, id string) (*model.GetOrderResponse, error) CancelOrders(ctx context.Context, ids []string) (*model.CancelOrderResponse, error) CreateOrder(ctx context.Context, p *model.CreateOrderRequest) (*model.CreateOrderResponse, error) ListOrders(ctx context.Context, p *ListOrdersParams) (*model.ListOrdersResponse, error) GetPrice(ctx context.Context, currency string, side string) (*float64, error) GetQuote(ctx context.Context, currency string) (*Quote, error) GetExchangeRate(ctx context.Context, currency string) (*model.GetExchangeRateResponseData, error) GetProduct(ctx context.Context, productId string) (*model.GetProductResponse, error) // utility funcs CheckAuthentication(req *http.Request, body []byte) HttpClient() *http.Client IsTokenValid(timestamp int64) bool SetRateLimit(ms int64) }
func NewClient ¶
func NewClient(creds *Credentials) (cb CoinbaseClient)