Stockpicker – Introduction of a new engine in StrategyQuant X

There are many ways to trade equities (stocks, ETFs, etc.). SQX has the ability to generate, research and trade “standard” single-asset trading strategies that trade one individual asset – be it forex, futures contract, stocks, or ETFs.

But the nature of stocks allows many other trading styles:

  • Asset rotation / rebalancing – where you rebalance the weight of different assets in your portfolio
  • Pair trading and similar – where you trade the differences between correlated or cointegrated pair of stocks
  • Stocks picking – where you trade a whole group of stocks. There are even multiple different styles of stocks picking.
  • … and there are other even more “exotic” styles

 

The common thing with these different styles of stock-trading algorithms is that they usually trade groups of stocks – either several stocks in a group, several pairs of stocks, or hundreds of stocks that constitute indexes like S&P 500.

 

Note that this kind of trading algorithm is not as same as using one symbol and define additional charts with another symbols. This is possible in SQX right now, but it doesn’t give us the possibility to create this special type of stocks strategies.

 

To offer our users access to this new vast area of possible strategies we are introducing a new Stockpicker engine in SQX – it will be in the upcoming Build 136.

 

Our new Stockpicker engine uses the third mentioned style of trading stocks – it supports strategies that trade big number of stocks, for example 500 stocks in the S&P 500 or 2000 stocks in Russel 2000 index.


According to our best knowledge StrategyQuant X is the WORLD’S FIRST AND ONLY platform that offers automatic generation and research of this kind of strategies and you as our users are the first who can benefit from it.

Note – this new engine and its backtesting and generation of strategies is still under development at the time of writing this article. The first preview is available in SQX Build 136 Dev 1 version, but it is still a first preview and there is still some work on it until the final release.
This article is only a first one in the series where we’ll explain this trading style, the new engine, and its possibilities.

 

Introducing Stock groups

As said earlier, Stockpicker engine creates algo strategies that trade on group of stocks, not individual assets. In order to support it we added a new Stock groups feature to Data manager:

Stockpicker stock groups

It already contains predefined standard indexes, and it enables you to create your own stock groups.

To distinguish stock groups from standard symbols, they are enclosed in [ ], for example [StockGroupName].

Default (uneditable) stock groups provided by us are enclosed in double quotes [[ ]]

 

Stock group is defined by its name and its constituents – the list of stocks it contains:

Stock group edit

SQX Stockpicker engine natively supports Survivorship bias – which is important for realistic backtests (more about this in another article) – so you can add also dates from – to when the stock belonged to index.

 

How Stockpicker strategy looks like

An example Stockpicker strategy in pseudo code:

//--------------------------------------------------------------------
// Trading options logic
//--------------------------------------------------------------------
Entry type: On Bar Open
Order place type: Immediately

//--------------------------------------------------------------------
// Trading rule: Long (On Bar Open)
//--------------------------------------------------------------------
Entry Condition: (Kaufman Adaptive Moving Average(Main chart, PRICE_TYPICAL, 146)[2] is rising for 2 bars at 3 bar ago)
Order: Open Long order at Market;
Exit: At end of day (DayClose)

//--------------------------------------------------------------------
// Trading rule: Short (On Bar Open)
//--------------------------------------------------------------------
Entry Condition: (Kaufman Adaptive Moving Average(Main chart, PRICE_TYPICAL, 146)[2] is falling for 2 bars at 3 bar ago)
Order: Open Short order at Market;
Exit: At end of day (DayClose)

//--------------------------------------------------------------------
// Trading rule: Position Score (On Bar Open)
//--------------------------------------------------------------------
Position Score = LowDaily(Main chart)[2];
Max positions: 5

Stockpicker strategy consist of Long + Short rule and Position score rule. It trades on a Daily timeframe only.

Long and Short rules define:

  • Entry condition(s) – when should the strategy open trade
  • Order – type of order – Market, Stop, Limit
  • Exit – when it should close the trade

In our example the strategy will have a long entry signal when:

(Kaufman Adaptive Moving Average(Main chart, PRICE_TYPICAL, 146)[2] is rising for 2 bars at 3 bar ago), and it will close it ad the end of day

 

