prime

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: Apache-2.0 Imports: 16 Imported by: 5

README

Prime Go SDK README

GoDoc Go Report Card

Overview

The Prime Go SDK is a sample libary that demonstrates the structure of a Coinbase Prime driver for the REST APIs.

License

The Prime Go SDK sample library is free and open source and released under the Apache License, Version 2.0.

The application and code are only available for demonstration purposes.

Usage

To use the Prime Go SDK, initialize the Credentials struct and create a new client. The Credentials struct is JSON enabled. Ensure that Prime API credentials are stored in a secure manner.

credentials := &prime.Credentials{}
if err := json.Unmarshal([]byte(os.Getenv("PRIME_CREDENTIALS")), credentials); err != nil {
    return nil, fmt.Errorf("unable to deserialize prime credentials JSON: %w", err)
}

client := prime.NewClient(credentials, http.Client{})

There are convenience functions to read the credentials as an environment variable (prime.ReadEnvCredentials) and to deserialize the JSON structure (prime.UnmarshalCredentials) if pulled from a different source. The JSON format expected by both is:

{
  "accessKey": "",
  "passphrase": "",
  "signingKey": "",
  "portfolioId": "",
  "svcAccountId": "",
  "entityId": ""
}

Coinbase Prime API credentials can be created in the Prime web console under Settings -> APIs. Entity ID can be retrieved by calling Get Portfolio.

Once the client is initialized, make the desired call. For example, to list portfolios, pass in the request object, check for an error, and if nil, process the response.

response, err := client.ListPortfolios(ctx, &prime.ListPortfoliosRequest{})

Build

To build the sample library, ensure that Go 1.19+ is installed and then run:

go build *.go

Documentation

Index

Constants

View Source
const (
	WalletTypeVault   = "VAULT"
	WalletTypeTrading = "TRADING"
	WalletTypeOther   = "WALLET_TYPE_OTHER"

	WalletDepositTypeWire   = "WIRE"
	WalletDepositTypeSwift  = "SWIFT"
	WalletDepositTypeCrypto = "CRYPTO"

	BalanceTypeTrading = "TRADING_BALANCES"
	BalanceTypeVault   = "VAULT_BALANCES"
	BalanceTypeTotal   = "TOTAL_BALANCES"

	OrderSideBuy  = "BUY"
	OrderSideSell = "SELL"

	OrderTypeMarket = "MARKET"
	OrderTypeLimit  = "LIMIT"
	OrderTypeTwap   = "TWAP"
	OrderTypeBlock  = "BLOCK"

	TimeInForceGoodUntilTime      = "GOOD_UNTIL_DATE_TIME"
	TimeInForceGoodUntilCancelled = "GOOD_UNTIL_CANCELLED"
	TimeInForceImmediateOrCancel  = "IMMEDIATE_OR_CANCEL"
)

Variables

This section is empty.

Functions

func AdjustOrderSize

func AdjustOrderSize(amount, baseMin, baseMax, baseIncrement decimal.Decimal) decimal.Decimal

func CalculateOrderSize

func CalculateOrderSize(
	product *Product,
	amount decimal.Decimal,
	holds decimal.Decimal,
) (orderSize decimal.Decimal, err error)

func TimeToStr

func TimeToStr(t time.Time) string

Types

type AccountMetadata

type AccountMetadata struct {
	Consensus *Consensus `json:"consensus"`
}

type Activity

type Activity struct {
	Id              string           `json:"id"`
	ReferenceId     string           `json:"reference_id"`
	Category        string           `json:"category"`
	PrimaryType     string           `json:"type"`
	SecondaryType   string           `json:"secondary_type"`
	Status          string           `json:"status"`
	CreatedBy       string           `json:"created_by"`
	Title           string           `json:"title"`
	Description     string           `json:"description"`
	UserActions     []*UserAction    `json:"user_actions"`
	AccountMetadata *AccountMetadata `json:"account_metadata"`
	OrdersMetadata  *OrdersMetadata  `json:"orders_metadata"`
	Symbols         []string         `json:"symbols"`
	Created         string           `json:"created_at"`
	Updated         string           `json:"updated_at"`
}

type AddressBookEntry

type AddressBookEntry struct {
	Id                    string                   `json:"id"`
	Symbol                string                   `json:"currency_symbol"`
	Name                  string                   `json:"name"`
	Address               string                   `json:"address"`
	AccountIdentifier     string                   `json:"account_identifier"`
	AccountIdentifierName string                   `json:"account_identifier_name"`
	State                 string                   `json:"state"`
	ExplorerLink          string                   `json:"explorer_link"`
	LastUsed              time.Time                `json:"last_used_at"`
	Added                 time.Time                `json:"added_at"`
	AddedBy               *AddressBookEntryAddedBy `json:"added_by"`
}

type AddressBookEntryAddedBy

type AddressBookEntryAddedBy struct {
	Id        string `json:"id"`
	Name      string `json:"name"`
	AvatarUrl string `json:"avatar_url"`
}

type Allocation

type Allocation struct {
	RootId        string                   `json:"root_id"`
	ReversalId    string                   `json:"reversal_id"`
	Completed     string                   `json:"allocation_completed_at"`
	UserId        string                   `json:"user_id"`
	ProductId     string                   `json:"product_id"`
	AvgPrice      string                   `json:"avg_price"`
	BaseQuantity  string                   `json:"base_quantity"`
	QuoteValue    string                   `json:"quote_value"`
	FeesAllocated string                   `json:"fees_allocated"`
	Status        string                   `json:"status"`
	Source        string                   `json:"source"`
	OrderIds      []string                 `json:"order_ids"`
	Destinations  []*AllocationDestination `json:"destinations"`
}

type AllocationDestination

type AllocationDestination struct {
	LegId             string `json:"leg_id"`
	SourcePortfolioId string `json:"portfolio_id"`
	AllocationBase    string `json:"allocation_base"`
	AllocationQuote   string `json:"allocation_quote"`
	FeesAllocatedLeg  string `json:"fees_allocated_leg"`
}

type AllocationLeg

type AllocationLeg struct {
	LegId                  string `json:"allocation_leg_id"`
	DestinationPortfolioId string `json:"destination_portfolio_id"`
	Amount                 string `json:"amount"`
}

type Asset

type Asset struct {
	Name             string `json:"name"`
	Symbol           string `json:"symbol"`
	DecimalPrecision string `json:"decial_precision"`
	TradingSupported bool   `json:"trading_supported"`
	ExplorerUrl      string `json:"explorer_url"`
}

type Balance

type Balance struct {
	Symbol               string `json:"symbol"`
	Amount               string `json:"amount"`
	Holds                string `json:"holds"`
	BondedAmount         string `json:"bonded_amount"`
	ReservedAmount       string `json:"reserved_amount"`
	UnbondingAmount      string `json:"unbonding_amount"`
	UnvestedAmount       string `json:"unvested_amount"`
	PendingRewardsAmount string `json:"pending_rewards_amount"`
	PastRewardsAmount    string `json:"past_rewards_amount"`
	BondableAmount       string `json:"bondable_amount"`
	WithdrawableAmount   string `json:"withdrawable_amount"`
}

func (Balance) AmountNum

func (b Balance) AmountNum() (amount decimal.Decimal, err error)

func (Balance) HoldsNum

func (b Balance) HoldsNum() (holds decimal.Decimal, err error)

type BalanceWithHolds

type BalanceWithHolds struct {
	Total string `json:"total"`
	Holds string `json:"holds"`
}

type BlockchainAddress

type BlockchainAddress struct {
	Address           string `json:"address"`
	AccountIdentifier string `json:"account_identifier"`
}

type CancelOrderRequest

type CancelOrderRequest struct {
	PortfolioId string `json:"portfolio_id"`
	OrderId     string `json:"order_id"`
}

type CancelOrderResponse

type CancelOrderResponse struct {
	OrderId string              `json:"id"`
	Request *CancelOrderRequest `json:"request"`
}

type Client

type Client struct {
	HttpClient  http.Client
	Credentials *Credentials
	HttpBaseUrl string
}

func NewClient

func NewClient(credentials *Credentials, httpClient http.Client) *Client

func (*Client) BaseUrl

func (c *Client) BaseUrl(u string) *Client

func (Client) CancelOrder

func (c Client) CancelOrder(ctx context.Context, request *CancelOrderRequest) (*CancelOrderResponse, error)

func (Client) CreateAddressBookEntry

func (c Client) CreateAddressBookEntry(
	ctx context.Context,
	request *CreateAddressBookEntryRequest,
) (*CreateAddressBookEntryResponse, error)

func (Client) CreateConversion

func (c Client) CreateConversion(
	ctx context.Context,
	request *CreateConversionRequest,
) (*CreateConversionResponse, error)

func (Client) CreateOrder

func (c Client) CreateOrder(ctx context.Context, request *CreateOrderRequest) (*CreateOrderResponse, error)

func (Client) CreateOrderPreview

func (c Client) CreateOrderPreview(
	ctx context.Context,
	request *CreateOrderRequest,
) (*CreateOrderPreviewResponse, error)

func (Client) CreatePortfolioAllocations

func (c Client) CreatePortfolioAllocations(
	ctx context.Context,
	request *CreatePortfolioAllocationsRequest,
) (*CreatePortfolioAllocationsResponse, error)

func (Client) CreateWallet

func (c Client) CreateWallet(ctx context.Context, request *CreateWalletRequest) (*CreateWalletResponse, error)

func (Client) CreateWalletTransfer

func (c Client) CreateWalletTransfer(
	ctx context.Context,
	request *CreateWalletTransferRequest,
) (*CreateWalletTransferResponse, error)

func (Client) CreateWalletWithdrawal

func (c Client) CreateWalletWithdrawal(
	ctx context.Context,
	request *CreateWalletWithdrawalRequest,
) (*CreateWalletWithdrawalResponse, error)

func (Client) GetActivity

func (c Client) GetActivity(
	ctx context.Context,
	request *GetActivityRequest,
) (*GetActivityResponse, error)

func (Client) GetAddressBook

func (c Client) GetAddressBook(
	ctx context.Context,
	request *GetAddressBookRequest,
) (*GetAddressBookResponse, error)

func (Client) GetEntityPaymentMethod

func (c Client) GetEntityPaymentMethod(
	ctx context.Context,
	request *GetEntityPaymentMethodRequest,
) (*GetEntityPaymentMethodResponse, error)

func (Client) GetOrder

func (c Client) GetOrder(
	ctx context.Context,
	request *GetOrderRequest,
) (*GetOrderResponse, error)

func (Client) GetPortfolio

func (c Client) GetPortfolio(
	ctx context.Context,
	request *GetPortfolioRequest,
) (*GetPortfolioResponse, error)

func (Client) GetPortfolioAllocation

func (c Client) GetPortfolioAllocation(
	ctx context.Context,
	request *GetPortfolioAllocationRequest,
) (*GetPortfolioAllocationResponse, error)

func (Client) GetPortfolioCommission

func (c Client) GetPortfolioCommission(
	ctx context.Context,
	request *GetPortfolioCommissionRequest,
) (*GetPortfolioCommissionResponse, error)

