Portfolio Boss Documentation

Design Strategies from Scratch

 

 

This scenario is the most exciting.

Instead of wondering what rules and technical indicators to use, you let the Divine Engine do the thinking, and design strategies from scratch. You read that right. You don't have to add any filters, at all. Just enough guidelines so the Divine Engine knows what it's looking for.

For example, you can tell the Divine Engine to craft strategies that yield an annual return of 80%, with acceptable Drawdown like 30%, and that each month must be a winning month, so you can laugh all the way to the bank, every month, liquidating your profits instead of losses.

 

 

The Divine Engine will then add, mix, and match various rules, filters, and values. They're tested thoroughly, and it will see which ones stick to conform with your trading goals. You may even be surprised at the final form the Divine Engine serves you on a platter.

The way it thinks is very different from the human brain with its cognitive biases. Thus rules, filters, and values that you deem impossible or counter-productive may actually be the key to mind boggling results.

 

In short, you explore a new world.

 

 


 

1.  The very first thing you do is create a new blank strategy, as shown in the video below:

 

 


 

2.  As the blank strategy opens before your eyes, let's go to the “System Settings” Panel. This panel is populated by the default values, so there's nothing for you to change here. But feel free to change the rules here as you see fit, for example the rule “Total Positions to Hold”:

 

 

If you have doubts on any of the rules, please consult the help page for the “System Settings” Panel. Down the road, we'll also discuss how the Divine Engine can find the best “System Settings” values for you.

 


 

3.  Now, let's get to the “Instruments” panel to add Portfolios to this strategy.

 

 

Keep in mind, the more instruments you have (the larger your Portfolio), the longer it takes for the Divine Engine to finish. In our case, we'll be using the portfolios “Indices Nasdaq 100” and “Indices Nasdaq 100 Historical Deletions” as they're quite small. If you decide to use bigger Portfolios (for example the S&P 500), you may find exotic and high performing instruments with such a bigger pool. But be warned it will take longer for the Divine Engine to finish. Generally, the Divine Engine can accept 1,000 different instruments in your portfolio. But if you use the “Random” search mode (explained later), you can go well beyond 1,000 instruments.

If you want lightning fast Divine Engine run, you can put one or two instruments in your Portfolio:

 

 

Usually it's an ETF instrument, be it an index ETF (like QQQ), or commodities (GLD), etc., along with its inverse counterpart to be put on the Cash Equivalent (e.g. PSQ as inverse of QQQ).

 

 

As shown above, you can also trade a single stock (instead of ETF), which can then be shorted through the Cash Equivalent rules highlighted above. Obviously this technique may run the risk of not diversifying your trades (very volatile equity curve).

 


 

4.  Take a look at the “Buy Filters”, “Ranking”, and “Sell Filters” Panels. These panels contain the bread and butter technical indicators for the strategy.

 

 

But as you notice, these panels are empty. We'll let them be, as the Divine Engine will decide the best technical indicators for us.

 


 

5.  Now that we added the portfolios, let's turn on the Divine Engine. Nope, we won't be turning a special ignition key (though that would be nice). Simply go to the top of this page, and click a button that says “Enable Divine Engine”.

 

 

You may be greeted by the “invalid strategy” dialog, which shows you what rules & parameters to set so this strategy becomes “valid” (backtest-able).

 

 

But don't worry for now, just press OK. We'll learn in the following sections what needs to be set.

 


 

6.  After the Divine Engine is enabled, a new panel appears: the Backtest Parameterization Panel. Let's scroll down to it.

 

 

Now, this is where you order your custom tailored suits; in other words, what you're looking for in a strategy. You may look for the highest CAGR with the lowest Drawdown possible, etc. This panel also defines how the Divine Engine backtest will be performed.

We have a dedicated help page explaining all the features of this panel. But for now, you'll only see what's important to you.

 


 

7.  On this panel, just make sure the “Search Algorithm” is set to “Evolutionary”, instead of “Random”.

 

 

