← 返回 optiver 的题目列表Proportional Allocation Backtest
类型:online_judge
Implement a proportional allocation backtest system. The system receives a list of historical prices and an initial capital, and outputs the net asset value for each period based on a specified proportional strategy.
Input
prices: A 2D list of historical prices, each row represents prices for a period.
capital: An integer representing the initial capital.
strategy: A list representing the proportional strategy for each asset.
Output
Return a list representing the net asset value for each period.
Test Example
Example 1
Input: prices = [[1, 2], [2, 3]], capital = 100, strategy = [0.5, 0.5]
Output: [100, 125]
Constraints
The length of each row in prices and strategy are equal and do not exceed 10.
capital is between [1, 1000].
Example
Input
2
1 2
2 3
100
0.5 0.5