What is the probability of profit
of your next trade? You would think every trader can answer this simple
question. Say you look at your historical trades (live or backtest) and count
the winners and losers, and come up with a percentage of winning trades, say 60%. Is the probability of profit of your next trade 0.6? This might be a good
initial estimate, but it is also a completely useless number. Let me explain.

This 0.6 is what may be called an *unconditional
probability *of profit. It is the same for every trade that you will
ever make (unless your winning ratio changes significantly in the future), so
it is useless as a guide to whether you should take the next specific trade or
not. It can of course tell you whether you should trade this strategy in
general (e.g. you may not want to trade a strategy with an unconditional
probability of profit, a.k.a. winning ratio, less than 0.51). But it can’t do
so on a trade-by-trade basis. The latter is the *conditional probability* of
profit. As the adjective suggests, this probability is conditioned on the
specific market environment at the time when you expect to trade.

Let's say you are trading a short volatility strategy. It can be an algorithmic, or even discretionary, strategy. If you are trading it during a very calm market, it is likely that your conditional probability of profit would be quite high. If you are trading during a financial crisis, it could be very low. The conditions that can determine the probability may even be quantifiable. The level of VIX? The recent SPY returns? How about the interest rate change or Nonfarm Payroll number just announced? Or even the % change in Covid-19 cases on the previous day? You may not have taken all these myriad numbers into account when you were building your simple trading strategy, or when you decide to make a discretionary trade, but you can't deny they may have an impact on the conditional probability of profit. So how are we to compute this probability?

*Spoiler alert*: computing this conditional probability helped us earned 64% YTD return as of June 2020. You can find out how to do that with predictnow.ai. But more on that later.

The only known way to compute this
conditional probability is machine learning. Let's return to the example of
your short volatility strategy above. Suppose you prepare a spreadsheet of the
returns of the historical trades you have done, like this:

Again, these trades could be due to
an algorithm, or it could be discretionary (perhaps based on some combination
of fundamental analysis and intuition like what Warren Buffet does).

Now let's say we only care about
whether they are profitable or not, so we ignore the magnitude of returns and
label those trades that are profitable 1, otherwise 0. (These are called
"metalabels" by Marcos Lopez de Prado, who pioneered this financial machine learning technique. They are “meta” because he
assumed the original simple strategy is used to predict the ups and downs of
the market itself – those are the base predictions, or labels. The metalabels
are on whether those base predictions are correct or not.) The resulting
spreadsheet looks like this.

Simple, right? Now comes the hard
part. Your intuition tells you that there are some variables that you didn't
take into account in your original, simple, trading strategy. There are just
too many of these variables, and you don't know how to incorporate them to
improve your trading strategy. You don't even know if some of them are useless.
But that's not a problem for machine learning. You can add as many variables,
called features / predictors / independent variables, as you like, useful or
not. The machine learning algorithm will get rid of the useless features via a
process called feature selection.
But more on that later.

So let's say for every historical
trade (represented by a row in the spreadsheet), you collect some features like
VIX, 1-day SPY return, change in interest rate on the previous day, etc. We
must, of course, ensure that these features' values were known prior to each
trade's entry time, otherwise there will be look-ahead bias and you won't be
able to use this system for live trading. So here is how your spreadsheet
augmented with features may look:

OK, now that you have prepared all
these historical data, how do you build (or "train", in machine
learning parlance) a predictive model based on that? You may not know it, but
you have probably used the simplest kind of machine learning model already,
maybe way back in a college statistics class. It is called linear regression,
or its close sibling logistic regression for our binary (profit or not) classification
problem. Those features that you created above are just the independent
variables, often called X (a vector of many variables), and the labels are just
the dependent variable often called Y (with values of 0 or 1). But applying
linear or logistic regression on a large, disparate set of features to predict
a label usually fails, because many relationships cannot be captured by a
linear model. The nonlinear co-dependences between these
predictors need to be discovered and utilized. For example, maybe when VIX
<= 15, the 1-day SPY return isn't useful for predicting the probability of
profit of your trade. But when VIX >= 15, 1-day SPY return is very useful.
This type of relationship is best discovered using a "supervised" hierarchical
learning algorithm called random forest, which is what we have implemented
on predictnow.ai.

