r/algotrading • • Mar 28 '20 Bravo

Are you new here? Want to know where to start? Looking for resources? START HERE!

1.5k Upvotes

Hello and welcome to the /r/AlgoTrading Community!

Please do not post a new thread until you have read through our WIKI/FAQ. It is highly likely that your questions are already answered there.

All members are expected to follow our sidebar rules. Some rules have a zero tolerance policy, so be sure to read through them to avoid being perma-banned without the ability to appeal. (Mobile users, click the info tab at the top of our subreddit to view the sidebar rules.)

Don't forget to join our live trading chatrooms!

Finally, the two most commonly posted questions by new members are as followed:

Be friendly and professional toward each other and enjoy your stay! :)


r/algotrading • • 3d ago

Weekly Discussion Thread - November 24, 2026

3 Upvotes

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:

  • Market Trends: What’s moving in the markets today?
  • Trading Ideas and Strategies: Share insights or discuss approaches you’re exploring. What have you found success with? What mistakes have you made that others may be able to avoid?
  • Questions & Advice: Looking for feedback on a concept, library, or application?
  • Tools and Platforms: Discuss tools, data sources, platforms, or other resources you find useful (or not!).
  • Resources for Beginners: New to the community? Don’t hesitate to ask questions and learn from others.

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.


r/algotrading • • 14h ago

Strategy Making real progress

Thumbnail gallery
20 Upvotes

I am running a test on market replay, I have done various covering 5 years. I am shadow trading several configurations. So far so good for this test. Two evals passed, good WR and drawdown. The PF is holding steady for most configurations.


r/algotrading • • 1h ago

Strategy Question for the sub

1 Upvotes

on range-based strategies, do you use a minimum stop distance, say a fraction of ATR? And if you'd only add it after seeing a tiny-range day like Thanksgiving, how do you stop it becoming a curve fit?


r/algotrading • • 6h ago

Strategy Do algorithms actually perform similarly to robust backtests?

1 Upvotes

Never traded using algorithms. So I’m curious from people who actually do. I’m sure it’s very difficult to find a repeatable mechanical edge that (mostly) passes all tests. I’m talking about ones that account for out-of-sample, curve fitting, walk-forward, Monte Carlo, costs, and more. Whether it be intraday, swing trading, options etc.

However, I have seen a handful of backtests where people do find these strategies that look really good on paper even after trying to account for all these. Which makes me wonder, how many of you have strategies that perform very similarly to your backtests? Is it common that they work exactly as intended or do they often perform way differently, even after making the backtest as robust as possible?


r/algotrading • • 13h ago

Strategy I tested a Kalshi 15 minute BTC strategy that sits out three markets after a loss

3 Upvotes

I wanted to test an idea on 15 minute BTC prediction markets. If a trade loses money after fees, the strategy sits out the next three markets. For an entry, BTC on Coinbase has to be at least $22 past the settlement cutoff and its five minute move has to be at least 0.02% in the same direction. The strategy buys that side if the contract is offered at 32c to 80c and usually holds to settlement.

The first backtest came back at +$445.33 PnL, with a max drawdown of $13.20 and a 1.77 Sharpe. I then ran 100 variants with different buy price floors and ceilings. All 100 came back with positive reported PnL. The best was +$537.29 with a 2.42 Sharpe ratio and 596 closed positions. The weakest was +$17.20 with a 0.24 Sharpe ratio and 20 closed positions. Those two runs left 600 and 15 contracts unsettled. After counting the entry fees on those contracts, the totals were +$529.04 and +$16.93 before assigning them any value.

I mapped the PnL against the two buy price settings to see if the winner was a one-off. The floors went from 5c to 56c and the ceilings from 57c to 95c. The original 5c floor and 95c ceiling came out on top. The 32c floor came close at +$532.82 with the same ceiling. As I raised the floor from 32c to 56c, average PnL across the ceilings dropped from $455.43 to $160.96.

Honestly it seems like just having it stop trading when it starts to lose is a bandaid of an actual problem with the overall strategy. I'm going to try to figure out what causes those trades to lose in the first place and see if there's a direct signal I can use to filter them out instead of this. How can I go about extrapolating what causes these losses? I feel like it'd be impossible to map out every scenario right?

Full Report


r/algotrading • • 11h ago

Strategy CMV - algo trading LARP

0 Upvotes

Feel a little like a lot of people on here just doing eval’s all day instead of actually making money off of Algo trading. What makes me realize that is they over engineer specific methodologies which are entirely regime dependent and would already be outdated but talk about it like they found a new system. That’s not actually how any of this works models expire and you have to create a new one from scratch that’s why it’s very hard to make money.


r/algotrading • • 1d ago

Education What is best instrument to capture 30-50 bps move in ETFs in 1-3 day period?

5 Upvotes

I am thinking about first or second ITM option (high delta) with one week out expiry. What other options for keeping friction / transaction cost low?


r/algotrading • • 1d ago

Data What metrics do you monitor when moving a trading bot to live?

12 Upvotes

Moving a trading bot from backtesting or demo to a live account seems like a whole different challenge. Of course, profitability is important, but I'm guessing there are several other factors that matter just as much when real money is on the line.

During the initial stages of live trading, what metrics do you usually keep a close eye on? I'm particularly interested in knowing what experienced algo traders consider the biggest warning signs. Would love some insights from you all.


r/algotrading • • 18h ago

Other/Meta vibe coding actually works

Post image
0 Upvotes

maybe I'm tooting my horn a little too soon since I've only used the strategy for 7 trading days but the results are better than I expected.

Background

I discovered this strategy a little over a year ago and I was raking in $1,000+ daily capturing part of the bid-ask spread until I discovered the CBOE 390 rule. I was placing around 1,000 orders manually every trading day until the spreads suddenly went to zero/negative. called up Schwab and they said I was marked 'professional,' great.

90 days pass, I resume the strategy trading under 390 / day and I'm making $400 / day. I try out different stocks to see which capture the best spreads and I worked my way back up to making $1000 / day again.

as of the last two months I'm netting $4,000-6,000 / mo after commission, due to narrower spreads across my stock universe and Schwab capping me at 300 trades / day before the spreads fall to zero/negative. $5,000 a month ain't bad but it's not the $15-30K / mo (broker statements below) I was used to so I decided to automate the strategy to possibly allow scale for other users.

Automation

I had a background in C.S. but never learned anything useful from my classes, plus it's been 8 years since college, so I decided to use Claude to develop the algorithm for me. it took a lot of trial and error at first, seemingly disregarding instructions like inventory limits and canceling orders that I specifically asked it not to. it was losing money and I felt defeated after developing this for weeks, so I decided to restart from scratch.

I went back and forth with Claude for days laying out the rules, making sure the bot would react how I would react in a manual setting, and finally let Claude develop the algorithm once the rules were ironed out.

after that, I asked Claude to use an agent to check the rules vs the code for the algorithm, and another agent to check for bugs. this process took another day or two to get everything right before going live. I pressed 'Start' on the bot and it works!

Results

the first couple days I only made $70 so I set up new re-entry rules to help exit at more favorable prices. after running those changes through Claude and the agent, I had my first 'big' day $339 profit after option fees.

since then, I started running it on a second account for a friend, and combined we have made $2,081.30 over 11 account-days averaging $189 / day between the accounts.

of course I'm still ironing things out, trying new stocks, different start times, changing up trade cadence, etc. but the results are a lot better than what I expected.

Conclusion

all-in-all vibe coding a trading bot can work, you just have to have a proven strategy to begin with. Claude got it wrong when I let it fill in the gaps, but got it right when I spelled everything out exactly and had it check its work.

it's only been 7 days so I'll post an update after a month, wins, losses, and the changes in between.

TL;DR

I've been capturing options bid-ask spreads by hand for about a year, but the CBOE 390-order rule capped how much I could make. I used Claude to automate it: I wrote out every rule first, then had agents check the code against the rules and look for bugs. After 7 trading days on two accounts, it's up $2,081.30 after fees. Still early and still tweaking.


r/algotrading • • 2d ago

Strategy How to manage multiple strategies on same symbol?

7 Upvotes

So till date I was running my "best" strategies and by symbol.. so 1 each for TQQQ, TSLA, CBOE, MNQ, MES, etc..

Now stupid AI is finding more strategies and I'm finding it difficult to run them together on IBKR.

for example, take MNQ.

One might do breakout during sessions.. so it exits when the session closes, another does overnight .. and buys towards end of close.

so one is buying and another selling.. which is fine as I can manage the flattening and maintain account validation/reconciliation in code.

but stop losses, trailing, etc.. become an issue. I always keep stop losses as protection against network disconnection, data issues or just bugs. I might have a strategy going long with a stopl oss, but another is going short.

different clientIDs don't solve the problem because the orders/execution is still flattened.

