Function percentToCloseCost

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
  • Parameters

    • percentToClose: number

      Percentage of position to close (0–100)

    • investedCost: number

      Current invested cost basis (from getPositionInvestedCost)

    Returns number

    Dollar amount that will be closed