Speeding up tick data calculations in Python

Speeding up tick data calculations in Python

Time, time, time. At the current moment, we likely have a bit more time than usual. Despite this, it's unlikely any of us actively want to wait longer for code to execute! Last week, I wrote about libraries for working with large datasets, like Dask and Vaex, or using databases like kdb+/q. This week, I'll continue the theme, given all the feedback and suggestions I've got about the article. This time, the focus is on Python tools which can be useful for speeding up calculations, plus other tips and tricks you can use with tick data, which aren't necessarily Python specific (thanks to @ewankirk for a few of these in reply to my original tweet, in particular with respect to tricks with tick data).

Cython - https://cython.org/

Python is an interpreted language, hence it doesn't need compiling to run it. The flip side is that it tends to be slower than compiled languages. Cython allows you to "compile" some of your code. Essentially, it is basically special Python-like code that can be converted into C and statically compiled down into machine code. You can also "release the GIL" with Cython allowing true parallelization of your code. Many Python libraries use Cython to speed up computation such as Pandas.

If you take time to annotate your code with type declarations for Cython and rewrite it, it can help to speed it up more. How fast it will be depends upon how much of the Python code you've written can be converted by Cython. If you want to play around with Cython, it's pretty easy to do so in Jupyter notebooks. All you need to do is add %%cython to your code cell and your code in that cell with be compiled

Numba - https://numba.pydata.org/

Numba is similar to Cython, in that it can convert....

To read the rest of the article on the Cuemacro website, please click here!

Sahand Haji Ali Ahmad, PhD

Systematic Trader (Quant-Algo) , Cofounder and CEO of Causal Experts

4 年

Good one :)

要查看或添加评论,请登录

Saeed Amen的更多文章

  • Learning from running financial models live

    Learning from running financial models live

    Let's say you are the world's best burger chef (we all have ambitions, right). You'd be serving up all manner of…

    1 条评论
  • DeepSeek, objectives and constraints

    DeepSeek, objectives and constraints

    When a new burger joint opens up, there's often a buzz. Everyone (well, at least me) wants to try the new burger.

    1 条评论
  • Hundreds of quant papers from #QuantLinkADay in 2024

    Hundreds of quant papers from #QuantLinkADay in 2024

    I tweet a lot (from @saeedamenfx and at BlueSky at @saeedamenfx.bsky.

  • What we’ve learnt from reading thousands of Fed communications

    What we’ve learnt from reading thousands of Fed communications

    We recently had the last FOMC decision of 2024. Market l participants reacted to the hawkish tone including Powell’s…

    1 条评论
  • Takeaways from QuantMinds 2024 in London

    Takeaways from QuantMinds 2024 in London

    Over the past years, the quant industry has changed substantially. My first visit to Global Derivatives was just over a…

    12 条评论
  • Takeaways from Web Summit 2024

    Takeaways from Web Summit 2024

    Think of Lisbon and no doubt it’ll conjure images of explorers setting sail in centuries past across the ocean, the…

    1 条评论
  • FILS Europe 2024 Takeaways

    FILS Europe 2024 Takeaways

    Paris is home to many things, the Eiffel Tower, the Arc de Triomphe, burgers (ok, I made that one up!). In recent…

    4 条评论
  • Don't look back in hangar steak

    Don't look back in hangar steak

    I'm currently in the queue for Oasis tickets. Rather than mindlessly watching the counter of people in the queue ahead…

    5 条评论
  • The Olympic spirit for forecasting

    The Olympic spirit for forecasting

    The Olympics finally finished, and the Paralympics are about to begin. I managed to go to some of the Olympic football…

  • Eleven years of independence

    Eleven years of independence

    Regrets become ever more edged with the passing of time. Recalling a time long gone, when perhaps a decision made, was…

    5 条评论

社区洞察

其他会员也浏览了