Taking a Look at the ATS Dakota 3 Swarm Adapters

November 12th, 2013 Comments off

BioComp Dakota 3 is now available from BioComp Systems. Dakota 3 is built upon the Microsoft .Net Framework, is highly customizable and multi-core capable. Here at AdaptiveTradingSystems.com we’ve been working hard coding up our add-ins for Dakota 3. This article takes a look at the ATS Dakota 3 Swarm Adapters, one of the main components in a trading system built using BioComp’s Swarm Technology.

The ATS Swarm Adapters for BioComp Dakota 3 extends the set of standard swarm adaptation algorithms that are installed with Dakota 3. Swarm adapters control the movement of trade bots within the trade bot parameter space. The goal of a swarm adapter is to move the trade bots into the most profitable region within the parameter space. In academia, this is described as particle swarm adaptation in a dynamic environment. The parameter space is a representation of all possible adapted trade bot parameter values. Changing a trade bot’s adapted parameter values is equivalent to moving the trade bot within the parameter space.

The bot trading method and related adapted parameters are defined by the signal generator. All trade bots within a given swarm are based on the same signal generator. An example of an adapted parameter is the period of a stochastic oscillator. A minimum and maximum value for the oscillator period is set in the signal generator. The swarm adapter will assign a new oscillator period to each trade bot in the swarm as each bar is processed. The new value is likely to be different to the previous value, although this is not necessarily the case. The new value for the stochastic oscillator period is constrained to be greater than or equal to the minimum value and less than or equal to the maximum value as defined by the signal generator.

Swarm adapters use information that includes each trade bot’s historical performance over a lookback window and each of the trade bot’s current adapted parameter values to determine how much to modify each trade bot’s adapted parameter values by. For example, a flocking algorithm will modify each trade bot’s parameter values so that they move toward the best performing bot in the swarm. Different swarm adapters will potentially use different information and apply different rules to determine the movement of each trade bot within the bot parameter space.

Using the ATS Dakota 3 Swarm Adapters

To use an ATS Swarm Adapter, expand the Adapter node on the Swarm tab within Dakota 3 and select one of the ATS Swarm Adapters as pictured below.

ATSSwarmAdapterTree

 

Figure 1.

Each of the ATS Swarm Adapters is based on a different adaptation algorithm and has its own parameter values that can be modified to change the properties of the swarm.

Fixed Position Top N Swarm Adapter

The Fixed Position Top N swarm adapter does not adapt bot parameter values. Rather, bots remain in the same position within the parameter space that was initially assigned to them. The top N performing bots are used to create the system signal.

FixedPosTopNSwarmAdapterProperties

Figure 2.

Parameters

Top N: The best performing N number of trade bots will be used to create the swarm signal. Other trade bots signals will be ignored.

An example of using the Fixed Position Top N swarm adapter would be to create a swarm with 100 trade bots and use the Halton Initializer to position the bots approximately evenly throughout the parameter space. If the number of adapted trade bot parameters was 1 then a swarm size of 10 trade bots would probably suffice. If the number of adapted trade bot parameters was 2 then 100 trade bots is about the number to use. Ideally, if there were 3 adapted parameters then the swarm size would be set to 1,000 trade bots. In practice using 1,000 trade bots is probably going to be too time consuming. You could try 300 to 500 trade bots if using this approach.

Formation Flocking Swarm Adapter

The Formation Flocking swarm adapter forces trade bots to maintain similar relative positions to one another while moving all trade bots towards the best performing bot in the swarm.

FormationFlockingSwarmAdapterProperties

Figure 3.

Parameters

Velocity Factor: The Velocity Factor determines how much a given trade bot’s previous velocity within the parameter space contributes to the bot’s new velocity during the adaptation process.

Convergence Rate: The Convergence Rate is the rate at which trade bots converge toward the position of the best bot in the swarm.

Noise Level: The Noise Level is the maximum amount of noise that is added to each trade bot’s new velocity when adapting. The value is a proportion of the parameter range.

Formation Flocking Adapted Swarm Adapter

