coinbasego

package module
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 16 Imported by: 0

README

coinbasego

A client written in golang to work with the coinbasego exchange rest API.

Coinbase pro reference docs: https://docs.cloud.coinbase.com/exchange/reference

NOTE: Does not implement every feature in the reference doc.

Installation

go get github.com/NekoFluff/coinbasego

Documentation

Index

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 APIKeyClaims struct {
	*jwt.Claims
	URI string `json:"uri"`
}

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      AccountType `json:"type"`
	Ready     bool        `json:"ready"`
	Hold      struct {
		Value    string `json:"value"`
		Currency string `json:"currency"`
	} `json:"hold"`
	RetailPortfolioID string          `json:"retail_portfolio_id"`
	Platform          AccountPlatform `json:"platform"`
}

type AccountPlatform added in v1.5.0

type AccountPlatform string
const (
	AccountPlatformConsumer    AccountPlatform = "ACCOUNT_PLATFORM_CONSUMER"
	AccountPlatformCFM         AccountPlatform = "ACCOUNT_PLATFORM_CFM"
	AccountPlatformUnspecified AccountPlatform = "ACCOUNT_PLATFORM_UNSPECIFIED"
)

type AccountResponse added in v1.3.0

type AccountResponse struct {
	Account Account `json:"account"`
}

type AccountType added in v1.5.0

type AccountType string
const (
	AccountTypeCrypto  AccountType = "ACCOUNT_TYPE_CRYPTO"
	AccountTypeFiat    AccountType = "ACCOUNT_TYPE_FIAT"
	AccountTypeVault   AccountType = "ACCOUNT_TYPE_VAULT"
	AccountTypeUnknown AccountType = "ACCOUNT_TYPE_UNSPECIFIED"
)

type AccountsParams

type AccountsParams struct {
	PaginationParams
	RetailPortfolioID string `url:"retail_portfolio_id,omitempty"`
}

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

func (c *Candle) UnmarshalJSON(b []byte) error

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) Account

func (client *Client) Account(uuid string) (*Account, error)

func (*Client) Accounts

func (client *Client) Accounts() ([]Account, error)

func (*Client) AccountsPage added in v1.5.0

func (client *Client) AccountsPage(p AccountsParams) (*AccountsResponse, error)

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) (*CreateOrderResponse, error)

func (*Client) JWT added in v1.3.0

func (c *Client) JWT(r Request) (string, error)

func (*Client) Order

func (client *Client) Order(id string) (*Order, error)

func (*Client) Orders

func (client *Client) Orders(p OrdersParams) ([]Order, error)

func (*Client) PortfolioBreakdown added in v1.5.0

func (client *Client) PortfolioBreakdown(portfolioUUID string, currency string) (*PortfolioBreakdown, error)

func (*Client) Portfolios added in v1.3.0

func (client *Client) Portfolios(p PortfoliosParams) ([]Portfolio, error)

func (*Client) Product

func (client *Client) Product(id string) (*Product, error)

func (*Client) Products

func (client *Client) Products(p ProductsParams) ([]Product, error)

type ClientCredentials

type ClientCredentials struct {
	KeyName   string
	KeySecret string
}

type CostBasisMethod added in v1.5.0

type CostBasisMethod string
const (
	CostBasisMethodUnspecified CostBasisMethod = "COST_BASIS_METHOD_UNSPECIFIED"
	CostBasisMethodHIFO        CostBasisMethod = "COST_BASIS_METHOD_HIFO"
	CostBasisMethodLIFO        CostBasisMethod = "COST_BASIS_METHOD_LIFO"
	CostBasisMethodFIFO        CostBasisMethod = "COST_BASIS_METHOD_FIFO"
)

type CreateOrderErrorResponse added in v1.5.0

type CreateOrderErrorResponse struct {
	Error                 string `json:"error"`
	Message               string `json:"message"`
	ErrorDetails          string `json:"error_details"`
	PreviewFailureReason  string `json:"preview_failure_reason"`
	NewOrderFailureReason string `json:"new_order_failure_reason"`
}

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"
	RetailPortfolioID          string              `json:"retail_portfolio_id,omitempty"` // Deprecated
	PreviewID                  string              `json:"preview_id,omitempty"`
	AttachedOrderConfiguration *OrderConfiguration `json:"attached_order_configuration,omitempty"`
	SorPreference              SorPreference       `json:"sor_preference,omitempty"`
	PredictionMetadata         *PredictionMetadata `json:"prediction_metadata,omitempty"`
	CostBasisMethod            CostBasisMethod     `json:"cost_basis_method,omitempty"`
}

