Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change leverage for Binance margin asset #1511

Open
gschurck opened this issue Apr 7, 2024 · 0 comments
Open

Change leverage for Binance margin asset #1511

gschurck opened this issue Apr 7, 2024 · 0 comments
Labels

Comments

@gschurck
Copy link

gschurck commented Apr 7, 2024

How to change leverage for Binance margin asset ?

I see that the setLeverage function is only available for futures :

// SetLeverage sets the account's initial leverage for the asset type and pair
func (b *Binance) SetLeverage(ctx context.Context, item asset.Item, pair currency.Pair, _ margin.Type, amount float64, _ order.Side) error {
	switch item {
	case asset.USDTMarginedFutures:
		_, err := b.UChangeInitialLeverageRequest(ctx, pair, amount)
		return err
	case asset.CoinMarginedFutures:
		_, err := b.FuturesChangeInitialLeverage(ctx, pair, amount)
		return err
	default:
		return fmt.Errorf("%w %v", asset.ErrNotSupported, item)
	}
}

And that submitting an order with a leverage different than 0 or 1 is not supported :

// SubmitOrder submits a new order
func (b *Binance) SubmitOrder(ctx context.Context, s *order.Submit) (*order.SubmitResponse, error) {
	if err := s.Validate(); err != nil {
		return nil, err
	}
	var orderID string
	status := order.New
	var trades []order.TradeHistory
	if s.Leverage != 0 && s.Leverage != 1 {
		return nil, fmt.Errorf("%w received '%v'", order.ErrSubmitLeverageNotSupported, s.Leverage)
	}
        ...
}

Then how to change the leverage for Binance margin ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: To Do
Development

No branches or pull requests

2 participants