Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: How to get into quantitative trading?
92 points by P6Rs4r 9 months ago | hide | past | favorite | 81 comments
I used to be a dev at a quantitative trading shop a few years ago but I lost touch with the trading and programming world for a few years. I'm trying to get back into this and would like to create a system to automate my trading for my personal account. I'd also like to have a backtesting platform. Are there are any resources for this?



Not sure if Options trading for Income / Theta harvesting counts as Quantitative trading, but I found success here.

Long story short: I created an option backtester (MesoSim) and started analyzing public domain trades.

I have a couple of listed in this blog: https://blog.deltaray.io/tags/strategies/

If you are interested I'd suggest taking a look at the Weekend Effect, it's relatively easy to understand.

Best luck to you getting back to trading!


You should know this is a really bad idea, unless loosing money is your goal

"Automated" trading, even if there is an edge (and unless you are a crook, there is not) will sink you with transaction costs

You should know this.


Transaction costs can be surprisingly low these days. Like in crypto you can get 0.02% maker fees or less and in stocks it's sometimes free. See Alpaca for example https://brokerchooser.com/broker-reviews/alpaca-trading-revi... - "Commission-free stock and ETF trading"


> You should know this.

Anyone who worked in quantitative trading knows you can consistently outperform the S&P500/VTI/SPY over 20+ year horizons.

Buy and hold passive US equity index funds gives a Sharpe ratio of ~0.7 with annual return of 8-10%. Meanwhile, high frequency trading does upward of Sharpe 10+ with 40-60% annual return, with 10+ year track records, of course.

Hell, even Citadel hedge fund, after their ridiculous 50% performance fee, returned 19% _after fees_ annually to outside passive investors over 20 years. And this is billions of AUM, so the ”quant don’t scale” argument goes out the window.

Why is nobody talking about this? Because the elite politicians and businessmen invest in these very quant funds, and thus suppress any news or regulation. Sucks for middle class professionals with <$5M net worth.


Nobody's saying that alpha doesn't exist.

But before you unleash your automated proprietary model, you should be able to explain why you think you have any edge whatsoever over your far better funded, far more experienced counterparties.

And, no, getting great results from backtesting your model is not evidence of edge in the future against adversaries with access to better data than you have.


> you should be able to explain

RenTech famously tried to understand exact mechanics of their successful models after they (models) proved to be successful. Sometimes they succeeded.


Citadel isn't making the bulk of their alpha from simply finding an edge, its making trades in dark pools based on trade information they receive for executing trades. The individual trader won't be able to make trades at the speed required when finding small price discrepancies, nor would they have the capital to really earn anything.


Citadel securities is the market maker, Citadel is the hedge fund and doesn’t have access to data from the other side


Did they pinky promise not to access the data or are there some actual barriers in place?


It being illegal seems like a pretty big barrier to me.


> It being illegal seems like a pretty big barrier to me.

That speaks volumes about your integrity. Good on you!

But it is not true.


I wouldn't be so sure about that. Also, even if people cross the barrier it doesn't mean it is not there or isn't big. But thanks for the compliment!


How many hedge funds are there? A few thousand? How many beat the s&p? Of those how much can be attributed statistically to skill rather than luck?


> How many hedge funds are there? A few thousand? How many beat the s&p?

The average index fund fails to outperform the S&P.

How many passive index funds are there worldwide? Thousands? How many beat VTI or S&P500? Answer: QQQ and small cap.

> Of those how much can be attributed statistically to skill rather than luck?

If you are picking S&P as your champion, then I am allowed to pick a hedge fund as my champion.

And Citadel outperforms S&P over 20+ year horizon. Citadel 19% vs S&P 10%.


>The average index fund fails to outperform the S&P

This is a straw man as most people understand investing in indexes as buying a an index that tracks the s&p.

>If you are picking S&P as your champion, then I am allowed to pick a hedge fund as my champion.

You are making a false equivalence. The s&p is a proxy for the us market and therefore is a benchmark. It captures the captures the bets placed by all market participants including citadel.

