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

OKX getOpenPositions is inconsistenet #4776

Open
douggie opened this issue Oct 2, 2023 · 0 comments
Open

OKX getOpenPositions is inconsistenet #4776

douggie opened this issue Oct 2, 2023 · 0 comments

Comments

@douggie
Copy link
Collaborator

douggie commented Oct 2, 2023

Hi,
the getOpenPositions for coin based positions will display in the notional amoutns i.e. number of contracts * multiplier but for the usdt based positions it will display contracts.

I suggest we always display contract position by changing this

 public static OpenPositions adaptOpenPositions(OkexResponse<List<OkexPosition>> positions, ExchangeMetaData exchangeMetaData) {
    List<OpenPosition> openPositions = new ArrayList<>();

    positions.getData().forEach(okexPosition -> openPositions.add(
        new OpenPosition.Builder().instrument(adaptOkexInstrumentId(okexPosition.getInstrumentId()))
            .liquidationPrice(okexPosition.getLiquidationPrice()).price(okexPosition.getAverageOpenPrice()).type(adaptOpenPositionType(okexPosition))
            .size(okexPosition.getPosition().abs()
                .multiply(exchangeMetaData.getInstruments().get(adaptOkexInstrumentId(okexPosition.getInstrumentId())).getContractValue()))
            .unRealisedPnl(okexPosition.getUnrealizedPnL()).build()));
    return new OpenPositions(openPositions);
  }

to

public static OpenPositions adaptOpenPositions(OkexResponse<List<OkexPosition>> positions, ExchangeMetaData exchangeMetaData) {
    List<OpenPosition> openPositions = new ArrayList<>();

    positions.getData().forEach(okexPosition -> openPositions.add(
        new OpenPosition.Builder().instrument(adaptOkexInstrumentId(okexPosition.getInstrumentId()))
            .liquidationPrice(okexPosition.getLiquidationPrice()).price(okexPosition.getAverageOpenPrice()).type(adaptOpenPositionType(okexPosition))
            .size(okexPosition.getPosition())
            .unRealisedPnl(okexPosition.getUnrealizedPnL()).build()));
    return new OpenPositions(openPositions);
  }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant