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

Re: [GT] alias resolution ... sub resolve_alias revisited



Weigert, Thomas wrote:
Robert,

This is a good idea, except that you break backtest if you use
  while ($sysname !~ /\|/) {

Here is the reason: You could use as a simple alias name to stand for a
"full system name". In that case, there will be no vertical bars in the
full system name and the expansion will fail. It is better to
specifically look for the absence of any of the components in a full
system name.

hey tom

frankly i've stared at that while loop and it's associated
comment trying to comprehend it's intent only to decide that
it's to ensure there is a least one | symbol in the final
$sysname expansion. if that is truly it's purpose then there
may be a better way to accomplish it between your regex pattern
and the original.

aliases::global::macd		SY:MacdDiff | CS:Stop:Fixed 8
aliases::global::macd_ex_p	SY:MacdDiff |
aliases::global::macd_ex	SY:MacdDiff

macd works using backtest.pl macd GOOG

macd_ex_p works and without a close strategy too!

macd_ex one fails, after one pass thru the while loop in question
% backtest.pl macd_ex GOOG
backtest.pl: error: alias key "Aliases::Global::SY:MacdDiff" was not found.

if this is the crux of the issue, then $sysname needs to be looked at
to ensure it includes the minimum set of required system components?

humm -- putting the burden of system components into resolve_alias
doesn't make much sense! maybe a simple regex pattern that does the
check you are (might be) advocating is the way to go:

epiphany!!!

   while ($sysname !~ /:/) {

of course the pattern /:/ requires that an alias NOT contain a colon, but
i think that is probably acceptable -- is there anywhere a specification
for what an alias might have to be or must not be? backtest.pl had the
most description, Tools.pm discussed @ based aliases some, maybe some
more about aliases on the web pages?

anyway, the pattern /:/ works for this series of aliases of aliases
aliases::global::a1	a2
aliases::global::a2	A3
aliases::global::A3	S4
aliases::global::S4	SY5
aliases::global::SY5	macd_ex

using %   backtest.pl a1 GOOG

but the patterns
  /^(I|Indicators|S|Signals|...|PortfolioEvaluation)/
  /\|/
as well as other attempts of mine including
 /^[ACIMOPST]/
 /^(A|CS|I|MM|OF|PE|SY|S|TF)/
all fail.

but throw in a colon and things get good fast!

never-the-less, with this change to resolve_alias, meaning no longer
requiring at least two system components in a returned $sysname, the
burden of ensuring that $sysname does in fact represent a minimally
specified system description, whatever that might be falls on the
using apps. in fact, as shown, backtest.pl (old version anyway)
fails in that regard when getting a system via the alias mechanism.

a bit of a concern exists though, with this change we are shifting
the operation of resolve_alias a bit as described above to not require
the semblance of a minimal system. if the original intent of resolve_alias
was to perform that task we are making a change in the wrong direction.
(note the change is needed to resolve an alias, but it also is removing
the only processing that ensured a system was being described)

based solely on the resolve_alias pod "Return the long name of the
_system_ as described in the configuration file." the word *system*
indicates the alias is expected to expand into a system. is there
anywhere a specification for what a system description must contain.
likely, but i've gotta do some real work so need to close this soon.
therefore i'd advocate adding additional checks in resolve_alias
that ensure the returned $sysname is in fact representative of a
minimal system.

or is resolve_alias the correct place for these checks? maybe that
should be done when the alias is initially created? hard, since it
is basically a hand-hacked file, pushing the burden onto conf->load
and each user app.

gotta go -- looking for more discussion (suggestions etc)

aloha

ras



Cheers, Th.




-----Original Message-----
From: Robert A. Schmied [mailto:ras
AT
acm.org]
Sent: Thursday, May 01, 2008 1:26 AM
To: devel
AT
geniustrader.org
Subject: [GT] alias resolution ... sub resolve_alias revisited

aloha gt'ers

< snip >

examples are better than my ramblings:

with these aliases in your .gt/options file:
aliases::global::mysma[]            	SY:SMA | TF:AcceptAll |
CS:Stop:Fixed #1
aliases::global::tfs[]              	SY:TFS #1 #2 | CS:SY:TFS #1 |
CS:Stop:Fixed #3
aliases::global::tts                	TTS
aliases::global::tts[]              	SY:TTS #1 #2 |
CS:Stop:ExtremePrices #2 #3 | TF:OneTrade
aliases::global::ttsx               	TTS[20,10,1]
aliases::global::rw_sys4[]          	SY:Generic S:Generic:And {
S:Generic:Above { I:Generic:Eval int( { I:Generic:PeriodAgo 1 {
I:Prices VOLUME } } * #1 ) } { I:Generic:Eval int( {
I:Generic:PeriodAgo 2 { I:Prices VOLUME } } * #2 ) } } {
S:Generic:Above { I:Generic:Eval int( { I:Generic:PeriodAgo 1 {
I:Prices CLOSE } } * #3 ) } { I:Generic:Eval int( {

I:Generic:PeriodAgo

2 { I:Prices CLOSE } } * #4 ) } } | OF:ClosedToClose | TF:LongOnly |
CS:Stop::KeepRunUp | MM:FixedShares


< snip >


finally i've not incorporated the alternate while ($sysname !~ /\|/)
regex
as i've yet to find a condition where it helps. of course the amount

of

testing
i've conducted is very limited and certainly simplistic. however, i'd
argue that
gt identifiers (e.g. indicator, signal and system component
specifications) are
case sensitive and have been so forever, so the pattern /i modifier is
likely
incorrect.


feedback is welcome

ras


< snip >

   # The alias content may list another alias ...
   while ($sysname !~ /\|/) {
   #while ($sysname !~
/^(I|Indicators|S|Signals|SY|Systems|CS|CloseStrategy|
   #
MM|MoneyManagement|TF|TradeFilters|OF|OrderFactory|
   #                    A|Analyzers|PE|PortfolioEvaluation)/i) {
   #while ($sysname !~ /^(I|SY|S|CS|MM|TF|OF|A|PE)|
   #                   ^(Indicators|Signals|Systems|CloseStrategy|
   #
MoneyManagement|TradeFilters|OrderFactory|Analyzers|
   #                   PortfolioEvaluation)/i) {
       $sysname = resolve_alias($sysname);
   }
   my $n = 1;
   foreach (@param)
   {
       $sysname =~ s/#$n/$_/g;
       $n++;
   }
< snip >