func (Client) GetPortfolioCredit

func (c Client) GetPortfolioCredit(
	ctx context.Context,
	request *GetPortfolioCreditRequest,
) (*GetPortfolioCreditResponse, error)

func (Client) GetTransaction

func (c Client) GetTransaction(
	ctx context.Context,
	request *GetTransactionRequest,
) (*GetTransactionResponse, error)

func (Client) GetWallet

func (c Client) GetWallet(
	ctx context.Context,
	request *GetWalletRequest,
) (*GetWalletResponse, error)

func (Client) GetWalletBalance

func (c Client) GetWalletBalance(
	ctx context.Context,
	request *GetWalletBalanceRequest,
) (*GetWalletBalanceResponse, error)

func (Client) ListActivities

func (c Client) ListActivities(
	ctx context.Context,
	request *ListActivitiesRequest,
) (*ListActivitiesResponse, error)

func (Client) ListAssets

func (c Client) ListAssets(
	ctx context.Context,
	request *ListAssetsRequest,
) (*ListAssetsResponse, error)

func (Client) ListEntityUsers

func (c Client) ListEntityUsers(
	ctx context.Context,
	request *ListEntityUsersRequest,
) (*ListEntityUsersResponse, error)

func (Client) ListInvoices

func (c Client) ListInvoices(
	ctx context.Context,
	request *ListInvoicesRequest,
) (*ListInvoicesResponse, error)

func (Client) ListOpenOrders

func (c Client) ListOpenOrders(
	ctx context.Context,
	request *ListOpenOrdersRequest,
) (*ListOpenOrdersResponse, error)

ListOpenOrders enables searching for open orders by product id. This API endpoint is currently being adjusted by Coinbase. This function will change once the Prime endpoint design is finalized. This will not return more than 1k open orders and pagination is not supported. https://docs.cloud.coinbase.com/prime/reference/primerestapi_getopenorders

func (Client) ListOrderFills

func (c Client) ListOrderFills(
	ctx context.Context,
	request *ListOrderFillsRequest,
) (*ListOrderFillsResponse, error)

func (Client) ListOrders

func (c Client) ListOrders(
	ctx context.Context,
	request *ListOrdersRequest,
) (*ListOrdersResponse, error)

ListOrders returns orders based on query params. Start time is required. This API endpoint cannot list open orders, so do not add an OPEN status to the status param. https://docs.cloud.coinbase.com/prime/reference/primerestapi_getorders

func (Client) ListPortfolioAllocations

func (c Client) ListPortfolioAllocations(
	ctx context.Context,
	request *ListPortfolioAllocationsRequest,
) (*ListPortfolioAllocationsResponse, error)

func (Client) ListPortfolioBalances

func (c Client) ListPortfolioBalances(
	ctx context.Context,
	request *ListPortfolioBalancesRequest,
) (*ListPortfolioBalancesResponse, error)

func (Client) ListPortfolioTransactions

func (c Client) ListPortfolioTransactions(
	ctx context.Context,
	request *ListPortfolioTransactionsRequest,
) (*ListPortfolioTransactionsResponse, error)

func (Client) ListPortfolioUsers

func (c Client) ListPortfolioUsers(
	ctx context.Context,
	request *ListPortfolioUsersRequest,
) (*ListPortfolioUsersResponse, error)

func (Client) ListPortfolios

func (c Client) ListPortfolios(
	ctx context.Context,
	request *ListPortfoliosRequest,
) (*ListPortfoliosResponse, error)

func (Client) ListProducts

func (c Client) ListProducts(
	ctx context.Context,
	request *ListProductsRequest,
) (*ListProductsResponse, error)

func (Client) ListWalletBalances

func (c Client) ListWalletBalances(
	ctx context.Context,
	request *ListWalletBalancesRequest,
) (*ListWalletBalancesResponse, error)

func (Client) ListWalletTransactions

func (c Client) ListWalletTransactions(
	ctx context.Context,
	request *ListWalletTransactionsRequest,
) (*ListWalletTransactionsResponse, error)

func (Client) ListWallets

func (c Client) ListWallets(
	ctx context.Context,
	request *ListWalletsRequest,
) (*ListWalletsResponse, error)

type Commission

type Commission struct {
	Type          string `json:"type"`
	Rate          string `json:"rate"`
	TradingVolume string `json:"trading_volume"`
}

func (Commission) RateNum

func (p Commission) RateNum() (rate decimal.Decimal, err error)

type Consensus

type Consensus struct {
	ApprovalDeadline string `json:"approval_deadline"`
	PassedConsensus  bool   `json:"has_passed_consensus"`
}

type CreateAddressBookEntryRequest

type CreateAddressBookEntryRequest struct {
	PortfolioId       string `json:"portfolio_id"`
	Address           string `json:"address"`
	Symbol            string `json:"currency_symbol"`
	Name              string `json:"name"`
	AccountIdentifier string `json:"account_identifier,omitempty"`
}

type CreateAddressBookEntryResponse

type CreateAddressBookEntryResponse struct {
	ActivityId         string                         `json:"activity_id"`
	Type               string                         `json:"activity_type"`
	RemainingApprovals int32                          `json:"num_approvals_remaining"`
	Request            *CreateAddressBookEntryRequest `json:"request"`
}

type CreateConversionRequest

type CreateConversionRequest struct {
	PortfolioId         string `json:"portfolio_id"`
	SourceWalletId      string `json:"wallet_id"`
	SourceSymbol        string `json:"source_symbol"`
	DestinationWalletId string `json:"destination"`
	DestinationSymbol   string `json:"destination_symbol"`
	IdempotencyKey      string `json:"idempotency_key"`
	Amount              string `json:"amount"`
}

