XChange icon indicating copy to clipboard operation
XChange copied to clipboard

OKX getOpenPositions is inconsistenet

Open douggie opened this issue 2 years ago • 0 comments

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);
  }}

douggie avatar Oct 02 '23 08:10 douggie