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)?

2 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'.

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 .

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