Tag Archives: Numba

Speedy Python with Numba and Genetic Programming

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.

https://gmarkall.github.io/tutorials/pycon-uk-2015/#12

 

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!

Python Numba tips for quant data analysis

Python Numba tips for quant data analysis

This is yet another Python Package to use for compiling just in time

I learned these from my Meteup webinar tonight

python numba for jit
the JIT compiler let you keep the python withou inhecting C++ code

 

for you numba links Numba Docs

1.3. Compiling Python code with @jit
http://numba.pydata.org/numba-doc/dev/user/jit.html

1.4. Creating Numpy universal functions
http://numba.pydata.org/numba-doc/dev/user/vectorize.html

1.6. Troubleshooting and tips
http://numba.pydata.org/numba-doc/dev/user/troubleshoot.html

1.7. Frequently Asked Questions
http://numba.pydata.org/numba-doc/dev/user/faq.html

1.8. Examples
http://numba.pydata.org/numba-doc/dev/user/examples.html

2. Reference Manual
http://numba.pydata.org/numba-doc/dev/reference/index.html

2.1. Numba Types
http://numba.pydata.org/numba-doc/dev/reference/types.html

Join my FREE newsletter to leaern more about using Python for automated trading

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!