16 ms·
Algorithmic Trading: A Practitioner’s Guide
- maest 4y agoThe best book that I've read on order execution was "Algorithmic Trading and DMA". [0] The book is kind of old now, but it was written by Barry Johnson, who worked at Morgan Stanley on their algo trading team. The book is kind of dry, but very thorough and clear on its concepts. It reads more like a university text book than anything else. It just goes through concepts one by one, chapter by chapter. [0]: https://www.amazon.co.uk/Algorithmic-Trading-DMA-introduction-strategies/dp/0956399207 https://www.amazon.co.uk/Algorithmic-Trading-DMA-introductio...
- kilgnad 4y agoHow would I implement algorithmic trading at home? And would this be a viable idea if I knew what I was doing? Has anyone done this successfully?
- wojciem 4y agoThere are platforms like alpaca.markets that deal with all the infra-aspects and allow you to concentrate on the algorithm part.
- Terretta 4y agosee also https://openbb.co/ https://openbb.co/ as for has anyone, well, there's the infamous wallstbets on reddit but also the less infamous /r/algotrading where you may have better luck with the question
- ari_giblets 4y agoI'd like to know how an individual can do this, 1) And avoid some code bug causing them to lose all their money, and 2) Not get lose all their money to some company's API fees...
- MonkeyClub 4y agoFor (1), test profusely beforehand, and apply your algos in paper trades first (demo APIs without real market execution). And of course, hedge your bets, don't put all your cash on one algo/instrument in one go, and do at least some DD. For (2), there are zero-fee brokers (e.g. those mentioned by downvoteme1 earlier) that you can use, so you don't have to keep feeding the broker.
- robswc 4y ago> And avoid some code bug causing them to lose all their money Well, everything has a non 0 chance but you can code certain conditions that have to be met before an order goes through. IMO, you would have to have significant capital to even end up in a situation where a bug causes lots of loss. Here is an example of something you might be thinking of. https://www.henricodolfing.com/2019/06/project-failure-case-study-knight-capital.html https://www.henricodolfing.com/2019/06/project-failure-case-... > Not get lose all their money to some company's API fees It's not too bad these days. A lot of brokers offer "zero-fees" which really just means you only have to pay the SEC ones which aren't too bad.
- taeric 4y agoI suspect the biggest catch for 1, is that you do it from an account where losing all of the money is an acceptable outcome. Clearly not the preferred outcome. But will not destroy you financially. Which leads in to 2. The idea is that you are aiming for algorithms that take into account the API fees. If you didn't account for that in the price of business, than this is the same as not accounting for taxes in how you pay for things. That is, you did it wrong.
- 000ooo000 4y agoI spent a good few months building a system for fun/interest. Darwinex has an interesting business model - check it out - but it shows leaderboards of supposed profit-generating trading systems. Thing is, one will be hard pressed to find solid, relevant, detailed and current information about legitimately profitable trading strategy. Once a strategy becomes widely used, the 'market inefficiencies' being exploited cease to be readily available, so there is a strong incentive to keep a good strategy private. I vaguely remember reading about HFT firms obscuring their trading activity for this reason. Additionally you will find the online world absolutely saturated with the grifter types. So good info is hard to come by. Be prepared to learn at least the fundamentals of both trading and statistics, do lots of testing, and basically figure it out on your own because nobody successful (and smart) is sharing their reliable, profitable strategies (that doesn't mean you can't learn from them - just don't copy paste). It is a very interesting domain though and I thoroughly enjoyed learning about it all and building mine.
- CTDOCodebases 4y agoThis is what the average punter doesn’t understand. You basically want alpha but alpha decays over time. Think of alpha as being some insight no matter how slight that a coin will land heads as apposed to tails more times than not. Now comibine this with a risk management system that involves you only risking 1% of capital (avoiding gamblers ruin) and you are off to the races.
- downvoteme1 4y agoFor starters, open a brokerage account at a broker that provides an API. There are many currently available including Ally, Tradier, Alpaca, Think or Swim, Interactive Brokers etc. Although, I think Think or Swim is currently not providing new keys due to their merger with Schwab. Once you got that part setup, try to write a simple program that buys or sells an equity from the command line . From their own you can start exploring trading algorithms. Some are pretty basic, like when the price crosses above a 200 DMA, then buy a stock as that usually signifies an upward run, while selling if the price falls below the 200DMA as that is bearish. Then you can read some books on price action, fundamental or technical analysis and build your own algos.
- dmurray 4y ago"Algorithmic trading" in the sense described in this article only makes sense if you have a customer who wants you to execute large trades and pay you a commission. You can try some trading using algorithms to identify profitable trading opportunities. That would normally fall under "prop trading" instead. There are definitely people doing this in ways achievable by a home hobbyist, but don't expect any low hanging fruit. Find some niche in some less liquid instruments. Don't look for anything that relies on being fast - someone else will be there who measures latency in nanoseconds.
- robswc 4y ago>How would I implement algorithmic trading at home? I made a python framework to try to help with this: https://github.com/robswc/stratis https://github.com/robswc/stratis However, it became hard to maintain an opensource version. I would say its still not a bad way to get a head start (bias there, ofc) I will say, its not something that can be done "on the side." I originally made a decent amount of $ by getting lucky in crypto. I figured I'd "just become a algo trader" and it was much more difficult than I could have imagined. I actually _just_ started a series on how to build an equity trading system from scratch. I planned to put part 1 out later this week but eh, I'll post it now, it touches on it better than my comment here can :) https://robswc.substack.com/p/building-an-equity-trading-system?sd=pf https://robswc.substack.com/p/building-an-equity-trading-sys... * the post assumes you already have alpha (a profitable strategy) > Has anyone done this successfully? Regarding this, I actually originally talked a bit with the (now infamous) SBF of FTX about this. I originally wanted to join Alameda Research... but at the time, I didn't want to move across the world. For years I regretted that decision (not so much now, lol) I started my own firm though and I have made a decent amount of $. Truth be told though, knowing what I know now, I might have put more energy into a start up. I enjoy the challenges of algotrading but doing some consulting work, I think I enjoy "building" more than running statistical tests, cleaning data, etc etc. To sum up this comment though, _if_ you had a profitable strategy and _if_ you built a system that could reliably execute trades, you certainly could be successful. It is very difficult though.
- dawsoneliasen 4y agoThink of it like any active trading strategy, or day trading, just that you’re automating it. It’s possible, but it’s a lot of work, and it’s very risky.
- aleksiy123 4y agohttps://www.quantconnect.com https://www.quantconnect.com Is a platform I experimented with and found pretty solid. I definitely learned some things however, I realised the amount of effort I needed to put in would be better used elsewhere.
- arminiusreturns 4y agoFirst, become a PDT (25k min to pattern day trade), meaning you can't execute more than 4 trades in a 5 business day time-period. So if you are serious, you have to get to that first... then realize that whatever broker you are using, they probably have an API. I do raw api calls, but you have to be so very careful. You can do something wrong and totally, absolutely jack yourself up, so this way is only for the very brave, but I think it offers good opportunities to understand the markets better if you can stomach the extreme risk profile. Check out https://algotrading101.com/learn/ https://algotrading101.com/learn/ for a good set of practical articles to give you some context. I wish I could still point to Quantopian, which is where I started my learning process on this, but it died.
- Galanwe 4y agoThere is litteraly 0 chance for you to be profitable in the medium to long term if you don't have years of experience in the industry. Anyone claiming that is not the case is just misinterpreting his PnL. The internet is full of people thinking they are market wizards just because they cannot residualize their idiosyncratic returns properly against beta, sector, country, size properly.
- kwere 4y agoTradestation is a broker that has tools/languages/backtesting that are oriented for systematic traders, the retail version of algorithmic trading
- hm64 4y agoMy favorite bit is when you connect it to core war. I was just thinking about core war in context of my PL class today. Core war renaissance!
- mistrial9 4y agoA colleague here tried to break into the trading world as an adult. He had a reference to be a member with a small cozy firm where his accounts could be held. He got "direct market access" (?) with a trading terminal that he said was good quality. Yet when I watched him work for several weeks each day, he was locked out of a SELL order more than once.. it didn't go through in any reasonable amount of time and he ended up losing some client's money and that was sort of the end. I don't know enough to know what happened, but it seemed like he was just pushed aside somehow, despite the cautious and reputable (?) parts he used. SF in the oughts iir
- auntienomen 4y agoThe article isn't about discretionary trading. It's about algorithmic trading, which is a bit like the word 'hacking' in that it means one thing to practitioners and another to the general public. To practitioners it refers to the use of algorithms to trade large quantities of stocks or futures or whatever. The goal is to reduce trading costs by executing small trades at the right time. This is distinct from and rather more common than quant trading where an algorithm actually decides what bet to make.
- nradov 4y agoYour story doesn't make any sense. Was this guy trading his own account, or was he employed as a proprietary trader, or was he running his own little investment fund using another company's platform? In any case, a legitimate trader won't be "locked out". Are you perhaps referring to a locked market? https://www.investopedia.com/terms/l/lockedmarket.asp https://www.investopedia.com/terms/l/lockedmarket.asp
- mistrial9 4y agoit was years ago.. the man decided on trades and executed them using a kind of terminal and base account that enabled that. Yet, "front running" is commonplace at all levels, in many forms. This man was a legitimate trader with credentials and ID, and when a SELL order was issued (get your money) the order did execute.. but how long did it take ? what prices changed while the order was being queued ?
- codeisawesome 4y agoI always wonder if this space hasn’t been entirely cornered by HFTs. Isn’t it futile as an individual?
- tsss 4y agoHFT exploits very short lived movements. If you had some algorithm to predict long-term trends, then you could beat HFT without relying on low latency.
- jjtheblunt 4y agoIs that essentially what Warren Buffett and Charlie Munger do?
- HeyZuess 4y agoBuffet and Munger are value investors, there are multiple strategies in both investing and trading. Jim Simmons might be a more relevant example here in regards to trading if you are comparing the two.
- baq 4y agoThey are value investors… who definitely know the technicalities of the market, and have at times taken serious size option positions. They say to just buy index funds because otherwise it’s a full time job with all the research and accounting.
- robswc 4y ago>Isn’t it futile as an individual? HFT is, more or less... but algo trading in general can be as simple as executing strategies you would otherwise manually perform. I believe there's still enough alpha out there.
- thkim 4y agoAlgo trading != HFT. HFT is a type of algorithmic trading strategies, categorized by trading interval. In the same categorization there are mid-freq strategies as well. The term "high frequency" is rather subjective, it depends on what alpha you're targeting after.
- WiSaGaN 4y agoI am surprised it does not mention propagator model, at least from the review.
- DennisP 4y agoWhat is propagator model?
- WiSaGaN 4y agoThe basic idea behind the propagator model is that order flow can be treated as a propagating wave that spreads through the market and affects prices. Thus given that we usually execute multiple orders for a given "meta" (big) trade, managing the effects of those earlier orders on later orders can have non-negligible impact on the execution performance. The propagator model then gives some solution to get the optimized execution under those assumptions. You can refer to https://www.goodreads.com/book/show/39096959-trades-quotes-and-prices https://www.goodreads.com/book/show/39096959-trades-quotes-a... for more information
- TacticalCoder 4y ago> There is also a special order type called post-only. It is designed to only supply liquidity, never take liquidity. If the market moves between the decision to send out an order, and the order reaching the exchange, the order will not cross. Instead, it will be hidden, or cancelled. This makes it easier for algorithm designers to get the behavior they intend (that is, resting orders will not accidentally be converted into crossing orders). I'd argue that an order that'd immediately be filled does provide liquidity to the market overall. One reason to use "post-only" is explained in TFA: > Many markets use the maker-taker fee structure. Traders that place orders that rest on the exchange earn a maker fee, and traders that “take” liquidity, that is execute orders against the existing resting orders, pay a taker fee. The taker fee is higher than the maker fee If you do post-only, you'll get maker fees.
- c54 4y agoYou might have multiple strategies in the same symbol, one intended to send out post-only orders and one intended to send out crossing orders. Niche functionality like this can help achieve that separation of concerns. Crossing orders are considered liquidity taking rather than providing since they're interacting with another market maker's resting (providing) orders.
- TacticalCoder 4y ago> Crossing orders are considered liquidity taking rather than providing since they're interacting with another market maker's resting (providing) orders. Ah that's interesting!
- siftrics 4y ago> I'd argue that an order that'd immediately be filled does provide liquidity to the market overall. No, it takes liquidity, by definition.
- porb121 4y agoif someone bids 10000000 shares for mid, and I hit their bid, who provided the liquidity?
- paulpauper 4y agoTrading seems dauting, especially when your competition are HFTs and huge firms, but there are even very simple patterns that can be profitable, that does not require any advanced coding, APIs, huge troves of data, quant formulas, etc. Once such simple method, which still works, is to short BTC and go long QQQ/SPY during market hours if there is relative weakness of BTC before the market open, whilst going long QQQ/SPY. Both legs are exited at the market close. This has been very profitable. Even the most advanced firms are bound to miss easy strategies. Pattern recognition, intuition are more valuable when to comes to trading than having more data or better tools.
- alienalp 4y agoBy the relative weakness do you just mean price drop? And how can SPY be hedge considering bitcoins incomparable volatility. Are position sizes proportional to volatility or something like that?
- paulpauper 4y agoThe US market opens at 6:30 AM PST. In the 30 minutes before the market open, BTC and the SPY/QQQ futures tend to be highly correlated, but let's say NQ (which is a futures contract that tracks the Nasdaq) rises .5% but BTC only rises .25%, then this would be relative weakness on the part of BTC. The trade would be to short BTC and go long QQQ in equal size.
- dougSF70 4y agoAs soon as your write about a successful strategy and publish it, it no longer becomes profitable. Trading pairs of stocks is one such example, firms made money from identifying stocks that have a negative correlation with one another. This went on for some time until someone published a paper on it and then it became unprofitable.
- rtcoms 4y agoPioneer of Turtle Trading system once said Dennis reasoned that even though he could publish all the rules in a newspaper, only a few traders would heed them since most traders tend to avoid following rules rigidly. He mentioned that most people only follow the trading rules as a method of improvising when they deem it necessary and that deviating from the rules can affect the performance of the trade.
- synergy20 4y agois this the same as 'quant trading'? I heard fresh outs who got offer from quant-trading companies making like half-million a year before their bonus.
- dawsoneliasen 4y agoI think it’s more or less the same idea, quant trading typically refers to people doing quantitative analysis as part of a larger strategy, and algorithmic trading is all about actually executing trades automatically. Definitely significant overlap
- Galanwe 4y agoThe term "quant" has many meanings. Originally it used to mean "quantitative", as opposed to "qualitative". It is a type of investment strategies where you target to be right "on average". Once you are right, say, 51% of the times, you aim to reach this asymptotic behavior by trading more and more. Either horizontally (trading more stocks) or vertically (trading more often). You want to keep the law of large numbers on your side to consistently earn that 1% edge that you found. This contrasts with qualitative investment strategies (sometimes called "discretionary") where you target very precise and punctual events on which you have a very high (say 90%) chance of being correct. You can imagine both these strategies with a coin toss game. With a quantitative approach, you would try to find something that allows you to have just even barely more than a 50% chance of winning. Once you find that, you want to bet as much as possible. This is close to the strategy of a casino: they have games which all have an ever so slightly positive expected value, then they just have to make a lot of people play these games. With a qualitative strategy, you would study very hard to find an event when you can predict at 90% chance the result of the coin toss. You don't play the game until this event is about to happen, and you bet big once it is about to happen. Nowadays, the term "quant" has a broader meaning, which roughly encompass any kind of financial work which is heavy on math, or sophisticated. You can even find "back office quants", "pricing quants", etc
- deleted 4y ago[deleted]
- 4y ago
- nemo44x 4y agoIs there a more socially unproductive, legit practice than this?
- ryeguy 4y agoThis is such weird commentary that pops up on every algotrading post. Why does it have to be socially productive? No one makes the claim it is.
- nemo44x 4y agoIt’s parasitic.
- qnt 4y agoYou can buy or sell 1 share of apple for a bid/ask spread of 1 cent today, or 0.006% of the stock price, and pay no commission to do so. There are very few other examples out there where pure competition between market participants have made things so cheap as to be indiscernible from free. Parasites indeed
- 40yearoldman 4y agoOkay, and is that bad? The entire world has systems which parasitic relationships exist that if they simply did not the entire ecosystem of live could collapse. But here we are with 26 letters complaining on perhaps the most advanced thing humans have made because you don’t see the value of saving some money while trading. People don’t exist to give things a way, expecting people to pay more is parasitic.
- auntienomen 4y agoThis is an article about how pension funds and other large players use algorithms to reduce their trading costs. You have a problem with that? Or did you not know you were in a Wendy's?
- nemo44x 4y agoYeah that’s maybe an edge case at best. It’s nickel vacuuming in most instances.
- eggy 4y agoI have been working my way through a 2013 book, "Professional Automated Trading: Theory and Practice" that uses Lisp as the language to implement a trading system of different frequencies using concepts from artificial life and control theory (I recall studying all of the stuff coming out of the Santa Fe Institute in the late 80's - Artificial Life I, swarm intelligence, etc.). Some of the AI/AL stuff is dated, but the trading knowledge covered and how to build an automated trading platform are great. He covers a lot of ground very concisely and based on solid experience. I love Lisp, so that was also why I gravitated towards this book. I am currently into the April programming language, Array Programming Reimagined In Lisp[1], and I may try to implement the mathy parts of the book's code in APL and the remainder in Lisp as presented with some improvements. April is very flexible and takes advantage of the libraries and symbolic processing of Lisp. The creator of April just switched it to lazy evaluation from eager evaluation last month. [1] https://github.com/phantomics/april https://github.com/phantomics/april
- rawoke083600 4y agoYou had my upvote at Lisp :P
- eggy 4y agoHa, yes, Lisp is the strange attractor or gravity well I always flow back into after trying other PLs. Don't get me wrong, I like Zig (to replace my old C ways), SPARK2014 (which has achieved what Rust is evolving towards), and my other loves - J and APL. That is why April was a binary black hole - the joy of Lisp with a REPL, a lot of libraries and legacy, symbolic processing, and the ability to embed diamonds of APL in the parentheses for the mathy parts. I just have plain, old fun when I open up Lisp. Immediate evaluation and hotloading code with a great IDE/editor in emacs/sly. I am learning Xah's Fly keys[1] to bring it all together to satisfy my modal thirst from vim in emacs. Clojure is a lot of fun too, and opens up a lot of libraries to use. Dragan Rocks[2] has some great libs for ML/DL Mark Watson is the main culprit for writing his book and having the nerve to publish it: Common LISP Modules: Artificial Intelligence in the Era of Neural Networks and Chaos Theory[3] I had been superficially studying AI then - GAs, ANNS, chaos and complexity - back in the late 80s, and this book introduced me to Lisp. Mark is sometimes on here, so Mark, thank you! [1] https://github.com/xahlee/xah-fly-keys https://github.com/xahlee/xah-fly-keys [2] https://dragan.rocks/ https://dragan.rocks/ [3] https://www.amazon.com/Common-LISP-Modules-Artificial-Intelligence/dp/0387976140 https://www.amazon.com/Common-LISP-Modules-Artificial-Intell...
- sarangab 4y agoAfter using systems like Quantopian, Tradingview/pinescript, thinkorswim, metatrader etc for years, decided to build an own system from scratch. We're building Invsto (https://invsto.com https://invsto.com) to make algorithmic trading easier for individuals. Happy to chat with anyone interested in the space.
- andrewstuart 4y agoAnyone here making real money from algo trading? I'm talking about people who write their own software rather than working for a company that does it professionally. I'd be interested to hear any tips or pointers on what strategies you've found that work.
- Lapsa 4y agoManaged to stay even for 3 months. Arcane stuff is what I got but I find it sensible.
- smdz 4y agoIt works, but do not expect huge returns. I have worked on multiple strategies. - Strategies using technical indicators do work, but you have to reasonable. If you find these giving higher than expected returns, or too many consecutive wins - take the money. Stop live trading and continue dummy trading - eventually there is a point where you can start live trading again. The thresholds will be determined from backtests. - Statistical strategies work for swing trading. However, these are very difficult to figure out. Need a lot of data (for backtesting). These work consistently over a longer period and might look loss making over a small period. - Scalping within 5-10 minutes works pretty consistently, signals based on options data. - Understand and realise the law of large numbers, and use that to your advantage. - Give importance to understanding the concept of Time. There is a whole lot of weird and scammy pseudo-science around it. Therefore do not blindly rely on one theory.
- hungryforcodes 4y agoI do similar stuff and confirm most of the above. It matches my experiences. The only other thing I'd say is that if you're in a bull market you may have easy wins. Then after -- when the market turns against you -- these will evaporate. So long term you have to ask yourself if you are REALLY beating the market. If you'd bought Amazon or Microsoft instead, over 20 years you'd probably be far ahead.
- beagle3 4y ago
- Temporary_31337 4y agoStrategies are interesting too, but which brokerages can I use to get a simple API with pricing that is low enough for a small trader?
- kilotaras 4y ago> good example in the book explaining why a tick size is needed. > Say that the current bid in the market is $20. If you want to buy at that price, you will be placed last in the list of orders. But since the sorting order is first by price, then by arrival time, you could get first in line by putting in an order with a price only slightly better than $20 (say $20.00000001). I don't buy the argument. Removing tick (or at least reducing it 100x) would put more emphasis on price discovery instead of speed.
- jwmoz 4y agoNot sure why a simple book review has so many upvotes. A couple years ago I read all I could on this and started systematic trading on crypto. Ended up with the best results on a public platform and ran a small trading operation with a few clients, one a crypto market maker. It's really hard due to all the market unknowns, stress and psychology/emotion. After the FTX debacle I lost ~35% of capital. Currently put it on pause and back software engineering. Had to rebuild my asset allocation system which was based on FTX api. Improved it to be realtime and using Binance api. There's still the counter party risk-Binance could get busted or USDT fraud.
- Aromasin 4y agoIt probably has so many upvotes because it's quite a novel topic for HN. You might not appreciate it as much, being in the industry, but algorithmic trading is a field most of us haven't explored. Most of the content on HN is focused on web design to be honest, so things outside of that can get quite a lot of traction.
- jwmoz 4y agoAh fair enough. For anyone interested I recommend Trading Systems by Tomasini and Stocks on the move by Clenow.
- EricLeer 4y agoDo you have some recommendations on good books on trading systems? I work in the energy trading world, and in general the systems there are behind the financial world by ~10 years. I hope to learn more about this topic!
- jwmoz 4y agoTry Trading Systems by Tomasini and Stocks on the move by Clenow, Python for finance. For the code side there's not much ultimately you have to build it yourself and learn.
- topicseed 4y agoHow complicated were your algo trading strategies? And have you thought of translating these to non-crypto?
- matt3210 4y agoMy algorithm worked great and I was in track to be a millionaire… in the bull market
- sobkas 4y agoInvest in FTL technology so you can start trading after for example release of critical document but before light can reach you from point where document was released. In other words insider trading. Otherwise don't bother.
- aryehof 4y agoIs it even possible to outperform the market in the long term, without some violation of the Efficient Market Hypothesis? Without insider knowledge/trading or some technical mechanism to access information or trades faster?