Speedy Python with Numba and Genetic Programming

(Last Updated On: May 22, 2017)

Speedy Python with Numba and Genetic Programming

A comment came in from highly active newsletter subscriber:

Python slow and inefficient”


You mention Cython in speeding up your code, you may like to consider for certain situations adding numba to your arsenal as well. Numba allows you to keep your python code in generic form and use a decorator to invoke a LLVM (JIT)compiler to compile the byte code run close to machine code times. http://numba.pydata.org/numba-doc/dev/user/examples.html


I use this often after profiling the python code to target bottlenecks, (http://markdewing.github.io/blog/posts/prototype-for-profiling-python/)

It can be used with multithread and also Numba Pro and CUDA with Nvidia GPUs. By profiling the code you can ascertain where the bottlenecks are in the code and where to target your efforts in speeding up code.



For comparison studies see https://www.ibm.com/developerworks/community/blogs/jfp/entry/How_To_Compute_Mandelbrodt_Set_Quickly?lang=en


(Another option for fast computation is to write a Fortran function directly ( yes I am of that vintage! J ), and use the f2py package to interface with the function.)


The other comment: you refer to the issue of the “market landscape always changing”, and you need a library of algorithms to cater for this.  I would add not only a library, but a “dynamic” library. One such approach would be to use Machine learning to generate new ideas constantly. Genetic Programs (GP) can generate trading ideas or systems from the data itself (more advanced applications will write the system code) , you may have a machine dedicated solely for this task. If you map your search space to a higher dimension you may discover patterns  that are exploitable and give you an edge. Being nimble counts.


I followed up with questions of:

What GP Python packages to use? Compatible with Machine Learning Python packages that this can work with? Any such examples for this use?

This story shall continue


NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Subscribe For Latest Updates

Sign up to best of business news, informed analysis and opinions on what matters to you.
Invalid email address
We promise not to spam you. You can unsubscribe at any time.


Check NEW site on stock forex and ETF analysis and automation

Scroll to Top