(Object position)
| 8209 | } |
| 8210 | |
| 8211 | public Object safePosition(Object position) |
| 8212 | { |
| 8213 | // simplified version of: /pull/12765/ |
| 8214 | Object unrealizedPnlString = this.safeString(position, "unrealisedPnl"); |
| 8215 | Object initialMarginString = this.safeString(position, "initialMargin"); |
| 8216 | // |
| 8217 | // PERCENTAGE |
| 8218 | // |
| 8219 | Object percentage = this.safeValue(position, "percentage"); |
| 8220 | if (Helpers.isTrue(Helpers.isTrue(Helpers.isTrue((Helpers.isEqual(percentage, null))) && Helpers.isTrue((!Helpers.isEqual(unrealizedPnlString, null)))) && Helpers.isTrue((!Helpers.isEqual(initialMarginString, null))))) |
| 8221 | { |
| 8222 | // as it was done in all implementations ( aax, btcex, bybit, deribit, gate, kucoinfutures, phemex ) |
| 8223 | Object percentageString = Precise.stringMul(Precise.stringDiv(unrealizedPnlString, initialMarginString, 4), "100"); |
| 8224 | Helpers.addElementToObject(position, "percentage", this.parseNumber(percentageString)); |
| 8225 | } |
| 8226 | // if contractSize is undefined get from market |
| 8227 | Object contractSize = this.safeNumber(position, "contractSize"); |
| 8228 | Object symbol = this.safeString(position, "symbol"); |
| 8229 | Object market = null; |
| 8230 | if (Helpers.isTrue(!Helpers.isEqual(symbol, null))) |
| 8231 | { |
| 8232 | market = this.safeValue(this.markets, symbol); |
| 8233 | } |
| 8234 | if (Helpers.isTrue(Helpers.isTrue(Helpers.isEqual(contractSize, null)) && Helpers.isTrue(!Helpers.isEqual(market, null)))) |
| 8235 | { |
| 8236 | contractSize = this.safeNumber(market, "contractSize"); |
| 8237 | Helpers.addElementToObject(position, "contractSize", contractSize); |
| 8238 | } |
| 8239 | return position; |
| 8240 | } |
| 8241 | |
| 8242 | public Object parsePositions(Object positions, Object... optionalArgs) |
| 8243 | { |
no test coverage detected