Live data from Hacker News

Case study: Algorithmic trading with Go

polygon.io

71–80 of 311 posts

Re: Case study: Algorithmic trading with Go

#71
post #25

This is really interesting. Have your strategies out performed buy and holding index funds, or are you mainly just doing this with a small amount of capital to learn how the markets work? I have always wanted to try algorithmic trading to learn about it, but I have always read it is a fools errand to think you will beat just buy and hold.

This is going to sound crazy given all the scams out there. But I was interested in testing the idea of small compounding returns. Like, could you get a daily 0.5% compounding return. Sure, you could go all in on TSLA for example and get a 1% daily return. But, could you do that with automation, using lots of small bets, across the entire market. You can, but there is a scale issue here. In that you need to make expo…

Just want to point out with 260 working days in the year:

1.005^260 = 366%

and

1.01^260 = 1329%

In case anyone sees "0.5%" _daily_ and thinks low risk.

Re: Case study: Algorithmic trading with Go

#72
post #25

Earlier quoted context omitted.

This is going to sound crazy given all the scams out there. But I was interested in testing the idea of small compounding returns. Like, could you get a daily 0.5% compounding return. Sure, you could go all in on TSLA for example and get a 1% daily return. But, could you do that with automation, using lots of small bets, across the entire market. You can, but there is a scale issue here. In that you need to make expo…

That makes sense to me and lines up with what buffet says about there are alot of people on wall street who can average 50% returns with 100k but once it gets into the millions it is much harder to find alpha.

I don't follow Berkshire Hathaway much, so I'm not aware of what Warren Buffet has said on this topic, but it sounds super interesting.

After a bit of digging, I found this Q&A from the 2019 shareholder meeting: https://www.youtube.com/watch?v=geRIJQJXRVo&t=17980s

