Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidCollateralMode = errors.New("invalid collateral mode")
ErrInvalidCollateralMode is returned when converting invalid string to collateral mode
Functions ¶
func IsValidCollateralModeString ¶
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 ¶
StringToMode converts a string to a collateral mode doesn't error, just returns unknown if the string is not recognised
func (Mode) 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 ¶
UnmarshalJSON converts json into collateral mode
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