Forum Navigation:


FORUMS > Programming and Software Forum < refresh >
Topic Title: Is Haskell used for qf?
Created On Wed Jul 16, 08 10:39 PM
Topic View:

Pages: [ 1 2 >> Next ]
View thread in raw text format


wynand494
Member

Posts: 66
Joined: Feb 2004

Wed Jul 16, 08 10:39 PM
User is offline

How popular is Haskell for qf? Any comparisons with c++ in terms of 1) ease of coding and 2)speed?

-------------------------
Time flies like an arrow. Fruit flies like a banana.
 
Reply
   
Quote
   
Top
   
Bottom
     



Y0da
Senior Member

Posts: 384
Joined: Aug 2007

Thu Jul 17, 08 12:11 AM
User is offline

The first time I see it mentioned on these forums
With the availability of fine meat like GSL, QuantLib,
and the "Numerical Recipes" book, C++ is bound to
be easier for quant coding. Not sure about speed though.
 
Reply
   
Quote
   
Top
   
Bottom
     



piterbarg
Senior Member

Posts: 443
Joined: Oct 2002

Tue Jul 29, 08 09:19 PM
User is offline

we use Haskell -- and actively looking for people who are very good at it. If you are one of them, pls send me a PM
It is used for things for which C++ is not so good, so does not really make sense to compare them
Vladimir
 
Reply
   
Quote
   
Top
   
Bottom
     



Y0da
Senior Member

Posts: 384
Joined: Aug 2007

Tue Jul 29, 08 10:58 PM
User is offline

Quote

Originally posted by: piterbarg
we use Haskell -- and actively looking for people who are very good at it. If you are one of them, pls send me a PM
It is used for things for which C++ is not so good, so does not really make sense to compare them
Vladimir

Can you name situations where Haskell can be better in QF?
Just would be nice to know.
 
Reply
   
Quote
   
Top
   
Bottom
     



nd
Member

Posts: 55
Joined: Sep 2004

Tue Jul 29, 08 11:30 PM
User is offline View users profile

It's been mentioned before but Simon Peyton-Jones worked on some QF haskell stuff.
Here's a recent talk:
http://ulf.wiger.net/weblog/2008/02/29/simon-peyton-jones-composing-contracts-an-adventure-in-financial-engineering/

My owe take is that Erlang is a better fit for a lot of QF stuff (pulling data off the wire, processing it
in some way, routing,etc)..

 
Reply
   
Quote
   
Top
   
Bottom
     



piterbarg
Senior Member

Posts: 443
Joined: Oct 2002

Wed Jul 30, 08 09:56 PM
User is offline

Quote

Originally posted by: Y0da
Quote

Originally posted by: piterbarg
we use Haskell -- and actively looking for people who are very good at it. If you are one of them, pls send me a PM
It is used for things for which C++ is not so good, so does not really make sense to compare them
Vladimir

Can you name situations where Haskell can be better in QF?
Just would be nice to know.


describing payoffs
 
Reply
   
Quote
   
Top
   
Bottom
     



katastrofa
Senior Member

Posts: 2012
Joined: Aug 2007

Wed Jul 30, 08 10:10 PM
User is offline

We use a custom language for that ;-)
 
Reply
   
Quote
   
Top
   
Bottom
     



arkestra
Member

Posts: 60
Joined: Nov 2005

Thu Jul 31, 08 10:33 PM
User is offline

Quote

Originally posted by: katastrofa
We use a custom language for that ;-)


It's easy to fire up sprint/lex-yacc and get a custom language going for payoffs for your exotic structured products. Well, by "easy" it's fairer to say that at least there are a reasonable number of people out there who can do that one nowadays.

But maybe you're looking to use common subexpression elimination across a very wide range and number of products, pushing your domain specific language as far into the vanilla realm as possible. Once you're getting away from just scripting payoffs on a standard bermudan-style template, you can get to the point where you're reinventing a full-on functional language if you aren't careful.
 
Reply
   
Quote
   
Top
   
Bottom
     



katastrofa
Senior Member

Posts: 2012
Joined: Aug 2007

Fri Aug 01, 08 08:22 AM
User is offline

Yes, but having a custom language means you can tailor its syntax so that non-programmers (say, analysts) can use it with ease. I don't know if forcing them to learn Haskell would be successful ;-)
 
