Quant Lab

back to home

Michigan Quant Lab

For Winter 2019, we will meet on Fridays, 10am-11:20pm in 110 Weiser Hall.

Meeting agenda

2019-01-25
  1. Warmup problem(s):
    • You can roll a die up to 3 times. After each roll, you can either keep the number facing up or forgo the number and keep rolling. At the end of the 3rd roll, you will have to take the number facing up. What is it worth to play the game?
  2. Python problem: There are 4 red and 4 black marbles in a bag. Draw one at time. If you have drawn more black than red, winnings are the number of black marbles in excess of red. Otherwise, you get nothing. Quit at any time.
    1. Solve by hand. What is your optimal strategy?
    2. Implement in Python. Verify if it matches your calculation by hand. Download the jupyter notebook here.
    3. Solve with 20 red and 20 black marbles. Does your program work? If not, what can you do about it? What is the computational complexity of your solution?
    4. What if there are 1000 red and 1000 black marbles?
    5. What if there are 1 million red and 1 million black marbles?
2019-01-11
  1. Warmup problem(s):
    • Solve a simple pair of equations efficiently...
    • Can you cover a 10x10 board with 1x4 tiles?
  2. MSCI Internship discussion with Patrick (Di) Lu
  3. Good luck to the Bloomberg Trading Challenge teams:
    • Prerna, Xinye, Yutian, Hui
    • Rick, Israel, Jiayi, Jack, Yifei
  4. IAQF competition (team entry due Friday, Jan 11th, 2019). Problem will be announced Jan 14th, 2019.
  5. There is a Quantopian contest starting Jan 31st.
  6. There are 4 red and 4 black marbles in a bag. Draw one at time. If you have drawn more black than red, winnings are the number of black marbles in excess of red. Otherwise, you get nothing. Quit at any time. What is your optimal strategy?
Fall 2018
2018-11-16 (last meeting of 2018)
  1. Fermi Problem: A classic...you travel back in time to 1 bya (billion years ago)n with a one liter bottle. You fill the bottle with water from the ocean, and dump it out. Then you return to the present day, and buy a liter of water. How many molecules in your purchased liter are from the liter you poured into the ocean?
  2. Brainteaser: you must select a random byte from a data stream of unknown size, but too large to store. How do you do it?
  3. Probability problem: You flip a coin 101 times, and a friend then flips the coin 100 times. What is the probability you flipped more heads?
  4. This week in the markets. Watch the yield curve.
  5. Yield curve bootstrapping recap. For more information, read Hagan and West.
  6. Recreational math and computing with numpy. Watch graphing a times table on a circle.
  7. .
2018-11-09
  1. Warmup: You flip a fair coin 100 times. What is the probability you flip an even number of heads? Prove your answer.
  2. Fermi Problem: How many tires are sold in the US per year?
  3. Fermi Problem: How much does the average taxpayer pay in interest on US Debt? US Debt Clock
  4. Discussion of US Treasury auctions.
  5. This week in the markets.
  6. Last time, we learned about pulling US Treasury interest rates into `pandas`. Now, we will use that data to build the instantaneous forward rate curve, and generate the yield curve. Start with this template.
2018-11-02 No meeting 2018-10-26
  1. Warmup: You have a coin, and you don’t know if it is fair. How can you use the coin to emulate a fair coin?
  2. Fermi Problem: How many US dollar coins would you have to lay on the surface area of Manhattan in order to fully cover it?
  3. This week in the markets.Is it Trump? Or the Fed? FAANG? How about China?
  4. Quantopian uses numerous data sources, including quandl. Quandl has an API that takes advantange of numpy and pandas. Launch jupyter, and open a copy of the Intro to quandl and iexfinance-template notebook
2018-10-19
  1. Introduction to Quantopian. Familiarization with research notebooks and online help.
  2. All sample tatistics fromhave sample bias, and we would like to have a window around our statistic with a probability that the actual value of the statistic. As an example, we complete the notebook exercises given in Noise in sample correlations
