SP-1 / Lesson 4

For easier and less intimidating viewing, better use a bigger display. Unless you're watching a video or recalling something

ClassworkProblem SetExtra

4. Real Stuff; Order Book

4.1 Intro & Order Book

Have you ever realised that there is no one price for anything? There is no one world-wide accepted number that is associated with how valuable one kg of gold is. You do not have to google Stock Exchange to realise this, you could also see it when going to any money exchange, there are always two different prices, usually called "buy" and "sell".

So, every transaction is about exchanging some amount of one good for some amount of another good. Even buying products in a shop has the same idea, i.e it is also a trade! It is just what you give when buying something is a bunch of pieces of paper, or "verifiable record", that we, people, agreed to have value. While, the real money bills are different from for example cryptocurrency in a sense that there is government standing behind the each currency trying to make sure it works as it should be, still, technically speaking, US dollars have value for the same reason that a bitcoin has value: we, people, assigned this value to it. If you do meet a human-like alien from another planet, good luck exchanging a bunch of rectangular pieces of paper with faces of US presidents and random numbers on them for a super-computer the alien obviously has.

Finance, economics, inflation, role of banks, loans, ... is a set of topics that is rather sophisticated. Even though the basic definitions are clear and even though there are tons of self-proclaimed experts on those matters, there are so many parameters and "things that could happen" that the future becomes unpredictable enough for us to be confident in it. Since the basic definitions and foundations of economics (which we could discuss) are not as important for the interviews and not as interesting (though this is subjective), we will move on talking about a place which makes trades possible. The order book.

Definition [Order Book]

An order book is the list of orders (manual or electronic) that a trading venue (in particular stock exchanges) uses to record the interest of buyers and sellers in a particular financial instrument. A matching engine uses the book to determine which orders can be fully or partially executed.

This is it, the trading revolves around these order books! Each order is basically a contract from someone that says "I am ready to buy/sell certain amount of something for this price", and so the order book is a place where people/companies put contracts like this. Whenever there are two people who "match", i.e one of them could sell to another one and both will be happy about the price and quantity, they are paired up and a corresponding trade is executed. Nowadays, in the 21st century, it is all automatic (but it was not decades ago).

This is it, the trading revolves around these order books! Each order is basically a contract from someone that says "I am ready to buy/sell certain amount of something for this price", and so the order book is a place where people/companies put contracts like this. Whenever there are two people who "match", i.e one of them could sell to another one and both will be happy about the price and quantity, they are paired up and a corresponding trade is executed. Nowadays, in the 21st century, it is all automatic (but it was not decades ago).

And so whoever claims to be able to draw magical triangles to help predicting the future price of something is completely full of crap. I believe whoever is doing this course is clever enough anyway, but just in case, the promotions (or reels from Instagram) like below are a total waste:

Instead what companies care more about, and where they use logic, Machine Learning (e.g linear regression) etc... to make informed decisions looks like this:

Well, technically speaking, the above is the top of the order book, and it is likely that when you to work for a company, there will be many many more columns in your data sets, potentially with unknown-to-you features (that the company keeps secret from most people). However, interestingly enough, for some of the goods even the top of the order book is informative and useful enough!

4.2 Bid & Ask

For many goods, assets, etc... Anyone can place an order in the order book. Different trading venues (with different order books) have their own set of rules as for what kind of orders you can place, who can place them and what are the fees. Yeap, the trading venue is the only here who makes money consistently and risk-free :)

All of the orders are either on the "buy" or "sell" side. At least in the most common and simple set up. So if you freeze everything at a particular points of time, you can visualise the set of orders like this:

Where each line is an order placed by someone, the length of the line symbolizes how big is the order. The red colour is often used for "sell orders", the green colour is often used for "buy orders".

However, one could get a bit annoyed that the picture above had words "ask" and "bid", not the "sell" and "buy". As you might guess, the "ask" corresponds to the sell orders, and so the "bid" corresponds to the buy orders. To be more precise, one could define:

Definition [Lowest Ask, Highest Bid]

At any point in time, the lowest ask is the smallest price that someone is willing to sell certain amount of product for, while the highest bid is the largest price someone is willing to buy a certain amount of product for. Given that all of the possible trades have been executed up until this point of time (i.e all the people who could be matched, were matched) ask price is larger than bid price.
You could remember this by remembering that "ask" starts with "a", just as the word "above", while "bid" starts with "b" just as the word "below"

When people say the word "size" they could either mean the size of the order that has been placed (and the meaning of this is clear), or the sum of sizes of all of the orders at a particular level (= certain price). E.g in the picture with "timestamp", "ask_price", ask_size", "bid_price", "bid_size" from above, the size means exactly this. I.e that table shows the information about the two closest to each other level from different sides.

Conclusions, and next steps

The above is mostly about the order book, and the basic definitions. For a number of reasons, this page (that can be found by general public) does not contain some of the things we can talk about during the class, in particular an example of a trading strategy. Sorry about this, please get in touch if you want to learn more here.

The next step, which is the Problem Set, is gonna be a bit unusual today. It will not be a bunch of problems, but rather one task that involves programming as well as data analysis for real data. This course is not about teaching software engineers and it is quite mathematical overall, however, basic programming skills are absolutely necessary to significantly increase your chances of getting the job. Besides, even if you know barely anything about Python or libraries like numpy or matplotlib: it will not take very long to learn those! It is much easier, even for a mathematician, to do get skilled in those rather than be great at logical & critical thinking.