Citadel does something beyond buying and selling equities to generate that alpha. And it’s likely not just restricted to equities. Nonetheless they are an outlier. Which is the point I was making. Most people won’t do better than the us market in aggregate over a similar stretch of time.


Individuals tends to lack the data sources, low latency access, strats, controls, deep bench, and deep pockets to make serious money. It's less risky to pool money with other smart rich bastards at shops that perform. Division of labor, specialization of trade.


Slightly related: what are "big players" more likely to do to get exposure to the S&P directionally:

1. SPY shares long/short on margin/leverage

1. SPY options

1. SPX options

1. /ES e-mini futures

1. a blend of all

Does one trump another in popularity?


it's usually front month ES, depending on volume. And MES for smaller accounts.


I'd love to talk to you more. I tried to make a Mastodon account to reach you. I just have questions about how you might know this/what else I could learn from you. I don't trade or anything like that, just interested in learning if you'd like to chat more.


I don't trade, either. I just code custom data collection, quantity allocation, future roll and automated execution algorithms for certified trading advisors.


ES trumps the others.


Nice, thanks. I wonder by how much. Here is why I ask:

a lot of technical analysis is done on psychological levels related to (in my opinion) SPY strike prices/SPX strike prices/SPX levels.

Yet, /ES is typically 20 points ahead of SPX. For example, there can be a battle zone of support/resistance at 4900 on SPX, but /ES blew past it a day ago. I wasn't sure if one had more power/prominence than the other.


The spread between SPX and ES is purely mechanical. It’s a function of expected future interest rates and dividends over the remaining life of the future.

There is no such thing as support/resistance in reality.


> There is no such thing as support/resistance in reality.

Where would you say 80% of the daily trade volume comes from on average?

The powers to be that I can think of:

institutional investors / fund managers slowly reallocating (selling stuff off, buying stuff) daily

high frequency trading algorithms trading shares back and forth to each other in an artificial way to generate synthetic volume/movement

market makers reacting to option chain volume to remain neutral

"hedge funds" / "quant funds" running their algorithm

what do those algorithms look for at the "minute by minute" scale if not things like support/resistance/patterns/volume?


In my experience a large % of the daily trade volume comes from me.


> Hell, even Citadel hedge fund, after their ridiculous 50% performance fee

Do you have a source?


> (and unless you are a crook, there is not)

What sort of shenanigans do you think profitable automated traders are engaged in?


Insider trading

Market rigging

Survivor bias (not shenanigans that one)


Insider trading: there's a lot of information freely available that can be used to make predictions

Market rigging: the market can be affected by your behaviour without you rigging anything

Survivorship bias: this can be argued for any competitive industry. Don't engage in it unless you're good at it.


Sigh! People really want to believe there is some magic trick to trading. There is not.

> Insider trading: there's a lot of information freely available that can be used to make predictions

The efficient market hypothesis deals with that. The freely available information is priced in (nothing is free, and it takes time)

> Market rigging: the market can be affected by your behaviour without you rigging anything

I am talking of things like: https://en.wikipedia.org/wiki/Libor_scandal and https://en.wikipedia.org/wiki/Forex_scandal. These are incidences where the traders got caught. Given the millions at stake, do you think many are caught?

To win at active trading you need an edge nobody else has. There have been cases of traders having insights not known to others. Pairs trading is the only example I know of. In that case the people who kept it secret made out like bandits for a few years, then the secret leaked and it is no longer profitable

The most common legal edge players have is scale: They are huge and nimble and can take advantage of opportunities at scale. It goes really well, until it does not, and another trading house collapses.

The most common edge I believe, after studying it for a decade, is crime. Big trading house, big crime


then how does renaissance technologies make so much?

it can be done...no one say it is easy, but it's doable


RenTech remains a touchy subject, as their only high performing fund is closed to external investors. Their available to the public stuff performs much less than their closed fund.


Medallion was open to external investors. They closed it because Medallion has an approximate $10 billion cap before it moves the market too much and starts losing money and thus they just keep it to themselves. So they no longer need capital from outside investors. And why make others money when you can make yourself money?

