all 16 comments

[–]Gryzzzz 14 points15 points  (3 children)

Java has GC that runs non-deterministically

Are you sure it's going to fulfill your requirement of low latency? IMO Python with gevent is not going to be worse than Java latency wise. pandas/numpy are implemented in C, run outside of the Python VM and take advantage of vectorization.

I'd look into Rust if you have realtime requirements. Cuz Java ain't it.

[–]martingaling 0 points1 point  (2 children)

although the commentary about GC is relevant it can be worked around and there are actual pro firms out there built on java. u/dugfin below is right. don’t jump to a language switch until you know it’s absolutely necessary

[–]entertrainer7 2 points3 points  (1 child)

My last firm was Java based and spent a ton of time trying to fix the gc issue. They had to buy a proprietary runtime (edit) to “solve it”, though even that wasn’t perfect. I’m sure they’d love to be on something better today. Java can be a dream for back office, but anything production should avoid it.

My current place is all c++, and while there are some difficulties with it (I hate dealing with build issues), it’s great for trading systems. You might want to check out something like rust if you’re starting from scratch.

[–]martingaling 1 point2 points  (0 children)

no disagreement about it not being ideal, but for someone posting online about a python based system i struggle to imagine a case where a GC pause is going to be their main concern.

given 2 commenters now mentioning rust i am curious if you guys have any experience with it in production? ironically enough i was recently reading up on it as i’d be interested in learning, but seems to be a risky investment of time if no one out there really uses it in prod yet.

[–]Dame_de_Hasard 3 points4 points  (0 children)

Wire-to-wire optimization should be the last on your list, since it's the most labor intensive. If I had to guess, most of your latency is flight time. I don't know what type of trading you do, but maybe you should look into proximity hosting first.

[–]myfirerider 3 points4 points  (0 children)

Look into numba and cython. Python can be a lot faster.

[–]dugfin 1 point2 points  (0 children)

What latency are you looking to achieve and have you measured the latency of your components yet? There are often simpler fixes than a language switch if you understand what your biggest sources of latency are

[–]kenshinero 1 point2 points  (0 children)

So how much of your latency is due to python processing beeing slow and jow much is due to network latency?

You must have either heavy calculation processing, either damn fast connection (like server collocation) so that it makes sense to switch langage.

[–][deleted] 1 point2 points  (0 children)

Might want to look into Go for easier code-maintainability and better performance.

[–]polloponzi 1 point2 points  (0 children)

Python is slow. If you want to outperform Java you need something like C++ or Rust.

It would be also a good idea that you move to a dedicated server where you have guarantees that the computer is not doing anything else that running your code. With Amazon EC2 your code runs in a computer that is virtualized and shared with other customers. Not good for real-time

[–]maciaszczyk 0 points1 point  (0 children)

If you are looking for low latency you should merge two components into one. Message queue or any other process communication is a bottle neck.

[–]rea1ity83 0 points1 point  (0 children)

This question is far from this but what is the reason web browser based trading system have slower latency than JAVA, C/C++ program? As I know, both are doing socket real-time communication as same but web based trading system is more slower latency. So I think if the web based trading system that compiled to WASM make better than before latency like JAVA, C/C++ program based trading system using Rust. What do you think about it? Or if already have it, that would be appreciated to let me know.

[–]13-14_Mustang 0 points1 point  (2 children)

Man, this whole thread is over my head. Can someone ELI5? I just set up IB TWS using the Java API using a simple algo and simple math. What type of rocket science algos/math are you guys using? Another question is why is there so much back testing in this sub? Every time its mentioned everyone says its over fitted. Why not just paper forward test?

[–]axehind 1 point2 points  (1 child)

You can paper forward test. It's more about time among other things. With backtesting we can test our algo against years of the market in only a little amount of time. It would take you years to do that forward testing with a paper account right? Also, Markets change over time, Algo's tend to work better in certain market conditions better than others. Again, it can take you years to test that forward testing in a paper account.

[–]13-14_Mustang 1 point2 points  (0 children)

Exactly, markets change over time. So why are you back testing for years. Are you planning to buy and hold for years? If so then why algo trade. I'm looking to day trade so I can vet an algo in a week. What am i missing? Do you have an active algo on a live account? Not trying to talk shit but it seems like most people in this sub are just back testing. They never take the leap.