type CreateConversionResponse

type CreateConversionResponse struct {
	ActivityId          string                   `json:"activity_id"`
	SourceSymbol        string                   `json:"source_symbol"`
	DestinationSymbol   string                   `json:"destination_symbol"`
	Amount              string                   `json:"amount"`
	DestinationWalletId string                   `json:"destination"`
	SourceWalletId      string                   `json:"source"`
	Request             *CreateConversionRequest `json:"request"`
}

type CreateOrderPreviewResponse

type CreateOrderPreviewResponse struct {
	Order   *Order              `json:"order"`
	Request *CreateOrderRequest `json:"request"`
}

type CreateOrderRequest

type CreateOrderRequest struct {
	Order *Order `json:"order"`
}

type CreateOrderResponse

type CreateOrderResponse struct {
	OrderId string              `json:"order_id"`
	Request *CreateOrderRequest `json:"request"`
}

type CreatePortfolioAllocationsRequest

type CreatePortfolioAllocationsRequest struct {
	AllocationId                    string           `json:"allocation_id"`
	SourcePortfolioId               string           `json:"source_portfolio_id"`
	ProductId                       string           `json:"product_id"`
	OrderIds                        []string         `json:"order_ids"`
	AllocationLegs                  []*AllocationLeg `json:"allocation_legs"`
	SizeType                        string           `json:"size_type"`
	RemainderDestinationPortfolioId string           `json:"remainder_destination_portfolio"`
}

type CreatePortfolioAllocationsResponse

type CreatePortfolioAllocationsResponse struct {
	Success       bool                               `json:"success"`
	AllocationId  string                             `json:"allocation_id"`
	FailureReason string                             `json:"failure_reason"`
	Request       *CreatePortfolioAllocationsRequest `json:"request"`
}

type CreateWalletRequest

type CreateWalletRequest struct {
	PortfolioId string `json:"portfolio_id"`
	Name        string `json:"name"`
	Symbol      string `json:"symbol"`
	Type        string `json:"wallet_type"`
}

type CreateWalletResponse

type CreateWalletResponse struct {
	ActivityId string               `json:"activity_id"`
	Name       string               `json:"name"`
	Symbol     string               `json:"symbol"`
	Type       string               `json:"wallet_type"`
	Request    *CreateWalletRequest `json:"request"`
}

type CreateWalletTransferRequest

type CreateWalletTransferRequest struct {
	PortfolioId         string `json:"portfolio_id"`
	SourceWalletId      string `json:"wallet_id"`
	Symbol              string `json:"currency_symbol"`
	DestinationWalletId string `json:"destination"`
	IdempotencyKey      string `json:"idempotency_key"`
	Amount              string `json:"amount"`
}

type CreateWalletTransferResponse

type CreateWalletTransferResponse struct {
	ActivityId         string                       `json:"activity_id"`
	ApprovalUrl        string                       `json:"approval_url"`
	Symbol             string                       `json:"symbol"`
	Amount             string                       `json:"amount"`
	Fee                string                       `json:"fee"`
	DestinationAddress string                       `json:"destination_address"`
	DestinationType    string                       `json:"destination_type"`
	SourceAddress      string                       `json:"source_address"`
	SourceType         string                       `json:"source_type"`
	TransactionId      string                       `json:"transaction_id"`
	Request            *CreateWalletTransferRequest `json:"request"`
}

type CreateWalletWithdrawalPaymentMethod

type CreateWalletWithdrawalPaymentMethod struct {
	Id string `json:"payment_method_id"`
}

type CreateWalletWithdrawalRequest

type CreateWalletWithdrawalRequest struct {
	PortfolioId       string                               `json:"portfolio_id"`
	SourceWalletId    string                               `json:"wallet_id"`
	Amount            string                               `json:"amount"`
	DestinationType   string                               `json:"destination_type"`
	IdempotencyKey    string                               `json:"idempotency_key"`
	Symbol            string                               `json:"currency_symbol"`
	PaymentMethod     *CreateWalletWithdrawalPaymentMethod `json:"payment_method"`
	BlockchainAddress *BlockchainAddress                   `json:"blockchain_address"`
}

type CreateWalletWithdrawalResponse

type CreateWalletWithdrawalResponse struct {
	ActivityId      string                         `json:"activity_id"`
	ApprovalUrl     string                         `json:"approval_url"`
	Symbol          string                         `json:"symbol"`
	Amount          string                         `json:"amount"`
	Fee             string                         `json:"fee"`
	DestinationType string                         `json:"destination_type"`
	SourceType      string                         `json:"source_type"`
	Destination     *BlockchainAddress             `json:"blockchain_destination"`
	Source          *BlockchainAddress             `json:"blockchain_source"`
	TransactionId   string                         `json:"transaction_id"`
	Request         *CreateWalletWithdrawalRequest `json:"request"`
}

type Credentials

type Credentials struct {
	AccessKey   string `json:"accessKey"`
	Passphrase  string `json:"passphrase"`
	SigningKey  string `json:"signingKey"`
	PortfolioId string `json:"portfolioId"`
	EntityId    string `json:"entityId"`

	// The Service Account ID is the API key's user id equivalent when looking at activities
	SvcAccountId string `json:"svcAccountId"`
}

func ReadEnvCredentials

func ReadEnvCredentials(variableName string) (*Credentials, error)

func UnmarshalCredentials

func UnmarshalCredentials(b []byte) (*Credentials, error)

type CryptoDepositInstructions

type CryptoDepositInstructions struct {
	Id                string `json:"id"`
	Name              string `json:"name"`
	Type              string `json:"type"`
	Address           string `json:"address"`
	AccountIdentifier string `json:"account_identifier"`
}