Reply
   
Quote
   
Top
   
Bottom
     



Cuchulainn
Senior Member

Posts: 35269
Joined: Jul 2004

Mon Aug 04, 08 01:31 PM
User is offline View users profile

dbl

-------------------------
www.datasimfinancial.com

Edited: Mon Aug 04, 08 at 01:32 PM by Cuchulainn
 
Reply
   
Quote
   
Top
   
Bottom
     



Cuchulainn
Senior Member

Posts: 35269
Joined: Jul 2004

Mon Aug 04, 08 01:32 PM
User is offline View users profile

Quote

Originally posted by: piterbarg
Quote

Originally posted by: Y0da
Quote

Originally posted by: piterbarg
we use Haskell -- and actively looking for people who are very good at it. If you are one of them, pls send me a PM
It is used for things for which C++ is not so good, so does not really make sense to compare them
Vladimir

Can you name situations where Haskell can be better in QF?
Just would be nice to know.


describing payoffs


Has anyone had a look at FC++?

-------------------------
www.datasimfinancial.com
 
Reply
   
Quote
   
Top
   
Bottom
     



demha
Member

Posts: 182
Joined: Jan 2011

Tue May 03, 11 01:41 PM
User is offline

Looks like a lot of ideas from FC++ and others have gone into the Boost Phoenix library http://www.boost.org/doc/libs/1_46_1/libs/spirit/phoenix/doc/html/index.html.

Look forward to Phoenix v2 when the Boost Lambda library gets merged with Phoenix. Anyone used phoenix? My dabblings with Haskell left me wanting to do similar things with C++.

Algebraic data types in C++

http://cpp-next.com/archive/2010/07/algebraic-data-types/
 
Reply
   
Quote
   
Top
   
Bottom
     



ktang
Member

Posts: 118
Joined: Jan 2010

Tue May 03, 11 02:14 PM
User is offline

Quote

Originally posted by: demha
Looks like a lot of ideas from FC++ and others have gone into the Boost Phoenix library http://www.boost.org/doc/libs/1_46_1/libs/spirit/phoenix/doc/html/index.html.

Look forward to Phoenix v2 when the Boost Lambda library gets merged with Phoenix. Anyone used phoenix? My dabblings with Haskell left me wanting to do similar things with C++.

Algebraic data types in C++

http://cpp-next.com/archive/2010/07/algebraic-data-types/


Phoenix is already a lambda library. And Phoenix v2 is built on top of proto. Everything you do with lambda, you can also do this with Phoenix, but not vice versa.

 
Reply
   
Quote
   
Top
   
Bottom
     



Cuchulainn
Senior Member

Posts: 35269
Joined: Jul 2004

Tue May 03, 11 02:30 PM
User is offline View users profile

Quote

Look forward to Phoenix v2 when the Boost Lambda library gets merged with Phoenix. Anyone used phoenix? My dabblings with Haskell left me wanting to do similar things with C++.


Yes.
Boost Lambda is deprecated by Phoenix which in its turn is deprecated by C++ 0X, almost surely. But the Lambda in C++ 0X is standard C++ and competes with some of the functionality of Phoenix.

For functional programming, Boost function, bind(!) and signals/slots are worth looking into as well. One point: the Phoenix syntax is not standard C++. In fact, I am 99% sure that what Phoenix does can be also done more easily with C++ 0X.

//
Example of C++ lambda and STL

http://www.datasimfinancial.com/forum/viewtopic.php?t=380

-------------------------
www.datasimfinancial.com

Edited: Tue May 03, 11 at 02:45 PM by Cuchulainn
 
Reply
   
Quote
   
Top
   
Bottom
     



Cuchulainn
Senior Member

Posts: 35269
Joined: Jul 2004

Tue May 03, 11 02:47 PM
User is offline View users profile

Quote

Phoenix is already a lambda library. And Phoenix v2 is built on top of proto. Everything you do with lambda, you can also do this with Phoenix, but not vice versa.


Lambda can only handle delayed arguments, which can be done in Phoenix 'Primitives' component. Seriously, why not go direct to C++ Lambda?

-------------------------
www.datasimfinancial.com

Edited: Tue May 03, 11 at 02:52 PM by Cuchulainn
 
Reply
   
Quote
   
Top
   
Bottom
     



kimosabe
Senior Member

Posts: 416
Joined: Nov 2003

Tue May 03, 11 02:57 PM
User is offline View users profile

You should check out LexiFi. In particular MLFi. Jean-Marc Eber has been at this for a while and seems to be on to something.

-------------------------
Pure, modern C++ high-performance xll add-ins. Create your own documentation natively integrated into Excel too!
 
Reply
   
Quote
   
Top
   
Bottom
     



demha
Member

Posts: 182
Joined: Jan 2011

Tue May 03, 11 04:11 PM
User is offline

Poked around a bit in boost libraries and Fusion seems to be the closest to what I was looking for:

A very silly example follows:

struct mult
{
typedef int result_type;
int operator()(int t, int d) const
{
return t * d;
}
};

std::cout << boost::fusion::fold(boost::fusion::make_vector(1, 2, 3, 4, 5), 1, mult()) << std::endl;

I'm sure there must be a way to make the mult() into a lambda.

This is equivalent to the Haskell code:

foldl (*) 1 [1,2,3,4,5]

I think the C++ code is actually pretty readable and concise. I like this library.

Heard of LexiFi a while ago. They seem to be onto a good thing.



Edited: Tue May 03, 11 at 04:13 PM by demha
 
Reply
   
Quote
   
Top
   
Bottom
     



ktang
Member

Posts: 118
Joined: Jan 2010

Tue May 03, 11 04:28 PM
User is offline

Quote

Originally posted by: Cuchulainn
Quote

Look forward to Phoenix v2 when the Boost Lambda library gets merged with Phoenix. Anyone used phoenix? My dabblings with Haskell left me wanting to do similar things with C++.



One point: the Phoenix syntax is not standard C++. In fact, I am 99% sure that what Phoenix does can be also done more easily with C++ 0X.

//
Example of C++ lambda and STL

http://www.datasimfinancial.com/forum/viewtopic.php?t=380


Yes, on the other hand C++ 0X is not implemented in every compiler. So you need to be careful if you want to port your code.
But if you use phoenix then portability is granted.
 
Reply
   
Quote
   
Top
   
Bottom
     



Cuchulainn
Senior Member

Posts: 35269
Joined: Jul 2004

Tue May 03, 11 04:32 PM
User is offline View users profile

Can you tell what the output is? And the intent, 'fold' etc.

My guess is you multiply each element of a vector by some number; new/modified vector?

struct mult
{
typedef int result_type;
int operator()(int t, int d) const
{
return t * d;
}
};

std::cout << boost::fusion::fold(boost::fusion::make_vector(1, 2, 3, 4, 5), 1, mult()) << std::endl;



-------------------------
www.datasimfinancial.com

Edited: Tue May 03, 11 at 04:43 PM by Cuchulainn

 
Reply
   
Quote
   
Top
   
Bottom
     



demha
Member

Posts: 182
Joined: Jan 2011

Tue May 03, 11 04:55 PM
User is offline

Ah, sure, forgot to include the output and the context.

fold:
===

fold(Sequence& seq, State const& initial_state, F f);

For a sequence seq, initial state initial_state, and binary function object or function pointer f, fold returns the result of the repeated application of binary f to the result of the previous f invocation (inital_state if it is the first call) and each element of seq.

So, in my trivial example:

std::cout << boost::fusion::fold(boost::fusion::make_vector(1, 2, 3, 4, 5), 1, mult()) << std::endl;

It applies mult(), and the intial value 1 repeatedly to elements from the vector one at a time. Result is 1 * 2 * 3 * 4 * 5 = 120. This is not a particularly good example of using fold, but just an illustration for my understanding of what boost::fusion is doing.

FC++ had a lot of the Haskell equivalents in the library (http://www.cc.gatech.edu/~yannis/fc++/boostpaper/fcpp.sectlibrary.html#id269814), but they seem to be dispersed around different libraries in boost AFAICT. My reasoning for looking for these in boost is that if someone is aware of these idioms, then it's very easy to understand code written in this style. However, I understand that it may be tricky for people who have not met them before, but it doesn't take long to familarise with them (much like the algorithms of STL).

Edited: Tue May 03, 11 at 04:59 PM by demha
 
Reply
   
Quote
   
Top
   
Bottom
     

Pages: [ 1 2 >> Next ]
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