I understand that I will have to manage it in code, but any pointers on what to do and what not to do; would be helpful. I see it as a problem that people here would have faced and solved.


r/algotrading • • 1d ago

Education Final-year CS student: how would you make this AI trading research question genuinely impressive?

1 Upvotes

Hey all! I'm a final-year Computer Science student in the UK, working on a 350-hour project. I'm fairly new to finance, but I love automation and algorithms.

My current research question:

"Do LLM-generated trading strategies hold up on unseen data better than simple baselines, and can fine-tuning a small LLM improve them?"

I want to make this as interesting and impressive as possible, so I'm after pointers, directions and honest opinions. Is this question worth pursuing? What angle would make it stand out? Anything you'd add, change or watch out for?

Thanks!


r/algotrading • • 1d ago

Other/Meta Convince me my strategy is overfit

Thumbnail gallery
0 Upvotes

Quick breakdown

Every rule and what counts as a pass was written down before running anything

Same core rules on every market, nothing tweaked per market to make it look better

The out of sample data is data from after I froze the rules.

Anything that failed I threw away, nothing was retuned till it passed

I know some stuff like GER and Silver isn’t amazing but it was part of the research so it was included.

Be as harsh as you want, I want to deploy this live but honestly this isn't my background, I come from nothing. Everything I've done I taught myself and I know a lot of you guys are professionals.


r/algotrading • • 2d ago

Infrastructure caught look-ahead bias in my rust L2 sim after days of tuning. starting data collection over.

9 Upvotes

been building a rust execution engine for btc/eth/sol/xrp perps across bybit, binance, okx, and mexc (8-shard ensemble on OBI + order flow).

thought i had a real edge until i audited the backtester properly. it was filling entries on tick i instead of i+1 with a passive offset that basically gifted free ticks, plus half the test was on 1m bars instead of actual L2 depth. forced i+1 fills with slippage against me and checked SL first — went straight red. pretty annoying tbh.

scrapped the old data and spun up a rust ws recorder pulling live L2 books + trades from all 4 venues (~50 ticks/sec) to collect clean data before retraining. also noticed raw trade flow comes in totally different contract units across bybit/okx/mexc so it was saturating weights until i normalized each venue separately.

anyone else running multi-venue rust/c++ setups here — how do you model queue position in offline sims without bogging down the loop?


r/algotrading • • 3d ago

Strategy Built an NQ intraday system. Backtest looks good, but I don't trust it. Feel a bit lost, what am I missing?

Thumbnail gallery
70 Upvotes

Honest situation: I've spent some good time building an NQ futures system, and the backtest has reached the point where I no longer trust it, which is exactly what worries me. So I'm asking people with more miles on them than me.

Here's the reality (slide attached). It's swing-based entries on 1-minute bars with an ML filter on which signals to take, long and short, one position at a time, 1 contract, flat before the close. Models retrain monthly, and the model predictions are an average of 12 seeds.

Backtest, Jan 2021 to Oct 2026, 1 NQ, commission and slippage included:

  • +$585k net, max drawdown $24.7k
  • Monthly Sharpe 2.6, 77% positive months, every year positive
  • ~640 trades a year, 45% win rate, profit factor 1.29, ~$158 a trade after costs
  • Costs doubled: still +$520k. A completely different set of 12 models: +$567k
  • most parameters are fine tuned in a walk forward to redeuce hindsight.

Why I don't believe it:

  • not everything is clear of hindsight, some generic concepts are decided after seeing the whole range. (for example: taking shorts only during cash hours)
  • The best four months are 118k of the 585k.
  • The short side is thinner and was flat in 2019-20.
  • I have no untouched history left to test on.

I just started forward paper trading this week. It's a handful of days, so it tells me nothing yet, but at least it's the one test I can't have fitted.

Where I'd love help and feedback:

  1. If you had to bet on how a result like this is secretly leaking or overfit, where would you look first?
  2. Is re-running with a different set of models plus doubled costs a meaningful robustness check, or am I only testing the easy stuff?
  3. Fills: entry at the next bar's open, stops and flattens 0.5 pt worse than the level, targets filled exactly. Too kind for NQ?
  4. How long would you paper trade before putting real money on it?

Thanks for reading. Brutal answers welcome, I'd rather hear it now than from the account.


r/algotrading • • 3d ago

Strategy Results after 6 days of live trading.

Post image
71 Upvotes

Just as the title says it above, I made an other post here earlier.


r/algotrading • • 2d ago

Infrastructure What aren't you able to automate in your trading yet?

