6 ms·
Positions, Profit and Loss
- Exuma 5y agoThis guy has a great writing style.
- is0tope 5y agoMuch appreciated! I am still learning.
- Exuma 5y agoI just sent your article to a lot of different people trying to learn. You have a natural gift for teaching, I'd highly recommend you keep making posts. I went down the rabbit hole learning a lot of this stuff about 1/2 a year ago and good information is quite challenging to find, it's all hyper dumbed down or hyper generalized and vague (investopedia).
- is0tope 5y agoThanks a lot, I am glad it is useful. If you have any ideas for topics that were hard to understand before, please do let me know!
- Exuma 5y agoHonestly I think the hardest thing to date that is nearly impossible to find information on is how a market maker actually works. I've googled for hours before only to get very vague definitions, nothing concrete with actual examples/formulas.
- is0tope 5y agoThank you, i will put "how market making works" on my list. Obviously that is a very detailed subject, but I think the basics can be covered pretty easily.
- Exuma 5y agoI agree, I'm sure it is wildly complicated, but something more than "market makers provide liquidity!!!" would do wonders. Something on par with the detail of your existing 2 posts would be 10/10...
- evo 5y agoHere's my understanding, starting with some background terminology: Everything that's tradable on an exchange (an "instrument") has a bid/ask spread that represents the highest price someone's willing to pay to buy (the bid), and the lowest price that someone's willing to pay to sell (the ask). There is _always_ a bid/ask spread, because as soon as anyone places an order that would reduce the spread to zero, that means they're willing to pay what someone's asking, or vice-versa, and therefore the exchange immediately converts it into a trade--done deal!--and now there's a spread again. Incidentally, executing a trade this way is "crossing the spread", you're opting to "pay the difference" between the bid and ask to get your trade done. Someone that crosses the spread is said to be "taking liquidity." They're willing to pay the surcharge of the bid/ask spread to get their trade executed right now. On the other hand, someone that sits at the bid/ask spread, waiting for someone to cross to execute, is said to be "offering liquidity," they're willing to patiently wait in order to save money equal to the spread. Now, a market maker is a participant that is _solely_ interested in making money off that bid/ask spread, basically like a sports bookie. They're willing to always be in the market, on both sides, and take the spread whenever someone crosses over. So if say AMZN is trading at 3332.95 x 3333.05, they'll be offering to buy at 3332.95, and sell at 3333.05, and any time people take those offers, they make a dime. Do this thousands of times a day, on many different instruments, and you've got a business. That said, there's real risks in market making, and understanding them requires the idea of "informed" versus "uninformed" trading. An uninformed trader comes to the market simply because they want to trade for some external goal unrelated to trading. Maybe they're selling stock for a house downpayment, or buying agricultural futures because they make potato chips and don't want to deal with the price shocks of a sudden drought. They're willing to cross the spread, and they don't particularly care if they lose a few pennies on the transaction, because that's not their goal. These traders are the meat and potatoes for market makers, because they don't move the fundamental price of the instrument, they're effectively noise. In a market of nothing but uninformed traders, you would expect your position as a market maker to fluctuate around zero, because you're buying roughly as much as you're selling. An informed trader, on the other hand, "knows something". They're aware of some material fact (or at least a strong hypothesis) that indicates the price of the instrument is going to move dramatically in the near future. They're willing to cross the spread, because they know the spread is going to move with them anyway. These are danger for market makers, because they will all pile in on one side of the trade, all buying, or all selling, and now the market maker will end up in a losing position--short when the price is going up, or long when the price is going down. Imagine running a Gamestop store: on a normal day, you might see half your customers buying a PS4 and half selling a PS4, but on the day that the PS5 is announced, suddenly everyone wants to sell their PS4 at the same time before you lower what you're offering. The classic market maker algorithm looks at "inventory", basically your absolute outstanding position, and tries to keep inventory as low as possible. When uninformed trading is taking place, your inventory is around zero, and you can stay very close to the minimum spread. As your inventory grows, and you become either increasingly more long or short, you start pulling your bids or asks away from the best bid/ask to try and bias future trades back into a 50/50 ratio. All market makers doing this simultaneously means the bid/ask spread starts to widen as there's increased uncertainty about the price. Another key element to market making comes down to trade volumes. You could, today, start market making, all you need to do is put in limit orders at the bid and ask and wait. However, you'd probably not make that much, because you're losing money to various trading commissions, exchange fees, roundtrip network latency, etc. Professional market makers make tens of thousands of automated trades in a day, and as a result, are able to negotiate substantially lower costs that make it worth doing. Many exchanges even have "designated market makers" that have special trading permissions in exchange for guaranteeing that they will _always_ provide some best bid/ask offer even in the worst case conditions, otherwise you in a sufficiently large event you could get a "liquidity crisis" (i.e. there's no one willing to buy or sell that instrument at any price). That ended up being more text than I thought it would--apologies.
- ReggieCommaRose 5y agoI work in a vanilla MM space and have had limited exposure to systems/technical side in the crypto space, would love to see the weird/cute crypto-specific problems that exist. For instance I was surprised to learn the other day that FPGAs are becoming standardized in the crypto space now as well, since to my knowledge network bottlenecks are more difficult to be precise about due to the common usage of websockets, the non-standardized colocation services offered, etc. But what crypto MMs are using FPGAs for, is to do actual JSON (maybe it's FIX by now?) parsing since that became a common bottleneck due to the lack of binary protocols from crypto exchanges.
- is0tope 5y agoThat's very interesting! I myself have not worked as a MM before so I don't know much about it. I can imagine it is possible since these days there is a lot of cross pollination between traditional finance and crypto. Most exchanges will do Json, though I know of several who have FIX interfaces also.
- Exuma 5y agoSo quick question: is it correct to assume that FIFO/LIFO doesn't matter if you want to get your overall profit (sum the cost column which consists of side x quantity x price for each trade)? In other words, FIFO/LIFO only applies when trying to find the profit of a single trade, but as a whole it doesn't matter? Or is that incorrect. Thanks Edit: Nevermind, I forgot this is for REALIZED gains. I feel like what I wrote above would only make sense if the entire position was closed flat. Ultimately I was trying to figure out the difference between summing the cost column (which seems to be profit/loss depending on sign?) vs matching trades with FIFO/LIFO but I have a hunch it has to do with realized vs unrealized gains.
- is0tope 5y agoSo all of these methods converge when the position is fully closed out. They are actually designed mostly for regular businesses that are buying and selling items, but it works for anything. You always end up making the same amount of money, but when you need to figure out profit, it is hard to do before you have sold all of your stock! These systems provide different ways of answering the question: "What is my profit _so far_?). Summing up all of the costs will give you the cost so far, but if you are half way through selling all of your items, it is not that useful, as you have no way of telling if you are making a profit or not on your sales! FIFO vs LIFO can matter depending on what you are trying to "show". I am not an accountant, but imagine if you bought a bunch of stock really cheap in the first half of the year, and in the second half bought a bunch more stock at a higher price. If you use FIFO, you will realise a big profit initially, followed by a smaller profit or loss in the second half when you start to use up your more expensive stock. With FIFO, you do the opposite (big loss up front), and with Average Cost it's more spread out. If you have mid year report coming up, and you want to look good, you might be tempted to use FIFO, in order to show that you made a higher profit initially. I'm guessing real accountants see right through this though!
- Exuma 5y agoOoooh, great point. Thank you, that makes perfect sense. So that's an interesting point that I never actually realized (pun intended 1000%)... is that FIFO/LIFO doesn't actually change your profit amount when the position is fully closed, it only matters, as you said, when "showing" that profit, ie... if you are trading over multiple years and you need to do your taxes, the tax years up front might show more profit, but less in later years, or vice versa, but over all the years the profit would be the same. That's obvious in retrospect, and I can't believe I didn't get that before. Thanks!
- Exuma 5y ago> By definition, this order must be the top of the book, because it’s price already had to be aggressive, and there could be no other bids above us. Therefore, the new best bid increases from $99 to $102, since that is the limit price of our order. I really wonder here, in this part of "Introduction to Limit Orders", how they handle race conditions. Do you think they use a synchronous queue that queues orders while it's transacting, or do they try to also handle inserting orders during the process of filling orders?
- is0tope 5y agoOrder books will almost always be single threaded or something similar. Only one order action is allowed at a time in each book, otherwise it would be chaos. Exchanges are very strict on "fairness" since if there is a (legal) edge to be had, you can bet that someone will find it and try and exploit it. That's just the game.
- tacostakohashi 5y ago> Notice that this method is a lot simpler than the other two, but because you have to use average price, you are exposed to floating point imprecision which is a lack of accuracy that computers have when computing decimals. Using average price and floating point imprecision are two separate, unrelated issues. You don't have to, and probably shouldn't use floating point to calculate the average price, and it's perfectly possible to use decimal arithmetic or fractions rather than floating point. The real issue here is that 2/3 does not have a decimal representation, not floating point imprecision. No matter what you do, if you need to express it as a decimal of finite length it will need to be rounded, and that's where the imprecision is. In practice, you can generally get away with using floats because the floating point error ends up being less than the rounding imprecision.
- hansvm 5y agoGiven that the average is just a means to an end (total P&L), why would they not simply rescale by total shares to make that technical difficulty go away?
- tacostakohashi 5y agoIt's not a technical difficulty, it's an arithmetic difficulty.
- hansvm 5y agoSorry, I probably wasn't clear enough --- the only reason there exists an arithmetical difficulty in the first place is because we're materializing an intermediate value we don't really care about with any kind of precision and using it to compute a value which needs perfect precision. The proposed solution is to never mess with division in the first place when computing P&L; operate on "total" values: cost basis, total profit, .... Edit: and as a super minor point of contention, I don't think it's wrong to call it a technical difficulty. You can represent the involved quantities exactly with a decimal ratio type, and the existence of a technical solution indicates that the problem is at least somewhat technical in nature.
- anovikov 5y agoQuestion: suppose i bought some security through a broker, and 2 business days have passed. How can i independently (of broker) check that it is indeed now in my name?
- is0tope 5y agoGood question. I am actually not super familiar with it, but in general your shares are owned under the name of the broker (called "street name"). That broker will then deal with portioning out dividends etc. I believe you can request to have personal ownership assigned, but this is expensive from what I have read. Unless you don't trust your broker (why are you using them?) it is unlikely to matter to an individual investor. You still have the legal right to the shares.
- anovikov 5y agoWell, it would be stupid to trust the broker. What technically prevents them to run away with all stocks? I currently manage it by simply having accounts with several to avoid putting all eggs in one basket. But this is hardly a solution.
- is0tope 5y agoThat is where your personal judgement comes in of course, but it would be hard for them to "run away with the stocks". These are not physical certificates, but just registrations in a central organisation. Brokers (in traditional finance) are regulated, audited, and also are often subject to insurance policies in case they went bankrupt, or similar. If you are dealing with a large and reputable institution, you are unlikely to gain any benefit by assigning the shares to yourself I would suspect. Someone please correct me if I am missing something though.
- rmah 5y agoWhat prevents them is custody. Funds, brokers, etc. are all required to use custody providers to keep track of assets and handle the actual transfer of assets.
- 5y ago
- paulpauper 5y agoFor most people, using these brokers will be something that they will be quite familiar with, even though the actual trading of their shares will happen somewhere in the background. Brokers in fact do not always have to go to an exchange directly, and many will route (send) client orders to various third parties such as market makers or other brokers. This was made quite apparent in 2020 when it was noticed that the broker RobinHood was selling client order flow (client orders) to the hedge fund Citadel. Online brokers have been doing this forever. TD Ameritrade is by far the worst offender in this regard, way worse than Robinhood.
- tedyoung 5y agoYes, brokerages have all been doing this for a while, but while TD Ameritrade pays more overall than Robinhood, does it also do more trades (not in terms of number of trades, but dollar value)? Without that info, it's hard to tell who's worse.
- ReggieCommaRose 5y agoDamn the formatting/design of your site is fantastic.
- is0tope 5y agoI wish I could take credit, but it's actually a theme for Hugo called Cactus (https://github.com/monkeyWzr/Hugo-theme-cactus https://github.com/monkeyWzr/Hugo-theme-cactus). I made some modifications to it however.