2018-10-05
  1. Homework: Let U be standard uniform. Given n observations of U, what is the distribution of the kth order statistic?
  2. Homework: Given X with distribution function F, show that F(X) is uniform
  3. Homework: Now that you’ve built a single stock historical simulation in a spreadsheet, build the same thing in Python (problem 2.22 in the primer).
  4. Historical simulation of multiple stocks.
  5. Monte Carlo portfolio simulation.
2018-09-28
2018-09-05
  1. If you haven’t already done so, install vscode (Visual Studio Code) with Anaconda. I couldn’t find a way to incrementally install it, so you can simply download and install Anaconda again. At the end of the install, it will ask you if you want to install Visual Studio Code.
  2. OOP with Python using Complex numbers as an example.
  3. Take a look at the HackerRank Interview prep kit, and in particular the Hash Tables: Ransom note exercise. Watch the Hash Tables video (on the right side of page).
  4. Read these articles to build knowledge of the market—I will be asking for summaries. Emerging markets, Contagion, Interest rates, and cryptocurrencies
Winter 2018
Apr 6, 2018
  1. Fermi Question
  2. SecurityManager, a simple Java8 app. Requires bonds.txt
Mar 23, 2018
  1. Fermi Question: What number of US dollar coins would you have to lay on the surface area of Manhattan in order to fully cover it?
  2. A simple game of cards: problem 8.21 from Quant Technical Interview Questions.
  3. More Java collections: Maps, and HashSets.
  4. Coming up next: Java interfaces, generics
  5. Market Review: Trump announced "first of many" tariffs, China responded. How will this effect the markets?
Mar 9, 2018
  1. Fermi Question: what is 4 to the 435th (as a power of ten)?
  2. Friends flipping coins, problem 3.21 from Quant Technical Interview Questions.If you need to install Java and Eclipse, see last meeting's instructions.
  3. Some important Java collections: Lists. See HRList for source.Maps, and HashSets. Along the way, learn a little bit about Java interfaces.
  4. Market Review
Feb 16, 2018
  1. Fermi Question: what is the weight of a bowling ball, measured in drops of water?
  2. Introduction to Java and Eclipse.
    1. You may need to install the JDK (Java Development Kit).
    2. Install the latest version Eclipse.
    3. Workflow for beginning of any project: Create Java Project, create package, create first class (e.g. HelloWorld).
  3. HackerRank Java Intro reading via Scanner.
  4. We implement the Alex and Beth Coin flipping problem from last week in both Python and Java, and compare the implementations.
  5. Market Review
Feb 9, 2018
  1. A question from Fermi Questions.
  2. Alex and Beth are flipping coins. See problem 3.20 from Quant interview book.
  3. Counting rectangles: Project Euler problem 85.
  4. Market Review
Feb 2, 2018
  1. A question from Fermi Questions.
  2. Imagine it's snowing...see problem 13 from the Quant interview book.
  3. Coding warmup: Sometimes, you just need more precision. Try Project Euler problem 80. But before you code it, put on your Fermi hat, and estimate the answer.
  4. A wrap-up on what we wrote last week for tranched credit indices.
  5. Market Report. How did Tesla raise money this past week?
Jan 26, 2018
  1. Brainteasers: How many footballs are needed to fill Michigan Stadium? How many cows are in Mexico? How much of the water from Archimedes' famous bath is in my coffee? Practice using Fermi Questions.
  2. Coding warmup: Project Euler problem 81. Does this look familiar?
  3. We've spent a couple of weeks talking about modeling a set of variables that are jointly normal with identical pairwise correlation, and we built a simulation of it. Let's use it to build a simple tranched credit index. For more depth on tranched credit indices, see this BIS article or this more entertaining FT report (requires free signup with Alphaville). And here is the code we wrote for tranched credit indices
  4. Market Report. What did Mnuchin and Trump say about the dollar? And is it time to sell stock?
