Datacast

Episode 65: Chaos Theory, High-Frequency Trading, and Experimentations at Scale with David Sweet

Episode Summary

David Sweet was a quantitative trader at GETCO, where he used experimental methods to tune trading strategies, and a machine learning engineer at Instagram, where he experimented on a large-scale recommender system. He is currently writing a book called "Tuning Up," an extension of lectures given at NYU Stern on tuning high-frequency trading systems. Before working in the industry, he received a Ph.D. in Physics and published research in Physical Review Letters and Nature. The latter publication – an experiment demonstrating chaos in geometrical optics -- has become a source of inspiration for computer graphics artists, undergraduate Physics instructors, and an exhibit called TetraSphere at the Museum of Mathematics in New York City.

Episode Notes

Show Notes

David’s Contact Info

Mentioned Content

Publications

Book

People

Tuning Up — From A/B testing to Bayesian optimization

Manning’s permanent 40% discount code (good for all Manning products in all formats) for Datacast listeners: poddcast19.

You can refer to this link: http://mng.bz/4MAR.

Here are two free eBook codes to get copies of Tuning Up for two lucky Datacast listeners: tngdtcr-AB2C and tngdtcr-6D43

You can refer to this link: http://mng.bz/G6Bq.

Episode Transcription

Key Takeaways

Here are highlights from my conversation with David:

On Studying at Duke University

I arrived at Duke on the year when they won the NCAA championship. Duke has a lot of school spirit, so it was insanely jubilant. The way Duke people celebrated was to take all the benches off the main quad and threw them into a bonfire. In general, Duke has a strong on-campus social life. I also got to learn about North Carolina barbecue. In the Northeast, where I’m from, barbecue is the event. In North Carolina, barbecue is the food — pulled pork and hash potatoes.

I got a BS in Physics and BA in Math. A nice thing about the Duke was the opportunities to do things beyond classes. For example, I did an independent study with Richard Palmer on neural networks and reinforcement learning, which were fairly new back in the 90s.

My favorite undergraduate Physics course was a seminar on General Relativity. It’s a fascinating topic and hard to grasp. However, in a seminar format, we had many group discussions, which provided a nice combination of intellectual and social interactions.

On Getting a Ph.D. in Physics at University of Maryland, College Park

For me, the question at the time would have been: “why not pursuing a doctorate?” I enjoyed Physics, and there was a lot more to learn. It was as natural as going from freshman to sophomore year.

Chaos theory was a popular topic in the 80s. In popular media, you would have seen fractals — images that are associated with chaotic systems. For example, chaos theory was featured in Jurassic Park. The defining characteristic of chaotic systems is expressed as sensitive dependence on initial conditions. Those initial conditions where you start the system might have looked the same to you, but there will be slight discrepancies in any realistic setups. Those discrepancies will grow explosively, so in any finite amount of time, you’ll observe the differences no matter how infinitesimal it was when you started. But the behavior of the system itself is bounded.

We want to talk about a state space in physics — where we can describe physical systems by variables such as position and momentum. In the late 90s, lots of work had been done on systems with few such variables because the computers back then weren’t capable of doing the simulations to study those with higher degrees of freedom. As computers got faster, I studied higher-dimensional version cognates of lower-dimensional results.

On His Nature Paper about “Topology in Chaotic Scattering

This paper includes a geometrical optics experiment, meaning that it’s a study of light rays bouncing off the universe.

Another outcome of this experiment was a pretty physics picture. When published in Nature, the figure from the paper was made the cover of that Nature magazine issue. As a result, more people became aware of our work — using it to demonstrate chaos and fractals in undergraduate labs and become a part of the Tetrasphere exhibit at the National Museum of Mathematics in NYC.

On The K Desktop Environment

The K Desktop environment is an open-sourced GUI desktop for Linux, including the menus, the windows, the session management, the utilities, etc. As the KDE project emerged into version 2.0, many developers came to the mailing list and showed interest in participating, but they needed to get set up. So I decided to put together a how-to manual to go from nothing to contribute to the project. It was very well-received.

