Trading Profit Percentage Change
Updated
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) → doubleExamples
Example 1
tradeIncreasePercent = 2profitDecreasePercent = 1return = 0.98The 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.0The relative total becomes 1.10 * 0.90 = 0.99, a decrease of 1%.
Example 3
tradeIncreasePercent = 100profitDecreasePercent = 50return = 0.0Twice as many trades at half the profit per trade leave total profit unchanged.
Example 4
tradeIncreasePercent = 0profitDecreasePercent = 100return = -100.0Profit per trade becomes zero, so the entire original total profit is lost.
Constraints
- For this exercise, assume
0 <= tradeIncreasePercent <= 1000and0 <= 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 Phone Screen questions
- Election District Budget Allocation AnalysisPHONE SCREEN · Seen Aug 2026
- Uniform Variables: Smaller Below Larger SquaredPHONE SCREEN · Seen Mar 2026
- Combination Sum with Unlimited ReusePHONE SCREEN · Seen Dec 2025
- Valid Range of a Three-Outcome Probability ParameterPHONE SCREEN · Seen Dec 2025
- Expected Fishing CatchPHONE SCREEN · Seen Dec 2025
- Count Routes Through a City GridPHONE SCREEN · Seen Nov 2024
- Expected City Arrival and Return DaysPHONE SCREEN · Seen Nov 2024
- Stationary City Population SharesPHONE SCREEN · Seen Nov 2024
- Maximum Falling Path SumPHONE SCREEN · Seen Nov 2024
- Poker Suit Expected ProfitPHONE SCREEN · Seen Sep 2023
Similar questions at other companies
- Parking Fee CalculatorBreeze · PHONE SCREEN
- Merchant Payout Reserve CalculatorStripe · PHONE SCREEN
- Sqrt(x)LinkedIn · PHONE SCREEN
- Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREEN
- Subtract Two Large Number StringsStackAdapt · PHONE SCREEN
- Circular Primes Below a LimitAmazon · PHONE SCREEN
- Palindrome NumberKotak Mahindra Bank · PHONE SCREEN
- Streaming AverageXantium · PHONE SCREEN
- Fair Coin from a Biased CoinAnthropic · PHONE SCREEN
- Stack Formula InterpreterTypeSafe AI · PHONE SCREEN