Jan 19, 2018
  1. Warmup: Project Euler problem 50. Solution is here.
  2. Recall the problem from last time: We built a simulation of n correlated assets, and via Monte Carlo simulation in Python, we found an empirical distribution of the number of assets that had negative return. Why is the number of assets that have positive return uniformly distributed? Try to figure it out on your own. But if you must, solution is here, starting on page 3.
  3. Market Report.
Jan 5, 2018
  1. Wrap up Python implementation of the bag with 3 red, and 3 black marbles (see previous week). How big can you scale up your solver?
  2. Student presentation: Solution to the minmax correlation problem from Jane Street? Solutions presented by Patrick Lu and Jiahua Gu.
  3. Consider problem 5.2 from the Quant Technical Interview Questions. We built a simulation of n correlated assets, and via Monte Carlo simulation in Python, we found an empirical distribution of the number of assets that had negative return. Challenge for next time: explain the distribution for the case where pairwise asset correlation is 0.5.
  4. Market Report: Bitcoin continues to be in the news.
2017
Dec 1, 2017
  1. Show that 1 is the only number in the sequence {1, 11, 111, 1111, ....} that is a perfect square.
  2. Have you seen the minmax correlation problem from Jane Street? Looking for someone to present a solution in first January meeting.
  3. Recall the problem of the bag with 3 red, and 3 black marbles (see previous week). Implement in Python. What's the strategy if there are 26 red, and 26 black (e.g. like a deck of cards)? What is there are 10,000 red?
  4. Market Report: Bitcoin history, Bitcoin bubble. Is Blockchain the real story? Ongoing transformation of retail to online—where will the warehouse space come from? The US may not be able to produce as much oil as we thought. Why?
Nov 17, 2017
  1. Complete Running Median problem.
  2. There is a bag with 3 red, and 3 black marbles. You draw marbles without replacement, winning a dollar if it is red, paying a dollar if black. What's your strategy?
  3. Market Report: Bitcoin volatility, Bitcoin as crisis currency, Bitcoin for Square. Norway divesting oil equities.
Nov 10, 2017
  1. Continue implementation of heap in Python, and apply it to the Running Median problem.
Nov 3, 2017
  1. Getting the right data structure: Review problem (6.14) from Quant interview book.
  2. What's a heap, and why do we care? We implement one in Python, and apply it to the Running Median problem.
  3. Market Report: What went on at the Fed this week ? Search Yellen and Powell. What does Blankfein think about tax cuts, and why?
Oct 27, 2017
  1. Market Report: What happened with Alphabet, Amazon, and Microsoft on Thursday? What are stress tests, who cares about them, and what did a US Treasury report just recommend?
  2. Two bags of marbles: Problem (8.20) from Quant interview book.
  3. What would be the price of 9 year US Treasury bond with 9% coupons? We'll figure it out using zero coupon data from Quandl. Bonus: what's a perpetuity, and how would you price one?
Oct 20, 2017
  1. Market Report: Where’s the the Dow? What’s been happening to it over the past week, month, year? SP500? NASDAQ? FTSE 100? Nikkei 225? What happened to ToysRUs CDS spreads last month?
  2. Discuss airplane boarding problem (8.18) from Quant interview book.
  3. Monte Carlo Simulation: clone the latest code. Discuss the summability of IES (incremental expected shortfall).
  4. Coherent risk measures, subadditivity, and an example of the failure of VaR to be subadditive.
Oct 6, 2017
  1. Warmup: Project Euler problems 46 and 47.
  2. What's a heap?
  3. Monte Carlo Simulation: clone the latest code. Calculating VaR at various quantiles shouldn't require re-sorting the PnL. We learn about lazy initialization. We apply the same thing to ES. Time permitting, we compute portfolio risk.
Sep 29, 2017
  1. Review last week's brainteaser on checkerboards, dominoes, and trominoes.
  2. Coding exercise: Project Euler problems 30 and 35.
  3. We will continue studying portfolio risk next week. At 9:50am, we will head over to the Tozzi Lab (Ross, room R0400) for Kai Petainen's Intro to FactSet and Bloomberg workshop, from 10am to noon. This is part of Kai's Fall series of workshops.
