Aan de slagGa gratis aan de slag

Define and backtest a simple strategy

You want to create a strategy to trade the so-called "FAANG" stocks, which is an acronym referring to the stocks of the five most popular and best-performing American technology companies: Facebook, Amazon, Apple, Netflix, and Alphabet (a.k.a. Google).

The idea is simple, you will hold an equal amount of each stock in your portfolio. Every week the strategy will buy or sell shares as needed in order to balance the equal weights.

First, you will inspect the data for the "FAANG" stocks. Second, you will define the strategy, which specifies buying an equal amount of each stock, and rebalance every week. Lastly, you will run the backtest and plot the result.

The bt package has been imported for you. The historical price data of the "FAANG" has been preloaded in bt_data.

Deze oefening maakt deel uit van de cursus

Financial Trading in Python

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Print the top five rows
print(____.____())
Code bewerken en uitvoeren