https://docs.cdp.coinbase.com/api-reference/advanced-trade-api/rest-api/orders/create-order

type CreateOrderResponse added in v1.5.0

type CreateOrderResponse struct {
	Success            bool                        `json:"success"`
	SuccessResponse    *CreateOrderSuccessResponse `json:"success_response"`
	ErrorResponse      *CreateOrderErrorResponse   `json:"error_response"`
	OrderConfiguration *OrderConfiguration         `json:"order_configuration"`
}

type CreateOrderSuccessResponse added in v1.5.0

type CreateOrderSuccessResponse struct {
	OrderID       string    `json:"order_id"`
	ProductID     string    `json:"product_id"`
	Side          OrderSide `json:"side"`
	ClientOrderID string    `json:"client_order_id"`
}

type CurrencyValue added in v1.5.0

type CurrencyValue struct {
	Value    string `json:"value"`
	Currency string `json:"currency"`
}

type DualCurrencyValue added in v1.5.0

type DualCurrencyValue struct {
	UserNativeCurrency CurrencyValue `json:"userNativeCurrency"`
	RawCurrency        CurrencyValue `json:"rawCurrency"`
}

type EquityPosition added in v1.5.0

type EquityPosition struct {
	Cbrn                   string        `json:"cbrn"`
	AccountUUID            string        `json:"account_uuid"`
	TotalBalanceFiat       CurrencyValue `json:"total_balance_fiat"`
	TotalBalanceEquity     CurrencyValue `json:"total_balance_equity"`
	AvailableToTradeEquity CurrencyValue `json:"available_to_trade_equity"`
	AvailableToTradeFiat   CurrencyValue `json:"available_to_trade_fiat"`
	AccountType            string        `json:"account_type"`
	Allocation             float64       `json:"allocation"`
	CostBasis              CurrencyValue `json:"cost_basis"`
	AverageEntryPrice      CurrencyValue `json:"average_entry_price"`
	UnrealizedPnl          CurrencyValue `json:"unrealized_pnl"`
}

type FcmMaintenance added in v1.5.0

type FcmMaintenance struct {
	StartTime string `json:"start_time"`
	EndTime   string `json:"end_time"`
}

type FcmTradingSessionDetails added in v1.5.0

type FcmTradingSessionDetails struct {
	IsSessionOpen                bool            `json:"is_session_open"`
	OpenTime                     string          `json:"open_time"`
	CloseTime                    string          `json:"close_time"`
	SessionState                 string          `json:"session_state"`
	AfterHoursOrderEntryDisabled bool            `json:"after_hours_order_entry_disabled"`
	ClosedReason                 string          `json:"closed_reason"`
	Maintenance                  *FcmMaintenance `json:"maintenance"`
}

type FutureProductDetails added in v1.5.0

type FutureProductDetails struct {
	Venue                   string            `json:"venue"`
	ContractCode            string            `json:"contract_code"`
	ContractExpiry          string            `json:"contract_expiry"`
	ContractSize            string            `json:"contract_size"`
	ContractRootUnit        string            `json:"contract_root_unit"`
	GroupDescription        string            `json:"group_description"`
	ContractExpiryTimezone  string            `json:"contract_expiry_timezone"`
	GroupShortDescription   string            `json:"group_short_description"`
	RiskManagedBy           string            `json:"risk_managed_by"`
	ContractExpiryType      string            `json:"contract_expiry_type"`
	PerpetualDetails        *PerpetualDetails `json:"perpetual_details"`
	ContractDisplayName     string            `json:"contract_display_name"`
	TimeToExpiryMs          string            `json:"time_to_expiry_ms"`
	NonCrypto               bool              `json:"non_crypto"`
	ContractExpiryName      string            `json:"contract_expiry_name"`
	TwentyFourBySeven       bool              `json:"twenty_four_by_seven"`
	FundingInterval         string            `json:"funding_interval"`
	OpenInterest            string            `json:"open_interest"`
	FundingRate             string            `json:"funding_rate"`
	FundingTime             string            `json:"funding_time"`
	DisplayName             string            `json:"display_name"`
	IntradayMarginRate      *MarginRate       `json:"intraday_margin_rate"`
	OvernightMarginRate     *MarginRate       `json:"overnight_margin_rate"`
	SettlementPrice         string            `json:"settlement_price"`
	FuturesAssetType        string            `json:"futures_asset_type"`
	IndexPrice              string            `json:"index_price"`
	ContractCodeDisplayName string            `json:"contract_code_display_name"`
	ProductGroupCbrn        string            `json:"product_group_cbrn"`
}