To build this tree, and all its cousins
that together form a "random forest", all you need to do is to upload
your spreadsheet above to predictnow.ai,
click a button, and it will probably be done in less than 15 minutes, often
much sooner. (Certainly faster than a pizza delivery.)

Figure 6: Uploading training data.

Once this random forest is built
(trained) with historical data, it is ready for your live trading. You can just
plug in the latest values for VIX, 1-day SPY, and any other features into a new
spreadsheet like this:

Figure 8: Live trading input.

Notice that the format of this
spreadsheet is the same as the training data, except that there is no known
Return of course - we are hoping to predict that! You can upload this to predictnow.ai together with the model you
just trained, press PREDICT,

Figure 9: Live prediction.

and
voila! You can now download the random forest's prediction of whether that
trade will be profitable, and with what** conditional probability**.

One of the output files (left in
Figure 10) tells you the most likely outcome of your trade: profit or not. The
other file (right one in Figure 10) tells you the probability of that outcome. **You
can use that probability to size your trade.** For example, you may decide
that if the probability of profit is higher than 0.6, you will buy $10K of
TSLA. But if the probability is between 0.51 and 0.6, you will only buy $5K,
while if the probability is lower than 0.51, you won’t buy at all.

Typically the live prediction will
take 1 second or less, while the training (which may not need to be re-done
more than once a quarter) typically won't take more than 15 minutes even for
thousands of rows of historical data with 100 features. You can make live predictions as frequently as you
like (*i.e.* as frequently as your input changes), but if you are a high
frequency trader, you would want to use our API so that our predictions can be
seamlessly integrated with your trading system.

But predicting the conditional
probability of profit for your next trade is not all that we can do. We can
also tell you what features are important in making that prediction. In fact,
you may be more interested in that than a black-box prediction, because this
list of important features, sorted in decreasing order of importance, may help
you improve your underlying simple trading strategy. In other words, it can help
improves your intuition about what works with your strategy, so you can change
your trading rules.

Going back to our example, predictnow.ai can generate such a graph for you:

Figure 11: Features with decreasing importance

You can see that VIX was deemed the most important feature, followed by 1-day SPY return, the latest interest rate change, and so on. Our internal predictive algorithm will actually remove all features that are "below average" and retrain the model, but you may benefit from incorporating just VIX and 1-day SPY return in your simple strategy when it generates a trading signal. Remember, your simple strategy does not need to be an algorithmic strategy. It could be discretionary.

(For the machine learning mavens among you, we use SHAP for feature selection, as discussed in our paper.)

You may wonder why our predictive service is restricted to only taking your strategy’s historical or live trades as input and predicting their probabilities of profit. Why can’t it be used directly to predict the market’s return? Of course it can: you only need to pretend that your strategy is buy-and-holding the market. It can even predict the magnitude, not just the sign, of the return. But as we all know, it is very hard to predict the market’s movement, because of low signal-to-noise ratio. Your own strategy, however, has presumably found a way to filter out those noise, and machine learning prediction is more likely to succeed in telling you what “regime” is favorable/unfavorable to your strategy, and with what probability. Another usage of our service is to use it to predict numbers that are not subject to arbitrage, things such as a company’s earning surprise, credit rating change, or the US nonfarm payroll surprise (as we have already done successfully). In these usages, there are no adversaries (your fellow traders) that are trying their hardest to arbitrage away your trading alpha, so these predictions will be more likely to work far into the future.

(For machine learning mavens, you may
wonder why we have only implemented random forest learning algorithm. The
beauty of random forest is that it is simple, but not too simple. Complicated
deep learning algorithms such as LSTM can indeed take into account the time series
dependence of the features and labels more readily, but they run serious risk
of data snooping due to the large number of parameters to fit. GPT-3, the
latest and hottest deep learning algorithm for natural language processing, for
example, has more than 175 *billion* parameters to fit. Imagine fitting
that to 1,000 historical trades!)