type ErrorMessage

type ErrorMessage struct {
	Value string `json:"message"`
}

type FiatDepositInstructions

type FiatDepositInstructions struct {
	Id            string `json:"id"`
	Name          string `json:"name"`
	Type          string `json:"type"`
	AccountNumber string `json:"account_number"`
	RoutingNumber string `json:"routing_number"`
	ReferenceCode string `json:"reference_code"`
}

type GetActivityRequest

type GetActivityRequest struct {
	PortfolioId string `json:"portfolio_id"`
	Id          string `json:"activity_id"`
}

type GetActivityResponse

type GetActivityResponse struct {
	Activity *Activity `json:"activity"`
	Request  *GetActivityRequest
}

type GetAddressBookRequest

type GetAddressBookRequest struct {
	PortfolioId string            `json:"portfolio_id"`
	Symbol      string            `json:"currency_symbol"`
	Search      string            `json:"search"`
	Pagination  *PaginationParams `json:"pagination_params"`
}

type GetAddressBookResponse

type GetAddressBookResponse struct {
	Addresses  []*AddressBookEntry    `json:"addresses"`
	Request    *GetAddressBookRequest `json:"request"`
	Pagination *Pagination            `json:"pagination"`
}

type GetEntityPaymentMethodRequest

type GetEntityPaymentMethodRequest struct {
	Id              string `json:"entity_id"`
	PaymentMethodId string `json:"payment_method_id"`
}

type GetEntityPaymentMethodResponse

type GetEntityPaymentMethodResponse struct {
	Id                string                         `json:"id"`
	Symbol            string                         `json:"symbol"`
	PaymentMethodType string                         `json:"payment_method_type"`
	Name              string                         `json:"name"`
	AccountNumber     string                         `json:"account_number"`
	BankCode          string                         `json:"bank_code"`
	Request           *GetEntityPaymentMethodRequest `json:"request"`
}

type GetOrderRequest

type GetOrderRequest struct {
	PortfolioId string `json:"portfolio_id"`
	OrderId     string `json:"order_id"`
}

type GetOrderResponse

type GetOrderResponse struct {
	Order   *Order           `json:"order"`
	Request *GetOrderRequest `json:"request"`
}

type GetPortfolioAllocationRequest

type GetPortfolioAllocationRequest struct {
	PortfolioId  string `json:"portfolio_id"`
	AllocationId string `json:"allocation_id"`
}

type GetPortfolioAllocationResponse

type GetPortfolioAllocationResponse struct {
	Allocation *Allocation                    `json:"allocation"`
	Request    *GetPortfolioAllocationRequest `json:"request"`
}

type GetPortfolioCommissionRequest

type GetPortfolioCommissionRequest struct {
	PortfolioId string `json:"portfolio_id"`
}

type GetPortfolioCommissionResponse

type GetPortfolioCommissionResponse struct {
	Commission *Commission                    `json:"commission"`
	Request    *GetPortfolioCommissionRequest `json:"request"`
}

type GetPortfolioCreditRequest

type GetPortfolioCreditRequest struct {
	Id string `json:"portfolio_id"`
}

type GetPortfolioCreditResponse

type GetPortfolioCreditResponse struct {
	PostTradeCredit *PostTradeCredit           `json:"post_trade_credit"`
	Request         *GetPortfolioCreditRequest `json:"request"`
}

type GetPortfolioRequest

type GetPortfolioRequest struct {
	PortfolioId string `json:"portfolio_id"`
}

type GetPortfolioResponse

type GetPortfolioResponse struct {
	Portfolio *Portfolio           `json:"portfolio"`
	Request   *GetPortfolioRequest `json:"request"`
}

type GetTransactionRequest

type GetTransactionRequest struct {
	PortfolioId   string `json:"portfolio_id"`
	TransactionId string `json:"transaction_id"`
}

type GetTransactionResponse

type GetTransactionResponse struct {
	Transaction *Transaction           `json:"transaction"`
	Request     *GetTransactionRequest `json:"request"`
}

type GetWalletBalanceRequest

type GetWalletBalanceRequest struct {
	PortfolioId string `json:"portfolio_id"`
	Id          string `json:"wallet_id"`
}

type GetWalletBalanceResponse

type GetWalletBalanceResponse struct {
	Balance *Balance `json:"balance"`
	Request *GetWalletBalanceRequest
}

type GetWalletDepositInstructionsRequest

type GetWalletDepositInstructionsRequest struct {
	PortfolioId string `json:"portfolio_id"`
	Id          string `json:"wallet_id"`
	Type        string `json:"deposit_type"`
}

type GetWalletDepositInstructionsResponse

type GetWalletDepositInstructionsResponse struct {
	Crypto  *CryptoDepositInstructions `json:"crypto_instructions"`
	Fiat    *FiatDepositInstructions   `json:"fiat_instructions"`
	Request *GetWalletDepositInstructionsRequest
}

type GetWalletRequest

type GetWalletRequest struct {
	PortfolioId string `json:"portfolio_id"`
	Id          string `json:"wallet_id"`
}

type GetWalletResponse

type GetWalletResponse struct {
	Wallet  *Wallet `json:"wallet"`
	Request *GetWalletRequest
}

type Invoice

type Invoice struct {
	Id            string         `json:"id"`
	BillingYear   int32          `json:"billing_year"`
	BillingMonth  int32          `json:"billing_month"`
	DueDate       string         `json:"due_date"`
	InvoiceNumber string         `json:"invoice_number"`
	State         string         `json:"state"`
	UsdAmountPaid float64        `json:"usd_amount_paid"`
	UsdAmountOwed float64        `json:"usd_amount_owed"`
	Items         []*InvoiceItem `json:"invoice_items"`
}

