Daily Returns
prices holds one price per day. Return the return of each day after the first: its price divided by the price of the day before, minus 1.
Example 1
prices [100.0,110.0,99.0]
returns [0.1,-0.1]
Constraints
- 2 to 9 prices, all positive
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More PyTorch problems
- End to EndEasy
- Floor at ZeroEasy
- Matrix Times MatrixEasy
- One HotEasy
- Only the PositivesEasy
- Rows That Sum to OneEasy
- Stack the RowsEasy
- The First GradientEasy