type FuturesPosition added in v1.5.0

type FuturesPosition struct {
	ProductID       string  `json:"product_id"`
	ContractSize    string  `json:"contract_size"`
	Side            string  `json:"side"`
	Amount          string  `json:"amount"`
	AvgEntryPrice   string  `json:"avg_entry_price"`
	CurrentPrice    string  `json:"current_price"`
	UnrealizedPnl   string  `json:"unrealized_pnl"`
	Expiry          string  `json:"expiry"`
	UnderlyingAsset string  `json:"underlying_asset"`
	AssetImgURL     string  `json:"asset_img_url"`
	ProductName     string  `json:"product_name"`
	Venue           string  `json:"venue"`
	NotionalValue   string  `json:"notional_value"`
	AssetColor      string  `json:"asset_color"`
	LastTradedAt    string  `json:"last_traded_at"`
	RollDate        string  `json:"roll_date"`
	PriceIncrement  string  `json:"price_increment"`
	PricePrecision  float64 `json:"price_precision"`
}

type Granularity

type Granularity string
const (
	GranularityUnknown        Granularity = "UNKNOWN_GRANULARITY"
	GranularityMinute         Granularity = "ONE_MINUTE"
	GranularityFiveMinutes    Granularity = "FIVE_MINUTE"
	GranularityFifteenMinutes Granularity = "FIFTEEN_MINUTE"
	GranularityThirtyMinutes  Granularity = "THIRTY_MINUTE"
	GranularityHour           Granularity = "ONE_HOUR"
	GranularityTwoHours       Granularity = "TWO_HOUR"
	GranularityFourHours      Granularity = "FOUR_HOUR"
	GranularitySixHours       Granularity = "SIX_HOUR"
	GranularityDay            Granularity = "ONE_DAY"
)

type LimitLimitFOK added in v1.4.0

type LimitLimitFOK struct {
	QuoteSize   string `json:"quote_size,omitempty"`
	BaseSize    string `json:"base_size,omitempty"`
	LimitPrice  string `json:"limit_price,omitempty"`
	RfqDisabled bool   `json:"rfq_disabled,omitempty"`
}

type LimitLimitGTC added in v1.4.0

type LimitLimitGTC struct {
	QuoteSize   string `json:"quote_size,omitempty"`
	BaseSize    string `json:"base_size,omitempty"`
	LimitPrice  string `json:"limit_price,omitempty"`
	PostOnly    bool   `json:"post_only,omitempty"`
	RfqDisabled bool   `json:"rfq_disabled,omitempty"`
}

type LimitLimitGTD added in v1.4.0

type LimitLimitGTD struct {
	QuoteSize  string    `json:"quote_size,omitempty"`
	BaseSize   string    `json:"base_size,omitempty"`
	LimitPrice string    `json:"limit_price,omitempty"`
	EndTime    time.Time `json:"end_time,omitempty"`
	PostOnly   bool      `json:"post_only,omitempty"`
}

type MarginRate added in v1.5.0

type MarginRate struct {
	LongMarginRate  string `json:"long_margin_rate"`
	ShortMarginRate string `json:"short_margin_rate"`
}

type MarketMarketFOK added in v1.5.0

type MarketMarketFOK struct {
	QuoteSize   string `json:"quote_size,omitempty"`
	BaseSize    string `json:"base_size,omitempty"`
	RfqDisabled bool   `json:"rfq_disabled,omitempty"`
}

type MarketMarketIOC added in v1.5.0

