Risk control: Sets and categories |
Top Previous Next |
Through the years, we’ve been exposed to all sorts of common wisdom that advises us, for example, to never risk more than X percent of equity on a single trade, or face the risk of being labeled a gunslinger. Others warn us to never risk more than Y percent of an account on currently open trades (cumulative open risk). Will sizing trades at 2% of equity (initial risk) on 16 markets, produce results that are equally volatile as sizing trades at 1% of equity on a 32 market portfolio? And how do you measure risk? Ed Seykota and Dave Druz state that, “In portfolio management, we call the distributed bet size the heat of the portfolio. A diversified portfolio risking 2% on each of five instruments has a total heat of 10%, as does a portfolio risking 5% on each of two instruments.” Determining Optimal Risk. Stocks & Commodities V. 11:3 (122-124). Are they right? Probably so! But when it’s your fund or your reputation on the line, what anyone else thinks should only motivate you to conduct your own research. As Mechanica author Bob Spear wrote some time ago about Mechanica’s predecessor, “it is the result of the years I spent seeking answers to mostly the wrong questions.” He continues: Users find that they are able to make great things happen when they can visualize, model, or simulate a complete trading plan, and my job was to design the software to be as non-restrictive in this process as I could possibly make it. Of the many questions I asked, precious few proved to be good ones. If you are like me though, once you do find a good question, that's just the beginning of a series of questions: Is it better to trade one market with one system…or a lot of markets with one system? Or a lot of markets with a lot of systems? Isn't Risk Control really just Profit Control? What sort of day-to-day ride can I expect? These are exactly the kinds of scenarios that Mechanica is uniquely designed to allow you to test.
Understanding Categories and Sets As we mentioned at the top of this lesson, position sizing is a strategic trading tool that can help you enhance the performance of your system by controlling risk; dynamically managing risk via conditional sizing and resizing operations is exactly what Mechanica is designed to do. Mechanica allows you to view your portfolio in layers, through multiple sizing and resizing category windows, so that you can methodically control risk at every level of every system, or across all systems universally. Mechanica Basic allows you to discretely address each of the various interrelated risk components in a portfolio, as well as the relative importance of each individual risk component to the whole. Once these risk components and their relationships have been defined and organized, you can begin to manipulate them to accomplish your goals. We started by identifying the logical relationships that naturally exist among the various components in a portfolio. Then, we broke these relationships down into categories that view risk from the perspective of sets. With regard to Initial Sizing, Mechanica allows you to accept or reject new trades, and determine the number of contracts or shares to put on, based on any combination of the following metrics:
It is this last item that we’ll be exploring in detail in the following pages. Before getting started, there is an important distinction to make. On the Initial Size page, the work we do (the action we take) is applied to a single new position, and by extension to the set(s) into which it seeks membership. By referencing set-level properties, we can allow or disallow membership in a set, and determine the size at which a new trade is to be placed, if indeed, membership is allowed. On the Resize page, we reference various properties to make decisions about how to modulate the size of positions. In both instances, the goal is to control risk and reward by controlling position size. Keywords To initialize the Position Category in Mechanica, simply type in POSITION on the Resize page, and precede it with the tilde character (“~”). Once initialized in this manner, Mechanica assumes that all code that follows is specific to positions. There are various category-legal keywords that are designed for use following a Category designation. They are: CONTRACTS / SHARES EQUITY RISK TOTAL-prefix words like TOTALRISK
These category-legal keywords return values that you will reference when developing risk-control strategies. They return values for the specific position which Mechanica is currently processing. Here is an example of the correct syntax as it would be employed on the Resize page: ~POSITION ' initializes POSITION category IF RISK > TOTALRISK * .02 THEN MULTIPLIER = .75 ' resize statement
In pseudo-code this means: IF PositionRISK > TOTALRISK * .02 THEN MULTIPLIER = .75
Controlling risk with Category-related keywords This exercise is designed to increase your understanding of category-related keywords, and at the same time, expand on the differences between the two modes of Include Today (Yes / No).
In the following example, a fixed number of contracts is traded. While this is not reflective of real world trading, it keeps things simple and makes the concepts easier to grasp.
Resources SYSTEM = 5 STARTDATE = 20010101 COL1 = OPEN COL2 = CLOSE
Trade Entry IF DATE = 20011211 THEN BUYOPEN
Trade in Progress & Exit IF DATE = 20011217 THEN SELLCLOSE
Discussion
Initial Size INCLUDETODAY = TRUE XRAYSTARTDATE = 20011211 XRAYENDATE = 20011217 STARTUPCASH = 25000000 IF SECTORPOSITIONS < 3 THEN NEWCONTRACTS = 8
Discussion Before running the Position Sizing Rules, let’s discuss the code: The first line sets the INCLUDETODAY mode to TRUE. This accomplishes the same thing as selecting Include Today YES under the Position Sizing menu. Since this feature can significantly alter the behavior of the Initial Size rules, it is better to place it in the code, where it will serve as a reminder of which mode you are operating in.
IF SECTORPOSITIONS < 3 THEN NEWCONTRACTS = 8
The statement above is logically equivalent to: IF SECTORPOSITIONS < 3 THEN NEWCONTRACTS = 8 ELSE _ NEWCONTRACTS = 0
Please note the underscore at the end of the line. It is simply used as a line continuation character in this documentation to indicate that this code belongs all on a single line in your program.
The sizing code we typed in for Lesson5d.siz appears below for the sake of convenience in discussion: Initial Size INCLUDETODAY = TRUE XRAYSTARTDATE = 20011211 XRAYENDATE = 20011217 STARTUPCASH = 25000000 IF SECTORPOSITIONS < 3 THEN NEWCONTRACTS = 8
Now, please look at the statement containing the category-related keyword SECTORPOSITIONS. This keyword returns the number of open positions currently held in the same sector as the trade currently under consideration for Initial Sizing. In plain English, it means: If the number of positions in the Currency SECTOR is less than three, then NEWCONTRACTS = 8, else NEWCONTRACTS = 0.
In order to see what actually happened, click the Daily Detail tab under the Portfolio Performance window, and look in the Open Positions column. This is what you should see:
INCLUDETODAY = TRUE IF SECTORPOSITIONS < 3 THEN NEWCONTRACTS = 8
Had the INCLUDETODAY statement been set to False instead of True, the outcome would have been quite different. The positions were sized as they were, because with INCLUDETODAY set to True, the values for all category-related keywords are updated throughout the trading day, each time a position was entered. So once the Canadian Dollar position was put on, the SECTORPOSITIONS condition became false, and subsequent positions were sized at zero (0) contracts.
INCLUDETODAY = FALSE IF SECTORPOSITIONS < 3 THEN NEWCONTRACTS = 8
All five trades were sized at eight (8) contracts when INCLUDETODAY was changed from True to False. In this mode, Mechanica looks at the values of all category-related keywords as of yesterday's close, and as of the entry date of our five (5) trades, yesterday's value of SECTORPOSITIONS was zero (0), and the implied limiting condition (IF SECTORPOSITIONS => 3) didn’t become true until the close of the entry day, after all positions had already been sized. IF SECTORPOSITIONS < 3 THEN NEWCONTRACTS = 8
Given the logic of the NEWCONTRACTS statement (above)… If, for instance, on the day before the entry day of our five Currency trades, the system(s) had been carrying three existing Currency trades—i.e. three trades in the Currencies SECTOR—then the five Currency trades that entered on 20011211 would have been sized at zero (0) contracts. As another example, if on the day before the entry day of our five Currency trades, the system(s) had been carrying two existing trades in the Currencies SECTOR, then the five Currency trades that entered on 20011211 would still have been sized at eight (8) contracts, because the implied limiting condition (IF SECTORPOSITIONS => 3) didn’t become true until the close of the entry day…because as of the close last night, there were only two positions open, and that is all we are allowed to see (with Include Today = False).
Resources 'SYSTEM = 5 SYSTEM = 6 STARTDATE = 20010101 COL1 = OPEN COL2 = CLOSE
Trade Entry 'IF DATE = 20011211 THEN BUYOPEN IF DATE = 20011210 THEN BUYOPEN
Trade in Progress & Exit IF DATE = 20011217 THEN SELLCLOSE
INCLUDETODAY = TRUE ' : : <- snip IF SECTORPOSITIONS < 3 THEN NEWCONTRACTS = 8 As of the beginning of the trading day on 20011210, SECTORPOSITIONS returned a value of 0, and FX_REV and MP_REV were sized at 8 contracts each. At the beginning of the next trading day (20011211) the Position Sizing Rules began sizing the original five (5) currency trades (and does so in alphabetical order, according to the default SortList). AD_REV (the Australian Dollar) was first up, and was sized at 8 contracts, because SECTORPOSITIONS < 3. Remember – when INCLUDETODAY is set to True, the values for all Category-related keywords are updated throughout the trading day, each time a position is entered. Thus, after the Australian Dollar position was put on, the SECTORPOSITIONS condition became false (SECTORPOSITIONS was no longer less than three), and the subsequent trades from System 5 were sized at zero (0) contracts.
We introduced the concept of Simultest in this exercise without a lot of explanation, but an entire lesson is dedicated to this important topic Critical Concept: Simultest. In essence, Simultest simply keeps previous trades from being overwritten, so that multiple Signal Rules files can be run, one after the other, with each system’s trades stored in a composite trade database, along with a unique system identifier. These trades can later be accessed by the Position Sizing Rules, with full knowledge of which trades were generated by which system. Of course, once the Signal Rules have been run and trades have been generated for a system—or for multiple systems, using Simultest mode as we did here—you are free to experiment with various Initial Sizing and Resizing strategies, without having to re-run the Signal Rules. At this point, it is sufficient to remember that:
|