Premium Market Analysis, Trader Education, Software, and Trading Strategies. Thirty Years Of Skin In The Game

Quantitative trading

Feature Engineering With DLPAL LS

DLPAL software offers capability of generating high quality features for use in algorithmic and machine learning trading strategies. In this article we include an example of how features engineered from ensembles of securities can be used to develop a long/short strategy for trading SPY ETF.

Deep Learning Price Action Lab™ (DLPAL) software is unique in many ways. An advantage of this software is that it is very easy to use. A key advantage is that besides its unique capability of identifying trading strategies based on parameter-less features, also known as predictors or factors. However, a major advantage of this software this software is that it also facilitates engineering of features that are useful in developing algorithmic and machine learning trading strategies. Even more important is the fact that all results are deterministic, which means that the same data with same specified objectives will always generate the same output, i.e., there is no stochasticity in the results. This is highly important for any method to qualify as scientific.

In this article we focus on feature engineering based on an ensemble of securities. In another recent article we presented a method for developing long/short equity strategies based on engineered features for each security in a group.

Feature engineering is the hardest aspect of machine learning and algorithmic trading. If the features (predictors or factors) used do not have economic value, performance is unlikely to be satisfactory. Algorithmic trading and machine learning cannot find gold where there is none. The use of widely known features is unlikely to produce anything of value. Developing an algo and applying machine learning is the easy part of this process despite some common misconceptions. A few operators of platforms where aspiring traders gather to test their programming skills offer known features that are “tortured until they confess to anything”. These approaches will probably fail because of data-mining bias. Note that this bias is cumulative and at some point grows out of control.

The P-ratio

The P-ratio is a feature (predictor or factor) calculated by DLPAL. In this example, it is the fraction of stocks in Dow 30 that after the close of a given day have positive directional bias, called Plong. This directional bias is in turn another engineered feature for each security in Dow 30. The calculations are quite involved and the details proprietary but Plong is a probability ranging from 0% to 100% that arises from a weighted average of probabilities of certain signals to occur, which also engineered features based on other, more primitive features.

The P-ratio along with four related features is calculated by DLPAL LS. In the case of Dow 30, we call it the P-Dow ratio. Its value ranges from 0 to 1. Extreme values or 0 or 1 rarely occur. If the ratio rises above 0.70, that corresponds to long signal and if it drops below 0.5 that generates a short signal. The asymmetry is due to the fact that equities have a positive structural bias.

Below is the DLPAL LS workspace for generating the ensemble P-Dow ratio features. The history length is set to 1848 bars because we want to generate history starting on 01/04/2010 to 05/05/2017.

blank

It took less than half a day for the program to generate the historical data file with the features running on a 64-bit Windows 10 laptop with Intel Core i5 CPU at 2.50 GHz. Below is how a historical file with the futures looks like.

blank

There are five features but we are only interested in Pratio in this articles. These features are explained in the manual. In this example we are not going to generate train and score files because we will be developing a simple strategy. These other files are needed in the case of machine learning applications.

Next, we combine the historical files with the features with the historical data of SPY ETF in the same date range. We do that in excel. This is how the combined csv file looks like after removing the head.

blank

We can now import the data in Amibroker and backtest our strategy. The results are shown below.

blank

Volume is AvgPL, Open Interest is AvgPS, AUX1 is Pratio and Aux2 is AvgSPL. We are interested only in Pratio. Below is the trading strategy:

Buy if AUX1 > 0.70
Short if AUX1 < 0.50

This is a long/short strategy. For the backtest, initial capital is $100K, equity is fully invested and commission is $0.01 per share. All orders are placed at the open of the next bar to prevent look-ahead bias. In the table below you can find the equity curve, underwater curve, monthly returns table and Monte Carlo simulation results. Click on images to enlarge.

blank blank
blank blank

Both equity and underwater equity curves show potential. Notice that return in 2015 is 18.1% versus -0.9% for buy and hold. From the Monte Carlo simulation it may be seen that the probability of a drawdown greater than 35% is below 5%.

The table below summarizes the performance of the strategy.

Parameter Strategy Buy and hold
CAGR 12.40% 13.00%
Max. DD 16.94% 18.61%
Sharpe 0.85 0.86
MAR 0.73 0.70
Trades 170 1
Win% 65.3%
Profit factor 1.83
Payoff 0.97

Results from this strategy were above expectation. MAR (CAGR/Max. DD) is higher for the strategy at 0.73 versus 0.70 for buy and hold. Therefore we verify that these features have some economic value.

This was just an example of what one can do with the features engineered by DLPAL. An example with features generated for each security in Dow 30 can be found here.

If you have any questions or comments, happy to connect on Twitter: @priceactionlab

For more information and requirements of getting a free, fully-functional, one-month trial of the software click here. Trails are only available to established hedge funds.

Please read our Disclaimer and Terms and Conditions before ordering a demo or full version of DLPAL LS.

Subscribe via RSS or Email, or follow us on Twitter.

Disclaimer:  No part of the analysis in this blog constitutes a trade recommendation. The past performance of any trading system or methodology is not necessarily indicative of future results. Read the full disclaimer here.

Copyright Notice