Live data from Hacker News

Case study: Algorithmic trading with Go

polygon.io

51–60 of 311 posts

Re: Case study: Algorithmic trading with Go

#51

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…

YES, 100%! I honestly, cannot agree more. I've read pretty much every book that I could get my hands on and no one talks about the platform. This makes so much sense. Thank you for your perspective. It seems like so much of this stuff is silod off into each company and no one is talking about it.

HFTs are definitely playing a completely different game. I was reading about the exchange architectures and how things are actually wired. I'm getting my data from SIPs while HTFs are directly connected to the exchanges [1]. I'm transacting in seconds and they, like you said, are transacting in microseconds, so there is no comparison. Which, in a way is actually nice in that I'm not really competing with them. Or, maybe I am but I can still make some money. haha.

Cheers and thanks for the awesome comment!

[1] https://www.researchgate.net/figure/Latencies-in-the-Electro...

Re: Case study: Algorithmic trading with Go

#52
post #32

Earlier quoted context omitted.

Awesome write up. I have a similar project in Go myself, although I just use minute bar data instead of realtime ticks. Can you share your approach for plugging in various strategies? I quickly learned that having a pluggable strategy system is tricky as it could span across multiple layers of the system. Also, with backtesting, are you storing and replaying all the quote/tick data? or just using the historical aggre…

I wish this was better, but honestly, I'm just hard coding them right into the BUY loop. So, I need to restart the app anytime I want to change something. That's why I build this logic to dump and reload the state into a gob file (go memory dump essentially). Ideally, you'd have some type of format to write out your algorithm, and then have a way of hot loading it or something. But, I don't change these enough to rea…

Fascinating. Have you considered open sourcing this without your algorithms ( empty buy/ sell loops)?

I’d like to play with something like this but I couldn’t be bothered to build it all from scratch.

Re: Case study: Algorithmic trading with Go

#53

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…

Not only are the platforms table stakes they are the more straightforward part to build. Even at the bleeding edge of latency you can usually work your way to the limits of your platform budget without having to find anything novel.

The strategies though are where the discovery is. There are a few strategies that are well known and still profitable but those are largely consolidated to the biggest firms. For everything else it’s a discovery process. And done strategies are only profitable for very short regimes.

I miss it sometimes too, but so much has been consolidated it’s largely a big firm world now.

Re: Case study: Algorithmic trading with Go

#54
post #46

Earlier quoted context omitted.

> Like, could you get a daily 0.5% compounding return It seems that this is the key to your approach. How is this part achieved?

That's sort of the secret sauce. But, having a platform like this is more than 75% of the solution. The rest is more around trend following.

It’s also stunningly easy to convince yourself you have a profitable algorithm when you actually have a money loser.

Gaining 0.5%/day 60% of the time and breaking even 39% of the time looks great until you run into the 1% of the time where you lose 50%.

Re: Case study: Algorithmic trading with Go

#55
post #46

Earlier quoted context omitted.

> Like, could you get a daily 0.5% compounding return It seems that this is the key to your approach. How is this part achieved?

That's sort of the secret sauce. But, having a platform like this is more than 75% of the solution. The rest is more around trend following.

I tend to frame it as the secret sauce is 99% of the solution, and the platform/API-interaction is trivial, as the term is used in science.

Re: Case study: Algorithmic trading with Go

#56
post #10

Fascinating application of the language and a terrific write-up. I would presume a GC language would normally be a disqualifying factor in real-time trading, but I think I'm coughing up some premature optimization, especially with what looks like a pretty beefy rig. Congratulations though, this is spectacular.

You say this as if memory allocation in general isn't extremely slow.

For trading systems that are still software based they absolutely do not allocate or reclaim on the hot path for this reason.

Re: Case study: Algorithmic trading with Go

#57
also having worked in the space: HFT should not exist. Break up the day into segments and have a single crossing. Do it every five minutes or whatever for sufficient timeliness. the millisecond race does not make anything better for anybody except the people doing the trading.

Re: Case study: Algorithmic trading with Go

#58
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 may be interested in this: https://www.techtrader.ai/#wall

Excerpt from his site:

"Tech Trader is a fully autonomous trading system live with no human intervention or updates, now for over 10 years. It is unique from conventional algorithmic systems, not only because it actually is fully automated, but because it takes a "human" approach to markets. It is not quant. It is not stat-arb. It is not high frequency. It is a program that looks at stocks the same way a person does but with the cold discipline and infinite attention span of a machine. It is analogous to having a thousand independent traders each focusing on a single stock, as opposed to a single quant manager trying to make sense of a thousand datapoints. A person doesn't think through stats, correlations, or complex math models when trading, and neither does Tech Trader. Tech Trader leverages technology to do what human traders do at scale rather than approach markets from the point of view of an academic, mathematician, or scientist.

Since its launch in Dec 2012, Tech Trader has been trading live capital completely on its own, fully automated in the truest sense with no human input, no tweaking, no updates. It is, for all intents and purposes, an autonomous hedge fund, one of the first to truly trade unsupervised for years on end. Whereas many "automated" or "AI" funds may have a hundred scientists providing the actual intelligence behind the curtain, the creator of Tech Trader consists of just one person - a self-taught individual going by the gaming moniker pftq, who created the system at age 21 and has long moved on to other interests. "

Re: Case study: Algorithmic trading with Go

#59
post #32

Earlier quoted context omitted.

I wish this was better, but honestly, I'm just hard coding them right into the BUY loop. So, I need to restart the app anytime I want to change something. That's why I build this logic to dump and reload the state into a gob file (go memory dump essentially). Ideally, you'd have some type of format to write out your algorithm, and then have a way of hot loading it or something. But, I don't change these enough to rea…

Fascinating. Have you considered open sourcing this without your algorithms ( empty buy/ sell loops)? I’d like to play with something like this but I couldn’t be bothered to build it all from scratch.

Yeah, I can do that. Ping me at [redacted] and I'll send you a note when I've done it.

Re: Case study: Algorithmic trading with Go

#60
post #46

Earlier quoted context omitted.

That's sort of the secret sauce. But, having a platform like this is more than 75% of the solution. The rest is more around trend following.

I tend to frame it as the secret sauce is 99% of the solution, and the platform/API-interaction is trivial , as the term is used in science.

Yeah, you could look at it like that too. But you need to have a platform before you can even do something like this. So, that's why I framed it like that.
Post reply on HN