Microsoft interview question

When to buy and sell stocks? Write clean code decoupling functions...