Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Live Trading: counter-trades

I was wondering how do you protect your algorithm from being taken advantage of during live trading sessions. A while back I watched a TED talk about how one set of companies "sniff out" trading patterns/signals out of the trading data and trade against them.

I thought I could use some sort of random function to introduce some variability in my purchase/sale patterns but that seem to be restricted.

The trouble with back-testing is that it does not take into account the actions of other players who are "listening" for trading patters in the live trading stream.... To the extent that this is true, your algos may not work in live trading despite producing good back-tested results.

Has anyone looked into this?

3 responses

Regarding the use of a random function, it is not actually restricted, as I understand. Rather, you need to use a fixed seed for the pseudo-random number generator, so that backtests are repeatable. You can use this:

http://docs.scipy.org/doc/numpy/reference/routines.random.html

This may be blocked, however (probably unnecessarily):

https://docs.python.org/2/library/random.html

Thanks Grant.

I can see how a fixed seed could be useful for replicating results, but for live trading, could we incorporate a truly random number (system clock?) into the timing of trades?

My investment thesis is that as long as stock attributes are in the acceptable range, timing of the trade should not matter (they would not change from one minute to another anyway). In addition to eliminating the effect of timing on returns, randomization could protect you from others "reverse engineering" your trading algorithm. My concern is writing algorithms with predictable trading patterns that are easy to front-run or trade against.

Maybe the problem isn't as bad as I make it sound...

I think that the fixed seed is required so that results can be replicated by Quantopian if your algorithm is live trading, I'm guessing for quality control (e.g. if a change is made to they platform, they can run algos before and after the change, to make sure that they aren't affected). I think that the terms of service may also allow them to run any algo on the platform and examine its "exhaust" (not its code) as a candidate for the hedge fund. So, they'd want results to be repeatable.