Great stuff.<p>I think the author would have been better suited without mentioning HFT, maybe algo trading model?, as its a lighting rod for controversy.<p>If anything I thin this is useful to illustrate just how hard it is to write a full blown trading system.<p>So maybe we could look at what you could add to this to make it something you could use in production(Note, please don't use this in production).<p>1) Risk system, before you write any algos, before you learn how to ingest market data, before you write anything else, you write the risk system.<p>in a true trading system because you always have orders flying between you and the exchange you never really know what your positions is. The Risk system allows you to deal with this uncertainty by giving each algo rules as to how many shares its allowed to be offside.<p>If you only ever take away one thing let it be this:<p><i>Trading Rule #1</i> Sooner or later your algo/code will make a mistake, it's your risk system that determines if you have a job tomorrow or not.<p>2) The system has no rate limiter, what do you do when the quotes come in too fast for you to deal with?<p>3) Locking the world, the system retrieves a quote and locks up the entire system while the quote is acted on. Essentially the very design of the system means you can only ever run one strategy for one set of tickers at a time.<p>If you wanted to tackle this start by looking at this data structure/library:<p><a href="https://lmax-exchange.github.io/disruptor/" rel="nofollow">https://lmax-exchange.github.io/disruptor/</a><p>4) Back testing, no HFT trade idea's go into production without backtracking, Every HFT firm is different but I think they'd all adhere to this rule.<p>5) Closing positions, every algo gets offside at some point. How do you notify a trader to close out a position? How does the trader close the position and notify the algo?<p>6) Multiple algos over multiple symbols.<p>7) Real time PnL. Your PnL is everything, it means you get paid, it means you can do this again tomorrow. it is the single most important piece of information(Risk metrics are a close second) that you can track. This is probably my only quibble with the demo.
Wow, didn't expect my repo to make it this far. It was my first time using Reddit, with the aim of introducing this for research more than actual trading.<p>Just some thoughts after reading comments:<p>- I've got a number of Python examples for trading futures, but a third-party app is required as 'the gateway'. Browse on GitHub if you wish: <a href="https://github.com/hftstrat/The-Gateway-code-samples" rel="nofollow">https://github.com/hftstrat/The-Gateway-code-samples</a><p>- Backtesting is a topic not to be taken lightly. There are far too many issues to address than just historical simulation. I've written a book covering this topic.<p>- In my book I've also covered the use of Oanda API with a simple trend-following strategy. Available on Amazon: <a href="http://www.amazon.com/Mastering-Python-Finance-James-Weiming/dp/1784394513" rel="nofollow">http://www.amazon.com/Mastering-Python-Finance-James-Weiming...</a><p>- Table of contents and source codes used in my book are also available on GitHub: <a href="https://github.com/jamesmawm/Mastering-Python-for-Finance-source-codes" rel="nofollow">https://github.com/jamesmawm/Mastering-Python-for-Finance-so...</a><p>Alright, I'm done with shameless promotion of my links ;p
Pretty cool stuff. Thanks for posting holoiii. Last year, I took some time off to build an IB API client in Java/Scala for options trading.<p>The biggest challenge I faced personally was dealing with concurrency of maintaining my positions, orders and quote ticks which led to orders as IB API is based on a asynchronous tick model. I ended up re-writing my code with lots of threads/locks to more code with immutability. Curious how you guys architected your IB client?<p>Also I hosted my client on the cloud on AWS. I subscribed to maybe a few symbols but always wondered in a more production environment whether bandwidth will kill you (subscribed to 100+ symbols and to a real tick-by-tick quote stream not quote snapshots).<p>Finally I'd love to hear more about folks out there who might be doing more options or futures trading off of IB API. The equity world is definitely very interesting but I found out early on that I enjoy trading delta-neutral and am not good at predicting directions.<p>Did you guys find that you have to scale up and write your own execution algo's when your size got too big for the market you are trading? Nowadays I use my IB client mostly as a GUI to view my positions and execute complex option spreads; so it's more of a "gray-box" for me. Do you guys trade pure algorithmically or half-and-half?
It is so, so infrequently that I get to say this about something HFT-related on the internet: fucking awesome, dude. There is actual information here that is of use and doesn't mislead. It's amazing.<p>edit: s/dude/guy-who-made-this
The one key part this seems to be missing is a backtesting framework. Did you look at <a href="https://www.quantopian.com/" rel="nofollow">https://www.quantopian.com/</a>?
Tangentially related question. As a relative newbie to (automated/ algo) trading systems, it seems most of posts here focus on systems that deal with large volumes of trades in very short timeframes.<p>I'd be interested in writing an automated system that would focus on trading (investing) over longer timespans (shares, options), with (average) returns. Are there any resources you would recommend to get into this? Or are automated systems really only employed in HFT?
Also, I recommend checking out the QuantStart project started by Michael Halls-moore. Really handy if you are using the Oanda Api. Plus, there exists some great articles on the quantstart site about the creation of the code.
<a href="https://github.com/mhallsmoore/qsforex" rel="nofollow">https://github.com/mhallsmoore/qsforex</a>
I have read the anti-FlashBoys book to try and grasp it (HFT is not bad and has cut spreads in equities by 5/6ths in ten years) but I still do not understand one HFT algorithm (other than the debunked front running idea)<p>Could someone explain what algo traders / HFT actually <i>do</i>?
Is it all looking for a variation off of a relationship between say OrangeGrowersInc and OrangeJuiceBottlers Inc? And why is speed so important then?
It's strange to call this HFT. The author makes a note of it, and I suppose has the right to call it whatever he wants.<p>However, newbies who use this project to learn automated trading should be aware that this is not considered HFT in the industry.
It's great that you're sharing, so thanks for that. I get it that it's better than pseudo code but I'm having a hard time seeing the words "high-frequency trading and Python" next to each other
see a few comments on the speed of python - given that the strategy is on a retail platform i'm not sure choice of language will be the bottleneck.