So does this stuff really work? We
have implemented this machine learning system for our Tail Reaper strategy in our fund
around the August of 2019. Yes, the 64% YTD return as of June 2020 (net of 25%
incentive fee!) is nice, but what's more amazing is that the machine learning
program told us to not enter any trade (due to the low conditional probability
of profit) from Nov 2019 - Jan 2020. In retrospect, that made sense because
Tail Reaper is a crisis alpha, tail hedge strategy. There was no crisis, no
tail movement, from which to reap profits in those calm months. But suddenly,
starting on February 1, 2020, this machine learning program told us to expect a
crisis. We thought the machine learning program was nuts - there were just a
handful of Covid-19 cases in the US at that time! Nonetheless we followed its
advice and restarted Tail Reaper. It went on to capture over 12% return later
that month, and the rest is history. *(Past
performance is not necessarily indicative of future results. For detailed
disclosure of this strategy, please visit qtscm.com.)*

Figure 12: Tail Reaper equity curve.

*For readers interested
in a free trial or to participate in a live webinar on how to use **predictnow.ai** to predict the conditional probability of
profit of your trades, please sign up **here**.*

## 22 comments:

Great article ernie!

surely will test my discretionary strategy ,with some extra features, with your tool.

Just a small question : Had your machine learning model seen some crisis situations in the past . If not, what features ( in the meta label model ) do you think hinted the model in feb that there was trouble ahead?

Thanks much.

Hi John,

Yes, the machine learning model was trained using data that contained the 2015 Q4 Chinese stock market crash (even though the base model only trades the ES futures), 2018 Q1 Volmageddon. As mentioned in my article, the out-of-sample test includes the 2020 Covid crisis.

The features include financial inputs from around the world only (no "alternative" data).

Ernie

Hi Ernie,

Thats great!

