Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidMarginType returned when the margin type is invalid ErrInvalidMarginType = errors.New("invalid margin type") // ErrMarginTypeUnsupported returned when the margin type is unsupported ErrMarginTypeUnsupported = errors.New("unsupported margin type") // ErrNewAllocatedMarginRequired returned when the new allocated margin is missing and is required ErrNewAllocatedMarginRequired = errors.New("new allocated margin required") // ErrOriginalPositionMarginRequired is returned when original position margin is empty and is required ErrOriginalPositionMarginRequired = errors.New("original allocated margin required") )
Functions ¶
func IsValidString ¶
IsValidString checks to see if the supplied string is a valid margin type
Types ¶
type BorrowCost ¶
BorrowCost contains the borrow rate costs
type LendingPayment ¶
LendingPayment contains a lending rate payment
type PositionChangeRequest ¶
type PositionChangeRequest struct {
// Required fields
Exchange string
Pair currency.Pair
Asset asset.Item
// Optional fields depending on desired outcome/exchange requirements
MarginType Type
OriginalAllocatedMargin float64
NewAllocatedMargin float64
MarginSide string
}
PositionChangeRequest used for wrapper functions to change margin fields for a position
type PositionChangeResponse ¶
type PositionChangeResponse struct {
Exchange string
Pair currency.Pair
Asset asset.Item
AllocatedMargin float64
MarginType Type
}
PositionChangeResponse holds response data for margin change requests
type Rate ¶
type Rate struct {
Time time.Time
MarketBorrowSize decimal.Decimal
HourlyRate decimal.Decimal
YearlyRate decimal.Decimal
HourlyBorrowRate decimal.Decimal
YearlyBorrowRate decimal.Decimal
LendingPayment LendingPayment
BorrowCost BorrowCost
}
Rate has the funding rate details and optionally the borrow rate
type RateHistoryRequest ¶
type RateHistoryRequest struct {
Exchange string
Asset asset.Item
Currency currency.Code
Pair currency.Pair
StartDate time.Time
EndDate time.Time
GetPredictedRate bool
GetLendingPayments bool
GetBorrowRates bool
GetBorrowCosts bool
// CalculateOffline allows for the borrow rate, lending payment amount
// and borrow costs to be calculated offline. It requires the takerfeerate
// and existing rates
CalculateOffline bool
TakeFeeRate decimal.Decimal
// Rates is used when calculating offline and determiningPayments
// Each Rate must have the Rate and Size fields populated
Rates []Rate
}
RateHistoryRequest is used to request a funding rate
type RateHistoryResponse ¶
type RateHistoryResponse struct {
Rates []Rate
SumBorrowCosts decimal.Decimal
AverageBorrowSize decimal.Decimal
SumLendingPayments decimal.Decimal
AverageLendingSize decimal.Decimal
PredictedRate Rate
TakerFeeRate decimal.Decimal
}
RateHistoryResponse has the funding rate details
type Type ¶
type Type uint8
Type defines the different margin types supported by exchanges
const ( // Unset is the default value Unset = Type(0) // Isolated means a margin trade is isolated from other margin trades Isolated Type = 1 << (iota - 1) // Multi means a margin trade is not isolated from other margin trades // it can sometimes be referred to as "cross" Multi // Unknown is an unknown margin type but is not unset Unknown )
Margin types
func StringToMarginType ¶
StringToMarginType converts a string to a margin type doesn't error, just returns unknown if the string is not recognised
func (Type) String ¶
String returns the string representation of the margin type in lowercase the absence of a lower func should hopefully highlight that String is lower
func (*Type) UnmarshalJSON ¶
UnmarshalJSON converts json into margin type