Position score rule is a specialty of Stockpicker strategies. Because Stockpicker strategy trades on a group of stocks (for example 500 stocks in S&P 500 index), it must determine how many positions should be open in parallel as well as the criterium on how to sort signals from different stocks:

  • Max positions = 5 means that this strategy will open positions in maximum 5 different stocks in parallel
  • Position score formula is the criterium by which to sort which stocks to choose if there is more than 5 stocks that could be opened at a given day.

 

How Stockpicker engine works:

This kind of engine is different because remember – it trades on 500 stocks in the group.

  1. At the entry – typically at market open – it will check the Long & Short rules on all stocks in the group that it is trading, for example on all 500 stocks in S&P 500.This could produce for example 12 different entry signals for 12 different stocks – AAPL, TSLA, …, AMZN, GOOG etc.
  2. It then uses the specified Position score formula to compute a score value for each of these 12 stocks.If there are no open positions, it will then choose Max positions of these stocks by the biggest score.Our example algorithm selects 5 stocks with the biggest position score and opens them at market.
  3. The trades are closed according to the exit rule – for example at the end of day, and a new evaluation is again made the following day and so on.

The trading result of this strategy applied on S&P 500 stock group could look as follows:

stockpicker trades

You can see that it opened 5 different stocks on day 1, and then another 5 stocks on day 2.

It can happen that less than 5 or even no trades are opened on a particular day – it depends in the entry conditions, etc.

Strategy can also use a different entry rule than Close at end of day – the trades can last for more than one day, but there will be never more than 5 stocks opened at the same time.

 

Stockpicker strategy in AlgoWizard

Stockpicker strategies have a completely different “architecture” than standard strategies, and we added this special type of strategy also in AlgoWizard editor.

The strategy definition is quite simple, it consists of defining Long (and Short) rules:

stockpicker entry rule

and Position score rule:

stockpicker position score rule

 

Stockpicker limitations in SQX

There are some limitations in SQX regarding the new Stockpicker engine and its strategies:

Stockpicker engine supports only TALib indicators

Right now, Stockpicker strategies can use only indicators from TALib library – TALib is a standardized library of technical indicators that consists of over 200+ most used indicators.

This means that internal indicators and signals implemented in SQX are for now not available for these strategies. This might change in the future, but it is like this for now.
There are also no predefined signals based on TALib indicators defined for now.

Source code of Stockpicker strategy is available only in Pseudo code

This is related to the next section – tradability of this class of strategies.

Stockpicker strategies work only on Daily timeframe

This type of strategies is traded usually on a Daily timefrane, and it is the only timeframe that is allowed for them in SQX for now.

Generation and backtest of Stockpicker strategies is slower than “normal” strategies

The engine is still in development, and it will be optimized further.
Moreover, with Stockpicker one strategy backtest means that the strategy is in fact backtested on hundreds of stocks in a given Stock group, so it must be somewhat slower than backtest on one symbol.

Advanced features like ATM  and cross checks don’t work on Stockpicker strategies yet

There is no support for these more advanced features yet, but we are working on it.

 

Tradability of Stockpicker strategies and the need for new cloud platform

This kind of strategies is difficult to trade automatically – not because it would be impossible, but because trading platforms are usually targeted towards one-strategy-per-chart approach.
It is not as simple as opening a chart in MetaTrader or Tradestation and attach a strategy to it, as we could do it with “standard” algo strategies.

There are programs like AmiBroker, that could backtest and to some extend trade this kind of strategies there is a Portfolio trader in MultiCharts that could theoretically trade these strategies live.
Some traders who trade this kind of strategies do it manually – it is possible because you usually need to check for the signal only once or twice a day.
More “advanced” traders (and some of SQX team members) that currently trade similar strategies use Python and a lot of programming and hacks to be able to trade them.

All these options are very cumbersome to use and prone to error. We want to offer a better way – not only to you, but also to ourselves – because we already trade this kind of strategies to.

 

We are glad to announce that we are developing our own cloud trading platform that will have a direct support for Stockpicker strategies produced by SQX and it will make trading it extremely simple.

A Beta version of this platform is very close to finish, it will be announced shortly. Our plan is to have it ready with the final release of StrategyQuant X Build 136 that will offer support for these new Stockpicker strategies.

Mark Fric

Mark Fric

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Emmanuel
Emmanuel
April 11, 2022 6:01 pm

Excellent ! I would like to test it !!!!

Continue reading