# [R-sig-hpc] Problems in applying parallel and GPU(cuda) computing for time efficient backtesting

Sat Jul 11 09:09:15 CEST 2015

```Hi, I just started to learn how to program in Cuda C/C++ and did go through several sample programs (like the vector add, stencil_1d, matrix multiplication and some others) to get the ideas of the basic concept of Cuda (like block, threads, index etc).

We would like to figure out how fast it would be to apply the cuda in stock stategy backtesting and do some simple tasks like generate (exponential) moving average series, breakout strategy from a long stock price time series. And I figured out that the most efficient way to do this performance task is to get a large number of stocks (say 20,000) and assign the tasks on each stock to each block/thread.

Here is a simple Breakout strategy:
inputs: x(20),y(10) ;
Vars: V20(10),V10(10),N2(10),N1(10),N(10);
V20=Volatility(x)of data2;
V10=Volatility(y)of data2;
if V10<>0 and N2<>0 then beginN1=(N*V20)/V10;
N2=IntPortion(N1);
value1=Average(high of data2,N2)of data2;
value2=Average(low of data2,N2)of data2;
if close crosses above value1  then beginbuy next bar at market;end;
if close crosses below value2  then beginsellshort next bar at market;end;

I was looking for similar examples for quite a while, but found nothing. Please let me know if you know how to apply parallel computation to the above pseudo code. Or have you seen any existing example?? Please give me the code if you have.
[[alternative HTML version deleted]]

```