Skip to content

Enable Automatic Debt Repayment #16

Open
@AlexCatarino

Description

Expected Behavior

Automatically repay dept for short-margin trades.

Actual Behavior

Debt is not automatically repaid and users need to manually do it.

Potential Solution

To enable auto replay, we need to set

body["sideEffectType"] = "MARGIN_BUY";

to

body["sideEffectType"] = "AUTO_REPAY";

However, we may want to do it via BinanceOrderProperties

Note

Lean doesn't model debt for short-margin trades, so the portfolio value is probably diverging.

From Binance user:

Currently, when closing a margin position, any outstanding debts need to be explicitly repaid via a separate API call. Closing a position via an opposite market order is not enough and will instead result in two opposite open positions. Setting the side effect type to AUTO_REPAY resolves this by automating the repay call when closing a short or leveraged margin position. I confirmed this with Binance support as my algorithms are constantly leaving open short positions behind after closing them.

Checklist

  • I have completely filled out this template
  • I have confirmed that this issue exists on the current master branch
  • I have confirmed that this is not a duplicate issue by searching issues
  • I have provided detailed steps to reproduce the issue

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions