CPU Intensive Trading System

Discussion in 'Hardware' started by naifwonder, Feb 27, 2008.

  1. MGJ

    MGJ

    Keep reminding yourself "I need a factor of 60 speedup". If you get a factor of 20 from faster hardware (which would be a miracle), you still need another factor of 3 from faster software. Perhaps this book might help in some way: http://tinyurl.com/2dra4f
     
    #11     Feb 28, 2008
  2. Definitely profile the code, you'll be amazed at what you can save.
     
    #12     Feb 28, 2008
  3. GTG

    GTG

    It might be your GUI updates. GDI+ is kind of slow. Your output looks like you are only updating the GUI once a second....but you should fish around your code and make sure that it isn't happening a whole lot more than that. It's easy to accidentally be updating the GUI with the same info 100's of times a second.

    Here's kind of the model I use to make sure the GUI doesn't slow down my system calculations. I have all of my calculations running in separate threads from the GUI. All of these classes maintain their states independent of the GUI. I put a timer control on my main form, to control updates. I set the timer to trigger once a second, as the human eye/brain can't process numerical data much faster than that anyway. The timer control triggers an event that instructs all of the worker threads to update their state to the GUI (using method invokers), all at once in a batch.
     
    #13     Feb 28, 2008
  4. First of all, I would like to thank you all for all the great feedback. It has been most helpful.

    I have been looking into optimizing the code before dropping the money on a new system, and it looks like I have found what's slowing it down. Although the system does run a large number of computations, the computer is handling that decently. The GUI is also doing okay. What is slowing it down is connecting to the MySQL database on every new tick and inserting the data into it.

    The thing is I am still fairly new at C# and am having somewhat of a tough time figuring this out. I have used NinjaTrader as my platform to develop this thing on. Using NinjaTrader, does anyone know if it is possible to open a MySql connection when a strategy initializes, keep it open, than have a query run using that open connection on each new tick? This should speed things up greatly as opposed to having to reinitialize a connection to the database with each new tick.
     
    #14     Mar 2, 2008