← 返回 optiver 的题目列表Investment Strategy Backtest
类型:online_judge
You are asked to manage an investment fund and backtest a specific trading strategy using historical stock price data.
The Strategy: Your capital allocation is based on the recent performance (last day's return) of a set of stocks.
Proportional Investment: You will invest in a stock only if its return was positive. The amount you invest in that stock is proportional to the size of its positive return.
Negative/Zero Return: If a stock's return was negative or zero, you will not invest in it.
All Negative Returns: If all stocks had negative or zero returns, you will not invest in any of them and hold 100% of your capital in cash.
Rebalancing: Adjust your holdings daily based on the market behavior from the previous day.
The Goal: Given an [N x T] array of stock prices (N stocks, T days), return an array with two numbers:
The average daily log return of your portfolio.
The standard deviation of the daily log returns.
Assumptions:
Fractional shares can be traded.
There are no transaction costs.
Example
Input
[[100, 101], [100, 102]]