Do you have a course / workshop where you teach your tail reaper strategy? (I have all three of your books, but they don't mention any tail strategy) .

Thanks a lot!

Hi John,

Actually, my previous blog post mentions some reference articles to trend following strategies that resemble Tail Reaper. Also, my 2nd book Algorithmic Trading did discuss similar momentum strategies as well. I do offer a Quantitative Momentum pre-recorded course that dicusses that. Please see http://epchan.com/EP%20Chan%20Course%20Offerings.pdf

Ernie

Thanks for the article Ernie. How often do you recommend re-training the model?

Hi Alex,

I recommend re-training whenever your data changes by 5% or more.

Ernie

Hi ernie,

Yes, i just read your tail paper . That provides a ton of context.

In "machine trading " you wrote about hidden markov models to tell whether we are in bull or bear market . Have you seen the model giving trouble pointers during march collapse? Or do you recommend for me to test that strategy too on s&p ?

Basically does HMM have the potential to be used as a tail risk strategy?

Thanks again for all your teachings . It has been so much valuable in my trading journey!

Best,

John.

Hi John,

Yes, I heard that HMM already performed well in predicting tail regimes.

Ernie

Hi Ernie -

You are doing some interesting things!

Shouldn't predicted direction accuracy > baseline win rate?

baseline 54-57% win rate -> 66-67% filtered via backtest win rate -> PredictNow.ai 48-49% win rate (predicted direction accuracy vs backtest actual p/l)

Ernie, I spent few hours playing with the PredictNow.ai tool and listened to your June presentation on it. I either am not doing it right, or it's not adding value to models I thoroughly backtested and am live trading. The 2 main models I tried are based on capturing the overnight return in certain equities, buying the close and selling the next open. In the baseline, taking all signals, the win rate would be 54-57%. By adding 10-30 filters and taking only the most productive 1/3rd of the signals, the win rate goes up to around 66-67%. Enter PredictNow.ai, I took my daily data with the variables used in my filters, and the training data results are all below 50% accuracy (ACCURACY SCORE FOR CV = 0.49; AUC SCORE FOR CV= 0.48). Shouldn't predicted direction accuracy > baseline win rate?

Mark,

Yes, if your filters are useful for predicting whether your signals will be profitable, the predictive accuracy and AUC score should be higher than 50%.

Please feel free to email me at ernest@predictnow.ai (with your predictnow.ai username), and we will take a look at your files to see if there is anything amiss.

Thanks,

Ernie

Hi Ernie,

One follow-up question on how to use the service. I have a bunch of features that I created from which I create a strategy. So in my case, the strategy is a function of all the indicators I have (i.e: the average of all the indicators). As I understood the service, the indicators are the features and the strategy output the labels.

When I read the post, I was under the impression that the strategy must be somewhat uncorrelated to the features. In other words if f(x) is the strategy, then x should not include the indicators used as the features of the model prediction. I assume that otherwise we end up with a conditional probability.

Have I gotten this wrong?

Thanks

Hi Alex,

Indeed, the features you use for metalabeling should be different (not necessarily uncorrelated or orthogonal) from the indicators you already use in your base strategy. Otherwise, metalabeling can't add too much value to your current strategy. The idea is to scour the world of predictors that can tell you whether your strategy is in a good "regime" to trade or not, predictors that are not already part of your strategy.

Hope this makes sense?

Ernie

Hi Ernie.

Interesting post. Would this work on sub-daily frequency features? I have a strategy that holds asset for a few days, but checks conditions intraday.

Also - would having Binary features be a problem?

Hi Ankit,

You can apply it to any frequency. It all depends on your labels. Labels can be 1 minute returns, or 1 month returns.

Yes, we can take binary, or in general categorical, features.

Best,

Ernie

Hi, I am posting this comment with the permission of Ernie to introduce my work called yMTa and hopefully have a broader audience for it's recognition. Thanks Ernie.

yMTa, is a freely available Windows software and includes many Market Trading related tools.

I am a developer and have implemented many trading algorithms for the past decade and always looking to find professional traders and include their working trading algorithm in yMTa software for free.

Please note that, I am not looking for a job or fund and just want you take a look at my work in yMTa or let me have an opportunity to show what can be done using yMTa. I also could be able to add new tools or algorithms to yMTa based on your advise or your more specific requirements.

Right now I am looking to find professional people in the field and be able to demonstrate what are the benefits of the tools in yMTa and find ways to make it more useful and have the right path in adding new tools to it.

Please take a look at my software and let's talk if you are interested.

yMTa,

A freely available Windows software, Includes many Market Trading related tools.

t.me/yMTaCh

Yashil MultiTrding

https://t.me/yMTaCh

Email: yashil1@yahoo.com

Telegram: @Yashil1

yMTa Download:

https://drive.google.com/drive/folders/1BHzFSr2pCve2-3KJCRkVOBjYXxaubFx9

yMTa English Telegram channel: t.me/yMTaCh

Old yMTa Persian Telegram channels:

https://t.me/yMT4ch

https://t.me/yMT4notify

https://t.me/yMT4demo

Hi Ernie,

Do you have any recommendation on how might one incorporate an LLC to benefit from active trader status? I am working full time, but also execute more than 80-100 trades a month in a personal trading account. I am thinking of eventually quitting my job and trade full time. Should I register as an LLC ?

Thanks

Hi,

Yes, if you want to limit your liability in case of Black Swan loss, you should incorporate.

To incorporate a LLC is quite trivial if you intend to be the sole member. Just go to bizfilings.com.

Ernie

Hi Ernie,

Not sure my previous comment made it. I wanted to know if for the labels I need to apply the triple barrier method before uploading it to PredictNow.ai or it is something that the service does automatically?

Also I wasn't sure if for trades that are long for multiple days or weeks, if my indicators are daily, which categories should these labels be if 1 is for profit and 0 is for loss?

Thanks,

Carlos

Hi Carlos,

Currently, you will have to create your own labels, as we do not know what your stop loss and profit target are.

The labels for 0 and 1 are generally for a round trip trade. If you have a portfolio with many stocks, you may instead want to predict the daily returns of the portfolio. That way, you can adjust the capital of the portfolio instead of a single constituent.

Ernie

Thanks Ernie. Got it. Do I then need to create the labels using Lopez de Prado's triple barrier method or is that not a must with your service?

Hi Carlos,

Yes, if you plan to use stop loss and profit target, you need to use triple barrier labels. Otherwise, you can apply two, or even just one, barrier.

Ernie

Post a Comment