Community
cancel
Showing results for 
Search instead for 
Did you mean: 
EDUARDO_M_
Beginner
17 Views

Trading App

I'll make a trading app that trades up to 5 assets concurrently. The trading server is accessed through websockets. So each concurrent work/task should open/close a websocket connection every minute (1min trading).

Tasking is the way to go?

Thank you!

0 Kudos
3 Replies
Alexei_K_Intel
Employee
17 Views

Hi Eduardo,

I do not know all details of your algorithm; however, the Intel TBB tasks approach is not suitable for IO operations (files, sockets and so on). Usually, Intel TBB tasks are used for computational (not blocking) activities. You may want to read the section about Intel TBB Task Scheduler in documentation.

Regards,
Alex

jimdempseyatthecove
Black Belt
17 Views

Eduardo,

I concur with Alex. You might find it sufficient enough to use OpenMP

const double PollingInterval = 60.0;
double lastRunTime = -PollingInterval;
bool Done = false;
for(double now = omp_get_wtime(); !Done; now = omp_get_wtime())
{
   if(now - lastRunTime > PollingInterval)
   {
      lastRunTime += 60.0; // do not use = now
      #pragma omp parallel for schedule(dynamic)
      for(int i=0; i < nAssets; ++i)
         Assets.tradeCheck();
   }
   Sleep(10); // sleep for 10ms
}

Keep in mind that if you have more Assets than you have worker threads that some assets will trade somewhat later than others.

Jim Dempsey

EDUARDO_M_
Beginner
17 Views

Thank you guys! I appreciate it.

Reply