Live data from Hacker News

Case study: Algorithmic trading with Go

polygon.io

191–200 of 311 posts

Re: Case study: Algorithmic trading with Go

#191

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…

There’s a very nice book about this subject called “Dark Pools”. I found it very enjoyable, you certainly seem to have the knowledge to enjoy it even more :-)

Re: Case study: Algorithmic trading with Go

#192

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.

HFT provides a great deal of liquidity and efficient pricing in markets that are adapted to it. It provides a real service, allowing people to transact without using a large bank or broker efficiently on an open market. The fact you can click buy and it buys on almost any stock is likely due to a HFT on the other side. That may not mean much to you directly but it does provide a lot of utility in markets. The biggest gripe people bring about HFT is it during high volatility HFTs usually pull out of the market at a time when people really value the increased liquidity. I think some of the more advanced HFT firms though have moved into longer time range trades which helps provide more liquidity in those markets.

Re: Case study: Algorithmic trading with Go

#193

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.

Nonsense - what could be more beneficial to society than providing imaginary "liquidity" by interposing yourself between legitimate buyers and sellers?

It's a bit like stock brokers - and why wouldn't we want stock brokers to operate at drastically faster-than-human timescales, because we all know the value of a company changes every nanosecond! And "flash crashes" create opportunities for investors to make huge amounts of money!

And just as crypto has poured money into GPU companies (providing opportunities for enterprising secondary market resellers of same) HFT has poured money into networking companies.

Short of creating the great firewall or helping governments slurp up all the traffic on the internet, what could be a more beneficial application of network technology?

HFT (like finance in general) has also gobbled up lots of tech grads, making it easier to find jobs at tech companies.

Re: Case study: Algorithmic trading with Go

#194
post #158

Earlier quoted context omitted.

Hey, thanks. Yeah, I agree with you. That's an oversight on my end. I'll tell you here though. I'm just using go routines and channels to talk between them and then a giant mutex for locking. That's basically it. So, as new data comes in, it builds aggregates (tick based candlesticks) as needed, this then triggers the the BUY logic loop on that new data, if something is detected, that triggers a IB API order. It is d…

Also, what's your approach to risk management? For example: 1. Do you have anything that limits the size of a single trade or position? 2. How do you measure and manage overall volatility/risk/VAR to your portfolio? 3. What kind of safeguards do you have to avoid catastrophic bugs? (For reference, see Knight capital and how a single bug brought down the entire company: https://www.henricodolfing.com/2019/06/project-f…

Here's some simple rules. I basically just read about these and then stole the ideas. I wish I had data to back this up and it seems to be working.

- No single bet can be more than 5% of all money. The small bet sizes are what really saves your bacon in that even if a few lose 10+% you're still fine overall. - I'm also limiting the amount of shares I bet and try to keep it in the low hundreds so that I get really fast fills. - I have something that stops everything if I lose more than 1k in a day.

I don't do anything to measure overall risk or volatility. Almost everything I'm in is highly volatile. I'm basically betting as things go up and then try to cash out. Sometimes you hit the top.

Yeah, I inspect all the trades at the end of the day, well and during the day, and try to feed anything new back into the system. This is 100% manual. But, like if a single trade loses $100 or something definitely I'm in there looking at what happened.

Re: Case study: Algorithmic trading with Go

#195

Earlier quoted context omitted.

> We as a society have managed to allocate so many of the “best and brightest” to either fintech wankery or placing ads in front of eyeballs. Those things have driven a load of proprietary and open source tech that helps everyone else.

Rising levels of inequality would suggest this is false.

What would rising levels of being lifted out of poverty suggest? The equality gap doesn’t count for much if you starve or freeze to death, and poverty is declining world wide.

Re: Case study: Algorithmic trading with Go

#196
post #194

Earlier quoted context omitted.

Also, what's your approach to risk management? For example: 1. Do you have anything that limits the size of a single trade or position? 2. How do you measure and manage overall volatility/risk/VAR to your portfolio? 3. What kind of safeguards do you have to avoid catastrophic bugs? (For reference, see Knight capital and how a single bug brought down the entire company: https://www.henricodolfing.com/2019/06/project-f…

