Live data from Hacker News

Case study: Algorithmic trading with Go

polygon.io

201–210 of 311 posts

Re: Case study: Algorithmic trading with Go

#201

Earlier quoted context omitted.

I am not disagreeing with you that the costs are dropping and that participants benefit from that. In fact I agree. Your projection that I find the field unfair is also unfounded. I love the field and find it immensely interesting. I just don’t take mythology surrounding it at face value because I often found it to be a) outdated b) full of mythology but no hard data. What I am saying is that the thesis that the cost…

It’s true I’m US centric. What I do know about European equities market structure actually points to one specific problem that actually we also have some of in the US. I’d suggest you look at clearing house collateral regulations, especially around ETF transactions, creation and redemption, and posting of OTC positions. That part of the system, which btw isn’t HFT, is very very shady. I agree it’s all quite understan…

Yes, toxic flows and adverse selection are the magical buzzwords that get thrown around a lot. I’m familiar with glosten-milgrom model and private information and all related paradoxes.

What you’re failing to disclose is that there is an easy way out of solving the adverse selection problem. For example you could buy “uninformed flow”. I think that you could agree that for the touted sophistication of the field you would expect something … more sophisticated?

Again, don’t get me wrong. I love the field but I think it’s stagnant in certain aspects and I like to have a sober view of it.

EDIT: As a thought experiment, envision a setup where the trading strategies compete on the basis of the strategy itself, with a single global market with a single API that takes bids and offers in rounds and anyone who wants to is allowed to participate for free with no fees whatsoever. For the sake of example, suppose it’s a government owned and operated project just like the GPS (for which you don’t have to pay a subscription) in your phone. No market access fees, no market data fees, no preferential latency treatment. A perfect coding competition playground.

How many current market participants do you think would survive in such an environment and if your answer is different than the current number, why?

Re: Case study: Algorithmic trading with Go

#202

Nicely done. A couple of pointers. One on data, one on that RAM usage. First I’ll go with the RAM usage because this is hackernews and everyone loves algorithms. —- There are a lot of libraries out there that do technical analysis, and most of them are designed for batch processing. TALib is an example - it works on large data sets but is not appropriate for live trading because it repeats calculations over and over…

Oh, one more thing. Your bar method.

Are you using number of trades or sum of trade sizes?

Because if the former, there is little distinction between me firing off two market buys of 100 shares each in quick succession vs me firing off one market buy of 200 shares, so your sampling shouldn’t be impacted by the difference.

I’m not altogether convinced by volume sampling. It’s an idea popularised by De Prado, but I’ve never seen it actually work in practice. It makes you trade more when the market is going through turmoil, it makes you trade more over time (as volume per day generally increases), and I haven’t seen any evidence of the importance of information content.

If you’re trading based on patterns in the market, it’s easy to lead yourself to believe that you’re predicting the market. That isn’t the case, though - the market is formed of many many independent people making guesses.

The thing you’re actually doing is predicting what other people are going to predict. If there’s an established pattern, like some moving average crossing another or a wedge or anything else like that, the reason it tends to complete is not mystical - it completes because other people see the pattern, think it’s going to go up (or down), buy (or sell), and then that has the effect of pushing the market in that direction (it also means that anyone late to the game can’t benefit from the movement).

As such, the strongest strategy when trying to use technical analysis to determine possible market moves is to use the resolution that everyone else is using. This is overwhelmingly time-based. There are people trading in the 1s regime, the 1m regime, the 15m regime, etc, and they’ll often stick to that and execute trades with a proportional rollout time and aim for a proportional profit.

If you pick just a random number of trades or amount of volume that suits you, you can easily find that you are out of sync, competing against no one in particular, and you’ll see that it’s impossible to find a pattern.

Many other people use price levels. So they’ll have their limits and stops at round numbers, or at percentage changes on the day, week, month, etc. So there is an argument for price bars too.

Re: Case study: Algorithmic trading with Go

#203
post #194

Earlier quoted context omitted.

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?

Around 45-50% win rate but I try and keep the runners going for as long as possible and exit out of the loser trades quickly (this basically just costs you the commission on losers but sometimes more). You can tell within a minute or two if what you expect to happen is going to happen. So, even with a 50/50 win/loss rate you can still make money. I make around 100-200 trades per day. Sell everything before market close.

Re: Case study: Algorithmic trading with Go

#205
post #92

I've been building a bot with Typescript because it is what I know and Python because of the tools available. It is an overwhelming lonely endeavor. With all my other projects, I've always worked on teams, although they have always been very small teams and most of my work was autonomous -- still there was the occasional meeting and stand-ups. I've been working on this for six months and thought about bringing a frie…

Count me in the group of solo algo trading developers. Maybe we should connect and chat.

This is why I miss Quantopian. They had a great discussion forum, an ongoing competition, and annual conferences.

I would be interested in some kind of regular meetup as well to discuss new techniques and to analyze publicly disclosed strategies, etc.

I recently posted this article on HN... There is so much more knowledge to share:

https://news.ycombinator.com/item?id=36344587

Re: Case study: Algorithmic trading with Go

#206

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.

It may seem so at the first glance, but such trading if carried out by many independent providers actually increases the liquidity if the market for everyone else.

Likewise with crypto. Personally I don't think that if you're calling an API over an Internet it matters if your trading bot is written in go or python (mine was in python). Use the language you're most comfortable in. The network and trade submission/execution at your broker will be 10x slower than your bot anyway. Unless the size of your operation approaches the size where you can get direct market access which seems to be reserved for big forms only.

Re: Case study: Algorithmic trading with Go

#207
post #14

Excellent write-up! Is there somewhere where I can read up on all the trading jargon? Also I wonder how can there be changes in the price of a stock after market if the exchange has closed? Isn’t the whole point that trades need to happen for stocks to get a certain value?

Work in finance. Nothing else comes close.

Re: Case study: Algorithmic trading with Go

#208
post #198
post #40

Earlier quoted context omitted.

> 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.

Yeah, I'm heavily testing everything it writes. So, I'm very sure it's correct or get it close enough and then code it. I've seen ChatGPT add imports, functions, etc that don't even exist in Go. What I've found so useful though, is not even coding, but asking it how to solve problems, and then having it code things up. With Google, you need to pretty much already know how to solve the problem then go looking for answers. With ChatGPT you can ask it how it would solve this problem. For algorithms and stuff it have been unreal. Thanks for the warning though. You're totally right.

Re: Case study: Algorithmic trading with Go

#210

Earlier quoted context omitted.

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

It's similar, though in theory you are paying the index fund to act as your agent, and the fee structure is observable.

Regarding liquidity, I imagine it's possible that the index fund might allow you to withdraw money faster than you could sell on your own, but realistically I kind of doubt it.

Post reply on HN