/r/algotrading
A place for redditors to discuss quantitative trading, statistical methods, econometrics, programming, implementation, automated strategies, and bounce ideas off each other for constructive criticism. Feel free to submit papers/links of things you find interesting.
/r/AlgoTrading place for redditors to discuss quantitative trading, statistical methods, econometrics, programming, implementation, automated strategies and to bounce ideas off each other for constructive criticism. Feel free to submit papers/links of things you find interesting.
This sub is not for the promotion of your blog, youtube, channel, or firm.
*THIS DOES NOT CONSTITUTE INVESTMENT ADVICE, USE AT OWN RISK*
*SEARCH THE SUB/GOOGLE/STACK OVERFLOW BEFORE ASKING QUESTIONS FOUND ON THE FRONTPAGE OF THE ABOVE WILL BE REMOVED*
Good places to start with code examples:
STRATEGY
Big-Intro to quantstrat and trading systems
R & quanstrat video tutorial
portfolio optimization
Great blog with more advanced code and ideas from the "systematic investor" note: code here does not follow standard R conventions
Blog here with strategy examples from Ilya Kipnis
quantivity paper feed
How to learn algortihmic trading
Strategy books thread
Quantopian Lecture Series
How to get historical data for free
Daily Bar data for Stocks
Tick level Forex Data
Historical Bar Data for Crypto Currencies - Binance
Historical Bar Data for Crypto Currencies - BitMEX
Charts with live feeds for global exchanges
TradingView HTML5/web based charts
Math/Stats/Machine Learning
Introduction to Statistical Learning with applications in R
Elements of Statistical Learning
Production Systems
aleph-null: open source python ib
quick-fix
node.js to ib api
subreddit thread on systems
Paper Feeds
Quant news feed
Quantocracy blog feed
Live Chat Rooms
Official Discord: Official Discord for /r/AlgoTrading
Open Source Quantitative Finance: Open Source Quantitative Finance
R Language in Finance Discord IRC Version sync'd to discord irc.libera.chat #r-finance
Book Recommendations List of recommended books on Algo Trading
Do's:
Don'ts:
FAQ's:
A: Read the sidebar, if you have a precise specific question please google it and should you not find the answer then you can ask here.
Q: I am a student and want to know what courses to study to get into algo trading?
A: Algotrading is at the intersection of statistics/computer science/machine learning/mathematics/finance/economics.
Q: Where should I apply for a job?
A: /r/financialcareers for that
Q: I have bug ABC with language XYZ ?
A: http://quant.stackexchange.com/ or http://http://stackoverflow.com/
If you get spam filtered, message the mods and we will review and unblock as required.
/r/algotrading
The strategy that I’m currently backtesting makes evaluations immediately after the most recent 5m candle is completed and places new/updates existing orders accordingly. I used yfinance 5m candles for all of my backtesting which works fine.
I want to start reliably forward testing using the same timeframe - immediately reexecute the strategy after the most recent 5m candle has been completed and place new/update existing orders on Alpaca using a bracket or OCO order.
Yfinance has a delay of about 10-15 seconds before the latest 5m candles closing price is shown. Not sure how reliable this is considering it’s free.
I don’t need volume information, just HLC. Is yfinance my best bet for something free/inexpensive or is there something better for a low price?
Question to all expert custom backtest builders here:
What market data source/API do you use to build your own backtester? Do you first query and save all the data in a database first, or do you use API calls to get the market data? If so which one?
What is an event driven backtesting framework? How is it different than a regular backtester? I have seen some people mention an event driven backtester and not sure what it means
I don't know how to code, I use a backtesting tool but it's too limited, I would like a better tool.
I know TradingView, what else? It could be a cheap backtesting tool or free ones.
Hello again everyone. I posted the other day and have looked into some trading sites since then so I will try and be more detailed this time
I have a strategy that needs to place trades on different stocks and cryptos on different exchanges. I want to be able to automate this so that the trades get placed when my specific criteria are met and it must all happen quick or else I will not be profitable (because I need the best position entries and exits for my strategy). I have looked into these services like: Ninjatrader, Tradingview, Metrader, Multi charts, Alpaca markets but I am not so sure any would work for me……. Can I get advice?
I was suggested to build my own trading bot but I am not sure I can do this. My python skills are OK? My only other option is to hire someone to build it for me. What do you all think? Thank you everyone
Anyone integrated live power outage data (USA / CA) as a signal in their energy arbitraging? If so, what data sources do you use? I've tried scraping data directly from utility websites, but there are over 1,000 companies and their websites change quite often (especially during major events), which breaks things. I'd prefer to have a service (paid is fine) that just handles those issues for me.
There seems to be a lot of discussion about this here with no clear answers. So I wanted to clarify a few things.
Thank you!
I've been searching for like 5 years of exper advisor that really work. I know they exists but they are at a different place than i am looking now. Its difficult to find it and those who are in your face don't even work properly. I'd never understand why you would upload something that doesn't work for yourself, why would it work for others. The market is absolutely flooded with bs. Considering there 1.8 million people here some genius has been working and workinf and it works. And yes sharing a strategy could really kill yourself when people use it too much and thats exactly what will happen so they must keep it very limited and the clients must get it as well cause cooying and pasting is easy too.
If somebody out here really got something good, shiiiit wouldn't i like to know.
Nothing seems to work for intraday, daily and weekly timeframes are better.
1 min, 5 min, 15 min, 30, min... Nothing works, bad returns, bad drawdown.
Of course you can build an algorithm that beats the market for intraday, but it will be very hard.
My advice after weeks of backtesting: focus on longer timeframes.
Hey guys. I’m not a technical person, but I’m looking for resources for someone else.
Is there any platform that lets you backtest with python? Just stocks. Maybe derivatives later.
If you had to code a strategy that involves data source APIs, is there any platform where I could code the strategy in its entirety and backtest it too? I should be able to backtest multiple positions/tickers at once.
If not, do you separately code and generate signals and then use a separate backtesting platform
I know there’s python libraries for backtesting, and I probably sounds silly- but I’d love to get some direction on steps/tools/platforms you use.
Thanks guys!
Title says it all, basically getting more into the research side of everything and wondering what's actually worth reading. The other day I spent maybe 2 hours reading this massive paper on pairs trading and I genuinely feel like I learned nothing useful except a few of the tricks the researchers used in their analysis
Let's say I have $100K cash in a margin account
09:30 I buy $100K worth of stock
10:00 I sell it for $110K
10:30 I buy $100K worth of stock
11:00 I sell it for $110K
11:30 I buy $100K worth of stock
12:00 I sell it for $110K
Do I pay margin interest for trading with unsettled funds?
If so, how much interest do I pay, do I pay for 30 minutes worth of interest at 10% APY or do I pay for 24 hours worth of interest (until it settles)?
Anyone aware of existing code to connect to Schwab API to pull options data into ninjatrader?
I'm trying to come up with a screener and one of the things i've been trying to do for a while now is creating support/resistance levels that can help me identify price action. The support/resistance levels are automatically generated and have their own properties such as how many times it was tested/strength and etc. These support/resistance levels have its own parameters which will be tested to different settings as part of the backtest so we can do things like be more conservative and have less levels or push it to have more. The image below is a sample of this.
I am currently backtesting the support/resistance levels but I realized that the results of the backtest are currently unreliable because the tolerance between buy and sell depends on the volatility of the stock's price as well. If the the stock is generally erratic then the backtest should be able to account this volatility to prevent false signals (as seen below where there are multiple buy and sell signals that are absurd).
I did put some tolerance to account for volatility, but it's not dynamic where it changes from stock to stock, it's just a constant like a +/- of [tolerance] * [support/resistance level]. I'm wondering what's the best measure of volatility out there that will minimize the errors of signal generation. I was thinking the best would be some kind of probability distribution that can capture the behavior properly. Not sure if something like a simple standard deviation can capture it properly so I need some leads on these.
The plots below are the plots from the backtest so each stock will have 1 plot using the same support/resistance level logic from above but applied to each stock.
EDIT: The previous charts had a look ahead bias due so I remedied it by having a training data set and a test data set. Training dataset is historical data minus the most recent data which I was going to use as the test dataset. Levels based entirely on the training dataset. Although the measures for volatility is still needed. Still lots of polishing but the idea is there
Hi all. I use Composer. I wasn't liking the drawdown in "V2.11 The Manhattan Project | 6mo 42,000% AR | 9.5% DD" in my IRA so I sold at a loss and redistributed my proceeds to the other symphonies in the acct. all of whom are doing a fair bit better and don't have the drawdown Man. Proj. seems to have. That said does anyone have a suggestion for a symphony or symphonies that have been around a few years and have a consistent history of small drawdowns and generally trend upward?
Am I asking for the Grail here? :)
Thanks in advance.
Hello all. I'm here asking for help getting pointed in the right direction. I've identified some spot price cash-and-carry opportunities in the Bitcoin futures market and I'm looking for a way to automate it. I have experience in Python and know the basics of several languages but I'm willing to learn something new.
The two things I'd like suggestions on are 1. exchange and 2. automation method. I'm trying to keep my exchange in the U.S. to keep things strictly legal so I've been looking at CME Group and Coinbase mostly. As far as automation method, I'm really struggling to narrow things down. It seems everywhere I turn there's a different suggestion and an endless amount of platforms that seem shady.
If anyone has experience on this and wants to share their experience I would really appreciate it!
Edit: corrected terminology
I'm looking for APIs that provide real-time stock data including volume and detailed metrics. I also need access to fundamental reports for companies (like earnings, balance sheets, etc.).Additionally, it would be great if the API offers the ability to categorize companies based on their industry. Yeah real time stock data doesnt comes without paying i'm ready to buy the paid api's too
All I do in my free time is code. I really like it, in fact I really enjoyed it but it is waning now. I have spent 600 plus hours trying to develop 1 algorithm but I have not seen any good results yet. Let me tell you a little about what I have been doing. I have dabbled and coded various machine learning models, genetic algos, gradient boosting algos, deep reinforcement learning agents, implemented various types of crossovers for filters and signals, researched many research articles, augmented my learning and coding with AI, implemented robust and varying feature generation, risk management, backtesting and forward testing criteria. I can go on and on. I have even spent additional funds for Pro subscription of ChatGPT along with Gemini, enrolled in a bootcamp, have years of experience in crypto and stocks. Watched hundreds of hours of YouTube videos. I cant list it all.
If there is 1, 2 or 3 things you can suggest to me what are they? Thank you for your help.
Hello reddit gods,
I'm new to algotrading and have made the typical EMA crossover with a trailing stop loss, and it appears to achieve a decent return as it can capture big waves of price movements.
Are there any reliable methods to reduce false signals for this strategy in terms of preventing entries during sideways choppy conditions?
ChatGPT has recommended a few things, but I wanted to get advice from some actual algotraders first! Suggestions have been ATR, Bollinger Bands, adx and slope of EMA etc. Any of these good?
Thank you.
I am looking for a C/C++ API where I can:
I would like to create a program in C/C++ which runs price analysis continuously and decides when to buy/sell a stock on a broker account that I fund based on that analysis.
Are there any reputable, low cost platforms for this in Europe or the U.S. ?
Either an API that is offered by the brokerage company or an API that can connect to an account at a brokerage company.
I'm fairly new to algotrading. Not the newest, but definitely still cutting my teeth.
I am running extensive backtests, and sometimes I get algos which have a good ROI %, but which are lower than the buy and hold ROI %.
It seems pretty intuitive to me that these algos are not worth running. If buy-and-hold beats them comfortably, why would I deploy the algo rather than buying and holding?
But it also strikes me that I might be looking at these metrics simplistically, and I would appreciate any feedback from more experienced algo traders.
Put short: Are there any situations in which you would run an algo which has a lower ROI % in backtests than the buy-and-hold ROI %?
Thanks!
So lets say i have strategy to get 100% ROI every year, then i have problem not every year i have same amount of total trade. sometime in a year i got 100 trade signal sometimes in a year only got 1 trade signal. so even with average trade return 2x, with unknown date to trade my "actual" trade return become far less than 1.5x . i tried many ways to get better trade return, like only take 2 trade every month and many more,yet the actual income is still far less than it should. so how do you guys solve such problem??
Hi,
As you probably know a chinese company released deepseek AI model which coused NVDA and other AI connected stock to drop massively.
I want to investigate this and reverse engineer this event to come up with a strategy to peofit from such occessions.
Sentimental approach is my first idea here, but I wonder if anyone has some tips here?
I would prefer to setup a trade based on some TA, but I am affraid that sentimental analysis is the right approach here
All other ideas are welcome
I was browsing through linkedin and in the section comments of one of the many deepseek related threads I saw the CEO of this company (which I thought it was interesting to get an API feed from) that said "Distilling reasoning layers is easier than distilling facts".
But I forgot to follow or screenshot smh.
The company has been around for a decade (as far as I remember from the founder's BIO) and starts with D, one word only.
They claim to have FactSet and Alphasense among their users.
Do you guys know what I am talking about ? Anyone can help me find it again
This is a dedicated space for open conversation on all things algorithmic and systematic trading. Whether you’re a seasoned quant or just getting started, feel free to join in and contribute to the discussion. Here are a few ideas for what to share or ask about:
Please remember to keep the conversation respectful and supportive. Our community is here to help each other grow, and thoughtful, constructive contributions are always welcome.
I’ll coming from crypto industry where holding money in exchange is a foolish thing. I usually kept it off exchange in cold wallet however since I’m getting into alto trading, how can i minimize keeping funds on exchange as much as possible?
Mainly I plan to make bots using python.
I would like to build model predicting stock price distribution for 2 future dates +180d and +360d. Based on historical data. And use that distribution to price European Options with Monte Carlo simulation.
I want to use different approach than Implied Volatility models. I want to ignore current market expectation (ignore current option prices), and rely only on the past data.
Also, how the model fit would be different. IV models fit to match the IV surface with Empirical IV, I would like to use other goal - use backtesting and compare model to real realised probabilities - i.e. trade millions of stock options on past data and the balance should be as close to 0 as possible (in a way like Maximum Likelihood Fitting).
The Model Should:
- Use Stochastic Volatility, Volatility Clusters and Volatility Mean Reversion. (I plan to measure it as rolling averages. And model it with Hidden Markov Chain, say we have 5 regimes of volatility, from low to high, and it should also handle clustering and mean reversion).
- Not assume that price distribution is Normal. Although using the various approximations is ok. (I plan to use empirically fit Gaussian Mixture as approximation of Heavy Tailed Distribution).
- Account for missing data. Say we predict price for wonderful stable growing company with 10y history. Its empirical distribution (annual log returns) will be wonderfull, no downturns or huge drops. But it is wrong, we are missing the data here, it's only a part of the whole reality, a lucky part. (I plan to account for that by fitting some abstract distribution (possibly Gaussian Mixture) over all stocks, and then calibrate it to the specific stock. So, after tuning this all-stock-distribution, even for wonderful growing company, it will account for a chance for drops and downturns).
- Get the core concepts and the structure right, while sacrificing high precision. Having 20% error is ok, but having 200 or 2000% error is not. (as they say - better be approximately right, than precisely wrong). So, simplifications are ok - like using discretisation, say using rough 10-20 bar histogram, instead of a more precise continuous smooth curves to represent stock price distribution is ok. What's not ok - is to ignore some crucial aspects, like heavy tail or assuming volatility as a stationary etc. (I plan to use discrete models, Markov Chain, they should be able to model those things, while sacrificing a little bit precision on discretisation).
The Model should not:
- Model path dependence, it's optional, we don't care, as we consider European Options only.
- Beat the market. We don't need that. We want a model that close enough to reality, a safety net, that protect us from making huge mispricing and errors, stress testing, playground to try new ideas etc. And doing it independently, ignoring the current opinion of the market.
- No need for well shaped symbolic form or math proof or high performance. Numerical simulations, Monte Carlo are good enough, and being slow is ok, even if it's x1000 times slower than other models, it's ok.
I would like to find good practical book about Monte Carlo and Markov Chain that does something similar (I found many books about IV, and GARCH, but not on this approach). Also, if you find a mistake in my reasoning, would be interesting to know. Thanks.
Anyone know of a free source for sentiment data? I only need to go back roughly a year or 2 for testing and then if the data looks good il pay for it. But struggling to find a source with that free tier first.
Has anyone been successful in algo trading memecoins?
I have monitored a couple of bots trading solana on pump fun and they seem extremely profitable. I just don't get their strategy. Mostly just buy and sell, crazy.
I'm currently working on model risk management at a brokerage firm. One of our Key Risk Indicators (KRIs) for Model Risk involves assessing the stability of our investment models. As I'm relatively new to this field, I'm seeking advice on this topic.
Specifically, are there any established metrics or methods to measure the stability of investment models? Our models are like using algorithms to select the top 10 stocks based on stock signals and fundamental analysis to seek alpha. The idea is how do we know that it's deviating from back-testing and should be revisited?
Any insights or recommendations would be greatly appreciated!