Frustrated with Alpaca's Wash Trade Flags on My HFT Strategy

I’ve been working on a high-frequency trading strategy that profits by winning microtrades. It’s all about quick buy/sell orders on the same stock throughout the day, but Alpaca’s been flagging my trades as wash trades. I’m not here for tax manipulation or anything shady—just trying to profit from small price movements.

This whole situation is a major setback. It’s frustrating that Alpaca doesn’t seem to distinguish between actual wash trading and legitimate HFT strategies. My trading’s been unnecessarily handcuffed because of this, and I’m stuck wondering how to move forward without ditching Alpaca for another platform.

Anyone else dealing with this? How are you managing or working around it? I need a solution that lets me run my strategy without getting flagged all the time.

Thanks for any advice or insights you can share.

@Roi_Bel Perhaps elaborate more on why this creates issues for your strategy. The Wash Trade Rule simply implies one cannot be both buying and selling at the same time. Algos typically respond to either a ‘buy’ signal or a ‘sell’ signal and therefore would either be buying or selling and not both. If, in a odd circumstance where both buys and sells are created, then simply submit a single order for the net of those orders.

If my algorithm were to buy for example 10 AAPL stock and 5 minutes later sell those stock to secure a +1% margin, wouldn’t this be detected as a wash trade?

@Roi_Bel If your algo submitted an order to buy 10 AAPL, then that order filled, then 5 minutes later the algo submitted an order to sell 10 AAPL, that would not be a wash trade. A wash trade is where a buy and a sell would fill against each other. Since the buy and sell orders were not open at the same time they would never fill against each other and never create a wash trade.

In my specific case, my algorithm trades on news that is released during pre-market hours. So if a news article is released that indicating a positive sentiment about a specific company, then I’ll enter a long trade on that companies stock. Conversely, if a few hours later still before markets open another article is released suggesting a negative sentiment towards the same company, then I want to cancel my previous trade and enter a short position on that stock.
The wash detection algorithm flags this as a wash trade, despite it occurring outside of open market hours, and it completely hinders my progress with my strategy.
Thank you so much for the support, I really appreciate it

@Roi_Bel Hmm. From what you explained, “then I want to cancel my previous trade and enter a short position on that stock” that will not be a wash trade. You do not have both a buy and a sell open at the same time since you cancel the previous buy before submitting a sell.

One thing that may be happening is the algo is not waiting for the initial order to actually be cancelled. Canceling orders (ie DELETE order) is really just a request to cancel the order. One must wait until the order actually gets canceled which happens asynchronously in the background. I personally just fetch all open orders before placing a new order. If there is already an open order for the symbol I do not place the new order and try again later. But, of course there are other approaches.

The other thing, and this is a long shot, what is the exact error you are getting? Could it be that the second sell order is being rejected not because of a wash trade but rather because it would create a day trade? If the account has less than $25,000 in equity it could be getting blocked for that.

Ah, I see where the confusion has come from! When I mentioned ‘canceling’ my trade, what I actually meant was balancing it out with an opposite position. So, for example, if I’m looking to exit a short position before the market opens, I’d place a long order for the exact same number of shares. The idea of literally canceling an open order had never crossed my mind! I’m going to give this fix a shot tomorrow before markets open, and hopefully my wash trade issue will go away. Thanks a ton for pointing this out!

Quick question on this note: Is it possible to partially cancel an order? Say I’ve bought 100 shares of AAPL in one trade; can I cancel just 30 of those shares, or is it an all-or-nothing deal? If not, should I start trading in groups of small individual trades instead of a single large trade to give me more customizability over my canceling options?

Thanks a lot! I really really appreciate the support!