type InvoiceItem

type InvoiceItem struct {
	Description    string  `json:"description"`
	CurrencySymbol string  `json:"currency_symbol"`
	InvoiceType    string  `json:"invoice_type"`
	Type           string  `json:"invoice_type"`
	Rate           float64 `json:"rate"`
	Quantity       float64 `json:"quantity"`
	Price          float64 `json:"price"`
	AverageAuc     float64 `json:"average_auc"`
	Total          float64 `json:"total"`
}

type ListActivitiesRequest

type ListActivitiesRequest struct {
	PortfolioId string            `json:"portfolio_id"`
	Symbols     []string          `json:"symbols"`
	Categories  []string          `json:"categories"`
	Statuses    []string          `json:"statuses"`
	Start       time.Time         `json:"start_time"`
	End         time.Time         `json:"end_time"`
	Pagination  *PaginationParams `json:"pagination_params"`
}

type ListActivitiesResponse

type ListActivitiesResponse struct {
	Activities []*Activity            `json:"activities"`
	Request    *ListActivitiesRequest `json:"request"`
	Pagination *Pagination            `json:"pagination"`
}

type ListAssetsRequest

type ListAssetsRequest struct {
	EntityId string `json:"entity_id"`
}

type ListAssetsResponse

type ListAssetsResponse struct {
	Assets  []*Asset           `json:"assets"`
	Request *ListAssetsRequest `json:"request"`
}

type ListEntityUsersRequest

type ListEntityUsersRequest struct {
	EntityId   string            `json:"entity_id"`
	Pagination *PaginationParams `json:"pagination_params"`
}

type ListEntityUsersResponse

type ListEntityUsersResponse struct {
	Users      []*User                 `json:"users"`
	Request    *ListEntityUsersRequest `json:"request"`
	Pagination *Pagination             `json:"pagination"`
}

type ListInvoicesRequest

type ListInvoicesRequest struct {
	EntityId     string            `json:"entity_id"`
	States       []string          `json:"states"`
	BillingYear  int32             `json:"billing_year"`
	BillingMonth int32             `json:"billing_month"`
	Pagination   *PaginationParams `json:"pagination_params"`
}

type ListInvoicesResponse

type ListInvoicesResponse struct {
	Invoices   []*Invoice           `json:"invoices"`
	Request    *ListInvoicesRequest `json:"request"`
	Pagination *Pagination          `json:"pagination"`
}

type ListOpenOrdersRequest

type ListOpenOrdersRequest struct {
	PortfolioId string `json:"portfolio_id"`
	ProductId   string `json:"product_id"`
}

type ListOpenOrdersResponse

type ListOpenOrdersResponse struct {
	Orders  []*Order               `json:"orders"`
	Request *ListOpenOrdersRequest `json:"request"`
}

type ListOrderFillsRequest

type ListOrderFillsRequest struct {
	PortfolioId string            `json:"portfolio_id"` // required
	OrderId     string            `json:"order_id"`     // required
	Pagination  *PaginationParams `json:"pagination_params"`
}

type ListOrderFillsResponse

type ListOrderFillsResponse struct {
	Fills      []*OrderFill           `json:"fills"`
	Pagination *Pagination            `json:"pagination"`
	Request    *ListOrderFillsRequest `json:"request"`
}

type ListOrdersRequest

type ListOrdersRequest struct {
	PortfolioId string            `json:"portfolio_id"` // required
	Statuses    []string          `json:"order_statuses"`
	ProductIds  []string          `json:"product_ids"`
	Type        string            `json:"order_type"`
	OtherSide   string            `json:"order_side"`
	Start       time.Time         `json:"start_date"` // required
	End         time.Time         `json:"end_date"`
	Pagination  *PaginationParams `json:"pagination_params"`
}

type ListOrdersResponse

type ListOrdersResponse struct {
	Orders     []*Order           `json:"orders"`
	Pagination *Pagination        `json:"pagination"`
	Request    *ListOrdersRequest `json:"request"`
}

type ListPortfolioAllocationsRequest

type ListPortfolioAllocationsRequest struct {
	PortfolioId string            `json:"portfolio_id"`
	ProductIds  []string          `json:"product_ids"`
	Side        string            `json:"order_side"`
	Start       time.Time         `json:"start_date"`
	End         time.Time         `json:"end_date"`
	Pagination  *PaginationParams `json:"pagination_params"`
}

type ListPortfolioAllocationsResponse

type ListPortfolioAllocationsResponse struct {
	Request    *ListPortfolioAllocationsRequest `json:"request"`
	Pagination *Pagination                      `json:"pagination"`
}

type ListPortfolioBalancesRequest

type ListPortfolioBalancesRequest struct {
	PortfolioId string   `json:"portfolio_id"`
	Type        string   `json:"balance_type"`
	Symbols     []string `json:"symbols"`
}

type ListPortfolioBalancesResponse

type ListPortfolioBalancesResponse struct {
	Balances              []*Balance                    `json:"balances"`
	Type                  string                        `json:"type"`
	TradingWalletBalances *BalanceWithHolds             `json:"trading_balances"`
	VaultWalletBalances   *BalanceWithHolds             `json:"vault_balances"`
	Request               *ListPortfolioBalancesRequest `json:"request"`
}

type ListPortfolioTransactionsRequest

type ListPortfolioTransactionsRequest struct {
	PortfolioId string            `json:"portfolio_id"`
	Symbols     string            `json:"symbols"`
	Types       []string          `json:"types"`
	Start       time.Time         `json:"start_time"`
	End         time.Time         `json:"end_time"`
	Pagination  *PaginationParams `json:"pagination_params"`
}