Here's some simple rules. I basically just read about these and then stole the ideas. I wish I had data to back this up and it seems to be working. - No single bet can be more than 5% of all money. The small bet sizes are what really saves your bacon in that even if a few lose 10+% you're still fine overall. - I'm also limiting the amount of shares I bet and try to keep it in the low hundreds so that I get really fas…

Thanks!

What is your 'win' rate? (Percentage of trades that make money as a fraction of overall trades)?

How many trades does your system make on average in a given day?

Do you hold positions overnight?

Re: Case study: Algorithmic trading with Go

#197
post #84

Earlier quoted context omitted.

"they are the more straightforward part to build" More straightforward, heh, sure. But still damnably complicated. Which just goes to show how much money and how much engineering talent is invested in this world that these things are so taken for granted.

So many intelligent people applied for something that has no value whatsoever to humanity regardless of how you look at it.

Whats the point in making a flyby comment without even mildly establishing the content in it?

Re: Case study: Algorithmic trading with Go

#198
post #40
post #11

Earlier quoted context omitted.

@WestCoastJustin I've been really wanting to use Go, but as you say, much of the community is Python due to the data analysis strengths. To the detriment of the other things Python does do poorly. Can you give some thoughts with your experimentation on the following from a Go perspective. 1. Supported TA libraries in Go. I'm familiar with TAlib (python), bloom, etc. - certain forks tailored to real time rather than h…

> Supported TA libraries in Go. I'm familiar with TAlib (python), bloom, etc. - certain forks tailored to real time rather than historical (eg: no re-compute on ticks) I've been basically, just manually coding the algorithms from python into Go. ChatGPT is amazing at this. I really only just about 4 so it was a one time thing. > Data storage (article mentioned you're all in memory). I've been using S3 & ArticDB Yeah,…

I'd be careful using ChatGPT for this. I tried the same recently to bootstrap spot yields from par, which is a fairly common code problem with hundreds of examples online. ChatGPT couldn't do it. It produced code that looked right, but would fail my tests abysmally. I ended up writing it by hand. I hope you are validating their code with known data.

Re: Case study: Algorithmic trading with Go

#199

Earlier quoted context omitted.

Seems more pointless than crypto to be honest.

Nonsense - what could be more beneficial to society than providing imaginary "liquidity" by interposing yourself between legitimate buyers and sellers? It's a bit like stock brokers - and why wouldn't we want stock brokers to operate at drastically faster-than-human timescales, because we all know the value of a company changes every nanosecond! And "flash crashes" create opportunities for investors to make huge amou…

> Nonsense - what could be more beneficial to society than providing imaginary "liquidity" by interposing yourself between legitimate buyers and sellers?

Now when I say the same thing about index funds people get all huffy

Re: Case study: Algorithmic trading with Go

#200
post #158

Earlier quoted context omitted.

Hey, thanks. Yeah, I agree with you. That's an oversight on my end. I'll tell you here though. I'm just using go routines and channels to talk between them and then a giant mutex for locking. That's basically it. So, as new data comes in, it builds aggregates (tick based candlesticks) as needed, this then triggers the the BUY logic loop on that new data, if something is detected, that triggers a IB API order. It is d…

Does it work synchronously or asynchronously? For example, if you integrate WebSockets then you could act as soon as you get new data. If it works synchronously then you regularly request data (say, every second) and then act. If you process many positions and then choose top 5 candidates then do you choose one of them for buying or you can allocate resources between them (depending on some score)?

Both? I'm getting a constant stream of data via the websocket. As data comes in it gets added to the large in-memory object, and then once I have X number of trades, I'll go and build the candlestick bar. As soon as that bar builds, it triggers the BUY loop to inspect it, and see if it matches what I'm looking for. If it does, it send a buy order out to the IB API. I'm not ranking anything. I'm just looking to see if that matches and then buy. So, I have something that tracks the total money I have, and if I have any free money (and we don't already own that stock), it makes a bet. That's the logic. I wish I had some ranking logic but that's what it's doing.

That logic is happening for 5500+ stocks all in real-time which is pretty insane. But, it works really really well. Go is amazing. At market open and close there is like 60k+ events per seconds across trades and quotes. So, that loop is processing like 60k events at times, and building each stock out, and then looking to see if we should buy/sell.

Post reply on HN