Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Case study: Using Grammatical Evolution to develop trading rules.
buy buy buy sell sell sell sell An automatic trading system decides when to buy and sell based on a certain rule set If we...
The following  BNF  (Backus–Naur Form) grammar makes it easy to describe a whole  universe of different rule sets. <S> ::=...
Such automatically generated trading rules can be tested on historical data. If we define a criterion for the quality of a...
GEVA 2.0 That is the setup used for the result on the following slides.
BNF grammar The encoding and the grammar distinguishes Grammatical Evolution from Evolutionary Algorithms / Programming.
The following settings were used to construct a simple trading system. BNF grammar Settings for the genetic search algorithm
sigdn = ifelse( ( sma40 <= sma20 ) | ( sma160 >= sma80 ) ,-1,0); sigup = ifelse( sma5 <= sma10 ,1,0);  The winning trading...
The best trading rules applied to the S&P 500 from 2000-01-02 to 2008-12-05. This is not an realistic test for real world ...
Remarks: <ul><li>The test doesn't give us information on the real world performance of this trading rules since:  </li><ul...
No commission was included, which might explain the many trades on the short side. </li></ul></ul>But, It clearly shows th...
Software used <ul><li>GEVA 2.0 from( http://ncra.ucd.ie/Site/GEVA.html )
R
R-package Quantmod and many more  </li></ul>
 
 
Further examples of BNF to construction of trading rules.
 
Upcoming SlideShare
Loading in …5
×

Using Grammatical Evolution to develop trading rules

1,509 views

Published on

  • Be the first to comment

Using Grammatical Evolution to develop trading rules

  1. 1. Case study: Using Grammatical Evolution to develop trading rules.
  2. 2. buy buy buy sell sell sell sell An automatic trading system decides when to buy and sell based on a certain rule set If we base the rules on moving averages (colored lines) one possible rule would be: buy, if yellow crosses above purple
  3. 3. The following BNF (Backus–Naur Form) grammar makes it easy to describe a whole universe of different rule sets. <S> ::= <tradingrule> <tradingrule> ::= sigdn = ifelse(<signal>,-1,0);sigup = ifelse(<signal>,1,0); <signal> ::= (<signal>) AND (<signal>)|(<signal>) OR (<signal>)|<var> <relop> <var> <relop> ::= <= | >= <var> ::= sma5|sma10|sma20|sma40|sma80|sma160
  4. 4. Such automatically generated trading rules can be tested on historical data. If we define a criterion for the quality of a trading rule we can then create an algorithm that searches for the best possible set of trading rules. Grammatical Evolution
  5. 5. GEVA 2.0 That is the setup used for the result on the following slides.
  6. 6. BNF grammar The encoding and the grammar distinguishes Grammatical Evolution from Evolutionary Algorithms / Programming.
  7. 7. The following settings were used to construct a simple trading system. BNF grammar Settings for the genetic search algorithm
  8. 8. sigdn = ifelse( ( sma40 <= sma20 ) | ( sma160 >= sma80 ) ,-1,0); sigup = ifelse( sma5 <= sma10 ,1,0); The winning trading rules after 100 generations are: The following formula has been used to calculate the fitness of each rule set.
  9. 9. The best trading rules applied to the S&P 500 from 2000-01-02 to 2008-12-05. This is not an realistic test for real world performance, please notice remarks on next slide.
  10. 10. Remarks: <ul><li>The test doesn't give us information on the real world performance of this trading rules since: </li><ul><li>The algorithm didn't actually forecast the price development, it already knew the future.
  11. 11. No commission was included, which might explain the many trades on the short side. </li></ul></ul>But, It clearly shows that the algorithm was capable to find trading rules that make intuitively sense and are profitable under the circumstances we provided. Further experiments with complexer grammar with more realistic settings is needed to obtain further insides.
  12. 12. Software used <ul><li>GEVA 2.0 from( http://ncra.ucd.ie/Site/GEVA.html )
  13. 13. R
  14. 14. R-package Quantmod and many more </li></ul>
  15. 17. Further examples of BNF to construction of trading rules.
  16. 19. Instruction on how to reproduce the show example. Requirements: <ul><li>Linux (Ubuntu)
  17. 20. R </li><ul><li>Packages: quantmod, TTR, rJava </li></ul><li>Eclipse </li></ul>In Eclipse: Edit/Import/Import Existing Project into Workspace
  18. 21. Edit run configuration for Main class “ Main.RunTradSys”
  19. 22. Extensions of the GEVA 2.0 code and files needed to modify the rule generation. Setup GEVA and starts instance of R Here get the rule sets pushed into R and feedback captured R files to setup the data and evaluate the rule sets. BNF grammar Properties for genetic search.

×