type ListPortfolioTransactionsResponse

type ListPortfolioTransactionsResponse struct {
	Transactions []*Transaction                    `json:"transactions"`
	Pagination   *Pagination                       `json:"pagination"`
	Request      *ListPortfolioTransactionsRequest `json:"request"`
}

type ListPortfolioUsersRequest

type ListPortfolioUsersRequest struct {
	PortfolioId string            `json:"portfolio_id"`
	Pagination  *PaginationParams `json:"pagination_params"`
}

type ListPortfolioUsersResponse

type ListPortfolioUsersResponse struct {
	Users      []*User                    `json:"users"`
	Request    *ListPortfolioUsersRequest `json:"request"`
	Pagination *Pagination                `json:"pagination"`
}

type ListPortfoliosRequest

type ListPortfoliosRequest struct{}

type ListPortfoliosResponse

type ListPortfoliosResponse struct {
	Portfolios []*Portfolio           `json:"portfolios"`
	Request    *ListPortfoliosRequest `json:"request"`
}

type ListProductsRequest

type ListProductsRequest struct {
	PortfolioId string            `json:"portfolio_id"`
	Pagination  *PaginationParams `json:"pagination_params"`
}

type ListProductsResponse

type ListProductsResponse struct {
	Products   []*Product           `json:"products"`
	Pagination *Pagination          `json:"pagination"`
	Request    *ListProductsRequest `json:"request"`
}

type ListWalletBalancesRequest

type ListWalletBalancesRequest struct {
	PortfolioId string   `json:"portfolio_id"`
	Type        string   `json:"balance_type"`
	Symbols     []string `json:"symbols"`
}

type ListWalletBalancesResponse

type ListWalletBalancesResponse struct {
	Balances              []*Balance                 `json:"balances"`
	Type                  string                     `json:"type"`
	TradingWalletBalances *BalanceWithHolds          `json:"trading_balances"`
	VaultWalletBalances   *BalanceWithHolds          `json:"vault_balances"`
	Request               *ListWalletBalancesRequest `json:"request"`
}

type ListWalletTransactionsRequest

type ListWalletTransactionsRequest struct {
	PortfolioId string            `json:"portfolio_id"`
	WalletId    string            `json:"wallet_id"`
	Symbols     string            `json:"symbols"`
	Types       []string          `json:"types"`
	Start       time.Time         `json:"start_time"`
	End         time.Time         `json:"end_time"`
	Pagination  *PaginationParams `json:"pagination_params"`
}

type ListWalletTransactionsResponse

type ListWalletTransactionsResponse struct {
	Transactions []*Transaction                 `json:"transactions"`
	Pagination   *Pagination                    `json:"pagination"`
	Request      *ListWalletTransactionsRequest `json:"request"`
}

type ListWalletsRequest

type ListWalletsRequest struct {
	PortfolioId string            `json:"portfolio_id"`
	Type        string            `json:"type"`
	Symbols     []string          `json:"symbols"`
	Pagination  *PaginationParams `json:"pagination_params"`
}

type ListWalletsResponse

type ListWalletsResponse struct {
	Wallets    []*Wallet           `json:"wallets"`
	Request    *ListWalletsRequest `json:"request"`
	Pagination *Pagination         `json:"pagination"`
}

func (ListWalletsResponse) HasNext

func (r ListWalletsResponse) HasNext() bool

type Order

type Order struct {
	PortfolioId string `json:"portfolio_id"`
	Side        string `json:"side"`

	// A client-generated order ID used for reference purposes (note: order will be rejected if this ID
	// is not unique among all currently active orders)
	ClientOrderId string `json:"client_order_id"`
	ProductId     string `json:"product_id"`
	Type          string `json:"type"`

	// Order size in base asset units (either `base_quantity` or `quote_value` is required)
	BaseQuantity string `json:"base_quantity"`

	// Order size in quote asset units, i.e. the amount the user wants to spend (when buying) or receive (when selling);
	// the quantity in base units will be determined based on the market liquidity and indicated `quote_value` (either
	// `base_quantity` or `quote_value` is required)
	QuoteValue string `json:"quote_value,omitempty"`

	LimitPrice string `json:"limit_price,omitempty"`

	// The start time of the order in UTC (TWAP only)
	StartTime string `json:"start_time,omitempty"`

	// The expiry time of the order in UTC (TWAP and limit GTD only)
	ExpiryTime  string `json:"expiry_time,omitempty"`
	TimeInForce string `json:"time_in_force,omitempty"`

	// An optional self trade prevention id (in the form of a UUID). The value is only honored for certain
	// clients who are permitted to specify a custom self trade prevention id
	StpId string `json:"stp_id,omitempty"`

	// Optionally specify a display size. This is the maximum order size that will show up on venue order books.
	// Specifying a value here effectively makes a LIMIT order into an "iceberg" style order.
	// This property only applies to LIMIT orders and will be ignored for other order types.
	DisplayQuoteSize string `json:"display_quote_size,omitempty"`
	DisplayBaseSize  string `json:"display_base_size,omitempty"`

	// If you pass is_raise_exact = TRUE, you must use quote_value = n where n is the amount you want,
	// so $2000 will then cost you 1 ETH + fee, requiring > 1 ETH
	IsRaiseExact string `json:"is_raise_exact,omitempty"`

	// Used for describe order and create order preview
	Id                 string `json:"id,omitempty"`
	UserId             string `json:"user_id,omitempty"`
	Created            string `json:"created_at,omitempty"`
	FilledQuantity     string `json:"filled_quantity,omitempty"`
	FilledValue        string `json:"filled_value,omitempty"`
	AverageFilledPrice string `json:"average_filled_price,omitempty"`
	Commission         string `json:"commission,omitempty"`
	ExchangeFee        string `json:"exchange_fee,omitempty"`
	Total              string `json:"order_total,omitempty"`
	BestBid            string `json:"best_bid,omitempty"`
	BestAsk            string `json:"best_ask,omitempty"`
	Slippage           string `json:"slippage,omitempty"`
}

