FastPrepTrading Profit Percentage Change

Trading Profit Percentage Change

IMC Trading logoIMC Trading● EasyNEW GRADPHONE SCREEN
Learn

Problem statement

A trader increases the number of completed trades by tradeIncreasePercent percent. The profit earned on each trade decreases by profitDecreasePercent percent. Total profit is the number of trades multiplied by the profit per trade.

For this exercise, assume these two changes are supplied as whole-number percentages, generalizing the reported 2% increase and 1% decrease example.

Return the signed percentage change in total profit relative to its positive original value. A positive result means growth, a negative result means a loss, and zero means no change. Return the numeric percentage without a percent sign or rounding.

For example, 0.98 means that total profit increased by 0.98%.

Function

totalProfitChange(tradeIncreasePercent: int, profitDecreasePercent: int) → double

Examples

Example 1

tradeIncreasePercent = 2profitDecreasePercent = 1return = 0.98

The new total is 1.02 * 0.99 = 1.0098 times the original total, so the increase is 0.98%.

Example 2

tradeIncreasePercent = 10profitDecreasePercent = 10return = -1.0

The relative total becomes 1.10 * 0.90 = 0.99, a decrease of 1%.

Example 3

tradeIncreasePercent = 100profitDecreasePercent = 50return = 0.0

Twice as many trades at half the profit per trade leave total profit unchanged.

Example 4

tradeIncreasePercent = 0profitDecreasePercent = 100return = -100.0

Profit per trade becomes zero, so the entire original total profit is lost.

Constraints

  • For this exercise, assume 0 <= tradeIncreasePercent <= 1000 and 0 <= profitDecreasePercent <= 100.
  • Both input percentages are integers.
  • The original trade count and profit per trade are positive; their actual values are unnecessary.
  • For this exercise, assume the result is a signed floating-point percentage change without rounding. Answers are accepted within absolute or relative error 10^-9.

More IMC Trading problems

See IMC Trading hiring insights
public double totalProfitChange(int tradeIncreasePercent, int profitDecreasePercent) {
    // Write your solution here.
}
tradeIncreasePercent2
profitDecreasePercent1
expected0.98
Checking account…