GPU Computing를 이용한 트레이딩시스템

1.
한 달전쯤 홍콩의 선물옵션트레이더와 통화할 일이 있었습니다. 옵션전략을 개발하는데 두가지 기술을 구한다는내용입니다. 첫째는 GPU기술입니다. Option Pricing을 GPU를 이용하여 하겠다고 합니다. 독일 사례를 이야기하면서 GPU개발을 하겠다고 하더군요. GPU를 이용한 Pricing은 GPU 예제에 나와 있지만 국내에서 이를 업무에 활용한 사례를 찾아보지 못했습니다.

독일사례란 오픈소스 CEP로 유명한 MarketCetera를 기반으로 하여 독일 Lakeview가 GPU기술을 이용한 옵션트레이딩시스템을 개발한 것을 말합니다.

Using these performance options, common calculations such as theoretical prices, implied volatilities, implied dividends and correlations as well as risk simulations, amongst others, can be done on NVIDIA GPUs, offering speed ups of 10-200x, depending on calculation, in comparison to current commercial trading systems that run calculations on traditional hardware.

회사의 설립자인 Peter Van Cleef는 High Frequency Trader Review와 가진 인터뷰에서 FPGA와 GPU 및 거래소기술에 대해 재미난 이야기를 하였습니다.

HFTR: OK, so continuing on the technology theme but drilling down a little, you guys are doing some interesting work around FPGA and NVIDIA GPU accelerators. Can you tell us a little bit about what you’re doing in that space

Peter: Basically you have two technologies there that are used for slightly different things. GPUs usually provide scalability in terms of calculations that you can do in parallel. For example option pricing calculations, some implied calculations for correlation dividends, things like that. Any calculations that you can parallelize can give you a huge advantage. You gain massive savings in terms of electric power consumtion; computing power and heat emission. Calculating risk scenarios that might take hours in some cases can be brought down to minutes or even fractional seconds, because in the complex risk analysis you can paralyze calculations. So that’s one feature where GPUs are used. But then GPUs, at the moment, you still don’t have perfect integration with the rest of the trading infrastructure so you have some overhead in terms of sending the data from the normal CPU, from the normal bus in your computer, to the GPU, and getting it back. So there’s some latency involved with that. For the moment you can’t buy the chips alone and build your own system, but I am sure that will come.

GPU를 이용하면 좋은 점도 있지만 CPU와 GPU간의 통신때문에 지연이 발생한다는 점을 강조합니다.

HFTR: And FPGA’s

Peter: FPGA basically can give you ultra fast response time, way below millisecond response time on the market. You would use those with pre-calculated values from the GPUs uploaded to the FPGA, pre-trade, and then when the market update comes, the FPGA card basically already has a memory of what the response will be and can send out that response immediately without having to go through the bus of the computer to the CPU to the storage to the memory and back, basically doing some calculation on the fly. So you use one technology for one part and the other technology for the other parts. You use FPGAs for feed handlers or for reacting to the market with electronic eyes and trading engines and stuff like that. And you would use GPUs to pre-calculate the values that maybe the FPGAs are loaded with.

HFTR: So do you see exchanges moving towards using FPGAs for matching engines, for example

Peter: Well for me it seems ridiculous that the exchanges are still rolling out new exchange systems in software. All of them are competing and saying they want to be the fastest, so they should be serious about speed. If they want to be serious about speed they would have to do it in hardware of course. For the moment none of the exchanges (as far as I’m aware) is even planning that far.
미래에 FPGA를 이용한 매매체결시스템이 가능하겠지만 현재 이를 시도하는 곳은 없고 아직까지는 소프트웨어의 영역이라고 진단합니다.

Interview with Peter Van Kleef, Lakeview Arbitrage International중에서

2.
최근 ZeroM의 성능때문에 GPU를 이용하는 방안을 검토한 적이 있습니다. 당장은 아니더라도 GPU와 CPU를 통합한 제품이 보편화되면 고민해볼 수 있지 않을까 생각합니다. 물론 개발자의 의견입니다.(^^)

가장 GPU Computing을 보여주는 자료입니다. 참고하세요.