type MarketMarketIOC struct {
	QuoteSize   string `json:"quote_size,omitempty"`
	BaseSize    string `json:"base_size,omitempty"`
	RfqDisabled bool   `json:"rfq_disabled,omitempty"`
}

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:"market_market_ioc,omitempty"`
	MarketMarketFOK       *MarketMarketFOK       `json:"market_market_fok,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"`
	TwapLimitGTD          *TwapLimitGTD          `json:"twap_limit_gtd,omitempty"`
	StopLimitStopLimitGTC *StopLimitStopLimitGTC `json:"stop_limit_stop_limit_gtc,omitempty"`
	StopLimitStopLimitGTD *StopLimitStopLimitGTD `json:"stop_limit_stop_limit_gtd,omitempty"`
	TriggerBracketGTC     *TriggerBracketGTC     `json:"trigger_bracket_gtc,omitempty"`
	TriggerBracketGTD     *TriggerBracketGTD     `json:"trigger_bracket_gtd,omitempty"`
	ScaledLimitGTC        *ScaledLimitGTC        `json:"scaled_limit_gtc,omitempty"`
	ScaledLimitGTD        *ScaledLimitGTD        `json:"scaled_limit_gtd,omitempty"`
}

type OrderResponse added in v1.3.0

type OrderResponse struct {
	Order Order `json:"order"`
}

type OrderSide

type OrderSide string
const (
	OrderSideBuy  OrderSide = "BUY"
	OrderSideSell OrderSide = "SELL"
)

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 OrderType

type OrderType string
const (
	OrderTypeUnknown   OrderType = "UNKNOWN_ORDER_TYPE"
	OrderTypeMarket    OrderType = "MARKET"
	OrderTypeLimit     OrderType = "LIMIT"
	OrderTypeStop      OrderType = "STOP"
	OrderTypeStopLimit OrderType = "STOP_LIMIT"
	OrderTypeBracket   OrderType = "BRACKET"
	OrderTypeTWAP      OrderType = "TWAP"
)

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 PaginationParams struct {
	Cursor string `url:"cursor,omitempty"`
	Limit  int    `url:"limit" binding:"required"`
}

type PaginationResponse

type PaginationResponse struct {
	HasNext bool   `json:"has_next"`
	Cursor  string `json:"cursor"`
	Size    int32  `json:"size"`
}

type PerpPosition added in v1.5.0

type PerpPosition struct {
	ProductID             string            `json:"product_id"`
	ProductUUID           string            `json:"product_uuid"`
	Symbol                string            `json:"symbol"`
	AssetImageURL         string            `json:"asset_image_url"`
	Vwap                  DualCurrencyValue `json:"vwap"`
	PositionSide          string            `json:"position_side"`
	NetSize               string            `json:"net_size"`
	BuyOrderSize          string            `json:"buy_order_size"`
	SellOrderSize         string            `json:"sell_order_size"`
	ImContribution        string            `json:"im_contribution"`
	UnrealizedPnl         DualCurrencyValue `json:"unrealized_pnl"`
	MarkPrice             DualCurrencyValue `json:"mark_price"`
	LiquidationPrice      DualCurrencyValue `json:"liquidation_price"`
	Leverage              string            `json:"leverage"`
	ImNotional            DualCurrencyValue `json:"im_notional"`
	MmNotional            DualCurrencyValue `json:"mm_notional"`
	PositionNotional      DualCurrencyValue `json:"position_notional"`
	MarginType            string            `json:"margin_type"`
	LiquidationBuffer     string            `json:"liquidation_buffer"`
	LiquidationPercentage string            `json:"liquidation_percentage"`
	AssetColor            string            `json:"asset_color"`
}

type PerpetualDetails added in v1.5.0

type PerpetualDetails struct {
	OpenInterest   string `json:"open_interest"`
	FundingRate    string `json:"funding_rate"`
	FundingTime    string `json:"funding_time"`
	MaxLeverage    string `json:"max_leverage"`
	BaseAssetUUID  string `json:"base_asset_uuid"`
	UnderlyingType string `json:"underlying_type"`
}

type Portfolio added in v1.3.0

type Portfolio struct {
	Name    string        `json:"name"`
	UUID    string        `json:"uuid"`
	Type    PortfolioType `json:"type"`
	Deleted bool          `json:"deleted"`
}

type PortfolioBalances added in v1.5.0

type PortfolioBalances struct {
	TotalBalance               CurrencyValue `json:"total_balance"`
	TotalFuturesBalance        CurrencyValue `json:"total_futures_balance"`
	TotalCashEquivalentBalance CurrencyValue `json:"total_cash_equivalent_balance"`
	TotalCryptoBalance         CurrencyValue `json:"total_crypto_balance"`
	FuturesUnrealizedPnl       CurrencyValue `json:"futures_unrealized_pnl"`
	PerpUnrealizedPnl          CurrencyValue `json:"perp_unrealized_pnl"`
	TotalEquitiesBalance       CurrencyValue `json:"total_equities_balance"`
}

type PortfolioBreakdown added in v1.5.0

type PortfolioBreakdown struct {
	Portfolio                  Portfolio                   `json:"portfolio"`
	PortfolioBalances          PortfolioBalances           `json:"portfolio_balances"`
	SpotPositions              []SpotPosition              `json:"spot_positions"`
	PerpPositions              []PerpPosition              `json:"perp_positions"`
	FuturesPositions           []FuturesPosition           `json:"futures_positions"`
	PredictionMarketsPositions []PredictionMarketsPosition `json:"prediction_markets_positions"`
	EquityPositions            []EquityPosition            `json:"equity_positions"`
}

type PortfolioType added in v1.5.0

type PortfolioType string
const (
	PortfolioTypeUndefined PortfolioType = "UNDEFINED"
	PortfolioTypeDefault   PortfolioType = "DEFAULT"
	PortfolioTypeConsumer  PortfolioType = "CONSUMER"
	PortfolioTypeINTX      PortfolioType = "INTX"
)

type PortfoliosParams added in v1.5.0

type PortfoliosParams struct {
	PortfolioType PortfolioType `url:"portfolio_type,omitempty"`
}

type PredictionMarketsPosition added in v1.5.0

type PredictionMarketsPosition struct {
	ProductType       string                          `json:"product_type"`
	Cbrn              string                          `json:"cbrn"`
	PredictionMarkets PredictionMarketsPositionDetail `json:"prediction_markets"`
}

type PredictionMarketsPositionDetail added in v1.5.0

type PredictionMarketsPositionDetail struct {
	Side              string        `json:"side"`
	LastTradedAt      string        `json:"last_traded_at"`
	AverageEntryPrice CurrencyValue `json:"average_entry_price"`
	CurrentPrice      CurrencyValue `json:"current_price"`
	UnrealizedPnl     CurrencyValue `json:"unrealized_pnl"`
	NotionalValue     CurrencyValue `json:"notional_value"`
	CostBasis         CurrencyValue `json:"cost_basis"`
	ContractsOwned    string        `json:"contracts_owned"`
	QuoteCbrn         string        `json:"quote_cbrn"`
}

type PredictionMetadata added in v1.5.0

type PredictionMetadata struct {
	PredictionSide                    string `json:"prediction_side,omitempty"`
	PreviewOrderEstAverageFilledPrice string `json:"preview_order_est_average_filled_price,omitempty"`
	SupportsFractionalBaseSize        bool   `json:"supports_fractional_base_size,omitempty"`
}

type PriceDistribution added in v1.5.0

type PriceDistribution string
const (
	PriceDistributionFlat PriceDistribution = "FLAT"
)

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"`
	BaseMaxSize               string                    `json:"base_max_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"`
	BaseDisplaySymbol         string                    `json:"base_display_symbol"`
	QuoteDisplaySymbol        string                    `json:"quote_display_symbol"`
	ProductType               string                    `json:"product_type"`
	QuoteCurrencyID           string                    `json:"quote_currency_id"`
	BaseCurrencyID            string                    `json:"base_currency_id"`
	FcmTradingSessionDetails  *FcmTradingSessionDetails `json:"fcm_trading_session_details"`
	MidMarketPrice            string                    `json:"mid_market_price"`
	Alias                     string                    `json:"alias"`
	AliasTo                   []string                  `json:"alias_to"`
	ViewOnly                  bool                      `json:"view_only"`
	PriceIncrement            string                    `json:"price_increment"`
	DisplayName               string                    `json:"display_name"`
	ProductVenue              string                    `json:"product_venue"`
	ApproximateQuote24hVolume string                    `json:"approximate_quote_24h_volume"`
	NewAt                     string                    `json:"new_at"`
	MarketCap                 string                    `json:"market_cap"`
	IconColor                 string                    `json:"icon_color"`
	IconURL                   string                    `json:"icon_url"`
	DisplayNameOverwrite      string                    `json:"display_name_overwrite"`
	IsAlphaTesting            bool                      `json:"is_alpha_testing"`
	AboutDescription          string                    `json:"about_description"`
	BestBidPrice              string                    `json:"best_bid_price"`
	BestAskPrice              string                    `json:"best_ask_price"`
	FutureProductDetails      *FutureProductDetails     `json:"future_product_details"`
}