And the meeting minutes in PDF form (see page 120, question #32): https://s3.amazonaws.com/static.contentres.com/media/documen...

The text from that document...

32. It’s easy to make 50% on a million, but much more difficult on larger amounts

WARREN BUFFETT: Station 9. We’re just about — yeah, we’ve got time for a couple more.

AUDIENCE MEMBER: My name is John Dorso (phonetic), and I’m from New York. Mr. Buffett, you’ve said that you could return 50 percent per annum if you were managing a one-million-dollar portfolio. What type of strategy would you use? Would you invest in cigar butts, i.e., average businesses at very cheap prices? Or would it be some type of arbitrage strategy? Thank you.

WARREN BUFFETT: It might well be the arbitrage strategy, but in a very different, perhaps, way than customary arbitrages, a lot of it. One way or another, I can assure you, if Charlie was working with a million, or I was working with a million, we would find a way to make that with essentially no risk, not using a lot of leverage or anything of the sort. But you change the one million to a hundred million and that 50 goes down like a rock. There are little fringe inefficiencies that people don’t spot and you do get opportunities occasionally to do, but they don’t really have any applicability to Berkshire. Charlie?

CHARLIE MUNGER: Well, I agree totally. It’s just you used to say that large amounts of money, they develop their own anchors. It gets harder and harder. I’ve just seen genius after genius with a great record and pretty soon they’ve got 30 billion and two floors of young men and away goes the good record. That’s just the way it works. It’s hard as the money goes up.

WARREN BUFFETT: When Charlie was a lawyer, initially, I mean, you were developing a couple of real estate projects. I mean, if you really want to make a million dollars — or 50 percent on a million — and you’re willing to work at it — that’s doable. But it just has no applicability to managing huge sums. Wish it did, but it doesn’t.

CHARLIE MUNGER: Yeah. Lee Louley (phonetic), using nothing but the float on his student loans, had a million dollars, practically, shortly after he graduated as a total scholarship student. He found just a few things to do and did them.

Re: Case study: Algorithmic trading with Go

#73

QQ for everybody since OP is using IB API which is notoriously bad that many wrappers have been written for it (ib-insync). This is a general question, I'm wondering is there any good framework/wrappers out there that one can learn from to code up a complex trading application? Like dealing with all the asynchronous nature of process/submitting trading and quotes messages.

Yeah, I ended up taking https://github.com/gofinance/ib and rewrote my own wrapper. This took a long time but has been stable since. I'm basically only doing buy lmt, sell lmt, cancel, and updates orders though. So, the logic is pretty simple. Catching all the return messages and structuring them correctly took tons of debugging, trail, and error. Basically, mapping the messages into the correct orders for state tracking.

Re: Case study: Algorithmic trading with Go

#75
post #25

Earlier quoted context omitted.

This is going to sound crazy given all the scams out there. But I was interested in testing the idea of small compounding returns. Like, could you get a daily 0.5% compounding return. Sure, you could go all in on TSLA for example and get a 1% daily return. But, could you do that with automation, using lots of small bets, across the entire market. You can, but there is a scale issue here. In that you need to make expo…

Just want to point out with 260 working days in the year: 1.005^260 = 366% and 1.01^260 = 1329% In case anyone sees "0.5%" _daily_ and thinks low risk .

Yeah, I'm not saying this is low risk. It's more about trying to build a system to be in the right place at the right time. It is massively risky. I was sort of hesitant to even write that comment because you constantly see all these youtube day traders selling courses on making 1% daily. If you try that you'll lose money extremely quickly.

Re: Case study: Algorithmic trading with Go

#76
post #63
post #27

Earlier quoted context omitted.

I have won and lots thousands for sure. Haha. When stocks were on a rip the bot was making lots of money just because everything was going way up. Then, in 2022 when everything went way down, like tons of tech stocks, my bot sucked. So, I really need to add shorting or something. I'm still exploring things on the strategy side.

Aka, everyone thinks they’re an investing genius when the whole market is going up.

Yes, 100%. Everything looks amazing while the markets are going up. Sometimes, I've just shut the entire thing down when there is Fed news or the markets are taking a dump. That's a legit strategy too. Only run it while the markets are going up.

Re: Case study: Algorithmic trading with Go

#77
Really funny coincidence that I am seeing Interactive Brokers mentioned in this good article. Story + rant time, feel free to skip if you are not interested how one guy gambled and lost. It's also a tentative call for partnership if somebody is interested. And a call for chat if anyone has any interest in the topic.

(It's also kind of off-topic, my apologies for that. To me it seems semi-related but would agree with mods' assessment if it doesn't match mine.)

---

I recently "broke up" with some extremely toxic "investors" that wanted me to do a fully parallel trading demo -- meaning it receives ticks for N instruments (I successfully got to little less than 300) and trades with each of them depending on strategy. All in real-time.

I got very far but the open-source libraries for Interactive Brokers are quite low quality in general and it was very hard and slow to progress (one of them couldn't even post orders, another used Mutex-es for "parallelism" which was of course not parallel at all, another one seemed to work well but only worked on servers of older versions compared to those I have access to, etc). I also had to gather code from separate places and assemble my own Frankenstein as I went along.

Eventually I muscled through but by that time I have drained all my savings, my tax fund and even got a new loan. And the liaison + the investors of course refused to acknowledge the demo was basically 90% done (couldn't do full parallel trading due to defects of the IBKR libraries I have used and I used like 5 of them, and was in the process of repairing 2 of them to unlock the said full parallelism). They refused to send a small pre-funding wire (we're talking something small like $30k - $50k, not millions; for the work that was done, namely months of professional Rust programming work, that's a -75% discount if we look at market rates).

They had all the proof and paper trail they needed to see that I was very close but I had to stop because I was literally about to be unable to pay rent and bills. They still did not concede. Obviously I picked a job and dumped them but I still have some regrets because the door is technically still open (they have not cut my access to the IB Gateway servers that they own), but other factors like now-ruined health are seriously getting in the way as well. Not to mention completely shattered trust.

They insist "if you just finish the demo we'll give you money" and used every gaslighting technique I knew about (and many I didn't know about, so I learned a lot about gaslighting from them, lol) to try and coerce me to keep working for free with zero guarantees of funding -- but I no longer trust such rich investors to fulfill a promise without a binding and legally enforceable contract; I am in Eastern Europe, they are in the USA, even if they sign contract and violate it I practically cannot do anything to them i.e. I can't afford to travel and sue. Also they insist to get access to the source code but swear to everything that's holy that they will not run away with it and never give me a penny. Which is exactly what I think would happen.

I had to draw the line at one point. To me it was red flags all around.

---

I made many concessions and I will not make another one until they do. I'll be finding a new job soon again since the previous contract was agreed upon to be for several months, I helped a team accelerate bootstrapping a business-critical product (and we did that successfully). And then maybe, just maybe, after I settle a bit, I might work an hour or two on this again during some evenings. Maybe. And that won't be used to provide the demo to these toxic investors -- I'll use it to have a proven implementation that I can pitch to other people. These guys don't deserve the time of day from me.

I have quite a lot of good code (mostly Rust, but also some Elixir and Golang -- I experimented a lot) that interfaces with Interactive Brokers and I have many building blocks of a good trading bot framework. That kind of creative and thorough work needs funding and peace of mind to be finished properly, of course. And I can't afford to invest so much energy on this without a stable income so I am shifting focus to that for however long it might take for me to feel comfortable to invest time and energy in this again.

If any business person wants to partner up -- give me a shout. Mail is in profile. I also wouldn't refuse fellow techies (or anyone else really) stopping by and telling me how stupid and naive I was -- I'll agree right away and say that they are right. Because truth is truth.

I admit I still can't get over the fact how close I got but I can't afford to count the stars while my livelihood is being endangered the longer I coast on savings. Dreams don't pay bills. And some dreams need more than one person to be fulfilled.

Rant + story over. Thanks for reading if you stuck this far.

Re: Case study: Algorithmic trading with Go

#78
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. I…

Thanks, I'll check it out!

Re: Case study: Algorithmic trading with Go

#79
post #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.

I think you would still end up with races, they'd just move around. IEX's "speed bump" was just marketing and didn't really matter to actual HFTs. Plus, some of it is unavoidable if you don't have a single unified exchange. Where there's latency, there's inefficiencies, and where there's inefficiency, there's profit to be made. And competition among exchanges is healthy for the ecosystem, so I don't think we'd want t…

Why is competition among exchanges a good thing? Why not a single, very regulated, exchange which serves as a neutral playing field?
Post reply on HN