[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Portfolio testing



PureBytes Links

Trading Reference Links

At 10:17 AM -0700 3/28/01, Gary Fritz wrote:

>I want to do basket testing of N systems on M markets -- a
>"portfolio" of systems/markets, for one account. Should be able to
>handle any mix of systems, markets timeframes, etc. I want to be able
>to automatically run the tests in parallel, have the option to
>optimize them all simultaneously (i.e. test Param1 with a value X on
>all systems, then a value X+1 on all systems, etc) or individually
>(different value of Param1 on each system), see portfolio-level
>statistics and equity curves, be able to add/subtract individual
>tests to see how that affects the portfolio performance, etc.
>
>This TS's biggest weakness IMHO. If TS4 would do that, I'd have very
>little need to move to any other platform. I've considered:

I did something like this to trade a basket of 20 commodities with
Aberration in TradeStation 4.0 once.

You can use up to 30 data series and refer to them with an index
such as in:

   for j = 1 to 30 begin
      Val = Close of data(j);
   end;

so by being clever, you can usually rewrite your systems so that they
could appear in such a loop.

You need to do all the profit accounting in code rather than use
TradeStation's accounting, since TradeStation can only trade on
data1, but that is pretty easy.

You need to define arrays to save the values for each market:

Array:MP[20](0), nMP[20](0), ePrice[20](0), eDate[20](0),
       Num[20](0), nProfit[20](0), eRisk[20](0), rLim[20](0);

Then you need to keep track of the values yourself:

       {------Update Accounting-----}

       MP[j] = nMP[j];                  {Update market positions}

       {On an entry, save entry price and date}
       if (MP[j] = +1 or MP[j] = -1) and MP[j][1] = 0 then begin
          ePrice[j] = Open of data(j);
          eDate[j]  = Date of data(j);
       end;

       {On ExitLong update statistics}
       if MP[j] = 0 and MP[j][1] = +1 then begin
          posProfit = Num[j] * (Open of data(j) - ePrice[j])
             * BigPointValue of data(j);
          nProfit[j] = nProfit[j] + posProfit;
          tProfit = tProfit + posProfit;
          if prTrSumm then
             Print(Date of data(j):8:0, EDate[j]:7:0, j:3:0, " XL",
                Num[j]:3:0, "  ", GetSymbolName of data(j),
                Open of data(j):5:2, ePrice[j]:5:2, eRisk[j]:6:0,
                posProfit:6:0, nProfit[j]:8:0, tProfit:10:0);
       end;

It is a lot of work but is fairly straightforward.

If your trading system is complex, you will need to watch the memory
usage in TradeStation 4.0 or use Include Systems.

Bob Fulks