r/quantfinance • • 1d ago

C++/Python vs. C++/Rust: Which Stack Should I Choose for My Trading System Rebuild?

I currently have my servers set up for both dry-run and live trading in weather prediction markets, primarily on Kalshi. I also have access to Polymarket and ForecastEx WebSocket feeds. I’m now expanding into crypto, primarily tracking four cryptocurrencies across 15-minute and one-hour prediction markets.

My system currently uses C++ and Python. The live trading engines run exclusively in C++, while almost everything else is written in Python.

I’m preparing the next iteration of the system and moving it into a new repository to clean up the architecture, standardize workflows, and eliminate unnecessary code. My goal is to reduce the codebase by 50–75%.

That brings me to my next question: should I use this opportunity to change the language split? I’m considering two options:

  • C++ and Rust: C++ would handle all trading functionality, while Rust would handle operations, data transport, database ingestion, and related infrastructure.
  • C++ and Python: Keep the existing language combination, but expand C++ to cover all trading functionality while retaining Python for operations and related workflows.

What are the pros and cons of each approach? Since I’m already reorganizing the system and moving to a new repository, would this be the right time to make that change? Or is there another code that I'm completely missing here?

1 Upvotes

10 comments sorted by

2

u/AoideusWasBanned 1d ago

Doing a rewrite and switching languages at the same time sounds like two projects to me. I'd keep Python for the ops side, move the trading parts fully into C++, and only try Rust later on one piece that actually hurts.

2

u/fletchmm 1d ago

Ok so you're saying do the complete audit and make the system transfer over to the new repo that is lean/mean/and completely standardized and documented moving forward. Only once that is fully complete, revise the new repo and make the code switch happpen? Don't do them at the same time?

1

u/AoideusWasBanned 1d ago

Yeah, that's what I meant. Get the lean repo running in the languages you already have first, then swap one piece at a time. If something breaks you know which change did it.

Your split looks ok to me. Ingestion is probably the safest spot to try Rust since it doesn't make trading decisions.

2

u/fletchmm 1d ago

Also this was an idea for a progressive code switch. I really dont like the idea of running 3 different languages in my system but I'm open to any ideas that are good ideas. This is what a progressive switch would look like initially:

  • C++: all production trading decisions, risk enforcement, order execution, and authoritative live trading state.
  • Rust: capture/transport services, receiving, buffering, recovery, ingestion, and storage management.
  • Python: research, model development, experiment orchestration, analysis, reporting, and selected administrative tools.

1

u/Salty_Hedgehog_6931 15h ago

Why not c++ and eliminate everything else.

1

u/fletchmm 14h ago

RUST does do a handful of things better. The compiler forces robust code development and ownership which doesn’t allow invalid memory access, data races, and unhandled data states.

I truly believe that it is much better for operational/relay/database core code to use. C++ and RUST perform in the same performance tier because they both compile down to the native machine code

1

u/Salty_Hedgehog_6931 14h ago

Idk it seems like you’re complicating it.

1

u/fletchmm 14h ago

I don’t think so, but I’ll find out soon enough. Most of these systems are running on C++/Python. Python is very good at the experimental and research side but as for the core trading operations and operational code/scripts, I think that is the right call of making the switch to rust.

Take a look at that GitHub I posted earlier. I found somebody that tested this after the fact and his findings line with my exact thoughts

1

u/fletchmm 14h ago

I could also use polars which is written natively in rust and is a first class python binding built on top of it. Essentially allowing you to coding use python with a rust build.

I’m gonna see it through, but it definitely has legs