The Formation Flocking Adapted swarm adapter forces trade bots to maintain similar relative positions to one another while moving all trade bots towards the best performing bot in the swarm. The convergence rate increases up to the maximum convergence rate and the velocity factor decreases down the minimum velocity factor as the performance of the best bot in the swarm approaches the performance threshold. If the proportion of trade bots that are profitable falls below an internal threshold then all trades bots will tend to spread throughout the parameter space in search of a more profitable region.

FormationFlockingAdaptedSwarmAdapterProperties

Figure 4.

Parameters

Min Velocity Factor: The Min Velocity Factor determines how much a given trade bot’s previous velocity within the parameter space, contributes to the bot’s new velocity when the best bot’s performance is less than or equal to zero.

Max Velocity Factor: The Max Velocity Factor determines how much a given trade bot’s previous velocity within the parameter space contributes to the bot’s new velocity when the best bot’s performance is greater than or equal to the Performance Threshold.

Min Convergence Rate: The Min Convergence Rate is the rate at which trade bots converge toward the position of the best bot in the swarm if the performance of the best bot is less than or equal to zero.

Max Convergence Rate: The Max Convergence Rate is the rate at which trade bots converge toward the position of the best bot in the swarm if the performance of the best bot is greater than or equal to the Performance Threshold.

Performance Threshold: The Performance Threshold is the trade bot performance value used to adapt the convergence rate. The Bot Performance Metric and Performance Lookback period that are being used should be considered when setting this value.

Noise Level: The Noise Level is the maximum amount of noise that is added to each trade bot’s new velocity when adapting. The value is a proportion of the parameter range.

Standard PSA Swarm Adapter

The Standard PSA swarm adapter moves trade bots towards the best performing bot in the swarm and toward each bot’s best historical location. Each bot’s best performance and the adapted parameter values when the best performance was achieved are recorded. The best performance value is faded over time. Minimum bot velocities are enforced to prevent over-convergence of the swarm.

StandardPSASwarmAdapterProperties

Figure 5.

Parameters

Velocity Factor: The Velocity Factor determines how much a given trade bot’s previous velocity within the parameter space contributes to the bot’s new velocity.

Convergence Rate: The Convergence Rate is the rate at which trade bots converge toward the position of the best bot in the swarm and toward their historical best position.

Noise Level: The Noise Level is the maximum amount of noise that is added to each trade bot’s new velocity when adapting. The value is a proportion of the parameter range.

Standard PSA Adapted Swarm Adapter

The Standard PSA swarm adapter moves trade bots towards the best performing bot in the swarm and toward each bot’s best historical location. The convergence rate increases up to the maximum convergence rate and the velocity factor decreases down the minimum velocity factor as the performance of the best bot in the swarm approaches the performance threshold. Each bot’s best performance and the adapted parameter values when the best performance was achieved are recorded. The best performance value is faded over time. Minimum bot velocities are enforced to prevent over-convergence of the swarm.

StandardPSAAdaptedSwarmAdapterProperties

Figure 6.

Parameters

Min Velocity Factor: The Min Velocity Factor determines how much a given trade bot’s previous velocity within the parameter space contributes to the bot’s new when the best bot’s performance is less than or equal to zero.

Max Velocity Factor: The Max Velocity Factor determines how much a given trade bot’s previous velocity within the parameter space contributes to the bot’s new velocity when the best bot’s performance is greater than or equal to the Performance Threshold.

Min Convergence Rate: The Min Convergence Rate is the rate at which trade bots converge toward the position of the best bot in the swarm and towards their personal best positions if the performance of the best bot is less than or equal to zero.

Max Convergence Rate: The Max Convergence Rate is the rate at which trade bots converge toward the position of the best bot in the swarm and towards their personal best position if the performance of the best bot is greater than or equal to the Performance Threshold.

Performance Threshold: The Performance Threshold is the trade bot performance value used to adapt the velocity factor and convergence rate. The Bot Performance Metric and Performance Lookback period that are being used should be considered when setting this value.

Noise Level: The Noise Level is the maximum amount of noise that is added to each trade bot’s new velocity when adapting. The value is a proportion of the parameter range.

That’s it for version 1.00 of the ATS Dakota 3 Swarm Adapters.

Regards,

James

Developer of Trading Systems that Adapt

Categories: Software Tags:

Modeling with Profit 8 and the SIP Indicators Part 2

January 31st, 2012 Comments off