func (*Product) FixPrice

func (p *Product) FixPrice(size float64) float64

type ProductID

type ProductID string

type ProductsPagination added in v1.5.0

type ProductsPagination struct {
	PrevCursor string `json:"prev_cursor"`
	NextCursor string `json:"next_cursor"`
	HasNext    bool   `json:"has_next"`
	HasPrev    bool   `json:"has_prev"`
}

type ProductsParams

type ProductsParams struct {
	Limit                  int32    `url:"limit,omitempty"`
	Offset                 int32    `url:"offset,omitempty"`
	ProductType            string   `url:"product_type,omitempty"`
	ProductIDs             []string `url:"product_ids,omitempty"`
	ContractExpiryType     string   `url:"contract_expiry_type,omitempty"`
	ExpiringContractStatus string   `url:"expiring_contract_status,omitempty"`
	GetTradabilityStatus   bool     `url:"get_tradability_status,omitempty"`
	GetAllProducts         bool     `url:"get_all_products,omitempty"`
	ProductsSortOrder      string   `url:"products_sort_order,omitempty"`
	Cursor                 string   `url:"cursor,omitempty"`
	FuturesUnderlyingType  string   `url:"futures_underlying_type,omitempty"`
	UserCountryCode        string   `url:"user_country_code,omitempty"`
}