type OrderFill

type OrderFill struct {
	Id             string    `json:"id"`
	Side           string    `json:"side"`
	ProductId      string    `json:"product_id"`
	FilledQuantity string    `json:"filled_quantity"`
	FilledValue    string    `json:"filled_value"`
	Price          string    `json:"price"`
	Time           time.Time `json:"time"`
	Commission     string    `json:"commission"`
	Venue          string    `json:"venue"`
}

type OrdersMetadata

type OrdersMetadata struct{}

An empty/unimplemented/placeholder object in Prime

type Pagination

type Pagination struct {
	NextCursor    string `json:"next_cursor"`
	SortDirection string `json:"sort_direction"`
	HasNext       bool   `json:"has_next"`
}

type PaginationParams

type PaginationParams struct {
	Cursor        string `json:"cursor"`
	Limit         string `json:"limit"`
	SortDirection string `json:"sort_direction"`
}

type Portfolio

type Portfolio struct {
	Id             string `json:"id"`
	Name           string `json:"name"`
	EntityId       string `json:"entity_id"`
	OrganizationId string `json:"organization_id"`
}

type PostTradeCredit

type PostTradeCredit struct {
	Id                     string                      `json:"portfolio_id"`
	Currency               string                      `json:"currency"`
	Limit                  string                      `json:"limit"`
	Utilized               string                      `json:"utilized"`
	Available              string                      `json:"available"`
	Frozen                 bool                        `json:"frozen"`
	AmountsDue             []*PostTradeCreditAmountDue `json:"amounts_due"`
	FrozenReason           string                      `json:"frozen_reason"`
	Enabled                bool                        `json:"enabled"`
	AdjustedCreditUtilized string                      `json:"adjusted_credit_utilized"`
	AdjustedEquity         string                      `json:"adjusted_portfolio_equity"`
}

type PostTradeCreditAmountDue

type PostTradeCreditAmountDue struct {
	Currency string    `json:"currency"`
	Amount   string    `json:"amount"`
	DueDate  time.Time `json:"due_date"`
}

type Product

type Product struct {
	Id             string   `json:"id"`
	BaseIncrement  string   `json:"base_increment"`
	QuoteIncrement string   `json:"quote_increment"`
	BaseMinSize    string   `json:"base_min_size"`
	BaseMaxSize    string   `json:"base_max_size"`
	QuoteMinSize   string   `json:"quote_min_size"`
	QuoteMaxSize   string   `json:"quote_max_size"`
	Permissions    []string `json:"permissions"`
}

func (Product) BaseIncrementNum

func (p Product) BaseIncrementNum() (amount decimal.Decimal, err error)

func (Product) BaseMaxSizeNum

func (p Product) BaseMaxSizeNum() (amount decimal.Decimal, err error)

func (Product) BaseMinSizeNum

func (p Product) BaseMinSizeNum() (amount decimal.Decimal, err error)

func (Product) QuoteIncrementNum

func (p Product) QuoteIncrementNum() (amount decimal.Decimal, err error)

func (Product) QuoteMaxSizeNum

func (p Product) QuoteMaxSizeNum() (amount decimal.Decimal, err error)

func (Product) QuoteMinSizeNum

func (p Product) QuoteMinSizeNum() (amount decimal.Decimal, err error)

type Transaction

type Transaction struct {
	Id                string    `json:"id"`
	WalletId          string    `json:"wallet_id"`
	PortfolioId       string    `json:"portfolio_id"`
	Type              string    `json:"type"`
	Status            string    `json:"status"`
	Symbol            string    `json:"symbol"`
	Created           time.Time `json:"created_at"`
	Completed         time.Time `json:"completed_at"`
	Amount            string    `json:"amount"`
	TransferFrom      *Transfer `json:"transfer_from"`
	TransferTo        *Transfer `json:"transfer_to"`
	NetworkFees       string    `json:"network_fees"`
	Fees              string    `json:"fees"`
	FeeSymbol         string    `json:"fee_symbol"`
	BlockchainIds     []string  `json:"blockchain_ids"`
	TransactionId     string    `json:"transaction_id"`
	DestinationSymbol string    `json:"destination_symbol"`
}

type TransactionsMetadata

type TransactionsMetadata struct {
	Consensus *Consensus `json:"consensus"`
}

type Transfer

type Transfer struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

func (Transfer) ValueNum

func (tr Transfer) ValueNum() (amount decimal.Decimal, err error)

type User

type User struct {
	Id          string `json:"id"`
	Name        string `json:"name"`
	Email       string `json:"email"`
	EntityId    string `json:"entity_id"`
	PortfolioId string `json:"portfolio_id,omitempty"`
	Role        string `json:"role"`
}

type UserAction

type UserAction struct {
	Action               string                `json:"action"`
	UserId               string                `json:"user_id"`
	Timestamp            string                `json:"timestamp"`
	TransactionsMetadata *TransactionsMetadata `json:"transactions_metadata"`
}

type Wallet

type Wallet struct {
	Id      string    `json:"id"`
	Type    string    `json:"type"`
	Name    string    `json:"name"`
	Symbol  string    `json:"symbol"`
	Created time.Time `json:"created_at"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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