Their other funds can't just do what Medallion does, otherwise you are just increasing the cap of Medallion and thus hurting it, which is why they aren't as successful.


It was closed to external investors in 1993, and had gains of 98% in 2008, in the middle of an economic meltdown.

How come they figured it out for one single fund, but aren't able to make any alternative strong strategies except the secret and closed one?


Strategies have limits on how much money they can manage. By limits, I mean - either it's impossible to put in more (could be because there are no more counterparties to trade with above a certain amount) or it would significantly decrease performance.


And in the 30 years since closure, which has seen China, USA, and Europe boom and multiply in size, somehow the strategy still has limits?

My questions are valid, and there might be valid answers. We don't know, because nobody knows how Medallion works. All we know is that nobody else can replicate it, not even RenTech itself. Which makes asking questions very important.


Yes, it would still have limits. There are several trading / arbitrage companies that are bringing roughly the same money over the years - for the past 20 years (I used to work for one).

That being said, RenTech is indeed very interesting. For all we know, it could be a money laundering operation or something similar to Madoff's structure. Or they are just very very good, or lucky. Time will tell !


> All we know is that nobody else can replicate it, not even RenTech itself.

Several firms have done similar things.


Do you have examples? Googling is not yielding any results for me.


> had gains of 98% in 2008, in the middle of an economic meltdown

Medallion does not act on its own or any human sentiment. It is a black box trading strategy that looks for signals. It's not aurprise that during downturns, the overall market is incredibly inefficient. Medallion makes money off of the market's inefficiencies. I don't know what that has to donwith internal vs external investors though.

> How come they figured it out for one single fund, but aren't able to make any alternative strong strategies except the secret and closed one?

I dislike responding to a question with a question, but why would that work? Medallion has made several people billionaires and has done so incredibly quickly. Trying to replicate it with the same strategy will just step on its toes.

It helps to understand Medallion. It is a massive statistical trading system that places a huge amount of bets across all markets, like all of them, and hopes to win say 51% of the bets. When it reaches a certain size, they cap it by taking off all money above the cap and returning it to investors. You can't add more money to Medallion and keep its performance up. It moves the market too much and degrades its positions.


Nothing can help understand Medallion, because there is no actual information about it. Everything you just said is conjecture.


I suggest the book The Man Who Beat the Market and watching or listening to interviews by those who worked there. There's enough information that gives a sense of what Medallion does and how it works.


I have read the book. It is unconfirmed hearsay at best.


which is why they aren't successful.

fixed it


LTCM enters the chat


Lots of other great answers, another one I came across recently is FinGPT[0]. For backtesting there is zipline [1], but doesn't look like it's maintained anymore.

[0] FinGPT: Open-Source Financial Large Language Models https://github.com/AI4Finance-Foundation/FinGPT

[1] Zipline is a Pythonic algorithmic trading library https://github.com/quantopian/zipline


another comment in here mentioned Zipline Reloaded¹, a fork from a guy who wrote a book using Zipline. Last commit 6 months ago, much better than 3 years from the original.

¹: https://github.com/stefan-jansen/zipline-reloaded


Fastest way is probably to just write the code. You can get crypto market data for free. https://www.binance.com/en-AU/landing/data and others.

