collateral

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidCollateralMode = errors.New("invalid collateral mode")

ErrInvalidCollateralMode is returned when converting invalid string to collateral mode

Functions

func IsValidCollateralModeString

func IsValidCollateralModeString(m string) bool

IsValidCollateralModeString checks to see if the supplied string is a valid collateral mode

Types

type ByCurrency

type ByCurrency struct {
	Currency                    currency.Code
	SkipContribution            bool
	TotalFunds                  decimal.Decimal
	AvailableForUseAsCollateral decimal.Decimal
	CollateralContribution      decimal.Decimal
	AdditionalCollateralUsed    decimal.Decimal
	FairMarketValue             decimal.Decimal
	Weighting                   decimal.Decimal
	ScaledCurrency              currency.Code
	UnrealisedPNL               decimal.Decimal
	ScaledUsed                  decimal.Decimal
	ScaledUsedBreakdown         *UsedBreakdown
	Error                       error
}

ByCurrency individual collateral contribution along with what the potentially scaled collateral currency it is represented as eg in Bybit ScaledCurrency is USDC

type ByPosition

type ByPosition struct {
	PositionCurrency currency.Pair
	Size             decimal.Decimal
	OpenOrderSize    decimal.Decimal
	PositionSize     decimal.Decimal
	MarkPrice        decimal.Decimal
	RequiredMargin   decimal.Decimal
	CollateralUsed   decimal.Decimal
}

ByPosition shows how much collateral is used from positions

type Mode

type Mode uint8

Mode defines the different collateral types supported by exchanges For example, FTX had a global collateral pool Binance has either singular position collateral calculation or cross aka asset level collateral calculation

const (
	// UnsetMode is the default value
	UnsetMode Mode = 0
	// SingleMode has allocated collateral per position
	SingleMode Mode = 1 << (iota - 1)
	// MultiMode has collateral allocated across the whole asset
	MultiMode
	// PortfolioMode has collateral allocated across account
	PortfolioMode
	// UnknownMode has collateral allocated in an unknown manner at present, but is not unset
	UnknownMode
)

func StringToMode

func StringToMode(m string) (Mode, error)

StringToMode converts a string to a collateral mode doesn't error, just returns unknown if the string is not recognised

func (Mode) String

func (t Mode) String() string

String returns the string representation of the collateral mode in lowercase the absence of a lower func should hopefully highlight that String is lower

func (*Mode) UnmarshalJSON

func (t *Mode) UnmarshalJSON(d []byte) error

UnmarshalJSON converts json into collateral mode

func (Mode) Upper

func (t Mode) Upper() string

Upper returns the upper case string representation of the collateral mode

func (Mode) Valid

func (t Mode) Valid() bool

Valid returns whether the collateral mode is valid

type UsedBreakdown

type UsedBreakdown struct {
	LockedInStakes                  decimal.Decimal
	LockedInNFTBids                 decimal.Decimal
	LockedInFeeVoucher              decimal.Decimal
	LockedInSpotMarginFundingOffers decimal.Decimal
	LockedInSpotOrders              decimal.Decimal
	LockedAsCollateral              decimal.Decimal
	UsedInPositions                 decimal.Decimal
	UsedInSpotMarginBorrows         decimal.Decimal
}

UsedBreakdown provides a detailed breakdown of where collateral is currently being allocated

Jump to

Keyboard shortcuts

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