Documentation
¶
Index ¶
- Constants
- type APIKeyClaims
- type Account
- type AccountResponse
- type AccountsParams
- type AccountsResponse
- type CancelAfter
- type Candle
- type CandlesParams
- type CandlesResponse
- type Client
- func (client *Client) Account(uuid string) (*Account, error)
- func (client *Client) Accounts() ([]Account, error)
- func (client *Client) Candles(productID string, p CandlesParams) ([]Candle, error)
- func (client *Client) CreateOrder(body CreateOrderRequest) (*Order, error)
- func (c *Client) JWT(r Request) (string, error)
- func (client *Client) Order(id string) (*Order, error)
- func (client *Client) Orders(p OrdersParams) ([]Order, error)
- func (client *Client) Portfolios() ([]Portfolio, error)
- func (client *Client) Product(id string) (*Product, error)
- func (client *Client) Products() ([]Product, error)
- type ClientCredentials
- type CreateOrderRequest
- type Granularity
- type LimitLimitFOK
- type LimitLimitGTC
- type LimitLimitGTD
- type MarketmarketIOC
- type Order
- type OrderConfiguration
- type OrderResponse
- type OrderSide
- type OrderStatus
- type OrderType
- type OrdersParams
- type OrdersResponse
- type PaginationParams
- type PaginationResponse
- type Portfolio
- type PortfoliosResponse
- type Product
- type ProductID
- type ProductsParams
- type Request
- type SorLimitIOC
- type TimeInForce
Constants ¶
View Source
const ( CancelAfterMin = "min" CancelAFterHour = "hour" CancelAfterDay = "day" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIKeyClaims ¶ added in v1.3.0
type Account ¶
type Account struct {
UUID string `json:"uuid" binding:"required"`
Name string `json:"name" binding:"required"`
Currency string `json:"currency" binding:"required"`
AvailableBalance struct {
Value string `json:"value" binding:"required"`
Currency string `json:"currency" binding:"required"`
} `json:"available_balance" binding:"required"`
Default bool `json:"default"`
Active bool `json:"active"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
DeletedAt string `json:"deleted_at"`
Type string `json:"type"`
Ready bool `json:"ready"`
Hold struct {
Value string `json:"value" binding:"required"`
Currency string `json:"currency" binding:"required"`
}
RetailPortfolioID string `json:"retail_portfolio_id"`
Platform string `json:"platform"`
}
type AccountResponse ¶ added in v1.3.0
type AccountResponse struct {
Account Account `json:"account"`
}
type AccountsParams ¶
type AccountsParams struct {
PaginationParams
}
type AccountsResponse ¶ added in v1.3.0
type AccountsResponse struct {
PaginationResponse
Accounts []Account `json:"accounts"`
}
type CancelAfter ¶
type CancelAfter string
type Candle ¶
type Candle struct {
Start time.Time `json:"start"`
Low float64 `json:"low"`
High float64 `json:"high"`
Open float64 `json:"open"`
Close float64 `json:"close"`
Volume string `json:"volume"`
}
func (*Candle) UnmarshalJSON ¶
type CandlesParams ¶
type CandlesParams struct {
Limit int32 `url:"limit,omitempty"`
Granularity Granularity `url:"granularity,omitempty"`
Start int64 `url:"start,omitempty"`
End int64 `url:"end,omitempty"`
}
type CandlesResponse ¶ added in v1.3.0
type CandlesResponse struct {
Candles []Candle `json:"candles"`
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(credentials ClientCredentials) *Client
func (*Client) Candles ¶
func (client *Client) Candles(productID string, p CandlesParams) ([]Candle, error)
func (*Client) CreateOrder ¶ added in v1.4.0
func (client *Client) CreateOrder(body CreateOrderRequest) (*Order, error)
func (*Client) Portfolios ¶ added in v1.3.0
type ClientCredentials ¶
type CreateOrderRequest ¶ added in v1.4.0
type CreateOrderRequest struct {
// Required fields
ClientOrderID string `json:"client_order_id" binding:"required"`
ProductID ProductID `json:"product_id" binding:"required"`
Side OrderSide `json:"side" binding:"required"`
OrderConfiguration OrderConfiguration `json:"order_configuration" binding:"required"`
// Optional Fields
Leverage string `json:"leverage,omitempty"`
MarginType string `json:"margin_type,omitempty"` // Either "CROSS" or "ISOLATED"
PreviewID string `json:"preview_id,omitempty"`
AttachedOrderConfiguration OrderConfiguration `json:"attached_order_configuration,omitempty"`
SmartOrderRoutingDisabled bool `json:"sor_disabled,omitempty"`
}
https://docs.cdp.coinbase.com/api-reference/advanced-trade-api/rest-api/orders/create-order
type Granularity ¶
type Granularity string
var ( GranularityMinute Granularity = "ONE_MINUTE" GranularityFiveMinutes Granularity = "FIVE_MINUTE" GranularityFifteenMinutes Granularity = "FIFTEEN_MINUTE" GranularityHour Granularity = "ONE_HOUR" GranularitySixHours Granularity = "SIX_HOUR" GranularityDay Granularity = "ONE_DAY" )
type LimitLimitFOK ¶ added in v1.4.0
type LimitLimitGTC ¶ added in v1.4.0
type LimitLimitGTD ¶ added in v1.4.0
type MarketmarketIOC ¶ added in v1.4.0
type Order ¶
type Order struct {
OrderID string `json:"order_id"`
ProductID string `json:"product_id"`
UserID string `json:"user_id"`
OrderConfiguration OrderConfiguration `json:"order_configuration"`
Side OrderSide `json:"side"`
ClientOrderID string `json:"client_order_id"`
Status OrderStatus `json:"status"`
TimeInForce TimeInForce `json:"time_in_force"`
CreatedTime time.Time `json:"created_time"`
CompletionPercentage string `json:"completion_percentage"`
FilledSize string `json:"filled_size"`
AverageFilledPrice string `json:"average_filled_price"`
NumberOfFills string `json:"number_of_fills"`
FilledValue string `json:"filled_value"`
PendingCancel bool `json:"pending_cancel"`
SizeInQuote bool `json:"size_in_quote"`
TotalFees string `json:"total_fees"`
SizeInclusiveOfFees bool `json:"size_inclusive_of_fees"`
TotalValueAfterFees string `json:"total_value_after_fees"`
TriggerStatus string `json:"trigger_status"` // TODO: This is an enum
OrderType OrderType `json:"order_type"`
RejectReason string `json:"reject_reason"` // TODO: This is an enum
Settled bool `json:"settled"`
ProductType string `json:"product_type"` // TODO: This is an enum
RejectMessage string `json:"reject_message"`
CancelMessage string `json:"cancel_message"`
OrderPlacementSource string `json:"order_placement_source"` // TODO: This is an enum
OutstandingHoldAmount string `json:"outstanding_hold_amount"`
IsLiquidation bool `json:"is_liquidation"`
LastFillTime time.Time `json:"last_fill_time"`
// TODO: Edit history
Leverage string `json:"leverage"`
}
type OrderConfiguration ¶ added in v1.4.0
type OrderConfiguration struct {
MarketmarketIOC *MarketmarketIOC `json:"marketmarket_ioc,omitempty"`
SorLimitIOC *SorLimitIOC `json:"sor_limit_ioc,omitempty"`
LimitLimitGTC *LimitLimitGTC `json:"limit_limit_gtc,omitempty"`
LimitLimitGTD *LimitLimitGTD `json:"limit_limit_gtd,omitempty"`
LimitLimitFOK *LimitLimitFOK `json:"limit_limit_fok,omitempty"`
}
type OrderResponse ¶ added in v1.3.0
type OrderResponse struct {
Order Order `json:"order"`
}
type OrderStatus ¶
type OrderStatus string
const ( OrderStatusOpen OrderStatus = "OPEN" OrderStatusPending OrderStatus = "PENDING" OrderStatusFilled OrderStatus = "FILLED" OrderStatusCancelled OrderStatus = "CANCELLED" OrderStatusExpired OrderStatus = "EXPIRED" OrderStatusFailed OrderStatus = "FAILED" OrderStatusUnknown OrderStatus = "UNKNOWN_ORDER_STATUS" OrderStatusQueued OrderStatus = "QUEUED" OrderStatusCancelQueued OrderStatus = "CANCEL_QUEUED" )
type OrdersParams ¶
type OrdersParams struct {
PaginationParams
OrderIDs []string `url:"order_ids,omitempty"`
ProductIDs []ProductID `url:"product_ids,omitempty"`
OrderStatus OrderStatus `url:"order_status,omitempty"`
TimeInForces []TimeInForce `url:"time_in_forces,omitempty"`
OrderTypes []OrderType `url:"order_types,omitempty"`
OrderSide OrderSide `url:"order_side,omitempty"`
StartDate time.Time `url:"start_date,omitempty"` // RFC3339 timestamp, e.g. 2006-01-02T15:04:05Z
EndDate time.Time `url:"end_date,omitempty"` // RFC3339 timestamp, e.g. 2006-01-02T15:04:05Z
}
type OrdersResponse ¶ added in v1.3.0
type OrdersResponse struct {
PaginationResponse
Orders []Order `json:"orders"`
}
type PaginationParams ¶
type PaginationResponse ¶
type PortfoliosResponse ¶ added in v1.3.0
type PortfoliosResponse struct {
Portfolios []Portfolio
}
type Product ¶
type Product struct {
ProductID string `json:"product_id"`
Price string `json:"price"`
PricePercentageChange24H string `json:"price_percentage_change_24h"`
Volume24H string `json:"volume_24h"`
VolumePercentageChange24H string `json:"volume_percentage_change_24h"`
BaseIncrement string `json:"base_increment"`
QuoteIncrement string `json:"quote_increment"`
QuoteMinSize string `json:"quote_min_size"`
QuoteMaxSize string `json:"quote_max_size"`
BaseMinSize string `json:"base_min_size"`
BaseName string `json:"base_name"`
QuoteName string `json:"quote_name"`
Watched bool `json:"watched"`
IsDisabled bool `json:"is_disabled"`
New bool `json:"new"`
Status string `json:"status"`
CancelOnly bool `json:"cancel_only"`
LimitOnly bool `json:"limit_only"`
PostOnly bool `json:"post_only"`
TradingDisabled bool `json:"trading_disabled"`
AuctionMode bool `json:"auction_mode"`
ProductType string `json:"product_type"`
QuoteCurrencyID string `json:"quote_currency_id"`
BaseCurrencyID string `json:"base_currency_id"`
}
type ProductsParams ¶
type ProductsParams struct {
PaginationParams
}
type SorLimitIOC ¶ added in v1.4.0
type TimeInForce ¶
type TimeInForce string
const ( TimeInForceUnknown TimeInForce = "UNKNOWN_TIME_IN_FORCE" TimeInForceGoodUntilDateTime TimeInForce = "GOOD_UNTIL_DATE_TIME" TimeInForceGoodUntilCancelled TimeInForce = "GOOD_UNTIL_CANCELLED" TimeInForceImmediateOrCancel TimeInForce = "IMMEDIATE_OR_CANCEL" TimeInForceFillOrKill TimeInForce = "FILL_OR_KILL" )
Click to show internal directories.
Click to hide internal directories.