D. Python Environment Setup
On GitHub, new a project and choose Python.gitignore
Git clone the new project with a token, which gives you permission to push
In vs code, go to File > Open Folder to open the project
Manual
python -m venv .venvin the project root to create a virtual environment called.venvA virtual environment is a folder for an independent
python.exeand its ownsite-packageswhich thispython.execan import fromvenv is part of the python standard library
-mis to run a module,venvin this case
.venv\Scripts\activateto activate the virtual environment to start use the independentpython.exeCreate a
requirements.txtfile in the project root to keep a list of all packages (and possibly versions) you want to usepip install -r requirements.txtto pip install packages from the listpip downloads packages from pypi.org
uv
uv initin the project root to initialize the projectIt creates a
pyproject.tomlfile amoung otherspyproject.tomlis the recommended replacement ofrequirements.txt. Other package managers (e.g. poetry) will also give you apyproject.tomlfile
uv syncto create and sync the venv as defined inpyproject.tomlYou still need to manually run
.venv\Scripts\activateactivate the virtual environmentOr you can choose the project venv in vs code at the bottom right corner. Once done, vs code will activate the venv automatically every time you start a new command prompt
uv add numpyto add numpy topyproject.tomland to the venvuv remove numpyto remove numpy frompyproject.tomland from the venvTry not to edit
pyproject.tmolmanually; Do it through uv-
uv venv --python 3.12.4uv python install 3.12.4
Git
Download Git and install
git initin the project root to version control the project by GitCreate a
.gitignorefile in the project rootCopy the contents of Python.gitignore and paste in yours
The same repo has recomended
.gitignorein other languages/type of projects
git add *to add current code changes to the staging areaThe staging area is an intermediate space to keep the changes before you commit
git commit -m "YOUR_COMMIT_MESSAGE"Commit message is required
Configure Git username and email
git config --global user.name "YOUR_NAME"git config --global user.email "your_email@example.com"Please use the same username and email as your GitHub account
VS Code
Install the Python extension
Open a
.pyfile and look at the bottom right, VS Code should be aware of the venv. Kill the terminal and open a new one and the venv will be activated automaticallyKeyboard shortcut
Ctrl + Shift + G: Focus version control tab on the leftCtrl + Shift + E: Focus file explorer on the leftCtrl + 1: Focus editorWhen you are in editor,
Ctrl + Page Up/Dnto switch between files
Ctrl + Shift + ~: Focus terminalCtrl + Shift + Y: Focus debug consoleCtrl + Shift + I: Focus github copilot chat
Side Project Ideas
GARCH
Fit a GARCH(1, 1) model to the SPX daily return using the arch package
There is an open source library yfinance that scrapes yahoo finance, but it breaks from time to time
One reliable data source is Alpha Vantage
Free API key has a limit of 25 requests per day
Follow the example on this Plotly Dash documentation page to build and run your first app locally
Deploy your docker image on Render free teir
Numerical Math
If we know the point values of a \(C^{\infty}\) function \(f\) at \(a\) and \(a+h\), we can use a linear function
\[y = f(a) + (x-a)\frac{f(a+h) - f(a)}{h}\]to approximate \(f\) in the interval \([a, a+h]\). This is linear interpolation. This approximation has an error bond \(Ch^2\). Can you find me the error bond and its proof?