Documentation ¶
Index ¶
- func CalculateBaseQuantity(session *bbgo.ExchangeSession, market types.Market, ...) (fixedpoint.Value, error)
- func CalculateMarginCost(price, quantity, leverage fixedpoint.Value) fixedpoint.Value
- func CalculateMaxPosition(price, availableMargin, leverage fixedpoint.Value) fixedpoint.Value
- func CalculateMinRequiredLeverage(price, quantity, availableMargin fixedpoint.Value) fixedpoint.Value
- func CalculateOpenLoss(numContract, markPrice, orderPrice fixedpoint.Value, side types.SideType) fixedpoint.Value
- func CalculatePositionCost(markPrice, orderPrice, quantity, leverage fixedpoint.Value, ...) fixedpoint.Value
- func CalculateQuoteQuantity(session *bbgo.ExchangeSession, ctx context.Context, quoteCurrency string, ...) (fixedpoint.Value, error)
- type AccountValueCalculator
- func (c *AccountValueCalculator) AvailableQuote(ctx context.Context) (fixedpoint.Value, error)
- func (c *AccountValueCalculator) DebtValue(ctx context.Context) (fixedpoint.Value, error)
- func (c *AccountValueCalculator) MarginLevel(ctx context.Context) (fixedpoint.Value, error)
- func (c *AccountValueCalculator) MarketValue(ctx context.Context) (fixedpoint.Value, error)
- func (c *AccountValueCalculator) NetValue(ctx context.Context) (fixedpoint.Value, error)
- func (c *AccountValueCalculator) UpdatePrices(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateBaseQuantity ¶ added in v1.38.0
func CalculateBaseQuantity(session *bbgo.ExchangeSession, market types.Market, price, quantity, leverage fixedpoint.Value) (fixedpoint.Value, error)
func CalculateMarginCost ¶
func CalculateMarginCost(price, quantity, leverage fixedpoint.Value) fixedpoint.Value
CalculateMarginCost calculate the margin cost of the given notional position by price * quantity
func CalculateMaxPosition ¶
func CalculateMaxPosition(price, availableMargin, leverage fixedpoint.Value) fixedpoint.Value
CalculateMaxPosition calculates the maximum notional value of the position and return the max quantity you can use.
func CalculateMinRequiredLeverage ¶
func CalculateMinRequiredLeverage(price, quantity, availableMargin fixedpoint.Value) fixedpoint.Value
CalculateMinRequiredLeverage calculates the leverage of the given position (price and quantity)
func CalculateOpenLoss ¶
func CalculateOpenLoss(numContract, markPrice, orderPrice fixedpoint.Value, side types.SideType) fixedpoint.Value
How to Calculate Cost Required to Open a Position in Perpetual Futures Contracts
See <https://www.binance.com/en/support/faq/87fa7ee33b574f7084d42bd2ce2e463b>
For Long Position: = Number of Contract * Absolute Value {min[0, direction of order x (mark price - order price)]}
For short position: = Number of Contract * Absolute Value {min[0, direction of order x (mark price - order price)]}
func CalculatePositionCost ¶
func CalculatePositionCost(markPrice, orderPrice, quantity, leverage fixedpoint.Value, side types.SideType) fixedpoint.Value
func CalculateQuoteQuantity ¶ added in v1.39.0
func CalculateQuoteQuantity(session *bbgo.ExchangeSession, ctx context.Context, quoteCurrency string, leverage fixedpoint.Value) (fixedpoint.Value, error)
Types ¶
type AccountValueCalculator ¶ added in v1.38.0
type AccountValueCalculator struct {
// contains filtered or unexported fields
}
func NewAccountValueCalculator ¶ added in v1.38.0
func NewAccountValueCalculator(session *bbgo.ExchangeSession, quoteCurrency string) *AccountValueCalculator
func (*AccountValueCalculator) AvailableQuote ¶ added in v1.39.0
func (c *AccountValueCalculator) AvailableQuote(ctx context.Context) (fixedpoint.Value, error)
func (*AccountValueCalculator) DebtValue ¶ added in v1.38.0
func (c *AccountValueCalculator) DebtValue(ctx context.Context) (fixedpoint.Value, error)
func (*AccountValueCalculator) MarginLevel ¶ added in v1.38.0
func (c *AccountValueCalculator) MarginLevel(ctx context.Context) (fixedpoint.Value, error)
MarginLevel calculates the margin level from the asset market value and the debt value See https://www.binance.com/en/support/faq/360030493931
func (*AccountValueCalculator) MarketValue ¶ added in v1.38.0
func (c *AccountValueCalculator) MarketValue(ctx context.Context) (fixedpoint.Value, error)
func (*AccountValueCalculator) NetValue ¶ added in v1.38.0
func (c *AccountValueCalculator) NetValue(ctx context.Context) (fixedpoint.Value, error)
func (*AccountValueCalculator) UpdatePrices ¶ added in v1.38.0
func (c *AccountValueCalculator) UpdatePrices(ctx context.Context) error