Back to Community
Wash Trading

Hey does anyone know how to program it so that a system won't wash trade(selling a stock to yourself)?

3 responses

The Quantopian order methods handle 'wash trading' for you. You will never see both a long and a short position for the same security in your account. The most you will ever see is a single position for a security which will have either a positive or negative value indicating a long or a short position at any given time. If you order a negative qty of shares the order method simply decrements your current holdings of that security. If you order a positive qty it increments it. For good or for bad, in Quantopian you don't actually specify long sales or short sales rather you just increase or decrease your position. The good is you never need to worry about 'wash trades'.

I got an email from Robinhood saying I executed a wash trade, because of my Quantopian Algo, it sold a security to myself.

Ahh, yes I can see that may happen. While the quantopian order methods don't generate both long and short orders AT THE SAME TIME, I can see how a long order could be placed while a previous short order is still not filled. The order method doesn't look at pending orders.

Maybe take a look at this post https://www.quantopian.com/posts/new-orders-filled-without-of-my-control .

The simplest may be to qualify placing any orders with get_open_orders returning an empty dictionary (if that works with your strategy).