Convert an absolute dollar amount to a percentage of the invested position cost. Use the result as the percent argument to commitPartialProfit / commitPartialLoss.
percent
commitPartialProfit
commitPartialLoss
const percent = investedCostToPercent(150, 300); // 50await commitPartialProfit("BTCUSDT", percent); Copy
const percent = investedCostToPercent(150, 300); // 50await commitPartialProfit("BTCUSDT", percent);
Dollar value to close (e.g. 150)
Total invested cost from getPositionInvestedCost (e.g. 300)
getPositionInvestedCost
Percentage of the position to close (0–100)
Convert an absolute dollar amount to a percentage of the invested position cost. Use the result as the
percentargument tocommitPartialProfit/commitPartialLoss.Example