This article describes the construction of a neural network system for trading the SP futures contract. The neural network modeling software used to construct the system is BioComp Profit 8. Profit 8 is based on BioComp Systems’ commercial Intellect 3.0 architecture. To be accurate, Intellect builds mesh models rather than neural network models. Mesh models are proprietary models that outperform both neural networks and state vector machines. The Profit 8 system described in Part 1 of Modeling with Profit 8 and the SIP Indicators stopped working due to a bug fix related to the R Squared Performance Metric that was used by the system.

The inputs to our models are the SIP indicators. The SIP indicators are published by Adaptive Trading Systems on a daily basis and are used for modeling the 3 to 15 trading day price trends of the SP futures contract. The SIP indicators include Buy Pressure, Sell Pressure, Net Pressure, High Buy Pressure, High Sell Pressure, Advancing Pressure and Declining Pressure. You can download the indicators by installing the ATS Mercury application that is available toward the bottom of the Trading Signals page. The indicator values are delayed by 1 trading day for non-subscribers.

Method:

Step 1. Adding the SIP Indicators to the Securities List

This step assumes that you have downloaded the SIP indicators to your computer. For further information on downloading the SIP indicators go to the Trading Signals page at AdaptiveTradingSystems.com.

Start Profit 8 and click on the Add Text File toolbar button to open the file selection dialog. Browse to the location of the SIP indicator text files and open the first file. The File Definition Dialog will then appear.

Step-1. Adding the SIP Indicators

Step-1. Adding the SIP Indicators

Click on the SIP indicator column name (in the example it is SIPAP) and click on the Close radio button in the Settings section. Click on Ok to finish adding the SIP indicator to the Securities list in Profit 8. Repeat this step for each of the SIP indicators.

Step 2. Adding the Data Series for Modeling

On the Data tab in Profit 8, double click on the security name of the data series that you are modeling. This example models the continuously linked non-adjusted SP futures contract data from Pinnacle Data Corp. Scroll down the list of securities until you see the the SIP indicators. Double click on each SIP indicator until they have all been added to the list of ‘Data to Use’.

Step 2. Adding the Data Series for Modeling

Step 2. Adding the Data Series for Modeling



Step 3. Setting the Data Import Dates

The most recent 2.5 years of data will held back for validating the models. This is referred to as the out-of-sample (OOS) period. To ensure that the last 2.5 years of data is not used, the end date for importing data is set to 07/15/2009.

Step 3. Setting the Data Import Dates

Step 3. Setting the Data Import Dates

The modeling end date of 07/15/2009 was chosen so that the modeling period overlaps the start of the ‘GFC period’ whilst providing for a reasonable amount of OOS data.

Step 4. Importing the Data

Click on the ‘Import Data’ toolbar button to import data from 07/01/1997 to 07/15/2009.

Step 4. Importing the Data

Step 4. Importing the Data



Step 5. Equity Engine Parameters

No transaction costs are applied in this example. Change the Slippage and Commission values to zero on the Equity Calculations tab.

Step 5. Equity Engine Parameters

Step 5. Equity Engine Parameters



Step 6. Setting the Trading Delay

Change the ‘Project the signal by’ to 1 to apply a trading delay of 1 bar. Signals generated on any given day are executed on the close of the next trading day when using a trading delay of 1 bar.

Step 6. Setting the Trading Delay

Step 6. Setting the Trading Delay



Step 7. Building the Predicted Series

The available inputs and predicted series used to build mesh models are defined on the Indicators tab in Profit 8. In this case, there is no need to modify the dates that optimizations are applied to because no optimizations will be run. Go to the Indicators tab and delete series SP.NON_VOLUME from the list of indicators. Apply the Ln() transform to series SP.NON_CLOSE, the transformed series will then appear at the bottom of the list of indicators.

Step 7. Building the Predicted Series

Step 7. Building the Predicted Series

Select the Ln(SP.NON_Close) series at the bottom of the list and apply the 1 period Chg transform. Making sure the same series is still selected, apply the 2 period Shift transform. This completes the construction of the target / predicted series. The target series represents an ideal trading signal. Profit 8 will attempt to predict this series using the SIP indicators as the model inputs.

Step 8. Nominating the Predicted Series

Select the Model Building tab and then select the newly constructed target series in the Indicators list. Click on the drop down menu above the Indicators list and select ‘Predicted’.

