Compute the dollar cost of a partial close from percentToClose and current invested cost basis.
cost = (percentToClose / 100) * investedCost
// Position investedCost=$1000, closing 25%const cost = percentToCloseCost(25, 1000); // 250 Copy
// Position investedCost=$1000, closing 25%const cost = percentToCloseCost(25, 1000); // 250
Percentage of position to close (0–100)
Current invested cost basis (from getPositionInvestedCost)
getPositionInvestedCost
Dollar amount that will be closed
Compute the dollar cost of a partial close from percentToClose and current invested cost basis.
cost = (percentToClose / 100) * investedCost
Example