1. make sure the following was installed

sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python3-openssl git

2. Install pyenv

sudo apt install pyenv
curl https://pyenv.run | bash
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash

3. pyenv commands:

pyenv versionspyenv install -v 3.7.9pyenv global 3.7.9

4. pipenv

pipenv --python 3.7.9pipenv install <package>pipenv shell
python --version

5. update setuptools in pipenv. without this, wsl environment often raise error.

pip install -U setuptools



import pandas_datareader as pdr# Load the Data
datadf = pdr.DataReader(“MSFT”,
data_source=’yahoo’)[[‘Open’, ‘High’, ‘Low’, ‘Close’, ‘Volume’]]
data = bt.feeds.PandasData(dataname=datadf)
cerebro.adddata(data) # First add the original data — smaller timeframe
# this is key function to resample data to weekly
datadf1 = datadf.resample(‘W’, label=’left’).agg({
‘Open’: ‘first’,
‘High’: ‘max’,
‘Low’: ‘min’,
‘Close’: ‘last’,
‘Volume’: ‘sum’
datadf1.reset_index(level=0, inplace=True)
# have to add 1 day to each ‘Date’, tried many ways, only this works.
datadf1[‘Date’] = pd.to_datetime(datadf1[‘Date’]).apply(pd.DateOffset(1))
datadf1 = datadf1.set_index(‘Date’)
# end of resample to weekly