0 Upvotes

Backtesting, screening, alerts, order placements, anything else...

What would you like to automate in trading but haven't been able to yet? And why?


r/algotrading • • 3d ago

Infrastructure Looking for an arXiv endorser in q-fin (trading and market microstructure)

4 Upvotes

I have a working paper on automated spoof detection I'd like to post to arXiv under q-fin.TR and I need an endorser. I worked in high-frequency trading and have no university affiliation, so I can't get one through an institution.

If you have posted in q-fin and are willing to look, the link is https://arxiv.org/auth/endorse?x=RZRMEL (code RZRMEL).

Feel free to DM me first to review the working paper.


r/algotrading • • 3d ago

Strategy I backtested copying the top 5 performing hedge funds from Form 13F filings (2016–2026) — 20.7% vs 12.6% SPY, but the control portfolios are humbling

18 Upvotes

Hey folks,

A 13F filing only tells you what a fund held at quarter-end, and by the time it comes out 45 days later their book may have already changed. I wanted to test whether ranking managers by the past returns of their earlier 13F portfolios actually helps pick which current filings are worth following.

We tested this across 49 hedge funds (picked in 2026, so yes there is selection bias here, which is why I ran a bunch of control portfolios below). For each fund we take up to their top 20 non-option stock holdings by value, normalize weights, and rebalance at the close of the first trading session after each filing deadline. The backtest runs across 41 quarters from Aug 16, 2016 to Nov 17, 2026 with 10 bps fees on dollars traded (price returns only, no dividends, borrow fees, or cash interest).

To score managers, we calculate each fund's return between rebalance dates minus SPY over those same dates, and average over the last 4 quarters (requiring at least 2 observations). Then we take the top 5 funds and weight them either equally or by their positive scores. For a long-short version, we also short the bottom 5 using negative scores, netting overlapping stocks on a single cash balance.

Here is how the main 41-quarter run came out:

  • Long only (top 5, score-weighted): 20.7% a year, -33.6% max drawdown, 0.90 Sharpe, 1.12 beta
  • Long-short: 13.5% a year, -39.9% max drawdown, 0.70 Sharpe, 0.07 beta
  • SPY: 12.6% a year, -34.1% max drawdown, 0.75 Sharpe, 1.00 beta

Adding the short leg killed beta (1.12 down to 0.07), but it also cut annual returns from 20.7% to 13.5% and actually made the max drawdown worse (-39.9%).

We also tested changing the lookback (4 quarters vs 8), number of funds (5 vs 10), and equal vs score weights across the same 39-quarter matched window:

  • 4Q lookback, 5 funds: 20.6% score-weighted (14.5% long-short) vs 18.7% equal-weight (8.6% long-short)
  • 4Q lookback, 10 funds: 18.4% score-weighted (10.9% long-short) vs 16.8% equal-weight (5.8% long-short)
  • 8Q lookback, 5 funds: 16.0% score-weighted (5.1% long-short) vs 15.3% equal-weight (0.7% long-short)
  • 8Q lookback, 10 funds: 13.9% score-weighted (2.8% long-short) vs 12.5% equal-weight (-1.3% long-short)

Moving from 4Q to 8Q hurt every single pair, and going from 5 to 10 funds diluted returns. Score weighting beat equal weighting in every pair.

That looks solid on the surface, so we ran a set of simpler control portfolios over the exact same 39 quarters and 10 bps fees:

  • Score-weighted fund ranking: 20.6% a year, 0.88 Sharpe, -33.6% max drawdown
  • Equal-weight fund ranking: 18.7% a year, 0.83 Sharpe, -33.2% max drawdown
  • Current holdings momentum (ranking managers by the past-year return of the stocks in their latest filing, top 5 equal-weight): 18.7% a year, 0.80 Sharpe, -35.1% max drawdown
  • Top 20 stocks by prior 3-month dollar volume (no 13F data at all): 19.9% a year, 0.80 Sharpe, -44.0% max drawdown
  • Straight 13F consensus (most widely held stocks): 14.6% a year, 0.69 Sharpe, -50.3% max drawdown
  • Random 5 funds each quarter (200 runs): 11.2% median (middle 90% between 7.4% and 14.2%, none matched 18.7%)
  • SPY: 12.4% a year, 0.73 Sharpe, -34.1% max drawdown

