Search
× Search
Tuesday, November 19, 2024

Archived Discussions

Recent member discussions

The Algorithmic Traders' Association prides itself on providing a forum for the publication and dissemination of its members' white papers, research, reflections, works in progress, and other contributions. Please Note that archive searches and some of our members' publications are reserved for members only, so please log in or sign up to gain the most from our members' contributions.

Programming in nanoseconds

photo

 Oskar Mencer, CEO Maxeler Technologies

 Friday, May 18, 2018

Would anyone in this group be interested in a Java-variant where every line of code gets annotated with the number of nanoseconds it will take to execute, and that execution always stays exactly the same? something like this: 12.8ns: d.buy = ask.Price <= low.Price && security.ID = trade.ID; 6.4ns: d.quantity = d.buy ? ask.Quantity : bid.Quantity; so a total of 19.2ns, every time...or help me understand why this would be a bad idea?


Print

5 comments on article "Programming in nanoseconds"

photo

 Dan Pikul, Computer Systems Engineer

 Tuesday, May 22, 2018



I'm not sure if this would be possible pre-compilation, at least not with ns precision. Even post compilation, there are so many factors that go into execution time; CPU arch, clock frequency, memory timings, etc. that could affect your results. Like Dorian said, go FPGA if you want perfect timing accuracy.


photo

 Jason Zavaglia, Masters Student at UNSW

 Wednesday, May 23, 2018



Impossible to do - you cannot predict at what clock frequency the CPU will run, even assuming you have exclusive use of it. The clock frequency of modern Intel chips varies which makes profiling only possible to do on a statistical basis.


photo

 private private,

 Wednesday, May 23, 2018



This question remember me concepts about real time programming.

As the previous comments indicated, the speed depend on too many factors. In order to prevent this, the idea would be assign a maximum time.

To assign to each instruction, I think it is excessive, but it can be applied to a block of instructions. When you enter in the block, take the time in nanoseconds, and when finish the block, take it again. If the different is less than the maximum time, wait the difference.

I don’t know how to do exactly in Java, but in C++ it is easy


photo

 Ebrahim Ahmed, Evolving trading technology and alpha discovery.

 Wednesday, May 23, 2018



Using nanoseconds isn’t very useful when comparing code against other code on different hardware, it would be better to report cycles instead.


photo

 Albert Hendriks, Freelance Java developer

 Friday, May 25, 2018



It is impossible because of the halting problem.

Please login or register to post comments.

TRADING FUTURES AND OPTIONS INVOLVES SUBSTANTIAL RISK OF LOSS AND IS NOT SUITABLE FOR ALL INVESTORS
Terms Of UsePrivacy StatementCopyright 2018 Algorithmic Traders Association