Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

Trading App

EDUARDO_M_
Beginner
346 Views

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
346 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

0 Kudos
jimdempseyatthecove
Honored Contributor III
346 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

0 Kudos
EDUARDO_M_
Beginner
346 Views

Thank you guys! I appreciate it.

0 Kudos
Reply