If you want equities, I think you can get that from Databento for low cost (won't need the CME cert for their stuff to get historical from here).

Then just write the code. The basic structure is not that much in a modern language (use Java, Rust). To trade, you can use Sequencer architecture as basic https://sissoftwarefactory.com/blog/an-introduction-to-the-s... (article describes so maybe jog your memory, but has only old code link so useless if not new to you, just sequence your messages) ChatGPT will help build this quick.

IMHO if you want to do this, crypto markets are ideal. Fees are high, but low upfront costs. Can eke out small wins with low capacity strategy.

Should be advised, though. Everyone who wants to get into this does this stuff and then finds that if you want to do big, you need to apply large force on long lever. So everyone and their uncle had "a few profitable strategies as a side bet". Means nothing at small scale. Only for fun.


Your biggest problems will be brokers, data, and capital. The coding part of quant finance is surprisingly boring (unless you are doing HFT but most aren't). For infrastructure just use AWS and co-locate next to the exchange (especially if you are doing crypto where everything's in the cloud). For data try https://databento.com/, there are also other sources.

Affordable data, especially tick level L3 data at scale is difficult to get. Having enough capital to make trading worth well (pricing in losses etc.) is also difficult. Direct market access etc. all cost money. Use interactive brokers if you need a compromise between fully professional and amateur. Spend more time on your financial models, and less time building beautiful frameworks. The engineering of quant finance is the least interesting part. Focus on the market microstructure and financial models. If your model is bad, you lose money regardless of how great your infra is.

It's difficult to find a good off the shelf backtester. This ties into your model too. At its core, a backtester is just a for loop. Computation of variables like slippage and integration of monte Carlo Sims is where the secret sauce lies. Those are all proprietary.

Best of luck in seeking alpha


I've recently been studying up on it with a view to unleash the bots soon. I can recommend a couple of Udemy courses, details below.

There's a guy here explaining how to make trading bots in Python https://youtu.be/sUQmuL95_oY He has free code available on github to try out. He also explains how to backtest. There are a couple of popular packages like backtesting.py out there.

ccxt is a handy python package if you want to trade crypto. There are various free tutorials for it.

I also recommend playing around with Tradingview. It draws graphs and you can make your own indicators with their language Pinescript and even trade off that although Python probably gives you more flexibility.

Udemy courses https://www.udemy.com/course/algorithmic-trading-strategies-... and https://www.udemy.com/course/complete-algorthmic-forex-tradi... I paid about £14 each - they keep chopping and changing with the discounts

The details vary a bit depending what you want to trade - crypto, stocks fx or whatever.

One tip - chatgpt4 is surprisingly helpful and can almost code a whole bot for you if you know what you want. One slight pain for me has been finding brokers with the what I want. I'm the wrong nationality or they don't have futures or there isn't enough liquidity or they are sketchy or such like.


HN is the wrong crowd to ask, because they’re behind the curve on a lot of things.

Hop on FinTwit or CryptoTwit.

Derivatives (options/futures) are your best bang:buck. But crypto is where the real speculation is.

Read up on a practical trading book (hypothesis building, backtesting without bias, and risk management via Kelly etc.) and then start testing strategies.

Backtesting you can build yourself with any broker that has an API, but not all are made equal. It’s dead simple.

Look into [redacted]


What are some great Twitter account to follow?


I was wondering the same thing last year.

I ended up in twitter/reddit rabbit holes until I found a somewhat dodgy guy on twitter (@TerribleQuant - account is now deleted).

The person compiled a guide with study resources, courses, YT videos, podcasts, textbooks and everything else you can think of in 21 pages.

If you look for: BBM PUBLISHING INC “Roadmap” Resource Guide 3rd Edition you might be able to find a copy.


It doesn't look like the account was deleted. I think the user just changed their username: https://twitter.com/quant_arb/status/1487265241692053509


Oh yeah, this guy is fun.


Noobie Question: Does this actually work? I thought alpha was very little and always fleeting so only big hedge funds generate profit from it.


I'm a trader who runs a couple of profitable strategies. You can generate alpha by implementing quantitative (or discretionary) strategies as long as you adhere to the basic principles of profitable trading with a strong emphasis on risk management. There are a million possible trading strategies, which of these will suit your personality/risk tolerance/system design is a matter of personal choice.


Could you please say more about what the "basic principles of profitable trading" are, or point us to a reference?


Sure. A trade can be decomposed into entry and exit criteria.

Only trade when you have an edge, i.e your model suggests that there is a higher probability of an outcome in your favor rather than a pure coin toss - either in entry or in exit.

Even coin toss entries can make money if you have an edge in exits and vice versa.

All in all, you can be right less than 50% of the time per trade, and still have alpha if your winning trade is 2 times your losing trade. Standard expected value stuff. Heck, I know traders who bat 30 or 35% and make colossal amounts of dollars.


I hope there's more to it than "buy low, sell high"..


Buy upward momentum, and sell downward momentum.


Slightly related: what are "big players" more likely to do to get exposure to the S&P directionally: 1. SPY shares long/short on margin/leverage

1. SPY options

1. SPX options

1. /ES e-mini futures

1. a blend of all

Does one trump another in popularity?


is your strategy more profitable than indexing? or are you aiming for something else, like beta-neutrality?


there is always new stuff if you are astute enough to find it. look at r/wallstreetbets...some guys making tons of $ consistently there, albeit there is lot of survivorship bias too. position sizing is key. you run tests on certain strategies, like buying 0-day calls on dips in the morning, flip for profit at close. Use Kelly formula to optimize position size. etc.


There's pennies on the ground that the big places don't care about.


I played around with https://www.quantconnect.com/

Its a platform where you just focus on implementing strategy. Was fun but I realised it would be more work than just getting a better job.

I'm sure there are others as well.


for trading strategies: wilmott.com elitetrader.com researchgate.net

for quant: https://community.quantopian.com/home https://pyquantnews.com https://www.quantscience.io

for backtesting - zipline reloaded - is event based. It is very slow for optimization.

vectorbt - vector optimization - optimize the parameters. optimize - entry and exit parameters, number of ticks. useful for single-asset or spread strategies (i.e. refiner crack spread).


This might be a good resource to get started: https://github.com/paperswithbacktest/awesome-systematic-tra...


There are many resources for MetaTrader: https://www.mql5.com/en/market/mt4/free and you can test the Expert Advisors (trading bots) on historical data: https://strategyquant.com/doc/quantdatamanager/test-strategy...


Hit me up if you want to chat. I‘ve been a hobbyist algotrader for some years (with mixed results).

I’d say this: It is very hard to beat the market consistently. It is even harder to statistically prove and convince yourself that our new strategy actually now beats the market. There are a lot of gotchas and caveats to watch out for when backtesting.

I spent most of my time with time series techniques as this was most fun to me. My current stack is ccxt, binance, polygon.io and self made backtesting in python.


I wish I had started with QuantConnect before I wrote everything from scratch; all the other free/open source tools didn't seem to meet quality standards for me.


Check out numer.ai if you're feeling adventurous.


this makes me believe you never were in a quant shop, sorry. At least if your goal is making money.

I think it can be a fun project to make an engine, and try to make models, together with some form of ingestion pipeline and finally solve and calibrate the models. Try some simple products, and see how close you can get to real world prices.

Making pricing/risk engines are in my opinion somewhat close to game engines even through that the domain is so different.


Just curious, is there still non-quantitative professional (not-retail) trading in the forex or future or fixed income market?


Glancing at linkedin it still seems to going strong https://www.linkedin.com/jobs/foreign-exchange-trader-jobs-l...

I had a friend who was a forex trader at large banks and a lot of it is reading the psychology of the other people in the market. I think humans probably still have an edge there. He made a lot of money then did a lot of drugs then went a bit mad. One of the drawbacks of humans there.


Interesting, thanks for the pointer. I thought everything moved to algo now...


Check out TradersHelpingTraders channel on YouTube. They talk about their trading bots on their Discord.


The SEC rules if you're in the US are quite strict. You likely wouldn't be able to do quantitative trading own your own while working at a quant. Though, it might help you get hired as a modeler.


This is untrue. You generally can’t if you’re working for a broker dealer but you absolutely can trade for your own account working for a hedge fund. The fund might consider it a conflict of interest but the SEC won’t care.


> You likely wouldn't be able to do quantitative trading own your own while working at a quant

Sell-side bank like JPMorgan, HSBC, then yes you are correct.

Buy-side hedge fund or prop shop, no you are wrong. The SEC/CFTC does not care what you trade in your personal account.


I meant that logistically you'd not be able to do it.

Sure you can still trade of course. but you might need things like preauthorization for every trade, and have to hold them for a given time before selling, which kinda makes algorithmic trading more difficult.

But hey ya'll just pile on. o/




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: