Forum Navigation:

magazine

FORUMS > Programming and Software Forum < refresh >
Topic Title: python in quantitative finance
Created On Sun Jan 09, 11 01:34 AM
Topic View:

View thread in raw text format


tagoma
Senior Member

Posts: 11690
Joined: Feb 2010

Sun Jan 09, 11 01:34 AM
User is online View users profile

in general terms, can anyone explain the value-added of the python language in quantitative finance ? does it allow anything in particular ? is it a commonly used in banks ?

Edited: Sun Jan 09, 11 at 01:48 PM by tagoma
 
Reply
   
Quote
   
Top
   
Bottom
     



VegaPlus
Member

Posts: 80
Joined: Nov 2008

Sun Jan 09, 11 01:25 PM
User is offline

I can't tell you about why it's used but it is. For many interviews with major banks like JPM, Citi or GS, they asked me if I knew python. But it's less common than C++, of course.

Edited: Sun Jan 09, 11 at 01:26 PM by VegaPlus
 
Reply
   
Quote
   
Top
   
Bottom
     



tagoma
Senior Member

Posts: 11690
Joined: Feb 2010

Tue Jan 11, 11 09:27 PM
User is online View users profile

other comments ?
 
Reply
   
Quote
   
Top
   
Bottom
     



acastaldo
Senior Member

Posts: 1248
Joined: Oct 2002

Tue Jan 11, 11 10:41 PM
User is offline

Python is used at some quant hedge funds (Example)
 
Reply
   
Quote
   
Top
   
Bottom
     



Hansi
Senior Member

Posts: 3066
Joined: Jan 2010

Tue Jan 11, 11 11:16 PM
User is offline

I think wikipedia describes how I view it pretty well:

Quote

Python supports multiple programming paradigms, primarily but not limited to object oriented, imperative and, to a lesser extent, functional programming styles. It features a fully dynamic type system and automatic memory management, similar to that of Scheme, Ruby, Perl, and Tcl. Like other dynamic languages, Python is often used as a scripting language, but is also used in a wide range of non-scripting contexts.


I think most view is positively because it's a dynamic language but does offer a lot of possibilities of traditional structures and OO too. It's also easy to use for database connectivity, works well for quickly prototyping things and has a lot of community built modules and add-ons. It can also be used as scriptable which is a good thing IMO.

That being said I don't have much experience with Python but have used it on occasion for a few things. I dislike the 2.7.x vs 3.x discontinuity and divergence, doesn't quite make sense to me.

I prefer using R for prototyping and most of the above holds true for it as well as Python.

I've heard of a few groups in quant finance at banks and funds using Python and it seems to be relatively popular to put it as a preferred skill in job adverts.
 
Reply
   
Quote
   
Top
   
Bottom
     



quantmeh
Senior Member

Posts: 5968
Joined: Apr 2007

Tue Jan 11, 11 11:37 PM
User is offline

there's a kind of prog languages, which are called sometime 'glue' languages, or scripting. there's a use case for them in any field. Python has features of scripting languages
 
Reply
   
Quote
   
Top
   
Bottom
     



eredhuin
Senior Member

Posts: 262
Joined: Jul 2002

Tue Jan 11, 11 11:38 PM
User is offline

I haven't used it extensively but most of the heavy lifting for C++ versions of code can be easily scripted through Python. So, best of both worlds.

Say you have a quant library you're very proud of. Now you want to expose it for scripting. Why? You can readily reuse C++ code with two to ten lines of scripting language - and no recompiling.

Did you ever write a c++ program where you manually populate a vector with discount factors? Or write elaborate loaders just to call a function f? Ugly anti-pattern.

If the right parts of the code are in high performance languages (c++) then the performance impact of running a script should be minimized.

If you are curious pick up a copy of Python Scripting for Computational Science.
 
Reply
   
Quote
   
Top
   
Bottom
     



mtsm
Member

Posts: 148
Joined: Jul 2010

Wed Jan 12, 11 03:13 AM
User is offline

Quote

Originally posted by: edouard
in general terms, can anyone explain the value-added of the python language in quantitative finance ? does it allow anything in particular ? is it a commonly used in banks ?


That is because it is a much more modern language. It is fully object oriented. Some nice functional prog features. No complilation. For numeric computation numpy is extraordinary. STL is a piece of shit compared to what python/numpy has to offer over STL. It is just so much better. C++
feels so senile.

Don't get me wrong. If you have the resources, the time, the energy, I am convinced that C++ or its more modern cousin C# may be better, faster,
stabler, etc... But then again, have you ever tried doing something slightly more of the beaten path with boost libraries? For example, try using lambda
or spirit and compare with the features of a modern scripting language. Hands down.

Also python is a free de facto replacement for matlab.
 
Reply
   
Quote
   
Top
   
Bottom
     



tagoma
Senior Member

Posts: 11690
Joined: Feb 2010

Wed Jan 12, 11 11:19 AM
User is online View users profile

thank you.
 
Reply
   
Quote
   
Top
   
Bottom
     



spv205
Senior Member

Posts: 476
Joined: Jul 2002

Fri Jan 14, 11 06:13 PM
User is offline

I don't believe its used for derivatives pricing, where you want rock solid performance, managing 1000s of trades in a fixed well defined process.. (eg end of day runs, Value at Risk etc)

I believe its mainly used for algo /quantitative trading, where you are keen to prototype new strategies, and constantly tinkering with old strategies/ fine tuning etc.
 
Reply
   
Quote
   
Top
   
Bottom
     



bojan
Senior Member

Posts: 343
Joined: Aug 2008

Mon Jan 17, 11 09:30 AM
User is offline View users profile

Quote

Originally posted by: spv205
I don't believe its used for derivatives pricing, where you want rock solid performance, managing 1000s of trades in a fixed well defined process.. (eg end of day runs, Value at Risk etc)

I believe its mainly used for algo /quantitative trading, where you are keen to prototype new strategies, and constantly tinkering with old strategies/ fine tuning etc.


These uses sound about right but I don't think the reasons are. If you are doing algo/quantitative trading than you really need to have 100% confidence in your implementation -- if something goes wrong you lose real money right away. If the risk runs look a bit funny or don't go through, that is a bit of a problem for the management but you've not crystalised any losses. For Algo, people sometimes prototype in Python and then hand over to Java programmers for implementation.

I think one of the reasons are is that people who do risk systems haven't yet caught up with Python, and risk/pricing systems have a lifecycle of many years and so change rather slowly.

But there is an interesting point here -- writing large systems in Python is quite different from little programs and scripts. I've found that when you have more than about three people working on a large Python project it becomes quite tricky and requires a great deal of discipline and the right skill- and tool-set. So, large Python projects are not always an unqualified success.

-------------------------
http://www.bnikolic.co.uk/
 
Reply
   
Quote
   
Top
   
Bottom
     



arkestra
Member

Posts: 60
Joined: Nov 2005

Thu Feb 03, 11 10:52 PM
User is offline

Quote

Originally posted by: bojan
Quote

Originally posted by: spv205
I don't believe its used for derivatives pricing, where you want rock solid performance, managing 1000s of trades in a fixed well defined process.. (eg end of day runs, Value at Risk etc)

I believe its mainly used for algo /quantitative trading, where you are keen to prototype new strategies, and constantly tinkering with old strategies/ fine tuning etc.


These uses sound about right but I don't think the reasons are. If you are doing algo/quantitative trading than you really need to have 100% confidence in your implementation -- if something goes wrong you lose real money right away. If the risk runs look a bit funny or don't go through, that is a bit of a problem for the management but you've not crystalised any losses. For Algo, people sometimes prototype in Python and then hand over to Java programmers for implementation.

I think one of the reasons are is that people who do risk systems haven't yet caught up with Python, and risk/pricing systems have a lifecycle of many years and so change rather slowly.

But there is an interesting point here -- writing large systems in Python is quite different from little programs and scripts. I've found that when you have more than about three people working on a large Python project it becomes quite tricky and requires a great deal of discipline and the right skill- and tool-set. So, large Python projects are not always an unqualified success.


Python is easy to learn (in fact, it was originally designed partly with that end in mind). I personally find it very pleasant to use. Lots of others feel similarly and consequently there was a vogue 5-10 years ago for using it as a ready-made scripting environment and yoking it to C++ in-process.

Sadly this ended in tears everywhere I saw it done.

The problem was that python and C++ object lifetimes and typesystems do not align perfectly and so there is a fair bit of finesse involved in joining the 2 languages correctly - to the extent that I have never actually seen it done well.

Also, you start off getting seduced by the (extreme) ease of interfacing Python and C-style languages, but then the effort of shipping an embedded runtime kicks in - and what if there is another python engine in-process? Perhaps this is something Python offers more options on nowadays though.

Those looking for a non-C++ way of scripting now seem to be more looking at purely functional languages, perhaps Haskell, accessed via cross-process calls. Personally that's a route that I'm keener on following myself nowadays too if I had to do something now.

But I am working on other things than quant libs nowadays and so am holding out for something that can combine imperative and functional approaches well. God only knows when that will turn up.
 
Reply
   
Quote
   
Top
   
Bottom
     



bojan
Senior Member

Posts: 343
Joined: Aug 2008

Fri Feb 04, 11 05:42 AM
User is offline View users profile

Quote

Originally posted by: arkestra
Quote

Originally posted by: bojan
Python is easy to learn (in fact, it was originally designed partly with that end in mind). I personally find it very pleasant to use. Lots of others feel similarly and consequently there was a vogue 5-10 years ago for using it as a ready-made scripting environment and yoking it to C++ in-process.

Sadly this ended in tears everywhere I saw it done.



I've often seen it working extremely well.



-------------------------
http://www.bnikolic.co.uk/
 
Reply
   
Quote
   
Top
   
Bottom
     



arkestra
Member

Posts: 60
Joined: Nov 2005

Fri Feb 04, 11 09:04 PM
User is offline

Quote

Originally posted by: bojan
Quote

Originally posted by: arkestra
Quote

Originally posted by: bojan
Python is easy to learn (in fact, it was originally designed partly with that end in mind). I personally find it very pleasant to use. Lots of others feel similarly and consequently there was a vogue 5-10 years ago for using it as a ready-made scripting environment and yoking it to C++ in-process.

Sadly this ended in tears everywhere I saw it done.



I've often seen it working extremely well.


If it can be made to work over a multi-year time period then great. My observation has been initial apparent gains but over time other courses are pursued. Care to quote a shop + business area that have managed to get things to stick? I'm genuinely interested. Personally I like Python.
 
Reply
   
Quote
   
Top
   
Bottom
     

View thread in raw text format
FORUMS > Programming and Software Forum < refresh >

Forum Navigation:

© All material, including contents and design, copyright Wilmott Electronic Media Limited - FuseTalk 4.01 © 1999-2014 FuseTalk Inc. Terms & Conditions