Step 8. Selecting the Predicted Series

Step 8. Selecting the Predicted Series



Step 9. Data Handling Settings

Change the modeling start date to 7/15/1997 and the modeling end date to 7/15/2009. Set the Modeling, Optimization and Selection percentages to 60, 20 and 20. Change the modeling parameters so that Random data points are used.

Step 9. Data Handling Settings

Step 9. Data Handling Settings



Step 10. Model Settings

The default Model Settings are used as pictured below.

Step 10. Model Settings

Step 10. Model Settings



Step 11. Performance Settings

The default Performance Settings are used as pictured below. Note that the Optimization Metric is set to Relative Accuracy. Use of the Relative Accuracy tends to result in systems with lower profit margins over the modeling period. However, use of the Relative Accuracy metric has a strong tendency to produce systems that are more robust post the modeling period. I spent a considerable amount of time comparing Profit 8 to other similar neural network and state vector machine software solutions and Profit 8 using the Relative Accuracy optimization metric was the clear winner.

Step 11. Performance Settings

Step 11. Performance Settings



Step 12. Start Modeling

Click on the Start Modeling button to begin the modeling process.

Step 12. Start Modeling

Step 12. Start Modeling

Check the Profit 8 status bar at the bottom left of the application window to see when model construction has completed.

Step 13. Change Import End Date

To view the performance of the system over the out-of-sample period the data importation dates need to be modified. Change the end date to the last date that you have SP data for.

Step 13. Change Import End Date

Step 13. Change Import End Date

After updating the end date, click on the Import Data toolbar button to import the data. The system will process the new data automatically.

Step 14. View the Results

Click on the Results tab to see the in-sample and out-of-sample performance. Finally, save the system if you haven’t done so already.

Step 14. View the Results

Step 14. View the Results

As a market timing model developer I like to see the shape of the equity curve and the percent of perfect trading statistic. The majority of people reading this article are probably wondering how many points the system hypothetically made over the OOS period. A total of 71 positions were taken over the OOS period. The first trade post the modeling end date was opened on 7/17/2009 and the last trade in the OOS period was closed on 1/17/2012. The net points made was 667.8. This equates to $33,390 if trading the ES contract and $166,950 if trading the SP contract. Note that these figures are not net of trading costs. To calculate the total hypothetical trading cost multiply your estimate of the cost per completed trade by 71 or the cost per side by 142.

What I like about this system is:
- The SIP indicators have been published daily with no in hind-sight adjustments for years.
- Absolutely no optimization of inputs is done.
- Absolutely no model ‘pruning’ post construction is required or done.
- The OOS period spans one of the most difficult trading periods to date.

What I don’t like about the system is:
- The percent of perfect over the in-sample and out-of-sample periods is a little on the low side.

Regards,

James
Developer of Trading Systems that Adapt

Performance Metrics Part VI – Sharpe Ratio

February 10th, 2011 Comments off

Part VI of the series of articles on trading system performance metrics describes the calculation of the Sharpe Ratio.

The Sharpe Ratio is calculated by subtracting the risk free rate from the compound annual growth rate and dividing the result by one standard deviation of the bar by bar returns. The risk free rate is a user defined equity engine setting. The one period standard deviation of log returns is initially calculated, annualized and converted to a nominal return to form the denominator. There is no need to take the risk free rate into account when calculating the denominator because it is constant in this implementation.

Formula / Pseudo Code:

    NominalStdDevReturns = e^(StdDevLogReturns x BarsPerYear ^ 0.5) – 1
    If (StdDevReturns != 0)
    {
        SharpeRatio = (CAGR – RiskFreeRate) / NominalStdDevReturns
    }
    Else
    {
        SharpeRatio = 0
    }

Example:

    Given,
        RiskFreeRate = 0.05
        StdDevLogReturns = 0.01092566
        CAGR = 0.27026727
    Compute the Sharpe Ratio,
        NominalStdDevReturns = e^( 0.01092566 x 252^0.5) – 1
        NominalStdDevReturns = 0.18938870
        SharpeRatio = (0.27026727 – 0.05) / 0.18938870
        SharpeRatio = 1.16304332

Regards,

James
Developer of Trading Systems that Adapt