prime

package
v0.0.0-...-208116c Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

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

	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 GenerateUniqueId

func GenerateUniqueId(params ...string) string

func GetHttpTransport

func GetHttpTransport() *http.Transport

func PrimeGet

func PrimeGet(
	ctx context.Context,
	url string,
	request,
	response interface{},
) error

func PrimePost

func PrimePost(
	ctx context.Context,
	url string,
	request,
	response interface{},
) error

func SetCredentials

func SetCredentials(c *Credentials)

func SetHttpTransport

func SetHttpTransport(tr *http.Transport) *http.Transport

Types

type AssetBalances

type AssetBalances 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 (AssetBalances) AmountNum

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

func (AssetBalances) HoldsNum

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

func (AssetBalances) IsFiat

func (b AssetBalances) IsFiat() (f bool)

type BalanceWithHolds

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

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"`
	IdempotencyId       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"`
}

func CreateConversion

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

type CreateOrderPreviewResponse

type CreateOrderPreviewResponse struct {
	PortfolioId      string              `json:"portfolio_id"`
	Side             string              `json:"side"`
	ClientOrderId    string              `json:"client_order_id"`
	ProductId        string              `json:"product_id"`
	Type             string              `json:"type"`
	BaseQuantity     string              `json:"base_quantity"`
	QuoteValue       string              `json:"quote_value,omitempty"`
	LimitPrice       string              `json:"limit_price,omitempty"`
	StartTime        string              `json:"start_time,omitempty"`
	ExpiryTime       string              `json:"expiry_time,omitempty"`
	TimeInForce      string              `json:"time_in_force,omitempty"`
	StpId            string              `json:"stp_id,omitempty"`
	DisplayQuoteSize string              `json:"display_quote_size,omitempty"`
	DisplayBaseSize  string              `json:"display_base_size,omitempty"`
	IsRaiseExact     string              `json:"is_raise_exact,omitempty"`
	Commission       string              `json:"commission"`
	Slippage         string              `json:"slippage"`
	BestBid          string              `json:"best_bid"`
	BestAsk          string              `json:"best_ask"`
	AvgFillPrice     string              `json:"average_filled_price"`
	OrderTotal       string              `json:"order_total"`
	Request          *CreateOrderRequest `json:"request"`
}

func CreateOrderPreview

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

type CreateOrderRequest

type CreateOrderRequest struct {
	PortfolioId      string `json:"portfolio_id"`
	Side             string `json:"side"`
	ClientOrderId    string `json:"client_order_id"`
	ProductId        string `json:"product_id"`
	Type             string `json:"type"`
	BaseQuantity     string `json:"base_quantity"`
	QuoteValue       string `json:"quote_value,omitempty"`
	LimitPrice       string `json:"limit_price,omitempty"`
	StartTime        string `json:"start_time,omitempty"`
	ExpiryTime       string `json:"expiry_time,omitempty"`
	TimeInForce      string `json:"time_in_force,omitempty"`
	StpId            string `json:"stp_id,omitempty"`
	DisplayQuoteSize string `json:"display_quote_size,omitempty"`
	DisplayBaseSize  string `json:"display_base_size,omitempty"`
	IsRaiseExact     string `json:"is_raise_exact,omitempty"`
}

type CreateOrderResponse

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

func CreateOrder

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

type Credentials

type Credentials struct {
	AccessKey    string `json:"accessKey"`
	Passphrase   string `json:"passphrase"`
	SigningKey   string `json:"signingKey"`
	PortfolioId  string `json:"portfolioId"`
	SvcAccountId string `json:"svcAccountId"`
}

func GetCredentials

func GetCredentials() *Credentials

func InitCredentials

func InitCredentials() (*Credentials, error)

type DescribeBalancesRequest

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

type DescribeBalancesResponse

type DescribeBalancesResponse struct {
	Balances        []*AssetBalances         `json:"balances"`
	Type            string                   `json:"type"`
	TradingBalances *BalanceWithHolds        `json:"trading_balances"`
	VaultBalances   *BalanceWithHolds        `json:"vault_balances"`
	Request         *DescribeBalancesRequest `json:"request"`
}

func DescribeBalances

func DescribeBalances(
	ctx context.Context,
	request *DescribeBalancesRequest,
) (*DescribeBalancesResponse, error)

type DescribeProductsRequest

type DescribeProductsRequest struct {
	PortfolioId    string          `json:"portfolioId"`
	IteratorParams *IteratorParams `json:"iteratorParams"`
}

type DescribeProductsResponse

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

func DescribeProducts

func DescribeProducts(
	ctx context.Context,
	request *DescribeProductsRequest,
) (*DescribeProductsResponse, error)

func (DescribeProductsResponse) HasNext

func (r DescribeProductsResponse) HasNext() bool

type DescribeWalletsRequest

type DescribeWalletsRequest struct {
	PortfolioId    string          `json:"string"`
	Type           string          `json:"type"`
	Symbols        []string        `json:"symbols"`
	IteratorParams *IteratorParams `json:"iteratorParams"`
}

type DescribeWalletsResponse

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

func DescribeWallets

func DescribeWallets(
	ctx context.Context,
	request *DescribeWalletsRequest,
) (*DescribeWalletsResponse, error)

func (DescribeWalletsResponse) HasNext

func (r DescribeWalletsResponse) HasNext() bool

type ErrorMessage

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

type IteratorParams

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

type Pagination

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

type PortfolioCommission

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

func (PortfolioCommission) RateNum

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

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 Wallet

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

Jump to

Keyboard shortcuts

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