... cvxpy two: introduction


You can use a dataset that we provide in this video but you're also free to download your own dataset using the yahoo finance python api. We've used the following code;

import pandas as pd
import yfinance as yf
from functools import reduce

dataframes = [] 
tickets = ["MSFT", "KLM", "ING", "MOS"]
for tick in tickets:
    hist = yf.Ticker(tick).history(period="max")
    hist = (hist['Open']
            .rename(columns={'Open': tick})
df = (reduce(lambda d1, d2: d1.join(d2), dataframes)

If you prefer to use the same dataset to follow along you can download it here or you can fetch it via;

wget https://calmcode.io/datasets/stocks.csv

Feedback? See an issue? Something unclear? Feel free to mention it here.

If you want to be kept up to date, consider signing up for the newsletter.