Millburn Interview Question

Coding implementation in R