Study Guide: Week 5#
Open-ended questions on the material from week 5. The exam asks multiple-choice versions of questions like these. No answers are given: each question can be answered in a few sentences from the pages listed under its heading. The exam’s format is described in Exam Preparation.
Modules, Packages, and if __name__ == "__main__"#
Read: Modules, Packages, and if __name__ == "__main__"
and the python_imports/ examples
in the in-class repository.
What is the difference between a Python module and a Python package?
What does
python greet.pyprint? What does a different script print when it runsimport greet?# greet.py print(f"__name__ is {__name__!r}") def say_hello(): print("Hello!") if __name__ == "__main__": say_hello()
A module has a function that downloads data from a vendor, a function that reads the saved copy, and an
if __name__ == "__main__":block that runs the download and saves the result. Why is the download under that block rather than at the top level of the file?
Environments with uv and pixi#
Read: Modern Environment Tools: uv and pixi.
uv run doitworks in a fresh clone with no environment created or activated. What doesuv rundo before it runsdoit, and what two files does it read?What is a lockfile? What does
uv.lockrecord that a hand-writtenrequirements.txtdoes not?uvinstalls from PyPI andpixiinstalls from conda-forge. When would that difference make you choosepixi?uv runandpixi runboth run a command inside the project’s environment. What doesdoitdo that they do not?
Live Monitors#
Read: Building a Live Monitor with GitHub Actions.
A GitHub-hosted runner starts empty on every run. Where can a daily monitor keep what it computed yesterday, and why not commit it to
main?When does a pipeline need to keep state between runs at all? Compare a monitor whose source returns its whole history in one request with one that needs minutes of downloading for each day of data.
The monitor publishes its page as a single orphan commit that every run force-pushes to
gh-pages. What does that keep out of the repository’s history?The monitor’s daily task has
uptodate: [False]. What does that telldoit, and why does a daily update need it?What does a workflow run look like when a repository secret it needs is missing, and why does nothing get published?
Options Data on Databento#
Read: E-mini S&P 500 Options Data from Databento and Databento.
Why does a pipeline that needs an option price at every listed strike use the exchange’s settlement prices rather than daily trade bars?
A vendor’s volatility surface has no strikes below about 92% of the spot at a one-month maturity. What does a one-month probability of a 20% drop, computed from that surface, depend on?
SVIX and the Probability of a Crash#
Read: Replicating SVIX and the Probability of a Crash.
SVIX and the VIX are both built from the prices of out-of-the-money options across strikes. How do they weight the strikes differently?
Option prices across strikes reveal the market’s risk-neutral distribution of the return. What feature of the call price curve gives the probability that the return ends below a given strike?
Why is the risk-neutral probability of a crash larger than the probability that an investor who holds the market assigns to it?