Simultaneous calculations, programmatic question

Discussion in 'Automated Trading' started by mcgene4xpro, Mar 29, 2011.

  1. Hi,

    I am developing an ATS that would require simultaneous calculations ( 1000-10000 simple to moderate mathematical operations per tick). I have no programmatic knowledge for now and i am worry this simultaneous issue might provide a source of instability in the code and delay the execution.

    Now, i am working with a professional MQL4 programmer but later i am going to migrate to higher language.

    Any suggestions is highly appreciated.


  2. drp7804


    Not sure what sort of circumstances you're faced with, but if you can, it'd be good to do some initial testing to get an idea of how much CPU you'll need. Substitute simulations wherever you are unable to use the "real stuff".

    For example, if you can't hook up to a data feed, you could simulate incoming ticks by writing a routine which calls your tick callback function every X milliseconds, etc (you could even randomize the X interval, but not sure that matters for a CPU loading test).

    If you don't yet have the core of the strategy written, you could do a quick-n-dirty routine to try to simulate the load your strategy would place on the system.

    These aren't going to be the most accurate tests, so obviously, the more real stuff you can use, the better.

    So say either through testing or other means you come to the conclusion that you won't be able to fit on a single core/CPU. At that point, you're basically forced with either simplifying your strategy or spreading out onto multiple cores/CPUs. This means breaking the code out into parallel-izable jobs (multiple threads and/or processes). If you end up needing multiple machines (eg because you can't fit on however many cores you have on your current machine), then that means networking the machines together and communicating via sockets, etc.

    Not sure if that helps, but that's the general approach I'd take (making some assumptions about your situation, the project scope, and so forth).
  3. cuda
  4. Co-located data stream is running at, what, 125ns per tick, in the fastest case? (I don't believe there is any restriction on successive packets referencing the same symbol).

    In that case you're not going to get 1000 to 10000 calculations/tick without building custom hardware, which is the exact opposite of moving up the programming language ladder.

    And what precisely do you mean by "simultaneously"?
  5. As drp7804 says, do a simulation. What the OP has posted is far too vague to draw any conclusions from.

    If a simulation shows their may be performance issues, then profile the code, find the bottlenecks and review the situation.

    Remember that premature optimization is one of the real sins of programming. Make sure you do in fact have a potential performance issue before you before taking steps to rectify what may or may not be a problem.
  6. What you mean by simultaneous calculations? Are you saying they must all run in parallel? or they can be run sequentially just need to finish within each tick's timeframe?
  7. tdev


    Run performance tests first. drp7804 is totally right here.

    Only after that you may say if you need an optimization and what kind of optimization that would be.

    Moving the heavy logic outside of mql4 may be another way to speed up your code.
  8. in parallel
  10. yes, nvidia gpus offer massive parallel calculations.
    #10     Mar 31, 2011