A few other things that stood out when stress testing it:

  • Almost all of the outperformance happened in the first five years. Through 2021 it returned 29.7% vs 15.6% for SPY, then 11.4% vs 9.3% from 2022 onward. SPY actually beat the strategy over the last 8 quarters and the last 16 quarters.
  • Fee sensitivity over the full 41 quarters (0 / 10 / 20 / 50 bps): long-only went from 21.1% down to 18.9%, while long-short dropped harder from 14.4% down to 10.1%.
  • Statistical significance is pretty noisy. The 95% block-bootstrap interval (21-session blocks) for the 0.90 Sharpe was 0.33 to 1.53, and daily regression against SPY gave 6.7% annual alpha with a t-stat of 1.56.

Overall, ranking funds beat random draws and beat plain 13F consensus, and shorting the bottom funds just hurt. But seeing holdings momentum tie equal-weight ranking at 18.7% and a simple dollar-volume rule hit 19.9% with zero 13F data makes it hard to claim there is real manager-selection alpha here rather than concentrated momentum and large-cap liquidity exposure.

Hope this is interesting to folks. Curious if anyone else here has tested 13F strategies with a point-in-time fund universe or factor neutralization, would love to hear what you found.

Original article: https://tradytics.com/blog/copying-hedge-fund-holdings


r/algotrading • • 4d ago

Strategy Results of nearly 20,000 live paper trades from 16 AI models over 1 year (no resets)

Thumbnail gallery
204 Upvotes

I've been running a public AI Trading Arena where LLMs trade paper accounts in real time. The current season started on 7 November 2025, so it has now run for a full year, without a reset.

The setup, unchanged since day one. Each model gets $10,000 of paper capital, the same prompt and the same five markets: Bitcoin, the S&P 500, NVIDIA, EUR/USD and gold. Every 4 hours it decides on its own: long or short, size, stop, target, and when to close. Every entry comes with a written justification. Fees and slippage are charged. Nothing resets when a model blows up.

The board on 23 November 2026. 16 models still live, 19,985 trades between them. They joined between November 2025 and March 2026, so the windows differ. Returns include open positions at market prices, as on the live board.

ModelReturnMax drawdownWin rateTradesSince
Gemini 3.1 Pro (news)+81.6%-22.2%41.7%1,179Feb 2026
Kimi K2.5 (news)+39.5%-16.6%38.6%1,268Feb 2026
Kimi K2 Thinking (news)+26.2%-35.2%40.6%1,882Nov 2025
GPT-5.4 (news)+21.0%-22.6%35.8%732Mar 2026
Mistral Medium (news)+14.2%-47.4%38.0%1,297Nov 2025
GLM 5 (news)+8.7%-16.7%41.5%1,159Feb 2026
GPT-5.4 Mini (news)+6.4%-20.4%36.4%674Mar 2026
MiMo V2 Pro (news)+5.0%-11.9%42.5%746Mar 2026
Gemini 3 Pro (news)+1.9%-41.3%38.2%1,174Nov 2025
Qwen 3.5 Plus (news)-3.3%-19.1%37.1%856Feb 2026
Gemini 3 Pro (price only)-5.6%-48.4%36.4%816Nov 2025
Qwen 3 Max (news)-5.8%-48.0%36.3%1,835Nov 2025
Grok 4.20 Beta (news)-13.5%-28.9%37.1%1,295Mar 2026
DeepSeek V3.2 (news)-15.8%-32.2%42.7%2,411Nov 2025
MiniMax M2.7 (news)-15.9%-22.8%42.7%1,229Mar 2026
Nemotron 3 Super (news)-22.5%-37.5%37.0%1,432Mar 2026

"News" means the model also reads a real-time news feed. "Price only" means candles and nothing else.

1. Five models were up about 80% or more at some point. Four gave most of it back.

  • Mistral Medium peaked at +117% on August 21st. It is at +14% today.
  • Kimi K2 Thinking peaked at +82% on October 7th. It is at +26%.
  • Gemini 3 Pro (price only) peaked at +80% on February 9th. It is at -6%.
  • Qwen 3 Max peaked at +79% on February 6th. It is at -6%.

2. The leader keeps changing.

Qwen 3 Max led the board on 1 January and on 1 April. Mistral Medium led in mid-July and again in late September. Today's leader, Gemini 3.1 Pro, was third on both of those dates. Back the leader at any of those four dates and you would hold +14% or -6% today.

3. Win rate tells you nothing.

Every model wins between 35% and 43% of its trades. The highest win rate on the board, 42.7%, belongs to DeepSeek V3.2, which is at -16%. It also trades the most (2,411 trades) and holds the shortest, 8.5 hours on average.

