Live data from Hacker News

Case study: Algorithmic trading with Go

polygon.io

141–150 of 311 posts

Re: Case study: Algorithmic trading with Go

#141
post #2

Happy to answer any questions about this. It's been a side project that turned into a full blown obsession. There is nothing too secret about the system since it's more about having a solid platform that you can plug your strategies into. I'd probably even open source it but I'd have to clean up all my hacks :)

You connect to IB's TWS API... If you execute your trade there only, wouldn't it be an option to fetch the price in real-time from the IB API and not having to use polygon.io at all? I have no idea: does IB send the price feed in real time? (they certainly send the data in real-time to TWS as it constantly updates right? But is the order book available through their API?) Basically and even though I know this was pub…

Yeah, I initially tried that actually. They have very low resolution data and do not provide raw trades/quotes (something like a message every 250ms), you cannot watch the entire market so you're stuck with like 100 tickers [1] vs 5500 tickers, and fetching historical data is very cumbersome. You can basically pull down pre-aggregated candlestick data and I wanted to base things off the raw trades/quotes. I actually probably spend a month or two trying to make this work. So, that's why I'm using polygon.io in that you can stream trades/quotes for the entire stock market in real-time, without any caps, which is amazing!

[1] https://www.interactivebrokers.com/en/?f=%2Fen%2Fgeneral%2Fe...

Re: Case study: Algorithmic trading with Go

#142

I worked in HFT for a while. I find the whole space fascinating. I'm glad OP found similar thrills. "This aspect, the platform itself, seems to be often overlooked in most discussions. Many conversations revolve around strategies (mean reversion, trend following, linear regression, etc.), and backtesting, without fully addressing the practical mechanics or logistics of strategy implementation, particularly in the con…

Seems more pointless than crypto to be honest.

Re: Case study: Algorithmic trading with Go

#145
post #110

I worked in HFT for a while. I find the whole space fascinating. I'm glad OP found similar thrills. "This aspect, the platform itself, seems to be often overlooked in most discussions. Many conversations revolve around strategies (mean reversion, trend following, linear regression, etc.), and backtesting, without fully addressing the practical mechanics or logistics of strategy implementation, particularly in the con…

Sample size one. Contracting for a trading shop for 2 years taught me that it's not technical aptitude that keeps the business rolling.

If you don’t mind me asking how did you land a contract gig at trading company

Re: Case study: Algorithmic trading with Go

#146
post #124
post #106

Earlier quoted context omitted.

Hey, I write this. I did program this in Go. The reason is that it's my go to programming language. Using it is actually a disadvantage in that the industry uses C++ and Python but that's just what I know how to program in. I wasn't trying to be misleading. Go does work really well for taking in data, doing something with it, and then calling a remote API. So, it actually works really well but if you wanted to get a…

Go is great for network heavy apps like algo trading! I used Go to write trading algos that would find small windows of triangle arbitrages in crypto exchanges. Made me some money but the risk of a big loss made me stop pursing crypto trade and it required too much time and attention. It's a full time job from my experience. Reasons I could lose big at any given time if I scaled up the stakes: - Exchanges temporarily…

Have you tried non crypto markets

Re: Case study: Algorithmic trading with Go

#147

While I was laid off and looking for work, I connected with a cryptocurrency market making firm that had access to a private broker feed which is not attached to any matching, so would occasionally go crossed and offer a pure arb opportunity for the same pairs. I had done some algo trading with Java in Kospi 200 options in 2011-2012 so I decided to put together a simple bot for them to try and grab the crossed market…

Cool. Did you think Java was a good choice for this kind of work? Why not Go like OP or something else?

I mostly went with Java because it's what I knew best, and I thought was likely to be "fast enough" for the market I was in. I'm sure Go would be similar in this case but didn't want to have to take the time to learn it.

I do think that if Java can deliver on the combination of the foreign function/memory interface and value types, it might really start to look competitive for certain strategies which are just a bit too complex for the "do everything in the network card" approach. When the Aeron guys first implemented their protocols in Java, C#, and C++, C# was actually the fastest, which they attributed to the presence of both the optimizing runtime and value types.

Re: Case study: Algorithmic trading with Go

#148
post #130
post #128

Earlier quoted context omitted.

It was my (admittedly ignorant) impression that C++ was preferred over garbage-collected languages because you'd be more likely to avoid GC pauses. Yes, of course I know that Go's is super efficient, but if you're doing a million trades a day even a tiny percentage of slowdowns that would be otherwise preventable could be a career-limiting move. Am I just behind the times?

I think you're right! Go will never beat C++ in this aspect. I used Go because that's what I knew and for the non-professional trading I was aiming, C++ wouldn't have made much difference. My bottlenecks were network (1s+ per trade roundtrip) and chaotic unreliable crypto markets. Just note that Java is used in HTF, but it's a different beast than our average CRUD Java. For example this article states: "Essentially,…

I think there’s a way to disable GC in Go too, no?

Re: Case study: Algorithmic trading with Go

#149
post #93
post #90

I find this article to be absolutely pointless and clickbaity. It can be boiled down to: "you can use poligon.io for market data but algotrading is difficult anyway so there is not much to share yet".

Hey, I'm sorry you feel that way and I wrote it. Personally, I wanted to share the high-level structure of how you'd build your own system. I would have loved to have seen something like this when I went down this rabbit hole in that I needed to figure it all out myself. What do you think would have made it better? I'd be happy to roll that back in.

FWIW I thought it was a really good overview of the project structure and I appreciated the lessons learned as well.

Re: Case study: Algorithmic trading with Go

#150
post #126
post #89

Earlier quoted context omitted.

Essentially yes. When I worked in algo trading, it never bothered me that we were extracting profits from the markets, nor that we served little social good. It felt like a step up from where I’d been before (being told that we were making the world a better place, when every engineer knew otherwise.) At least we weren’t making things obviously worse. What did bother me, and was acknowledged by my coworkers, was how…

Seems like every person I've ever met in M&A has ended up hating life because of their career choice. They seem to burn out in 5 years or so after salting away a million bucks or 3. Was that your feeling doing the HFT thing?

I work at an HFT firm. Most fun I've ever had.
Post reply on HN