Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
DIY HFT Algobot

For six years, I wrote studies for TDAmeritrades ThinkOrSwim trading platform. (Initial work @ thinkscripter.com, subsequent work @ nextSignals.com) I literally wrote thousands of studies, all focused on indicating entries and exits for the S&P emini futures market. Bottom line: one indicator emerged with the highest consistency - i.e. showed positive expectancy. (Given a strategy with positive expectancy, the traders job is merely to put on the next trade (great explanation of this by Nick Radge.

So I gave the study to two close friends who were traders and asked them to “beta-test” my killer app, at the right edge of the chart. Their results surprised me. Did it work? Yes …but, in the process of testing, they both independently found something else that was more profitable.

THESIS

  1. The strategic bets you make, in pursuit of spectacular success, simultaneously increase your odds of spectacular failure (the “strategy paradox”).

  2. Today’s market is cohabited by high speed computer-automated traders and pensive investors. Empirically:

• High-frequency trading (HFT) exacerbates market volatility • HFT activation depends on price fluctuations • HFT activity favors price discovery (the auction)

THE STRATEGY (applied to the S&P emini)

  1. Create a custom template for a One-Cancels-Other (OCO) customized conditional order. Set the stop loss at 4 ticks away from entry. Set the profit (limit) order 2 ticks away from entry. Now all you have to do is click on the DOM (depth of market) interface at the price level you want to buy or sell. (Don’t worry about the 1:2 Reward:Risk ratio.)
  2. Wait for the auction process to pause. If price and momentum is down-trending (up-trending), sell (buy) - by clicking your desired price on the DOM user interface. When the order fills, you have a 2 tick profit limit order and a 4 tick stop loss order bracketing your entry.

So everyone can clearly see how this works, I screen captured 2 consecutive trades on /ES, this morning, shortly after the open. The Quicktime video lasts 1 minute, shows the order template settings and how to execute the trades. 2 trades, 1 minute exposure, $200. The demonstration video can be downloaded here . (The demo is carried out in an unfunded paper-trading acct.)

CONCLUSIONS

Because volatility is a natural consequence to an auction market process, price continuously fluctuates 1-2 ticks with little apparent directional bias. By simply trading with the trend, in both price and momentum, the vast majority of the orders profit. The strategy comes under the category of “feeding like a bird” and essentially imitates HFT in one of the most liquid markets in the world. Using 4 contracts, each successful trade profits $100 (excluding fees) and generally lasts a few seconds (during regular trading hours). (Do your own math for estimating annualized returns.) With positive expectancy, the trader’s job is merely to put on the trades, one after another. This “job,” however, could be performed automatically and responsibly overseen by the trader.

As an income-based strategy, it is a quite simple arbitrage and I suspect more could be done to tweak its success rate or expand its application to currency futures, e.g. Moreover, the strategy solves the strategy paradox; there is no need to predict direction for the next test of an auction bracket low, etc. And, the strategy is in keeping with Nassim Taleb’s concept of antifragility. Concerning randomness and uncertainty, Taleb writes, “Increasing randomness raises the probability of favorable outcomes and expands the payoff.” [Antifragile: Things That Gain From Disorder]

Folks, I have no experience with IB or with its automated trading functionality. I’m just wondering if, within this community, there is anyone that would like to automate and backtest this idea. If you want to "hack Wall Street," this might be one way! Thoughts and questions welcome.

Stephen Harlin, MD
linkedin.com/in/stephenharlin/

15 responses

Sorry, what exactly has a positive expectancy here?

Hi Simon,

Good pickup. I was ambiguous and neglected to explain that.

For about three weeks, we placed trades exactly as I described. A total of 1545 trades were taken. 77% were winners. No effort to adjust either the STP order or the profit target was made. We just put on the trades, watched the /ES wiggle …and 77% of the time, it wiggled up/down to our profit target before taking out the STP. Since trading is a probability game, we looked at expectancy.

Expectancy = (Probability of Win * Average Win) – (Probability of Loss * Average Loss)

= (0.77 * $100) - (0.23 * $200) = $31

Thus, the expectancy is positive. By setting a STP at -$200 and a limit order (to close) at +$100 …using an approach with a 77% chance of winning - there is 31% profit for each dollar wagered.

Hope that clarifies my reference to positive expectancy.

(Because our sample size is relatively small, albeit forward-tested, I thought I'd see if anyone here had an idea about how we might automate and test this with more validity.)

Stephen

Thanks - I meant do you have any clarification on rule 2? That would seem to be the key to this system. If we can nail down what "pause" means, what "price" and "momentum" trending mean, quantitatively, then we have a shot of back-testing this system.

What about slippage and comissions ?

And in Quantopian the minimum timeframe to trade is 1 min, not very good to compete with other HFT platforms/traders ...

Yes, Quantopian is not the right platform to scalp futures, but nonetheless, if there's a viable strategy in this somewhere, I'd like to flush it out! :)

Simon, working through a valuable answer to your question. Will post.

Antoine, good point ...didn't know about the 1-minute limit. Don't see a need to compete at a milli-second level though. I'll look at 1-minute aggregate. (Been living in tick charts.) Slippage in /ES futures not an issue. Commissions are obviously high ...but just the cost of doing business. We don't like them but they don't amount to enough to dissuade us.

As Antoine points out, this may be the wrong venue for this discussion. But Simon, here are some thoughts.

First, the strategy is directional. A long or short bias must exist at initiation. ( I'll discuss a buy-side scenario.) For a long to be profitable, you merely need the next bar (or few bars) to up-auction 2 ticks ...before down-auctioning and taking out your stop at 4 ticks below entry. So the strategy requires a bias and a one-bar-ahead prediction to be successful.

Professor Robert Ingle won a Nobel Prize for his ability to predict stock market returns one-bar-ahead!

Read about neural networks' ability to predict one bar ahead here.

What follows is one very simple scenario - for longs - that has a high predictive value.

Instrument: S&P eMini futures
Chart: 1085 ticks
Study period: 5 days
Position size: 4 contracts
Number of price bars during period of study: 1,959
Number of buy signals: 57
Precondition for buying the next bar: close > open and close - open = 4 ticks (Note: precisely 4 ticks. This is your signal to buy on the next bar.)
Entry level: When the 4-tick bar prints, place a buy order at 1 tick below its the 4-tick bar’s close
STP loss: 4 ticks below entry level (using a bracketed OCO order template)
Profit target: 2 ticks above entry level

The thinking here is this: when buyers push price up one full point (4 ticks), there is likely to be sufficient momentum to reasonably expect 2 ticks of follow-through, in the near-term.

So I looked at /ES for the past 5 days, wrote signaling studies with counts to see what would you get if you only took longs …after a 1 point up-bar printed. How often would you make your 2 ticks without getting your 4 tick STP loss order hit?

Here are the numbers from this very limited (5 day) test:

Total number of buy signals in 5 days:
57

Signals that resulted in $100 profit:
52

Signals that resulted in $200 loss:
5

Note: That’s a positive predictive value for this single specific buy signal of 91%. So, one point up-bars get a lot of follow-through. No big surprise.

52 profitable trades: $5200
5 losers: -$1,000
Fees & Commissions (IB) for 57 trades: -$458.28

Net profit: $3,741.72

(That’s nearly a $200,00 annual income garnished from a one price bar signal.)

Simon, since there are multiple ways to improve this, I think that if you’re interested in working on this further, why don’t you direct message me and we’ll take it from here. One could play with the STP, e.g. get out earlier on early adversity …use other indices for buying/selling pressure, etc. There's an inherent asymmetry in long and short signals ...that would need to be ironed out. There are countless variations on this theme.

I mainly wanted to share a sense of how a simple strategy that has positive expectancy can achieve accumulation …through small position sizing, defined risk, and withdrawing profits at a nearby target. But you guys have skills I don't have when it comes to nailing these things quantitatively. So I wondered what you might think!

If anyone thinks that this basic idea is enticing, could be further developed, automated, backtested, moved to a one-minute timeframe ...whatever …and that this is actually the right forum for this sort of thing, I’m game! Otherwise, give it a shot ...see what you think. Trade well.

Kind regards,
Stephen

What is the "auction" phase for E-mini S&P???

Hi Dimitrios,

My use of the term “auction” comes from Auction Market Theory. Briefly, the market uses an auction process in its quest for value. The market constantly rotates between horizontal development (aka periods of consolidation or balance) and vertical development (“up-auction or “down-auction”, aka breakouts and breakdowns). While in vertical development, the market is in search of value. However, when most market participants roughly agree that the market is fairly priced, the auction process is more range confined. There’s a great summary of the terms used in auction market theory here.

Hi Dimitrios,

My use of the term “auction” comes from Auction Market Theory. Briefly, the market uses an auction process in its quest for value. The market constantly rotates between horizontal development (aka periods of consolidation or balance) and vertical development (“up-auction or “down-auction”, aka breakouts and breakdowns). While in vertical development, the market is in search of value. However, when most market participants roughly agree that the market is fairly priced, the auction process is more range confined. There’s a great summary of the terms used in auction market theory here.

So quoting from your original post:

THE STRATEGY (applied to the S&P emini)
Create a custom template for a One-Cancels-Other (OCO) customized conditional order. Set the stop loss at 4 ticks away from entry. Set the profit (limit) order 2 ticks away from entry. Now all you have to do is click on the DOM (depth of market) interface at the price level you want to buy or sell. (Don’t worry about the 1:2 Reward:Risk ratio.)
Wait for the auction process to pause. If price and momentum is down-trending (up-trending), sell (buy) - by clicking your desired price on the DOM user interface. When the order fills, you have a 2 tick profit limit order and a 4 tick stop loss order bracketing your entry.<

What does "wait for the auction process to pause" mean?

I know what he means intuitively from my past as a trader - when you are in the zone, watching the tape and the depth, you can feel the activity as people are busy bidding and matching orders, but then, fairly regularly, there's a pause while everyone seems to catch their breath and wait for the next move. This is usually a good time to place breakout stops. I haven't had much luck systemizing these pauses though. I recall Linda Raschke (maybe? it was so long ago) had an indicator that relied on volatility compression to signal good times to wait for breakout moves. These are also the foundation of the "triangle breakout" setups etc etc. I haven't checked in on these sorts of indicators in years though to see how well they work.

I suppose these days I might try to build something that uses the previous five minute price range compressing combined with the trade frequency declining... perhaps that will be a weekend project for me...

In auction market theory, the price discovery process is characterized - in simple terms - as “run-**pause**.” Market’s auction within a relatively narrow range (the “**pause**”) before they up-auction or down-auction to retest a prior level and/or seek fair market value at a new high/low (the “run”).

The market is constantly auctioning and testing levels. So, what I was referring to is simply waiting to initiate a position until the market slowed down a little bit. As Simon suggests, technically, this is a time when the rate of change in price, momentum, and volatility all tend to contract. I, personally, monitor the expansion and contraction of volatility and momentum ...essentially constantly. (See below.)

I've attached an image of SPY with a subgraph showing implied volatility and momentum overlapping. Look at the spreads ...when the spread widens - e.g. implied volatility is peaking and momentum is troughing ...the market generally pauses and reverses to the upside. The opposite is true when implied volatility has reached a nadir while momentum has peaked. The SPY (day chart) really provides a nice example of this; take a look here.

Simon, good luck with your weekend project! Sounds sharp.

Stephen - ever make more progress with this?

Yeah, cool idea. But i doubt you could apply any tick by tick strategy. However did you find a way to code it?