Sep 22, 2017
  1. Warmup: Project Euler problems 20 and 25.
  2. Given the order statistics of a sample of size 10, what are the quantiles associated with each statistic? In particular, the first, and the last? We discuss some approaches to this.
  3. Monte Carlo Simulation: clone the latest code. Calculating VaR at various quantiles shouldn't require re-sorting the PnL. We learn about lazy initialization. We compute expected shortfall, aka AVaR (average VaR), aka CVaR (conditional VaR).
  4. Brainteaser: Checkerboards, dominoes, and trominoes.
Sep 15, 2017
  1. Monte Carlo Simulation: clone the latest code. We altered the Position object in a Portfolio keep track of its PnL, and we can calculate VaR of the position.
March 31, 2017
  1. Update as needed from GitHub. We will create a method called writeSimulation that can dump any number of market price simulations into a file.
  2. Question 3.11 from Quant interview book.
  3. We'll finish with practice problems from Project Euler.
March 24, 2017
  1. Spent some time getting everybody's code base synced up via umich-quant on GitHub.
  2. We added the Market class. A market consists of the risk factors to be simulated, with weighted returns from a specified period. A simulation of the market is generated by taking the inner product of each risk factor's returns with a market noise vector.
March 17, 2017
  1. We will complete HackerRank's Cracking the Coding Interview: Heaps: Find the Running Median, by implementing BaseHeap and MaxHeap, then MedianHeap. Source to date is available on GitHub.
  2. Update your fork of Python implementation of multi-factor Monte Carlo. If necessary, download historical S&P data from QuantQuote, on the Free Data tab.
  3. Questions 3.10 from Quant interview book.
March 10, 2017
  1. An easy warmup from HackerRank: Array Left Rotation
  2. Began HackerRank's Cracking the Coding Interview: Heaps: Find the Running Median. This is a very nice coding exercise: not only do you learn/review heap data structures, but it is an excellent example of polymorphism via both composition and inheritance. We got the MinHeap up and running. Next week will write BaseHeap and MaxHeap, then MedianHeap.
Feb 24, 2017
  1. Via GitHub, get the latest version of our Python implementation of multi-factor Monte Carlo. If necessary, download historical S&P data from QuantQuote, on the Free Data tab.
  2. We will add MarketUniverse and Market classes, implement simulation.
  3. From HackerRank's Cracking the Coding Interview: Trees, Ransom Notes, and Contacts. If you want to better understand hash tables, watch the video that accompanies Random Notes.
  4. Questions 1.10, 8.1, and 8.2 from Quant interview book.
Feb 17, 2017
  1. Continue implementation of Multifactor Monte Carlo in Python.
  2. Any questions about technical interview book?
Feb 10, 2017

To prepare:

  1. Review updates to technical interview book.
  2. Install pandas in PyCharm if necessary.
  3. Download historical S&P data from QuantQuote, on the Free Data tab. Discovered via Caltech Quantitative Finance Group, which has some interesting information.
  4. Begin implementation of Multifactor Monte Carlo in Python.
  5. One-on-one discussions to determine what you want to get from your time in the Michigan Quant Lab.
January 27, 2017

To prepare:

  1. Install PyCharm Community Edition. We’ll be doing some Python in an IDE that has better debugging support than Jupyter.
  2. Solve the BinaryTree problem from the technical interview book. You may use C++ or Python or both.
  3. Do LeetCode problems 2 and 20 (some of you have already done #20).
  4. Be able to explain why the sum of IES is equal to ES.
  5. We discovered that our C++ code for Monte Carlo does not react gracefully to an invalid name for a MarketFactor ("APL" is unknown). A better way to deal with this is through exceptions.

    Carlo Acerbi of MSCI presented on Backtesting expected shortfall.


Projects

Students in the quant program have the opportunity to develop projects inspired by real-world applications. This involves reading research, designing solutions, and implementing them in a relevant development environment, such as C++ or Python.