SYSTEM
AND
QUANTITATIVE METHODS
Learning Objective Statement
• Outline the investment process
• Describe quantitative analysis
• Outline the steps of the scientific method
• Express how an analyst can apply the scientific method to the investment process
• Explain how survivorship bias can impact quantitative test results
• Review when to use trigger rules, filter rules, and value rules
• Summarize signals, strategies, and models
• Explain the issues with using a backtest first, and explain the benefit of a signal test
12. Converting Condition Rules into Triggers
*Context:
- Condition 1: price must be above the 200-day moving average and,
- Condition 2: the Average True Range Percentage (ATRP) must be
below 5%.
- We need the two conditions to be “true” value.
- Boolean value = 0 for false and 1 for true.
*Coding script:
// store if the price is above the 200 SMA
var1 = Close() > MA(BARS=200);
// store if the ATRP is below 5%
var2 = ATRP() < 5;
// add the two variables together
var3 = var1 + var2;
// trigger when the sum(var3) changes to 2
var3 ChangeTo 2
- By this way, we change two non-discrete events into one discrete
event that can give us “trigger” signal!
13. The Role of Backtesting
3. First Trade Bias
- Backtesting allows the technical analyst to verify trading rules on historical data - Possibly the biggest driver of backtest success is the very first trade.
and simulate how well strategy performed. - This is magnified when the position size is a significant portion of the
- The results become a guide of what could be expected if the model was traded available capital.
on the market. - The figure: because of compounding returns, the difference between the
- We will be disappointed with the results when putting ideas into the market. two only grows larger the more trades that are added.
- Often these non-rule inputs into the backtest are set by guesswork rather than with
*The reasons: a full understanding of the opportunity the idea captures.
1. Too Many Degrees of Freedom - Backtesting is a critically important part of a quantitative process, but it is not
- What is our entry rule? where we should start.
- When do we exit? - We should first test our idea in isolation – the signal testing.
- Where do we place our stops?
- How much capital do we start with?
- How big will each position be?
- What date range should be tested?
- The issue is that each of these decisions impacts the result of the backtest.
- We need to isolate it for testing to see if that idea is worth pursuing or not.
2. Path Dependency
- There are hundreds, if not thousands, of other decisions we could have made.
- Every decision made impacts all of the available trades.
- The result we achieve with a backtest is completely dependent on the “path”.
- Only a specific selection of the available trades that match our entry rule will be
acted upon.
- The result is due to the path taken rather than due to the ability of our technical
analysis rule to capture an opportunity. It tells us nothing about the suitability of
our idea.
14. Signals – Strategies - Models
*Second step: Strategy *There are several types of strategies we
Testing can employ:
A strategy is the - Long signal strategy
combination of: - Short signal strategy
- Entry rules - Ranked rebalance strategy *Final step: Model Testing
- Exit rules - Long/short rebalance strategy - We combine multiple strategies to reduce the volatility in our
*First step: Signal Testing
- Starting capital - Overweight/underweight rebalance portfolio and to build consistent returns.
- Signals occur when our rules (our idea)
- Position size strategy - We define the rules of when the strategies are activated and
are triggered. And we should act.
- Stops - Buy/hold strategy how much capital is allocated to each strategy.
- Signals are not trades.
- Each strategy in the model directs its trades to the one
- Each strategy can be backtested independently and the results analyzed.
shared portfolio. In this way, strategies can be added and
- Key results: when we should be using this strategy or other strategies.
removed, or allocations between strategies adjusted, and the
- There is no magic strategy that will yield consistent returns in all market
impact on the overall portfolio measured.
conditions.
>>> Having multiple strategies that can be used together, or selected
independently, is an attribute that will set us apart.
15. The Quantitative Process
*Inspection *Signal Testing *Strategy Testing *Model Building
- Using a charting tool that allows - This step consists of testing the - Once we know the - There is no single magic
you to visualize when your rule signals generated by finding all profile of our signal, strategy. The more we try to
will trigger can save you from the signals and analyzing them. we can build an tweak a single strategy to
generating false signals and appropriate strategy accommodate all market phases,
rejecting your idea. and test that. the less effective it will be.
- A comprehensive model is one
that can target risk levels and
combine multiple strategies
together.
15. The Quantitative Process...
*Signal Testing
- When the conditions of our idea are met, we call that a signal for us to act on our idea.
- The way we test our signals is to find every instance of the signal through as much data as
possible.
- We take note price, returns over the following week, month, year, or quarter and repeat this for
every signal we find.
- We have no position sizing rules, no exit rules, no stops ( isolating the signal for testing).
- All we want to know is whether our idea is something that will capture, on average, a positive
return over a fixed amount of time.
- We can average the returns on each day, calculate the probability of gain, and study the average
path taken after our signal.
- The green plot shows the average path our signal took over the test period with 7,458 signals.
- The yellow plot is the average returns of the index (the benchmark - Nasdaq 100) with average of
7,458 signals on the benchmark.
- The red line shows the difference between the green line (our idea) and the yellow line (the
benchmark).
- The goal of a signal test is to understand the probability a signal will end in a profit and what
that average profit is.
15. The Quantitative Process...
*The most essential information of 63 trading days:
*Probability of gain (sometimes called the win rate)
- What percentage of our signals ended in profit after 63 days? Our target is to be over 60%.
*Mean return
- This is the average return of all the signals.
- If the mean and median are within a few percentage points of each other, then we know the
mean is not being overly influenced by outliers (extremely large wins that are distorting the
result).
*Standard deviation
- The smaller the standard deviation, the higher the probability that each signal will land in a tight
band around the average return value.
- Because the distribution is rarely “normal,” we often use an 80/20 interval as well.
*Profit analysis plot
- This is a standard frequency distribution that counts how many times each return was achieved.
We expect this plot to be a normal distribution with the peak at the mean return.
- If the plot was leptokurtic (very high but narrow peak), we would be happy because it increases
the probability we would be able to repeat this result every time we act on a signal.
*Main returns plot
- The signal profile starts outperforming the benchmark right from the start of the signal and
continues to do so throughout the whole testing period.
- If there was no advantage immediately when the signal occurred, we may be better waiting a
few days before acting.
- Similarly, if there is a massive outperformance immediately when the signal occurs but no
discernible outperformance after that, we may consider a time stop so we can release capital for
new opportunities.
15. The Quantitative Process...
*Two kind of Standard Deviation:
1. The distribution of returns.
- We are calculating an average from the returns of many signals. Whenever we calculate an average, we can also
calculate the standard deviation to give us an idea of the dispersion of those results.
- An average return of 10% over a month with a standard deviation of 1% would be an incredible result. It is telling us the
majority of signals are clustered around the 10% return. If the standard deviation was 50%, that would give us less
confidence in this signal.
2. The average deviation in the prices themselves.
- No security (or trade) travels in a straight line from entry to exit. There are always deviations around a moving average.
This is the same as the volatility we measure in a security. That value can also be averaged so we know what the signal
volatility is. The more volatile the security, the higher the deviation will be for that signal. Sometimes our signals can
occur when volatility is high, and the risk associated with a trade would be too great.
- If we only had one signal a month, we would use a large position size. If there were 10 signals a day, we would use a
smaller position size so that we were able to take advantage of the signals to diversify our holdings.
- Signal testing is a powerful first step in the quantitative process and it is not limited to equity traders who can script
their ideas into code.
16. Quant for Discretionary Analysts
*Different Strokes for Different Folks *How to Be Quantitative
- There are times when a discretionary approach works just as well as an - Track every trade and review its returns over a consistent period of time, whether
automated scan-based approach. we have the capital to take the trade or not.
- Futures trader: traded a single instrument — the Share Price Index (SPI)
futures in Australia using hand-charting the security. - Separate ourselves from the ego of needing to be right and focus on whether this
- The market: the volume was low, and consequently, the volatility was high. signal is worth using in our selection process.
- The reason this client was discretionary was that his criteria to trade, or not, - How difficult it is to see a signal at the start of the chart and ignore where that chart
was not easy to code into rules. goes after the signal.
- If you are working for a grain storage company, you may just analyze wheat, - If the market makes a loss after the signal, it can be easy to make up reasons why
corn, and soybeans, because that is all that is important for your decisions. we would not have taken the trade.
- Single security analysis lends itself to discretionary techniques like counting - Covering up the future data of the chart.
and cycles, including Gann analysis. The process was designed to remove the look-ahead bias (a bias that occurs when a
study relies on data or information that is not known during the study), and to allow
us to replicate the real-life scenario of being presented with a signal and having to
decide if we will act or not.
16. Quant for Discretionary Analysts...
*Quantitative Recordkeeping
*Why Only One Week to Three Months
- The recordkeeping helps us fully understand the quantitative process and how all
the calculations are performed. - Long-term investments are not where technical analysis gives the greatest
advantage.
For each signal we find, we need to record the following: - The markets rise and fall on fundamentals.
- Date - Technical analysis does not impact the market, but rather it gives us early warning
- Ticker when trends are changing.
- Price
- Return one week later - One CMT candidate was a technical analyst in a fundamentally driven firm:
- Return one month later The decisions to invest were made based on fundamental reasons, and when a
- Return three months later position was taken, it was typically held for months.
The technical analyst’s role was to decide when to execute.
*Calculate the Results
- Once we have our signals recorded, we can calculate the most important metrics
to give us an idea of the advantage our signal is giving us.
- Average return (annualized)
- Probability of gain (win rate)
- Standard deviation of returns
17. The Importance of Context
*The Importance of Context
- When we run a signal test over several years, we get the results for all the signals in the test
period no matter what the market conditions were.
- The rationale is that we should know the overall statistics of our signal over all time. With that
knowledge, we can have realistic expectations of how it would perform as part of a strategy no
matter what market conditions we are faced with.
- What if we can define the conditions both historically and in real time?
*Going Deeper
- The market environment becomes the context in which we should analyze our signal. We
compare the key values for the overall results against these two years.
- The Optex Signal being tested is a mean-reverting long signal, so this should not be surprising.
- In 2008, the primary trend was down, but our signal was taking long trades.
- In 2009, the primary trend changed to up, and we see the benefit our signals received.
- The key takeaway from this would be to find an objective way to determine if we should
consider our signal or not.
- We could do this with a moving average, i.e., we only take our Optex trade if the index is above
its 52-week moving average. The issue with this is there is a bit of lag.
- The Average Directional Movement Index (ADX) is usually a better way to define trend, and we
can also use it to filter on the strength of the trend.
17. The Importance of Context...
- Adding the ADX filter on the S&P 500 has removed three-
quarters of the signals, but only resulted in a small improvement
in all three of our key metrics, as shown in the table with the
ADX index filter.
- The most notable improvement is in the reduction of the
standard deviation.
When we compare this result to our first test, we see a
considerable improvement in the yellow plot for the index. This
is great because it shows us we are capturing trades when the
index is in an uptrend.
the yellow plot is the performance of the benchmark when our
signals are triggered.
The index is going to have lengthy periods of downtrends that
we are now not participating in.
Outperformance on a signal test plot is not as important as
outperformance in a portfolio.
17. The Importance of Context...
*Market Phases
- “Market phases” is a concept that divides market conditions into distinct phases
based on the business and economic cycles defined in intermarket analysis.
- Each phase is characterized by different leading and secondary asset classes that
tend to outperform during that period, using the four major asset classes: bonds,
stocks, commodities, and currencies.
- The phases are determined by looking at the relative strength chart of each asset
class against the others.
- The asset class that is outperforming all other asset classes is said to be the
leading asset class. In a similar way, we can define which asset class is second.
- Defining the leading and secondary asset classes creates a framework of 12
distinct market phases, each with its own characteristics and optimal trading
approaches.
- Select appropriate trading strategies for current conditions
- Filter trading signals to improve performance
- Adjust risk management parameters based on market context
17. The Importance of Context...
- Not every “stocks leading” phase leads to a downturn, but
there are very few “bonds leading” phases that do.
*Quantitative Goal
- Quantitative analysis allows us to know not only the value of
our idea, but also when market conditions are right for us to
activate our strategy.
- The goal will be to find strategies that maximize returns in each
of the 12 phases. That may mean strategies are switched on or
off, or it may mean the funds made available to the strategy are
adjusted. However, sometimes the best strategy is just to be in
cash.
18. Example 1: CFD
Signal Testing: different trend speeds.
System Testing: different systems
Porfolio Testing: uncorrelated assets.
Example 1: CFD
- Short term trend system.
- Donchian Channels breakout.
19. Example 2: VN Stock vs Commodities
Example 2: VN Stock vs
Commodities
- Long term trend system.
- SMA direction.
Thank You
For Your
Attention
Connect with us.