Gain access to exclusive tools that Wall Street's Elite don't want you to have. Don't miss the next issue...
Join 11,500+ Quant Scientists learning one article at a time
Join 11,500+ Quant Scientists learning one article at a time
In this QS Newsletter (get the code), we are sharing some development updates on Pytimetk, a new Python library for time series analysis built on top of Pandas and Polars. Our objective today is to see how to share how you can create financial features (factors) blazingly fast with the polars engine. Today, you learn:
New updates in Pytimetk for Quant Scientists (Quantitative Data Scientists)
3 New Functions for Financial Feature Engineering
BONUS: Get the Python Code for EVERYTHING you see in this post
Disclaimer:
The information and educational material provided by Quant Science, LLC are for educational purposes only and should not be considered as financial advice or recommendations to purchase, hold, or sell any securities or other financial instruments. Before you proceed, please review our full disclaimer here.
Pytimetk: A new Python package for time series and financial analysis
And here's what we are covering today: 3 New financial functions for 20X speed boost vs Pandas.
Want exclusive access to our FULL codebase for this Quant Science tutorial plus dozens more? The code is in the QS0012 Folder. Join here:
Are you interested in learning Algorithmic Trading with Python? Do you want to learn how to execute trades automatically, how to find edge, backtest trading strategies, analyze risk, then take your winning trades from Paper Account to Production (Live Trading)?
If the answer is Yes, then I have a Quick favor to ask - We're preparing for the next cohort of our new python for algorithmic trading course. If you can spare 60 seconds, we'd love to hear what would help make you a better trader from our course. Click here to enter your 60-second survey.
And you can join the waitlist for our next Cohort.
Pytimetk is a time series analysis package that makes time series easier, faster, and more enjoyable in Python. Full disclosure - Quant Science's co-founder (Matt Dancho) is the author. And he's been hard at work adding new Finance tools inside of Pytimetk.
Before I discuss that, let's talk speed. One of the novel features of Pytimetk is that it integrates a Polars backend (engine) for many time series and finance functions. Polars is between 3X and 1000X faster than Pandas for many tasks (see our speed comparisons here).
On rolling operations (very common in finance), our Polars engine is on average 10X faster than the Pandas engine.
So if you care about performance, then Pytimetk is your friend. (It's also easy to use, which makes it less painful to do financial and time series analysis)
Let's check out these 3 new functions today, shall we?
The goal with our tutorial today is to kick the tires on 3 new finance functions that are inside the development version of Pytimetk (Version 0.3.0.9000). Get the code: It's in the QS012 folder.
Before you begin, make sure to install the development version of Pytimetk:
pip install git+https://github.com/business-science/pytimetk.git
The first step in our analysis is to load the following libraries and setup our analysis parameters. Run this code:
Get the code: It's in the QS012 folder.
The code produces the following data:
Next, we will use Pytimetk's augment_macd()
Function to generate MACD features as new columns in the data frame. We will use the polars engine to get a speedup. Run this code:
Get the code: It's in the QS012 folder.
The resulting data frame now has 3 new MACD features added:
Just like MACD, we can make Bollinger Bands with the augment_bbands()
function. Note that now I'm adding multiple periods [20, 40, 60] to make multiple combinations of Bollinger Band Features. This adjust the rolling windows parameter used to make the bands. Run this code:
Get the code: It's in the QS012 folder.
We now have 9 new features:
Get the code: It's in the QS012 folder.
Now that you have the hang of it, you can begin chaining features operations to quickly add many finance and time series features. Run this code:
Get the code: It's in the QS012 folder.
Now you have 40+ features for running machine learning algorithms on your finance data:
Get the code: It's in the QS012 folder.
Pytimetk
is a new library. As of this writing, it's still under active development, so many of these functions are being added. We will keep you updated on progress. And we look forward to teaching them to you in our QS Algo Trading program.
Ready to take your investment game to the next level? Embracing Python for algorithmic trading can be a game-changer for your portfolio. If you're new to Python or want to sharpen your skills for financial analysis, our upcoming Python for Algorithmic Trading Course is the perfect opportunity. See you in our Python Algo-Trading course!
There's nothing worse than going at this alone--
❌ Learning Python is tough.
❌ Learning Trading is tough.
❌ Learning Math & Stats is tough.
It's no wonder why it's easy to feel lost.
And all of this increases the likelihood you will fail (not to mention lose money in the process). Protect your future.
👉 Join 5100+ future Quant Scientists on our Python for Algorithmic Trading Course Waitlist: https://learn.quantscience.io/python-algorithmic-trading-course-waitlist
Gain access to exclusive tools that Wall Street's Elite don't want you to have. Don't miss the next issue...
Join 11,500+ Quant Scientists learning one article at a time
Join 11,500+ Quant Scientists learning one article at a time