Why Python shouldn't be used for trading algorithms

Discussion in 'App Development' started by Drawdown Addict, Aug 19, 2025 at 11:11 AM.

  1. I know, you are going to say that it is the most popular language and everyone uses it for trading.
    Well, they shouldn't.

    There isn't a month that I am around this forum that I don't get a Python developer liking himself way too much and pointing out that anyone who dares to say anything wrong about that language is a useless developer.

    Just let me start by saying that a proper developer would never get angry if someone criticizes a language, because we can write in many of them, and we know their flaws. But Python developers do, they get so angry when you criticize the language they use that you feel like you are talking to a cult member.

    But let's state the facts. Automated trading is essentially handling money; isn't that obvious? And you need a strong language. A language that won't fail you in the most basic tasks:

    - Lack of private attributes. You wouldn't believe that if someone told you. You can't create an attribute that is only visible to its class; everything is public. Just with that, you can stop reading.
    Then they don't even blink when they write articles about applying SOLID principles in Python, really? Without private attributes?

    - Lack of constants. Every single thing is mutable, literally, everything. Way too SOLID, isn't it?
    Forget about configuration attributes that should be immutable across the whole application.

    - Horrible indentations. Who thought that something that you can't see, like a tab, is a way to create indentation in Python? Who the hell thought about that? What is wrong with brackets or parentheses?
    If you have been programming long enough, you would be able to remember that there was a time when teams changed tabs to 4 spaces, or vice-versa, just do that with a Python source and you will laugh for months with all the bugs that it will generate.

    - Collections are an aberration. Why would you create a map when you can't select any item from it? Then you have to cast it to a list and then use it? Way too efficient! Exactly what you need for trading, inefficient algorithms.

    - Horrible parallelism. Do you want to use async methods? With your shittty classes without private attributes? Well, I hope you are bald already, because you are going to pull your hair.


    - Non-existent decimal types. There is a type that is called decimal, but it is useless. Do you want to test it? Just do this simple check. Is 0.1 + 0.3 = 0.4 ? Well, in Python it isn't. That is exactly what you want to handle pips or steps in future markets, isn't it?

    - Dynamic typing. That is exactly what you want, isn't it? For trading algorithms, you declare an attribute that can contain several types; it will all look fine at the syntax level, but then it will blow right in your face when you run it and change a value. That is exactly what you want when you are handling money, isn't it?

    Want some more details about this:
    https://drmarkclewis.medium.com/the-struggle-of-dynamically-typed-languages-ef91a87164a1

    - Versioning. Do you want backwards compatibility from versions 3 to 2? Well fuck off. You don't get it. It is obvious that any language that wants to call itself a professional language should have backwards compatibility, not Python.

    Now, do you know why Python is popular? At the time, Google had to use a different language to get rid of Java, mainly because of its arguments with Oracle. The creator of Python worked as a Google developer, which is why it became popular; Google made it popular. At that time, C++ was a mess, even said by Stroustrup. So the company had to write a wrapper around it. But then C++ evolved with a very strong standard. It became the standard for many operating systems and evolved into versions that are reliable and strong, especially for trading!

    But what do they use now at Google? Not Python, dear, when they saw the monster they created, they immediately moved to another language, like Go or Carbon. Of course they did.



    Watch the interview from Lex Freedman with the creator of Python, and pay attention when he describes when he had to go to Dropbox to fix their code. A never-ending block of spaghetti where you would get a wrong tab, and you would pray to any god you know.

    Python is for small scripts that don't require any proper software development. The minute you try to do something complex and the project gets bigger, you end up fighting with the language.

    The main reason why many people use Python is that they don't know any better, and they keep copying code from someone else. Especially now that AIs vomit a bunch of Python code every time you ask them for any coding advice.

    Now, wait until a bunch of Python developers jump to this thread and call me every name they know, but I only wrote this post because I can link to it the next time I have to.

    Please don't use Python for your sanity and peace of mind.
     
  2. 2rosy

    2rosy

  3. traider

    traider

    Criticism: Python has no true private attributes; everything is public.

    Counterpoint:

    • Python uses name mangling (__attribute) to discourage access to internal attributes. It’s not bulletproof, but it’s intentional: Python trusts developers to be responsible.

    • This is part of Python’s “consenting adults” philosophy—you’re expected to respect boundaries, not be forced by the language.

    • SOLID principles can absolutely be applied in Python. Encapsulation is about design discipline, not enforced access modifier

    Criticism: Everything is mutable; no way to define constants.

    Counterpoint:

    • Python supports immutable types like tuple, frozenset, and str.

    • Constants are conventionally written in UPPERCASE, and tools like mypy or linters can enforce immutability.

    • For stricter control, use typing.Final (Python 3.8+) or third-party libraries like enforce
    ✅ Example:
    from typing import Final

    MAX_USERS: Final = 100



    Criticism: You can’t select items from a map (dict) without casting.

    Counterpoint:

    • Python’s dict is highly efficient and supports direct access:
    5. “Horrible Parallelism”
    Criticism: Async is painful, especially with Python’s class model.

    Counterpoint:

    • Python’s asyncio is robust and widely used in production (e.g. FastAPI, Discord bots).

    • For CPU-bound tasks, use multiprocessing; for I/O-bound, use asyncio or concurrent.futures.

    • Libraries like trio, curio, and anyio offer elegant async models.

    • Python’s GIL is a known limitation, but not a blocker for scalable async apps.
    ✅ Example:
    import asyncio

    async def fetch_data():
    await asyncio.sleep(1)
    return "Done"
     
  4. Snuskpelle

    Snuskpelle

    The interesting thing about programming languages is that their ecosystems (software & people) become moats. So no matter how flawed the language is people are going to stick with it, and you're going to be fighting an unending fight trying to change it.

    Not trying to either deride or defend Python, I program in C# and C++ almost all the time.
     
    nz_melon and Drawdown Addict like this.
  5. This is the usual level of a Python developer, they can't produce a reply by themselves, they ask an AI and copy what it vomits.
     
  6. traider

    traider

    LOL another language purist. If you program enough you should know every language has its place. Go and ask around and you will realise a huge number of top tier trading firms use python
     
    nz_melon likes this.
  7. First sentence of my post. By two users already.
     
  8. nz_melon

    nz_melon

    Funny, after you boldly stated less than 24 hours ago "python is a shit language" and "fuck off" when someone merely mentioned that they use python and never compared it with another language and did not even go into detail for what they specifically use python. You sound like a total hypocrite. But to the topic:

    See, you again box yourself in. The output, generated by ai, was absolutely correct. I am pretty sure you used ai to write your lengthy post, too. Your problem is that you seem married to your tools and seem hellbent on having to disagree with everyone else who uses different tools that work for them.

    I consider myself an expert C# developer (would very highly likely still outcompete you in any coding competition), I was ranked among the top in C# expertise on SO a few years ago (and was top ranked on SO/QF, too). C# or C++ have their place and are still widely used, so is python. So what?

    All your criticisms above regarding python as applied to trading algorithms are completely pointless because some use them every single day, both, for idea generation and validation as well as algorithm development and to run strategies in production. It works for them. And somehow you seem to have a huge issue with that.

    Your issues with python seem to be of a more personal, emotional, nature than anything else. And you seem to struggle with basic facts and the truth: you said "There isn't a month that I am around this forum that I don't get a Python developer liking himself way too much and pointing out that anyone who dares to say anything wrong about that language is a useless developer."

    Yet it was you who emphatically expressed his hatred for the language" python is shit", "fuxx off",... Were your replies. The other user, I in this case, never made an exclusivity claim or that python was in any way elevated over other languages or tools.

    https://www.elitetrader.com/et/threads/battle-of-the-ais.386029/page-3

     
    Last edited: Aug 19, 2025 at 3:21 PM
  9. nz_melon

    nz_melon

    Not many, but all. And so does every single investment bank. Not for their core algorithmic trading pursuits but for many other tasks. It's perfectly fine to run trading algorithms in python for a retail trader as long as the developer knows what he is doing and understands the pros and cons and handles the code accordingly. Sometimes latency and other requirements exclude certain tool choices and at other times they don't. Each case is different

    Every time you hear someone preach exclusivity in IT space you should run, not walk. OP seems to be a hypocrite because he is doing exactly what he is preaching against.



     
  10. MarkBrown

    MarkBrown