“Evolutionary” means that higher-performing strategies are built on the foundation of its lower-performing predecessors, throughout the generations. Each generation undergoes “crossbreeding” and “mutation”, as well as “tournaments” (survival of the fittest) to find the best performing strategies.

If you want to delve deeper on how exactly the Evolutionary search works, refer to the help page here.

 


 

8.  Also make sure the property “Rule Set Parameterization” is set to “Random Selection”. This way, the Divine Engine is allowed to add random rules and filters, along with their random values.

 

 

This is the most important setting for the “eureka!” moment. Otherwise, with this set to “Manual”, the Divine Engine will not add any filters (rules). You'll be limited to the filters you added manually (in our case, we don't even have them, so we'll have zero filters with this set to “Manual”).

Keep in mind, the random addition of filters may be affected by the number of parameters (and the value ranges) of each filter. More complex filters may have a higher chance of being added to the strategies. This is because with the wide and deep array of values, it's more difficult for such filters to find good value combinations.

 


 

9.  Still in Backtest Parameterization Panel, set the property “Tournament Fitness Function Rotation” to “Enabled”.

 

 

Thus you have enabled Rotational Fitness, a revolutionary way to introduce noise to the evolutionary progression. With Rotational Fitness, strategies may have better consistency. In other words, you don't have to worry whether its real-life performance will mimic the backtest performance.

 


 

10.  Now comes the fun part, where you can tell the Divine Engine what you want in a strategy, custom tailored to your trading needs and goals. Look at the “Fitness Function” section:

 

 

The very first time a strategy has its Divine Engine enabled, a Fitness Function (i.e. “Score”) is already added. It's a good overall Fitness Function, but it's not specific. If you wish to delete it, click the trash-bin icon.

 

 

Now click on the button “Add Fitness Function”.

 

 

A dialog appears, listing the various Fitness Functions.

A Fitness Function is essentially the “metric” that the Divine Engine looks in the various strategies it created. A “metric” is the yardstick of the strategy's performance, as you can find in the Metrics Tab. So for example, you may choose “Score”, “CAGR”, or “Max Drawdown” as the yardstick for the strategies' performance.

The Divine Engine will try its best to create strategies with as high a metric's value as possible. Or in the case of inverted metric like “Drawdown”, it'll create strategies that have the lowest possible value.

 

 

You can choose from the various metrics there. For example “Score” is often used, as it already covers both CAGR and Max Drawdown simultaneously. So the Divine Engine will create and find strategies with as high a CAGR as possible, while minimizing the Max Drawdown as low as possible.

You can add multiple Fitness Functions to further narrow down the criteria, for example:

 

  • R²: this metric shows how smooth the strategy's equity curve is, thus how consistently it performs.
  • Avg. Drawdown: the average depth of the troughs the strategy's equity curve experiences, thus the lower the better.
  • Winning Positions: in case you want to find strategies with higher chance of winning trades.
  • Winning Months: in case you want to find strategies with more winning months per year.
  • Avg. Position Gain: in case you want to find strategies with greater return per trade.
  • Avg. Trades per Year: in case you don't want too many or too little trades per year.
  • Total Trades/Rule Count: to avoid useless rules & filters that don't generate signals.

 


 

11.  As you can see we have multiple Fitness Functions. Let us now define their criteria:

 

 

For example, we have “CAGR” here. Naturally, we want the Divine Engine to “maximize” the CAGR value as high as possible. Therefore on the first parameter, we set it to “At Least”. Then on the second parameter we define the threshold CAGR value (the minimum that we want). In this case, we set it to 30%. That means, the Divine Engine will try to create strategies with a minimum CAGR of 30%, and higher. And then we have its “Weight” parameter set to “125%” which means the quest for high CAGR occupies “greater importance” for the Divine Engine.

 

 