Because of that, I got contacted by someone who was writing a book about KDE and needed a chapter on the KDE code. He asked me to write that chapter, essentially expanding my how-to manual. I did that to get my feet wet in writing. Then I thought maybe there’s more to that. Maybe I could write a whole book about KDE development. I pitched that idea to MacMillan Publishing, and they provided the support, resulting in a published book. The first half was on version 1.0, while the second half was on version 2.0. The book was definitely a group effort of many KDE developers.

On Open Content via Andamooka

In the early 2000s of the Internet, open-source has become quite popular. The specific problem is that: if you wrote documentation for some open-source software and that documentation was closed-source, the software couldn’t evolve. So people were discussing open licenses for documentation. One of the licenses is called OPL — Open Publication License. I asked MacMillan when the book could be released under this license as an experiment. They were on board. We printed the book and sold it while also having the PDF version freely available that anyone can download, modify, and redistribute with attributions.

The PDF was hosted on Andamooka, built under the Flash content management system. I then found other authors who had published OPL books and invited them to put their books on the site. One of the authors is Jimmy Wales, who was working on something called Nupedia (the precursor to Wikipedia).

On Becoming a Quant Analyst

I went into the industry because I was interested in building things. I love the novelty in research and found that satisfied. But building automated systems in the industry is even more fascinating to me. A trading strategy is an autonomous vehicle because it doesn’t require you to build things with your hand but with software.

So what happened when I entered the industry after getting a Ph.D.? It was an amazing shift. All my learnings had been in an incremental progression up until that point — each new year was built upon the previous year.

Going into the industry was like going back to square one: I had no finance, engineering, or economics expertise. It wasn’t because I had skipped steps in a steady progression or fell backward. It’s just that I got kicked off to the left field, in a sense.

I had underestimated how dramatic that change would be. It was tough but exciting at the same time. There was so much more to learn, study, or know that I needed to learn on the fly — either on my own or with my peers, not in a controlled environment like a classroom.

As a scientist, I had learned to build free-parameter models, in which I could analyze them by hand or by simulations. But for an online trading strategy, I needed to tune parameters to the real world. There were good answers, and I needed to find them, which led me to learn about experimental methods.

On Working at Lehman Brothers

Lehman Brothers was a huge bank. 30,000+ people worked there during my time in the mid-2000s. So on the trading floor of the building in Times Square where I worked, about 500 people were trading — lots of yelling on the phone, lots of what to buy and what to sell, etc.

For me, as a quant sitting in front of a computer, it felt like doing my math homework at a football game — not the most productive environment as you can imagine. So that was tough to get used to.

I worked on systems where positions were held intra-day. In my last year at Lehman, I worked with a small group of 4-to-6 people building a high-frequency trading system. There, the holding time was even shorter, maybe a minute or so. Then, I discovered companies like GETCO and TradeBot who were already doing these things successfully. While I loved the problem, I was not too fond of the idea of reinventing it. I knew the problem had been solved to a large extent elsewhere. That precipitated my transition to GETCO.

On Contextual Bandits at Teza Technologies

At Teza, I worked on execution algorithms for high-frequency timescales. At the time, we were short-staffed for this project and were interviewing people to work on A/B testing. At such short timescales, we need to understand what impact a cause might have on the execution.

While interviewing people, I was also looking at ways to get this thing up and running in an automated and efficient manner. I ended up learning about contextual bandits, which have three parts: (1) modeling of the cause / continuously refitting, (2) exploring different kinds of trade under new conditions, and (3) de-biasing the model from certain policies. Contextual bandits ran fairly autonomously, so I could work on improving other pieces of our execution ability.

On Cryptocurrency Trading

