Backtesting:
testing the trading algorithm on historical data

backtrader: Python Backtesting library for trading strategies

Learned from green book: get the essential understanding, board, can no depth
” The most successful applicants treat interview preparation as an extended learning process rather than cramming sessions, building deep understanding that serves them throughout their careers.” - GreenBook

You can roll a 6-side dice up to 3 times. After the first or the second roll, if you get a
number x, you can decide either to get x dollars or to choose to continue rolling. But
once you decide to continue, you forgo the number you just rolled. If you get to the third
roll, you’ll just get x dollars if the third number is x and the game stops. What is the
game worth and what is your strategy?

  • Dice 3 times at once, expected payoffs is 3.5
  • At the point after the second roll. choose either a third roll with expected payoffs 3.5 or keep current face value.
    • Keep current face value if face value of the second roll is greater than 3.5, which are 4,5,6.
    • Choose to roll the third times when the face value of the second roll is less than 3.5, which are 1,2,3.
    • expected payoff before the 2nd roll is 3/6 * 3.5 + 1/6 (4+5+6) = 4.25
  • At the point after the first roll
    • Choose either to have a 2nd roll or keep current face value.
      • current face value > 4.25, keep it, 5,6
      • < 4.25, keep rolling, 1,2,3,4
    • Expected payoff before first roll is 4 / 6 * 4.25 + 1/6 * (5+6) = 14/3