Next, we have “Max Drawdown”. This is an inverted metric, so naturally we want it to be as low as possible. Thus we set it to “At Most” “35%”. That means the Divine Engine will try to cap “Max Drawdown” to a maximum of 35%, and minimize it as low as possible. But note the “Weight” here is set to 75%. This tells the Divine Engine that the quest for minimal Drawdown has less importance compared to the previous CAGR (125%). The idea is this: as the common investing wisdom goes “With zero risk, comes zero return”, therefore if Drawdown has greater importance (or at least the same) with CAGR, it could be that the Divine Engine creates strategies with very low Drawdown but underwhelming CAGR.

 

 

Finally we have “Average Trades per Year”. As stated earlier, we don't want this either too low or too high. Too many trades and you'll get hit by huge commission fees and slippage. Too few, and you can't capitalize on smaller profits to accumulate (through higher frequency trading). Hence we set this to “Goal” “200”. That means the Divine Engine will target as close as possible to 200 trades per year, nothing higher, nothing lower. In fact, “Goal” is also useful for other metrics: for example, with CAGR set to “At Least”, the Divine Engine will maximize the CAGR as high as possible (to the sky and beyond), thus dwarfing other metrics that may not have such a large scale (Drawdown, for example, which is limited to a bottom of 0%), therefore it creates strategies with good CAGR but bad Drawdown. Or another example, if “Max Drawdown” is set to “At Most”, it may create strategies that stay in Cash most of the time as they have 0% Max Drawdown. Hence we could also set CAGR and Max Drawdown to use “Goal” to avoid such pitfalls. Note: the “Weight” here is set to 50% for “Avg. Trades per Year”, as we care more about CAGR and Drawdown than exact amount of trades.

Now keep in mind that these criteria you set aren't a guarantee. It's not like if you set CAGR to at least 30%, then strategies won't have have CAGR less than 30%, no. The Divine Engine will try its best through the Evolutionary progression to punish strategies that don't meet your criteria, and reward those that do. But still such criteria may not be met if they're too lofty. It's like trying to find a unicorn that doesn't exist. At best, you'll get a sloppy strategy that's good in one area, but very bad in the other (that's why we also set Max Drawdown to 75% weight compared to CAGR's 125%).

 

 

Aside from those options, you can read about the “Minimum” and “Maximum” target types in this documentation.

 


 

12.  Still in the “Backtest Parameterization” Panel: most of the properties here are set to their default values. You can actually start the Divine Engine backtest now, trusting these values will serve you well.

 

 

But we won't leave you in the dark, so let's get a cursory overview of these properties, starting with the:

 

 

“Population Size”: This property defines the amount of strategies contained in each Generation (128 strategies in this example). Every strategy may have different rules, filters, and values from the other, due to randomization, crossbreeding, and mutation (later explained). Bigger population means a longer Divine Engine process, but it may increase the chance of finding better performing strategies due to a larger population pool. Note that the value you input here must be a multiple of 4.

 

 

“Cross-Breeding Rate”: Those strategies (in each Generation) may exchange each other's rules and filters (mixing their DNA by having sex), to create offspring strategies. Higher rate of Cross-Breeding means there are more strategies willing to cross-breed, while lower rate means more offspring are created simply through cloning. Hence a higher value means more variations to the offspring, and lower value may hinder the evolutionary progress through homogenous strategies.

 

 

“Mutation Rate”: Offspring may get mutated to create even more variations between them. Mutation may mean some of their filters are replaced by new ones (“SMA” filter gets replaced by “Beta” filter, for example). But mostly it means the parameters' values are randomized again (from 200 days SMA to 136 days, for example). Beware that higher Mutation Rate may create monster strategies: their filters and values get so different from their parents, that either they become super strategies, or, (which happens more often) that they become cripples unfit for survival (abysmal Fitness Function score).

 

 

“Min. Generations”: Throughout the evolutionary progression, many generations are created. Each generation is comprised of the fittest parent strategies with their offspring. The population size of each generation is defined on the “Population Size” property previously explained. Whereas this property, “Min. Generations”, defines the minimum amount of generations to be created. Once this minimum generation is met, the “Exit Condition” kicks in (explained later). Higher value increases the Divine Engine processing time.

 

 

