Fork me on GitHub

financeta

App::financeta is a GUI to perform Technical Analysis for stocks using the Perl Data Language (PDL)

Table of Contents

Rules

App::financeta allows you to write English like logical statements or rules that then get automatically compiled to valid PDL code that will execute on the data that you have loaded.

The rules can be one or more statements that are separated by a semi-colon. Separating by a semi-colon allows the user to write very long and complex rules on multiple lines for clarity.

The rule has a simple syntax:

<ORDER> <when|if> <CONDITION> [<CONDITION> ... <CONDITION>] 

The ORDER and CONDITION parts need to be separated by the keywords when or if.

The ORDER part of the rule has the following syntax:

<buy|sell> [QUANTITY] at <PRICE> 

The order types are buy and sell which are keywords. The QUANTITY is optional and is an integer. If the quantity is not provided, 100 is assumed. The price is required and is either a real number or a variable. The price and quantity need to be separated by the at keyword.

Conditions can be a single condition or multiple conditions separated by logical operators given by keywords and, or, && or ||. The && and || are aliases for and and or. The NOT logical operator can be used with the not keyword or the ! sign.

Nested conditions are supported using parentheses ( and ). A nested condition consists of multiple single conditions and other nested conditions.

The single condition has the following possible syntaxes:

 COMPLEMENT:
    not <VARIABLE | NUMBER>

 COMPARISON:
    <VARIABLE> <becomes|crosses> <positive|negative|zero|VARIABLE|NUMBER> \
    [from <above|below>]

Variables are pre-generated by the App::financeta application based on the indicators that the user has added. When the user opens the editor to write the rules, the variables that are allowed are provided in the comments with their descriptions. Each variable begins with a $ sign and is followed by an alpha-numeric name.

There is a special declaration that can be used by the user and it is given below:

<allow|no> <long|short> trades

This declaration tells the code generator whether to allow or disallow long/short trades. The user can use this to tune their strategy output.

Comments are allowed, and any line beginning with the # sign begins a comment.

Examples

Here is a sample example generated for an MACD indicator:

### START OF AUTOGENERATED CODE - DO NOT EDIT
### The list of variables that you can use is below:
### $open
### $high
### $low
### $close
### $macd_12_26_9
### $macdsig_12_26_9
### $macdhist_12_26_9
### END OF AUTOGENERATED CODE

    no short trades;

    buy at $open when $macdhist_12_26_9 becomes positive and $macd_12_26_9 crosses $macdsig_12_26_9
    from below;

    sell at $high when $macdhist_12_26_9 becomes negative and $macd_12_26_9 crosses
        $macdsig_12_26_9 from above;

This shows that when the $macdhist_12_26_9 variable value becomes positive along with the crossing condition, a buy signal will be generated. Similarly, a sell signal will be generated when it becomes negative and ther crossing condition is valid. As you can see, short trades are not allowed in the strategy.

Table of Contents