{"id":2735,"date":"2019-01-12T16:44:42","date_gmt":"2019-01-12T15:44:42","guid":{"rendered":"https:\/\/www.krize-cr.cz\/test\/?p=2735"},"modified":"2019-02-11T15:46:23","modified_gmt":"2019-02-11T14:46:23","slug":"trading-system-generator","status":"publish","type":"post","link":"https:\/\/www.krize-cr.cz\/test\/trading-system-generator\/","title":{"rendered":"Trading System Generator"},"content":{"rendered":"<p>[:en]<\/p>\n<h3>Intro<\/h3>\n<p>Once upon a time there was a term Artificial intelligence defined. It\u2019s subcategories emerged soon after, some of them were inspired by nature. Be it reimplementation of evolution by natural selection proposed by Charles Darwin and Alfred Russel Wallace or deep learning inspired by the structures found in our own brains. Nowadays most of its implementations are tight to computational resources of universal processors, graphical cards, FPGA and ASIC circuits.<\/p>\n<h3>Genetic programming algorithm<\/h3>\n<p>We might have started from the easier target it seems. Genetic programming is a technique generating computer programs using evolution based algorithm.<\/p>\n<p>As the start of a run the evolution algorithm is generating a population with set number of randomly generated individuals. Each individual is represented as a list of specific number of trees.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-medium wp-image-454\" src=\"https:\/\/www.objectively.info\/assets\/wp-content\/uploads\/2019\/01\/genetic-281x300.png\" sizes=\"(max-width: 281px) 100vw, 281px\" srcset=\"https:\/\/www.objectively.info\/assets\/wp-content\/uploads\/2019\/01\/genetic-281x300.png 281w, https:\/\/www.objectively.info\/assets\/wp-content\/uploads\/2019\/01\/genetic.png 298w\" alt=\"\" width=\"281\" height=\"300\" \/><\/p>\n<p>Each tree in the individual represents specific trading strategy behavior \u2013 be it asset selection, entry condition, entry filter, stop loss, exit condition, exit filter. Six trees in every individual in this specific case.<\/p>\n<p>Each individual is run as a trading strategy. It might generate some trades then statistics are calculated. Various statistics can be used for the individual fitness.\u00a0<strong>Right now we are using sharpe ratio multiplied by number of trades to push the evolution algorithm to prefer individuals with higher number of trades.<\/strong><\/p>\n<p>Based on fitness the evolution algorithm selects individuals for mating and mutating phase. Mated\/mutated individuals are made part of the population and the individual\u2019s fitness is calculated again. The best individual is kept in the hall of fame.<\/p>\n<p>This iterative process goes on and after several generations we are expecting working trading strategy in the hall of fame.<\/p>\n<h3>Practicalities<\/h3>\n<p>\u201cSlowness\u201d of Python is negligent as most of the time is spend calculating an individual fitness. Our individuals are creating signals \u2013 genetic programming trees are made \u00a0with numpy and talib optimized functions (C code), the trading algorithm is represented as fully optimized state machine in Cython. In another words from programming point of view it\u2019s mixed vectorized and event based approach to trading system programming.<\/p>\n<h3>Possibilities<\/h3>\n<p>By changing of fitness function we can push the evolution algorithm to generate specific trading strategies. Be it specific risk profile, maximum profit or optimized portfolio. There is a possibility to optimize just part of already existing strategy \u2013 for an example we will be taking an existing strategy with defined entries and the genetic programing will be evolving strategy exits. Additional inputs are possible to use as well \u2013 sources of sentiment information, market and intermarket indices, deep learning networks with pre-trained alphas and well known market alpha signals, etc.<\/p>\n<p><strong>Interesting thing with genetic programming and big amount of alpha factors might be ability to select ones which really matter in the market without being tight to usual evaluation within specific number of days to the future.<\/strong><\/p>\n<p>Milo\u0148 Krej\u010da[:]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[:en]Pushing the evolution algorithm to prefer individuals with higher number of trades.[:]<\/p>\n","protected":false},"author":4,"featured_media":3030,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[104,51,106,70],"tags":[101,72,102],"_links":{"self":[{"href":"https:\/\/www.krize-cr.cz\/test\/wp-json\/wp\/v2\/posts\/2735"}],"collection":[{"href":"https:\/\/www.krize-cr.cz\/test\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.krize-cr.cz\/test\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.krize-cr.cz\/test\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.krize-cr.cz\/test\/wp-json\/wp\/v2\/comments?post=2735"}],"version-history":[{"count":7,"href":"https:\/\/www.krize-cr.cz\/test\/wp-json\/wp\/v2\/posts\/2735\/revisions"}],"predecessor-version":[{"id":3058,"href":"https:\/\/www.krize-cr.cz\/test\/wp-json\/wp\/v2\/posts\/2735\/revisions\/3058"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.krize-cr.cz\/test\/wp-json\/wp\/v2\/media\/3030"}],"wp:attachment":[{"href":"https:\/\/www.krize-cr.cz\/test\/wp-json\/wp\/v2\/media?parent=2735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.krize-cr.cz\/test\/wp-json\/wp\/v2\/categories?post=2735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.krize-cr.cz\/test\/wp-json\/wp\/v2\/tags?post=2735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}