type Request

type Request struct {
	Method  string
	PathURL string
	Body    []byte
	Params  interface{}
}

type ScaledLimitGTC added in v1.5.0

type ScaledLimitGTC struct {
	Orders            []ScaledLimitOrder `json:"orders,omitempty"`
	QuoteSize         string             `json:"quote_size,omitempty"`
	BaseSize          string             `json:"base_size,omitempty"`
	NumOrders         int                `json:"num_orders,omitempty"`
	MinPrice          string             `json:"min_price,omitempty"`
	MaxPrice          string             `json:"max_price,omitempty"`
	PriceDistribution PriceDistribution  `json:"price_distribution,omitempty"`
	SizeDistribution  SizeDistribution   `json:"size_distribution,omitempty"`
	SizeDiff          string             `json:"size_diff,omitempty"`
	SizeRatio         string             `json:"size_ratio,omitempty"`
}

type ScaledLimitGTD added in v1.5.0

type ScaledLimitGTD struct {
	Orders            []ScaledLimitOrder `json:"orders,omitempty"`
	QuoteSize         string             `json:"quote_size,omitempty"`
	BaseSize          string             `json:"base_size,omitempty"`
	NumOrders         int                `json:"num_orders,omitempty"`
	MinPrice          string             `json:"min_price,omitempty"`
	MaxPrice          string             `json:"max_price,omitempty"`
	EndTime           time.Time          `json:"end_time,omitempty"`
	PriceDistribution PriceDistribution  `json:"price_distribution,omitempty"`
	SizeDistribution  SizeDistribution   `json:"size_distribution,omitempty"`
	SizeDiff          string             `json:"size_diff,omitempty"`
	SizeRatio         string             `json:"size_ratio,omitempty"`
}

type ScaledLimitOrder added in v1.5.0

type ScaledLimitOrder struct {
	QuoteSize   string `json:"quote_size,omitempty"`
	BaseSize    string `json:"base_size,omitempty"`
	LimitPrice  string `json:"limit_price,omitempty"`
	PostOnly    bool   `json:"post_only,omitempty"`
	RfqDisabled bool   `json:"rfq_disabled,omitempty"`
}

type SizeDistribution added in v1.5.0

type SizeDistribution string
const (
	SizeDistributionUnknown SizeDistribution = "UNKNOWN_DISTRIBUTION"
)

type SorLimitIOC added in v1.4.0

