  Posted

The pseudocode for the BUY-SELL-WAIT function as defined in the "Trading Strategy Mining with Gene Expression Programming" paper is shown below:

IF (the value of buy-tree of day t > 0)
AND (the value of sell-tree of day t ≤ 0)
ELSE IF (the value of buy-tree of day t ≤ 0)
AND (the value of sell-tree of day t > 0)
THEN signal(t)←SELL (-1)
ELSE
signal(t)←WAIT (0)
END IF

It's a function of 2 arguments with 3 discrete outputs {-1, 0, +1}. And here's the C++ code for the BSW function:

if (arg > 0.0 && arg <= 0.0)
return 1.0;
else
if (arg <= 0.0 && arg > 0.0)
return -1.0;
else return 0.0;

I tried this function in GeneXproTools with the Iris dataset and it worked great, both as a linking function linking 2 expression trees and as part of the function set, both in unigenic and multigenic systems. In unigenic systems it usually ended up at the root of the tree, achieving high accuracy on the Iris data.

So, this is a great function and would have been a great addition to the built-in math functions of GeneXproTools. But unfortunately I could not find a neutral gene for this function (remember, we need to be able to add a neutral gene to an existing program in order to keep this functionality in GeneXproTools)! Maybe some math wizard out there can find one? But anyway, I had to modify the BSW function slightly for it to have a neutral gene so that it could be used as linking function too:

if (arg > 0.0 && arg < 0.0)
return 1.0;
else
if (arg < 0.0 && arg > 0.0)
return -1.0;
else return 0.0;

This function also works great with the Iris dataset both as a linking function connecting 2 trees and in single-gene systems connecting the left and right branches of the tree.

This function will be added to the built-in math functions of GeneXproTools and also to the linking functions of Regression, Classification and Logistic Regression (I don't see much use for it as linking function in Time Series Prediction so we won't implement it there, unless someone thinks it could be useful even there). I'm thinking of representing it as CL3A, which is a more generic name than the catchy BSW name. The "CL" part refers to "Classification"; the "3" indicates the number of discrete outputs; and "A" represents the order. So, yes, there are more functions like this one in store for us. I'll describe them in the next post.

Author