Unfortunately, Teza got shut down. While looking for something new, I connected to two traders/entrepreneurs running a trading shop. One of the investors is Mike Novogratz, who co-founded one of the first public hedge funds named Fortress. He had taken an interest in cryptocurrency and was looking to fund people who traded them. I had been interested in crypto and traded it by hand for a while. However, nobody in finance really took it seriously. So I was very surprised to hear that somebody in traditional trading looked to fund cryptocurrency trading.

Eventually, the three of us formed a company called Belverade Trading and started trading live in November 2017 (just when cryptocurrency started getting crazy). Those were a few months of sleepless nights — building, repairing, and improving our system as it was trading. It was a wild ride and one of the best experiences of my professional life.

Mike Novogratz also funded other cryptocurrencies within his ventures at the time. Each of these looked like a department within an investment bank. He decided to combine all of them and formed a single company. As a result, Belverade Trading was re-branded Galaxy Digital Trading. One of my partners left early to run a former business. I stayed for about 6 months to integrate the team and software that I had built into a mature and stable level.

Beyond the experience of being an entrepreneur and creating something of my own, doing it in the crypto community at that time was awesome. There was just a bunch of really passionate and optimistic people. There were no days gone by in which I was not inspired.

On Optimization of HFT Systems

I gave these lectures once a year (for a few years) at Vasant Dhar’s “Trading Strategy Systems” class at NYU Stern School of Business. The idea was to teach experimental optimization methods used in quantitative trading. I want to talk about the pros and cons of simulations and experiments and how they could work well together.

Most of the lectures also discussed different methods used for experimental optimization (A/B testing, multi-arm bandit response surface methodology, contextual bandits, Bayesian optimization, etc.) and showed how they are built on top of each other.

On Working as a Machine Learning Engineer at Instagram

I observed a growing gap in ML techniques used in finance vs. techniques in technology companies such as Google, Apple, Facebook, Uber. As these technologies became more gigantic, they were able to open basic research labs within their companies. These labs have produced cutting-edge algorithms/ideas and pushed them to the applied side. I had not seen finance companies having that level of innovation. Was that because these techniques are not applicable?

I was learning by reading papers and running little side projects on my own. But if you have ever taken a math class, you read the chapters, and you think you understand. But when you went ahead and did the homework problems, then you figured that you didn’t really understand at all. There’s something about hands-on practices that increase your understanding of whatever the topics might be.

So what I wanted was to go to one of these tech companies and use the ML techniques (that I was learning about) in practice. Hopefully, it could build confidence in my ability to predict whether these techniques would be useful in any given context.

At Instagram, I worked on Feed and Stories. If you use the Instagram app, the streaming of pictures is the feed, and the circles on the top are the temporary Stories. My team worked on the recommender system, deciding which images/stories to show to the users and the ranking order. A couple of nice things happened:

  1. I got the opportunity to work with recurrent neural networks, counterfactual policy estimation, and Bayesian optimization.
  2. Furthermore, at such a large company with so many experts in different algorithmic topics, I could sometimes ask deep questions from a person who wrote a paper that I had read. I could hit them up on Facebook’s internal communication tool, and they were friendly to respond.

On His New Book “Tuning Up

A big part of the research for the book has been interviewing colleagues and friends of friends from finance and tech companies.

I wonder if the industry has the right level of transparency. When people are afraid to talk, I wonder if there’s more to it than just maybe some efficiency due to the lack of transparency. Maybe there’s a toll taken on people if they can’t talk.

The pandemic came out of the blue a few months into writing the book.

On The Benefits of His Physics Degree

Some basic skills like math, programming, modeling simulations, etc., certainly help with engineering. But I didn’t have any finance or engineering background, so many of the specifics were missing.

But what’s has been the most helpful for my career is scientific thinking.

Studying physics or any other scientific subjects will teach you how to make a claim and then find ways to refute your own claim. You want to break your own ideas. Then, for whatever survives, you will have confidence in them. This is hard to do because this mindset doesn’t come naturally or is intuitive to human beings.

Bias towards simplicity (Occam’s razor) also gets hammered to me throughout my academic career, which is very useful in the industry.