“Max. Generations”: This property defines the absolute maximum amount of generations to be created throughout the evolutionary progression. Let's say we set this to “150”; that means the Divine Engine will create 150 generations before the evolutionary progression is stopped, and you get whatever best performing strategies within those 150 generations. This max generation may not be met, however, if an Exit Condition is hit. Higher value here means a longer backtest time, but the evolutionary progression may mature enough that you'll get the ultimate strategies that you want (or more!).

 

 

“Exit Conditions”: Now this one is optional, you don't have to specify an Exit Condition. But it may be useful, as the name implies, to exit or stop the Divine Engine process should the evolutionary progression only yields lower and lower performing strategies. So it's like telling a bunch of people to stop breeding, as their offspring only degrade throughout the generations. At the very least, you cut your fees in using The Boss (we charge hourly, unless you're the very lucky founding members of The Boss, who get unlimited time). We'll discuss “Exit Conditions” thoroughly in the help page for “Backtest Parameterization” Panel.

As of now, you can use the default Exit Condition applied when a strategy uses the Divine Engine for the first time. Or, you can add an Exit Condition by clicking the “Add Exit Condition” button.

 

 


 

13.  Next, we'll use multiple In Sample Periods. Take a look at the section “In Sample Periods” (on the Backtest Panel):

 

 

This is very important, as we want to ensure good real-life performance for the strategies created. With multiple In Sample Periods, each strategy will experience multiple slices of market conditions. We want to make sure it performs generally the same, for every period, so when it's deployed for the real future, it won't disappoint us. Simply put a value of 2, 3, or 5 on the property Number of In Sample Periods (as shown above). You may also raise the bar further with the Super Out-of-sample method.

For a detailed discussion on these topics, read the help page for In Sample Periods section.

 


 

14.  We're almost ready to launch your tests either in the local Divine Engine Queue, or by using The Boss (recommended). One last thing you want to check is this: make sure you have internet connection. No, it's not a joke…

 

 

The Boss is a cloud service, so we need internet connection to send the “recipe of our ultimate strategy” up to the server. Otherwise you'll get the error above when starting The Boss (please don't contact support if you see the internet cable unplugged and dangling…). You don't need an internet connection to run tests in the Local Divine Engine Queue, but doing so will certainly tie up your computer's resources for hours or even days.

Now, there could be cases where The Boss service experiences problems. In that case you can't start the Divine Engine backtest, or it will be put on queue quite a bit longer. Check the status of The Boss service from Portfolio Boss Status Page:

 

 


 

15. Now let's get it rock'n'rollin! Take a look at the top of this page, the button that says  

 

 

Click that button and a dialog appears showing you the cloud compute credits detail: note the estimated credit consumption for this backtest. You can also give this backtest a memo so you remember what it was about. If everything's good, simply click “OK” (or press Enter on your keyboard).

Now you can relax and wait it out. Or even better, you can still use Portfolio Boss normally even as the cloud backtest is running (you can create, open, and customize your strategies, backtesting them, and even do another cloud backtest). If it's time to close PB and shut down your computer, you can do so without affecting the cloud backtest. In short, your computer doesn't even have to lift a finger. As of the time of this writing, The Boss contains nearly 3,000 CPU cores (and will be increased more in the future).

When running in the local Divine Engine Queue, your own 4, 8, or 12-core machine needs to carry the weight. This may slow down your PC for other tasks and it may take days or weeksfor your PC to crunch all the data 24/7 which is why we recommend The Boss's cloud-based process for most cases. But the choice is ultimately up to you!

 

If you look at the Divine Engine Results Tab, you'll see that the Divine Engine backtest is running (indicated by the loading circle).

 

 

You'll also see the highest performing strategies created by the Divine Engine listed here, even as the evolutionary search is still progressing.

 

 

At the lower part, you can see the Fitness Series Chart is continually updated as well.

 

 

For in-depth explanation of the “Divine Engine Results” Tab, please refer to the help page here.

Note, even if you closed Portfolio Boss (and shut down your PC), the moment you open this strategy again Portfolio Boss will fetch the latest updates from the cloud, and populate this Tab accordingly.

If you wish to upgrade your license to include “The Boss” platform, please contact our Customer Support team at support@portfolioboss.com.

 

Note:

The dialog “Start Cloud-based Backtest” allows you to add a memo (description) for this backtest, as well as showing you the breakdown of compute credits:

    1. This is the percentage of free compute credit consumed thus far. Free compute credit is either: given to you each month if you have The Boss unlimited license; or, given one time as part of your purchase-package (e.g. a promo). The unlimited license receives 25,000 compute credits each month, which does not carry over (or stockpiled) to the next month; it simply resets to 25,000. If you run out of free credits (indicated by 100% consumption here), you either have to wait for the next month, or purchase additional credits.
    2. This is the estimated consumption of compute credit for this backtest you're about to execute. This is mainly affected by: the strategy's Portfolio size (the number of distinct instruments, capped at 1,000), the Population Size, and the Max. Generations.
    3. This is the amount of free compute credit remaining.
    4. This is the remaining compute credit that you purchased yourself (non-free).
    5. Write a memo here to describe this backtest (optional).
    6. The “Purchase” button directs you to our website so you can buy additional compute credits. These are sold in packages, and they don't expire (you can stockpile them forever).

The memo you wrote will be shown on the Divine Engine Results Tab:

 


 

16.  Once it's finished, let's feast on the results. The Divine Engine Results Tab is now fully populated with the highest performing strategies throughout the evolutionary progression.

 

 

These strategies are sorted top to bottom based on the highest Fitness Score, which you can see at the column “Fitness (IS)”. This score is the aggregated metrics' values normalized into a factor of 1. So it's not simply the CAGR, Max Drawdown, and Average Trade per Year's actual values. For more detail on how the metrics' actual values get normalized into a factor 1, read this explanation. A Fitness Score higher than 1 means the strategy exceeds your criteria/expectation. Less than 1 means it falls short of that.

 

 

To see the metrics' actual values, you can look at the columns as shown above.

Now to load a top strategy, click its “Load Parameters” button  . Thus its rules, filters, and values are loaded as the active strategy.

 

 

Take a look at the Buy Filters, Ranking, and Sell Filters panels to see exactly the various rules, filters, and values used by the strategy you loaded.

 

 

You can subsequently load another top strategy, and it will become the active strategy, replacing the previous one.

Each strategy that you loaded also shows its metrics report as shown on the Metrics Tab.

 

 

Note, a resulting strategy may contain only the Ranking Rules, without a Buy or Sell Filter:

 

 

Don't worry, you can trust the Divine Engine. It means the strategy is better off without those filters, as their addition would only reduce its performance. Besides, remember that a strategy only needs a Ranking Rule to be valid (unless it's a continually-switching strategy).

 


 

17.  Keep in mind, a strategy that you loaded shows only its Metrics Tab populated. You need to press the “standard” backtest button (not the Divine Engine backtest buttons) for its Performance, Positions, History, Trade Signals, and Chart Tabs to be populated as well:

 

 

 

A “standard backtest” is essentially a single backtest for that active strategy (to get its in-depth performance report). Whereas the “Divine Engine backtest” is a backtest for numerous strategies created by the Divine Engine, to find the best performing ones.

Once you pressed the “Start” button, a confirmation dialog appears, that lets you write a memo describing this standard backtest:

 

 

Such memo can be seen under the Manual Results Tab (this is where all standard backtests you did are listed). You can disable this dialog (for future backtests) by ticking “Don't show again”.

 

 


 

18.  Once you're ready to trade a strategy that you loaded, set its Notifications property to “Daily email”. Portfolio Boss will automatically perform a standard backtest, and send you the daily email notifications as usual.

 

 

Once it's set to “Daily email”, the strategy's rules are grayed-out and locked (you can't edit them); this is the read-only mode. If you wish to edit the strategy, you must override this mode with the button “Override read-only mode”. But if you load a top strategy (or a Backtest Item's start parameters), a confirmation dialog allows you to both override the mode and load that strategy.

Now this is important: before you decide to trade a top strategy, make sure its Fitness IS and Fitness OS score (in-sample and out-of-sample, respectively) are generally similar. That means, when the strategy is put to real trading, its performance will be consistent with the backtest result. You won't get nasty surprises.

 

 

You're better off picking a slightly lower performing strategy whose Fitness IS and OOS score generally match, than a top performing strategy with disparate Fitness IS vs OOS.

 


 

19.  Should you wish to create top strategies from scratch again, clean the slate with the button “Remove Replaceable Rules”.

 

 

This button removes any rules/filters whose flag is set to “Replaceable”. Let's say you loaded a top strategy, all its filters added by the Divine Engine have their flag set to “Replaceable”. With this button, you can delete them all at once instead of one by one. Then you can do another Divine Engine backtest with this clean slate. Note, flags other than “Replaceable” won't be removed; ditto any rule on the System Settings panel, even if it's set to “Replaceable”. Note, you may need to set the “Notifications” property to “None” (on the Backtest Panel), or override the read-only mode, so the active strategy can be manipulated.

You can also simply load the baseline strategy, and start the Divine Engine afresh:

 

 

Even if you have the same exact Divine Engine settings (by loading the baseline strategy), the strategies that'll be created could be different due to the random nature of the Evolutionary Search. This is why it's recommended to use an Exit Condition, so the fruitless evolution can be stopped early, and you can start over with the same settings. You may also restart Portfolio Boss so you have a new “randomization seed” for the next Divine Engine run.

 


 

Notes:

 

  • Theoretically, Genetic Algorithm (as represented by the Evolutionary Search Mode) will find your ultimate strategy that will become the envy of even the biggest and most successful Wall Street firm. Even more so if you utilize Genetic Programming (Cyber Code Engine). You just need to have a very, very long evolution, along with myriad variables (market data) thrown in, which means enormous amount of computing power spent. Imagine how the human species have evolved from single-celled organisms to space-faring advanced civilizations through billions of years of evolution. But obviously, something that guides the evolution must also be present, to achieve that goal ultimately. That means you must design the Fitness Functions to be faultless: logical, non-contradictory, and above all non-utopian. That is, for example, a 100% straight equity-curve can only exist if nobody is buying and selling through greed or panic.

 

  • A warning notification may be sent to your e-mail if you're about to run out of compute credits. You can either purchase, or wait for the next month's free compute credits. Do understand, despite the vast amount of computer core we have, we can't process unlimited number of backtest per month, hence the necessity to cap each user at 25,000 compute hour credits each month.

 

  • It's not a good idea to whip the Divine Engine hundreds of times to find that holy grail. That's called overfitting, and the chance the resulting strategies would work in real life is reduced about 1% for each Divine Engine run. If the same strategy rules, parameters, settings, and Portfolios are subjected to 10 Divine Engine runs, let's say, then there's a 10% chance the resulting strategies won't work in real life, despite showing good in-sample and out-of-sample performances. You can alleviate this overfitting problem somehow, with the use of Super Out-of-sample.

 

  • If you wish to “extract” a top strategy into its own stand-alone strategy, you can use the “Copy” button from the top of the Backtest Strategy Page:

 

 

So, once a top strategy is loaded as the active strategy, you press that button and give it a name:

 

 

Then press the “Copy” button on that dialog. Note that any Divine Engine parameterization settings (explained later) contained on that strategy will be carried over to the duplicate strategy (even after you restarted PB or your PC, it's still stored there).

This copy function is very useful so you don't lose a top strategy in a big pile of backtest results. You pull it out of the crowd as a standalone strategy, and do other Divine Engine backtests on this sandbox strategy.

 

 

 

 

 

Back to Top