Updating quantKit, the Python tool kit we are creating for research
Discussing updates to Python code base and goals for the project.
Disclaimer: the following post is an organized representation of my research and project notes. It doesn’t represent any type of advice, financial or otherwise. Its purpose is to be informative and educational. Backtest results are based on historical data, not real-time data. There is no guarantee that these hypothetical results will continue in the future. Day trading is extremely risky, and I do not suggest running any of these strategies live.
Ok, my break was too long. After the basement flooding issue, my father had a medical emergency and has been in and out of ICU for the last month. With everything going on, I fell off for a bit, but now I am back and ready to work.
As we know, I am shifting focus for the time being to research and creating tools to help us research trade systems better, and without vendor lock-in. That's the goal, anyway. Ultimately, it is going to be a learning process, so we can learn why our tools matter and how they improve our testing and research process. For me (HGT), this will consist of 3-4 distinct projects.
I am going to focus on creating a set of tools for testing in Python, building on the statistical testing tools I created last year for feature/indicator testing. I am also going to focus on creating strategy and indicator libraries for RealTest and Wealth 8 for the HGT users to play with and use. While learning how to create tools in Python, I will also work on building a platform for testing and running algorithmic strategies in Zig.
Today, we focus on what has been updated so far in the Python tools and where to access the project ( it's open source).
First, the name of the project is quantKit, and the goal is to make an efficient backtesting and researching tool set for algorithmic trade system development. I have no intentions of using this tool for live trading, so I won't focus on that part.
If you recall from any of the statistical testing posts, we had several tests that we created in this project. Some tests were simple, others more complex. While they worked, and matched the calculations and logic from the source material, they weren't the most efficiently written functions. So, my goal is to go back through these functions and refactor them to be more efficient.
I also intend to begin orienting the tool to be used from the command line. This means that everything will be printed to the command line first, and saved to file second (or at user request). The idea is to streamline development and remove any abstractions that could create more overhead or limit developer capability.
As an example, I went through the first test in the library and updated it to use Numpy's built in vector functions to increase the speed of the test by 85%. This is the simplest test of the bunch, and was already pretty fast, so I don't know what kind of performance increase we will see at the end, but I am hopeful that we can get the overall testing speed down to something more reasonable when testing a large amount of features. The photo below shows an example of how long it took to generate the simple stats report ( with relative entropy).
Not too shabby, right? This section is so simple that adding in multiprocessing for this test actually slowed down the overall speed of the report. I imagine I will see multiprocessing become more useful as we get to the more computational intensive tasks and permutation testing.
Next up is the mutual information function, then the mean break test, and lastly the optimal threshold test. Once these are complete, I will shift over to the backtesting engine and data management.
Check out the Python project repo below:
Happy hunting!
Feel free to comment below or e-mail me if you need help with anything, wish to criticize, or have thoughts on improvements. You can also DM me or start a chat thread. Red Team members can access this code and more at the private HGT GitHub repo. As always, this newsletter represents refined versions of my research notes. That means these notes are plastic. There could be mistakes or better ways to accomplish what I am trying to do. Nothing is perfect, and I always look for ways to improve my techniques.
Super Cool!!! 🔥😎