Risk control: Examples |
Top Previous Next |
Now that we’ve explored the behavior of Category-related keywords using simple scenarios to introduce the concept, this section is dedicated to presenting some real-world examples. Initial Size STARTUPCASH = 25000000 IF SECTORPOSITIONS < 4 THEN MEMORY[1] = .02 _ ELSE MEMORY[1] = .01
NEWCONTRACTS = (TOTALEQUITY * MEMORY[1]) / NEWRISK
First, recall, that SECTORPOSITIONS returns the number of open positions currently held in the same (commodity or stock) SECTOR as the trade being presented for Initial Sizing. Note also that the NEWCONTRACTS statement (above) appears to be of the typical fixed-fractional variety; a measure of equity is multiplied by a percentage, and divided by the dollar risk on the trade. In this example, the fixed-fraction is “un-fixed” by use of a memory variable whose value is controlled by a Category-related keyword: the risk per trade is cut in half when SECTORPOSITIONS returns a value greater than 4. Initial Size STARTUPCASH = 25000000 MEMORY[1] = (.02 / SECTORPOSITIONS) NEWCONTRACTS = (TOTALEQUITY * MEMORY[1]) / NEWRISK
In this example, a constant (2%) is divided by the number of SECTORPOSITIONS. The effect is that, as more and more positions come on line (in the energy sector, for instance), each subsequent position is sized smaller and smaller.
If you use multiple sizing criteria, it is better from a coding perspective to employ MEMORY[n] variables, or user-named variables (Lesson 3) to hold values, as we did above, and as is shown, below:
#8913.siz Initial Size STARTUPCASH = 25000000 'risk no more than 4% of equity... MEMORY[1] = (.04 * TOTALEQUITY) / NEWRISK '...or 3 times volatility MEMORY[2] = (TOTALEQUITY * .03) / (SIZING[1] * 3) IF MEMORY[1] < MEMORY[2] THEN MEMORY[2] = MEMORY[1] 'don't trade too much size IF MEMORY[2] > 100 THEN MEMORY[2] = 100 NEWCONTRACTS = MEMORY[2]
This example is excerpted from the sample rules file #8913.siz. The first three statements work together to set the value of MEMORY[2] to the lesser of 4% of equity, or 3 times (3%) of volatility. If MEMORY[2] is greater than 100 contracts, then the value of MEMORY[2] is set equal to 100. And finally… NEWCONTRACTS puts on the number of contracts specified by MEMORY[2].
Examples include:
|