type SorLimitIOC struct {
	QuoteSize   string `json:"quote_size,omitempty"`
	BaseSize    string `json:"base_size,omitempty"`
	LimitPrice  string `json:"limit_price,omitempty"`
	RfqDisabled bool   `json:"rfq_disabled,omitempty"`
}

type SorPreference added in v1.5.0

type SorPreference string
const (
	SorPreferenceUnspecified SorPreference = "SOR_PREFERENCE_UNSPECIFIED"
	SorPreferenceEnabled     SorPreference = "SOR_ENABLED"
	SorPreferenceDisabled    SorPreference = "SOR_DISABLED"
)

type SpotPosition added in v1.5.0

type SpotPosition struct {
	Asset                     string        `json:"asset"`
	AccountUUID               string        `json:"account_uuid"`
	TotalBalanceFiat          float64       `json:"total_balance_fiat"`
	TotalBalanceCrypto        float64       `json:"total_balance_crypto"`
	AvailableToTradeFiat      float64       `json:"available_to_trade_fiat"`
	Allocation                float64       `json:"allocation"`
	CostBasis                 CurrencyValue `json:"cost_basis"`
	AssetImgURL               string        `json:"asset_img_url"`
	IsCash                    bool          `json:"is_cash"`
	AverageEntryPrice         CurrencyValue `json:"average_entry_price"`
	AssetUUID                 string        `json:"asset_uuid"`
	AvailableToCryptoCrypto   float64       `json:"available_to_trade_crypto"`
	UnrealizedPnl             float64       `json:"unrealized_pnl"`
	AvailableToTransferFiat   float64       `json:"available_to_transfer_fiat"`
	AvailableToTransferCrypto float64       `json:"available_to_transfer_crypto"`
	AssetColor                string        `json:"asset_color"`
	AccountType               string        `json:"account_type"`
	FundingPnl                float64       `json:"funding_pnl"`
	AvailableToSendFiat       float64       `json:"available_to_send_fiat"`
	AvailableToSendCrypto     float64       `json:"available_to_send_crypto"`
}

type StopDirection added in v1.5.0

type StopDirection string
const (
	StopDirectionUp   StopDirection = "STOP_DIRECTION_STOP_UP"
	StopDirectionDown StopDirection = "STOP_DIRECTION_STOP_DOWN"
)

type StopLimitStopLimitGTC added in v1.5.0

type StopLimitStopLimitGTC struct {
	BaseSize      string        `json:"base_size,omitempty"`
	LimitPrice    string        `json:"limit_price,omitempty"`
	StopPrice     string        `json:"stop_price,omitempty"`
	StopDirection StopDirection `json:"stop_direction,omitempty"`
}

type StopLimitStopLimitGTD added in v1.5.0

type StopLimitStopLimitGTD struct {
	BaseSize      string        `json:"base_size,omitempty"`
	LimitPrice    string        `json:"limit_price,omitempty"`
	StopPrice     string        `json:"stop_price,omitempty"`
	EndTime       time.Time     `json:"end_time,omitempty"`
	StopDirection StopDirection `json:"stop_direction,omitempty"`
}

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"
)

type TriggerBracketGTC added in v1.5.0

type TriggerBracketGTC struct {
	BaseSize         string `json:"base_size,omitempty"`
	LimitPrice       string `json:"limit_price,omitempty"`
	StopTriggerPrice string `json:"stop_trigger_price,omitempty"`
}

type TriggerBracketGTD added in v1.5.0

type TriggerBracketGTD struct {
	BaseSize         string    `json:"base_size,omitempty"`
	LimitPrice       string    `json:"limit_price,omitempty"`
	StopTriggerPrice string    `json:"stop_trigger_price,omitempty"`
	EndTime          time.Time `json:"end_time,omitempty"`
}

type TwapLimitGTD added in v1.5.0

type TwapLimitGTD struct {
	QuoteSize      string    `json:"quote_size,omitempty"`
	BaseSize       string    `json:"base_size,omitempty"`
	StartTime      time.Time `json:"start_time,omitempty"`
	EndTime        time.Time `json:"end_time,omitempty"`
	LimitPrice     string    `json:"limit_price,omitempty"`
	NumberBuckets  string    `json:"number_buckets,omitempty"`
	BucketSize     string    `json:"bucket_size,omitempty"`
	BucketDuration string    `json:"bucket_duration,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL