Technical prerequisites
Before we begin working with R, Python, and Quarto in Advanced Empirical Finance, please set up your computer so that you can run code from day one. No prior experience with programming or development tools is required — this guide walks you through everything step by step. Should you encounter any issues, please do not hesitate to contact your TAs or me for assistance. To facilitate collaboration, please ask me via the Absalon discussion board to make sure everyone can benefit from the solution.
Prerequisites
Install the required software
- Install R (Version > 4.5.0). R is one of the two programming languages we use in this course. Choose the installer for your operating system (Windows, macOS, Linux) and follow the default installation settings.
- Install Python (Version > 3.11.0). Python is the second programming language we use. During installation on Windows, make sure to check “Add Python to PATH” if prompted.
- Install Positron (latest Version). Positron is the integrated development environment (IDE) we use. It supports R, Python, Git, and Quarto in one place. Install Positron using the default settings.
- Register a free GitHub account GitHub allows us to share course materials and collaborate. You can register on (https://github.com/).
- Install Git. Git is the version control system we use to connect to GitHub.
Set Up the Course Repository
- Configure Git in Positron:
- Open Positron, open the source control view
(Ctrl+Shift+G). If Git is not yet installed, the Source Control view will show instructions on how to install it - Once Git is detected you can clone the course Github repository by opening the source control view
(Ctrl+Shift+G)and clickingClone Repository. Then, you provide the course repository url https://github.com/advanced-empirical-finance/course-repository.git and choose a local folder where the repository should be stored. Cloning a repository simply means creating your own copy of a shared project so you can work on it on your computer without affecting the original.
- Open Positron, open the source control view
- Open the cloned repository in Positron by navigating to
File->Open Projectand selecting the folder where you cloned the repository. The folder contains all course materials, including R and Python scripts, datasets, lecture slides, templates for the mandatory assignment and configuration files for R and Python environments.
Install Required R and Python Packages
In R we use renv to ensure all students have the same package versions. To install all required R packages for the course, open the Console (not the Terminal) in Positron and install the
renvpackage by typing the commandsinstall.packages("renv") renv::restore()You can install new packages, e.g., by calling
install.packages("tidymodels"). To collaborate with your peers, just runrenv::snapshot()to keep track of all the packages you use, and share therenv.lockfile. Your colleagues only have to runrenv::restore()to replicate your exact R package environment.To verify that the R installation is working correctly, click on
New/New Fileand selectR fileto open a new R script in Positron and typelibrary(tidyfinance) download_data( type="stock_prices", symbols="AAPL", start_date="2000-01-01", end_date="2023-12-31")Mark everything and press
Ctrl + Enterto run the code. If everything is working correctly, you should see that you just downloaded financial data in the console.For Python we use
uv, a fast Python package manager. To install all required Python packages for the course, open the Terminal (not the Console) in Positron, install uv, e.g., viapip install uvand type the commanduv syncTo verify that everything is working correctly, click on
New/New Fileand selectPython fileto open a new Python script in Positron and typeimport tidyfinance as tf tf.download_data( domain="stock_prices", symbols="AAPL", start_date="2000-01-01", end_date="2023-12-31")Mark everything and press
Ctrl + Enterto run the code. If everything is working correctly, you should see that you just downloaded financial data in the console. If you receive an error you may have to activate the correct virtual environment first by clicking on the Icon on the top right (next tocourse-repository) and selecting the environment namedaef-2026.
Optional: Quarto and PDF support
Positron already includes Quarto, so you do not need to install it separately unless you want a standalone installation.
Install the newest version of Quarto. (Quarto comes prebundled with Positron, so you will have access to quarto once you have followed the previous step)
In order to create PDFs you will need to install a recent distribution of LaTeX. I recommend to install
TinyTeX, a lightweight, cross-platform, portable, and easy-to-maintain LaTeX distribution by typing the commandquarto install tool tinytex
in Positron / Terminal or directly in the console