12 Comments

  1. 다나끔

    그런데 GPU연산이 정수연산에서는 상당한 성능을 보이는데 플로팅 연산에서는 별 효과가 없다는 이야기를 들었습니다. 테스트 해 봐야 할 텐데.. 영 시간이 안나네요.

    Reply
    1. smallake

      뭐 제가 그런 분야는 잘 모르지만. GPU를 가지고 쓸 곳이 있는지 알아보는 시험을 한 적이 있어요..그런데 개발자가 이런 말을 하더군요.

      “GPU는 무한루프가 돌아서 오히려 낭비다”

      정확히 내용을 전달하기 보다는 의미만 전달하는 것이 목적이므로..이 말을 하면서 결론은 “쓸 곳이 없다”였습니다.그런데 생각해보았습니다. 열심히 분석해서 쓰는 놈들은 왜?

      결국 내가 알고 있는 것을 바꾸어서 – 알고리즘을 변형하여 – 더 나은 성능을 얻기보다는 있는 것을 그대로 적용하려고 하니까 부정적인 답변이 나온거죠. GPU가 전가의 보도도 아닌데 모든 것을 만족시키지 않을 것으로 생각합니다. 다만 내가 하는 업무중 어떤 것은 더 나은 성능을 낼 수 있도록 하겠죠. 그렇게 고민하는 것이 정답이 아닐지.

      하여튼 어떤 분이 이런 글을 썼네요.

      “SSE 명령어 셋 및 CUDA는 single precision floating point 에서만 수치적 정확도를 보장하므로 single floating을 사용해야 합니다. 최근 라이브러리들은 double precision을 지원하기는 하지만, 하드웨어가 아닌 소프트웨어 차원에서의 처리이므로 속도를 굉장히 희생합니다. 요구되는 정확도에 따라 선택을 해야 하겠지만 명령어 셋이나 하드웨어 가속기를 쓰는 주요한 이유는 속도이므로 double precision을 쓰는 것은 손해가 아닐까 합니다.”

      Reply
    2. 상우

      최근의 GPGPU 하드웨어는 double precision 을 처리할 수 있는 녀석도 있습니다.

      Reply
    3. smallake

      아!그런가요? 한번 알아보도록 하겠습니다. 감사합니다.꾸벅~~~

      Reply
  2. dolppi

    Peter Van Cleef 는 컨퍼런스에서 발표하는것 본 적이 있는데요.. 말은 엄청 빠르고, 제목은 엄청 좋은데, 정작 내용은 없어서 당황했던 기억이… ^^

    Lakeview는 오픈소스나 상용 트레이딩 시스템을 커스터마이징해서 주문 전략을 심어주는 곳이라고 들었습니다.

    Reply
    1. smallake

      그렇죠.

      파트너가 Marketcetera.해외 Pricing제품들중 GPU를 지원하는 곳이 점점 늘어나는 추세네요.

      Multicharts를 개발하는 곳에서 이런 글을 남겼었습니다.

      The program achitechture of MultiCharts does not allow to take advantage of systems like CUDA, GPU and others. In MC the calculations of current values are based on the calculations of previous values. We have contacted CUDA in the past and they have confirmed that their technology cannot be used to make MC calculations faster because of the algorythm used in MC. Which is common for trading software as normally CUDA, GPU and others are not used for trading. We do not know any examples of similar software that supports CUDA or GPU.

      시계열데이타를 처리하는데 한계가 있기때문에 GPU를 트레이딩에 직접 사용하기보다는 프라이싱이나 백테스팅영역에서 사용하지 않을까 생각합니다. 이점에서는 FPGA가 휠씬 더 유용하다는 생각.

      Reply
  3. salbang

    그런데 GPGPU DP유닛 수가 SP유닛 수의 1/8 밖에 안되서 속도가 그닥. 아직은 GPGPU에서 DP의 비중이 작습니다.

    Reply
    1. smallake

      찾다 보니 이런 시각이 있네요.

      “Most GPU supports only single precision because where most of the GPU market lies is in the gaming market and gamers don’t need double precision. Also most of gamers are looking for good performance/price ratios. Implementing DP is costful in term of transistor budget (and TDP), and if games don’t use double precision this is meaningless.”

      제품은 시장의 요구에 따라 발전하니까 DP를 필요한 어플리케이션이 늘면서 시장이 커지면 DP를 더 많이 지원하지 않을까요?

      사실 저에게 DP나 SP는 중요하지 않죠.개발자가 아니니까(^^) 그래도 덕분에 배웠습니다.

      Reply
  4. QTrader

    NVidia Fermi는 single과 double을 support 합니다.
    고속을 만들기 위해서는 어느정도 SP와 DP을 분할해야 됩니다.

    GTX470은 Game 용으로
    Memory가 상대적으로 적고
    DP에 약함 Heston Stochastic Portf ELN European Binomial Tree
    (주로 American 파생사용)
    millisec 속도차이 millisec 속도차이
    CPU Calisto 6,010 1,433  
    GPU 32bit – SP 189 32X 26 56X
    64bit – DP 331 18X 51 28X

    Multi Dimm PDE’s based on Finite Diff 15-30x

    Fermi C2050는 전문 계산용 GPU임: 4GB vs. 1.5GB GTX470
    SP란 Single Precision 32bit
    DP란 Double Precision 64bit
    * MC 같은 process는 Memory를 많이 차지함 Fermi Fermi
    C2050 C2050
    SP/DP pure DP
    Basket option – European, 10 assets 104X 50X
    Basket option – American, 10 assets 61X 29X
    Callable Range Accrual – LN LMM 52X 24X
    Snowblade – LN LMM 57X 28X
    Digital Cliquet – Heston SV 138X 67X
    Basket Equity-Linked Note – Heston SV 77X 35X
    CMS Spread Range Accrual Swap – 2Fac HW 359X 177X
    좋은 속도를 내기위해서 SP/DP을 같이 쓰는게 DP only보다 2배가 빠른걸 알수 있음

    Reply
    1. smallake

      좋은 정보 감사합니다. 누군가 실무에 적용했으면 합니다. GPU를 이용한 사례를 아직 듣지 못해서…

      Reply
  5. QTrader

    실사례가 없습니다. RM은 엄청 필요로 하는데…
    소스를 공개하여야 해서 현업이 싫어하고 두려워 하는 이유는
    금밥그릇이라고 생각합니다 ~ 인도에서 그정도 소스는 몇천불만 줘도 만들고
    script lang로 짜면 몇시간만에 C++ source로 변화시켜주는 회사도 있는데
    금융업계가 한국이란 우물안에서 치열하게 경쟁하지만 세계적으론 퇴색하고 있습니다.

    Reply
    1. smallake

      저도 GPU를 이용한 모델을 구상하는 것이 있는데 참고로 하겠습니다. 말씀대로 하면 해외에 아웃소싱을 하면 되겠네요.

      아웃소싱할 수 업체 아시면 소개해주세요.. 물론 구글링하면 가능하겠지만 그래도…(^^)

      Reply

Leave a Comment

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.