SERVING THE QUANTITATIVE FINANCE COMMUNITY

 
AndreyShihov
Topic Author
Posts: 2
Joined: August 12th, 2019, 2:38 pm

Parallel programming in Finance

August 16th, 2019, 10:19 am

Hello all,

I've been looking where I could use and improve my TPL C# skills in Finance?

I have done MCS for some path-dependent option pricing in python before. Done it again in C# TPL and improved performance almost 20 times on the same machine (8 cores). It is pleasant result but delightfully parallel fork-join implementation (I think it's most rational one in this case. minimum context switches and there is nothing to synchronise) is too simple. 

I have also done Basket Defaults Swap MCS pricing in python in the past. If I'll do it with TPL I'll end up with the same approach as in previous case. Another thing that puts me off doing it is the fact that MC isn't the most efficient method compared to FFT and Hull-White Recursion anyway. 

I've looked at american option pricing with MC (Boyle, Broadie and Glasserman 97). I might have just scratched the surface but my intuition whispers me that quite often MC is going to be simple to parallelise. Whereas considering my software development experience in finance I might be mistaking. 

I think (but I'm not sure) that algotraiding might need more advanced parallelism solutions than MC. So my next move is to dissect pyalgotrade and try to find if I could speed it up a bit with C#, TPL and other tools. Is it reasonable plan purely for exercise? Otherwise what would you suggest for stretching my neurons and fingers?

I'm waiting for CQF results coming in September and have one month for fun before I'll throw myself back at job market. 

Thanks!
 
User avatar
Cuchulainn
Posts: 59386
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: Parallel programming in Finance

August 16th, 2019, 1:15 pm

I would look into the full lifecycle of swap trading by extending your expertise to ADO.NET, P(LINQ) and possibly Reflection  API and profiling system throughput.

And Excel-DNA interfacing.

And the new-fangled TPL Dataflow?

http://hamidmosalla.com/2018/08/04/what ... we-use-it/

See C# book by Germani and Duffy for more pointers.
 
AndreyShihov
Topic Author
Posts: 2
Joined: August 12th, 2019, 2:38 pm

Re: Parallel programming in Finance

August 16th, 2019, 4:07 pm

I would look into the full lifecycle of swap trading by extending your expertise to ADO.NET, P(LINQ) and possibly Reflection  API and profiling system throughput.

Thanks Cuchulainn,

Sorry, I didn't mention, I work with C# 16+ years. Know most important perks of ADO.NET & EF as well as their bottlenecks pretty well. Working with Link for 6+ years. Have an intuition about PLink. Nice for quick and dirty solutions (plinq fans, pardon me), but perhaps not as flexible when need to solve a problems of a different class e.g beyond simple partitioning, e.g tricky balancing and synchronisation issues. 

Built in Visual Studio (OS) Profilers, Sysinternals, Concurrency Visualiser, ILSpy, SharpLab, Benchmark.NET highly respected and often used tools.

Very interested about swap trading lifecycle. Germani and Duffy?

And Excel-DNA interfacing.

One of the Excel Datasources is WebAPI. If it worth doing for one Excel User it might be useful for many in Organisation. I've not tried it yet but I think it's possible to use Servers Infrastructure for Parallel or even Distributed computations to be available over WebAPI. Just pass data as query string parameters to WebAPI, make servers hot and get fast results.

And the new-fangled TPL Dataflow?

http://hamidmosalla.com/2018/08/04/what ... we-use-it/

Thanks, nice article and tool, worth keeping in mind, as well as below "When not to use it" point: Performance is very important, because TPL Dataflow is an abstraction over thread etc.

I found an interesting project in comments: https://github.com/JasperFx/jasper. Might work as plan H if won't find anything else.

See C# book by Germani and Duffy for more pointers.

I found an online preview. It's a good book, especially for c# advanced beginners. Way better than "Applied C# in Financial Markets". However, I find it hard to justify the way how MCS (Monte Carlo Simulation) was implemented with Producer/Consumer pattern. Page 724. Producer produces RNGs and Consumer uses them to run MCS. Obvious disbalance and unnecessary use of BlockingCollection data structure. I won't buy it right away and give it a chance by looking at other chapters. I'm sure I'll find something interesting and then decide. 
 
User avatar
Cuchulainn
Posts: 59386
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: Parallel programming in Finance

August 16th, 2019, 4:58 pm

Thanks for the detailed feedback, AndreyShihov

For MonteCarlo, I ported single-threaded code to C++ Asynchronous Agent library. Can't remember speedup but it should be good for load balancing I reckon.

https://docs.microsoft.com/en-us/cpp/pa ... ew=vs-2019

In this case C++/CLI should be doable for this?

// Granted, Producer Consumer with Blocking might not be the most efficient solution.
ABOUT WILMOTT

PW by JB

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...


Twitter LinkedIn Instagram

JOBS BOARD

JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...


GZIP: On