4. Fees took most of the profit.

The 16 accounts started with $160,000 between them and hold $172,200 today: +$12,200 net ($1,700 of it still in open positions), after $34,800 of fees. Before fees, the same trades made about $47,000, so fees took about three quarters of it.

5. They still bet big.

The median position open right now is 35% of the model's equity (53 positions open as I write). Yet their size carries no information. Correlation between position size and forward return: 0.007.

What'd be interesting now that we have one year of lookback data is to check whether capping their position size would have made a difference. If yes, we could test that from now on.

For the curious who wonder how much this has cost so far: $3,470 in API calls over the last 12 months.

Happy to answer any technical question!


r/algotrading • • 3d ago

Strategy Does a Bitcoin breakout tell you which side wins a 15-minute Kalshi market?

2 Upvotes

I tested a strategy idea I had on the Kalshi 15 minute BTC market: three minutes after the open of the market we record the highest and lowest price of BTC from the last 15 minutes and use those as cutoff prices. The strategy trades the side it breaks away from based on those cutoff prices. My hunch is that if it breaks past those recent lows or highs it will continue to do so until the market settles.

The first backtest I ran came back positive so I decided to run 100 backtests on the strategy varying the entry price floor and ceiling. All 100 of them came back with a positive pnl with the best being +$387.85 with a 1.34 Sharpe Ratio. The worst reported a pnl of +$12.16 and only had 16 settled positions versus the 624 settled positions in the winning version showing how much the entry price settings affected the performance.

I plotted the 100 varied backtests’ pnl to parameter combination on a 3D surface to expose if the winning combination is due to lucky parameters. This graph was mostly smooth and gradually sloped up to a plateau of ideal combinations which is a good result.

I also ran a permutation test which reshuffles the coinbase signals and reruns the 100 backtests 100 more times with the reshuffled data, to check if the positive backtests were due to the signals that the strategy uses coincidentally lining up with profitable trades vs. an actual edge the strategy has discovered. The winner beat 99% of the reshuffled backtests suggesting that the strategy exploits real market structure rather than just signal to profit aligned luck.

Backtests of course will not guarantee this strategy is successful on their own, but I think this is the best setup I've seen so far going into paper trading.

Full Report


r/algotrading • • 3d ago

Strategy Question about luck

0 Upvotes

So you have a trading strategy that provides an 80% win rate with a r/r of 1:1. If you have a million simulations you’ll get totally different results from super unlikely to likely. So even if you have the best / worst strategy the outcome could be the opposite? How do people get the head around this? Everything is luck.. ?


r/algotrading • • 4d ago

Strategy Switched from discretionary to algo trading. did it actually fix your emotions and risk management?

6 Upvotes

For retail traders who switched to algo/systematic trading, how did it actually play out?

​1. Discretionary challenges: What was the final straw that pushed you to automate?

​2. Emotional attachment: Did letting a bot execute actually remove fear and greed, or do you still get tempted to manually intervene during drawdowns?

​3. Risk management: Did hard-coding your rules stop revenge trading and bad sizing, or did it just create new problems (like over-leveraging a curve-fitted backtest)?

​Would love to hear the honest pros and cons from folks who made the jump.


r/algotrading • • 3d ago

Education Broker api timed out on an order placement. did the order go through? how do you deal with this?

2 Upvotes

This is the bug that scares me more than any strategy bug.

your code sends a place-order request. the broker is slow, your http client times out, or the socket drops at that exact moment. you get no order id back. from your side the order failed. on the exchange it might already be filled.

the obvious fix is to retry, and that's how you end up with double the position. we did exactly that early on while building an execution engine for indian brokers. retry on timeout looked harmless in testing because the sandbox always failed cleanly. real brokers on a busy expiry morning don't.

what we ended up doing:

every order gets our own tag before it leaves, written to the db first and sent second. a timeout puts the order into an "unknown" state, not "rejected". nothing else for that leg fires while it's unknown. a reconciler checks the order book and tradebook, matches on the tag, and only then moves it to placed, filled or rejected. if it can't settle it within a short window, it alerts a human instead of guessing.

it's not free. you react slower. not every broker reliably echoes your tag back in the order book, so sometimes you're matching on symbol + qty + time, which is fuzzy. and the polling eats into your rate limit right when the broker is already struggling.

how are others handling this? do you retry placement at all on a timeout? has anyone found an indian broker api with a proper idempotency key so this whole problem goes away?