Ruby suitable for financial apps?

hi there,
I am about to embark on a mission critical financial web application,
and was wondering weather ruby on rails is the best fit for this type
of project.
More specifically I am worried about floating point errors. Would it be
more appropriate to use a more statically typed framework (.NET)?

thankyou.

Simon wrote:

hi there,
I am about to embark on a mission critical financial web application,
and was wondering weather ruby on rails is the best fit for this type
of project.
More specifically I am worried about floating point errors. Would it be
more appropriate to use a more statically typed framework (.NET)?

FWIW, in an upcoming Rails release you will be able to use the Ruby
BigDecimal type and map it to a decimal type in the database.

On Sun, Jul 30, 2006 at 06:25:14AM +0200, Simon wrote:

I am about to embark on a mission critical financial web application,
and was wondering weather ruby on rails is the best fit for this type
of project.

It’ll probably be a lot better than most, and certainly no worse,
intrinsically. You will be best off deciding based on your love of the
languages which you’ve got to choose from.

More specifically I am worried about floating point errors. Would it be
more appropriate to use a more statically typed framework (.NET)?

How is static typing going to effect the magnitude of the errors you get
from manipulating floating point numbers?

At any rate, if you’re using floats to manipulate monetary amounts,
you’re
screwed right from the get-go, not matter what language you choose.
Use
fixed-point or shifted-integer maths instead.

  • Matt

On 7/30/06, Simon [email protected] wrote:


Posted via http://www.ruby-forum.com/.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

There are a few solutions for this in terms of storage, where money
values
are stored as either integers or seperate dollars, cents into two
integer
columns.

I can’t speak for the float functions themselves. A plugin to get you
started.

http://www.agilewebdevelopment.com/plugins/dollars_and_cents

Very good question - i was also pondering a financial web app. Im
interesting in floating point as well as encryption possibilities.

thanks for any responses.

Ryan

On 30 Jul 2006, at 06:25, Simon wrote:

hi there,
I am about to embark on a mission critical financial web application,
and was wondering weather ruby on rails is the best fit for this type
of project.
More specifically I am worried about floating point errors. Would
it be
more appropriate to use a more statically typed framework (.NET)?

EdgeRails has some new features for decimals to avoid the floating
point errors.

Best regards

Peter De Berdt

On 7/29/06, [email protected] [email protected] wrote:

Very good question - i was also pondering a financial web app. Im
interesting in floating point as well as encryption possibilities.

The ruby openssl module works very good for encryption. It’s not
documented all that well and you might have to dig around for examples
on some stuff, depending on what features you need. A good place to
get examples is in the ruby distribution under test/openssl.

Use fixed-point or shifted-integer maths instead

How do you do that?

On Sun, Jul 30, 2006 at 01:20:12AM -0400, [email protected] wrote:

Very good question - i was also pondering a financial web app. Im
interesting in floating point as well as encryption possibilities.

Floats is floats is floats is sucky for anything involving money or
other
fixed-point arithmetic. For encryption you’ve got OpenSSL for your
basics,
and a number of other libraries for the more esoteric. A nice
asymmetric
example from Tobias:

http://blog.leetsoft.com/2006/3/14/simple-encryption

  • Matt

Thanks for all the responses to my post.
My general feeling is that Rails is not the most suitable for my type
of application at the moment although I wish it were.
Happy Railing!

On Mon, Jul 31, 2006 at 10:51:00AM +0200, Chris wrote:

Use fixed-point or shifted-integer maths instead

How do you do that?

With The Power Of Maths.

A FixedPoint class should be about… 40 lines of code, I’d say.
Serializing
that into a database DECIMAL wouldn’t be too hard – but didn’t someone
in
this thread point out some upcoming feature that will do all this
already?
If so, all the hard work’s done…

  • Matt


Sure, it’s possible to write C in an object-oriented way. But, in
practice,
getting an entire team to do that is like telling them to walk along a
straight line painted on the floor, with the lights off.
– Tess Snider, [email protected]

Tom A. wrote:

Steve B. wrote:

I’m curious to see how you think a framework (Ruby or .NET) can address
the relatively ancient problem of floating point errors that have been
with us since pre-PC days. I was always under the impression that you
have to painstakingly do this via sprintf functions.

I’m looking at more the language than the framework to solve floating
point errors but providing a facility to use something other than
floating points (such as decimal datatypes) so that these errors don’t
occur.
Can sprintf solve this problem with floating point types? If so I’d like
to know how.
Thanks.

Steve B. wrote:

I’m curious to see how you think a framework (Ruby or .NET) can address
the relatively ancient problem of floating point errors that have been
with us since pre-PC days. I was always under the impression that you
have to painstakingly do this via sprintf functions.

On Tue, Aug 01, 2006 at 04:41:28AM -0400, Tom A. wrote:

BigDecimal type and map it to a decimal type in the database.

I’m curious to see how you think a framework (Ruby or .NET) can address
the relatively ancient problem of floating point errors that have been
with us since pre-PC days.

The language or framework can help by allowing you to not use floats at
all
to approximate fixed-point arithmetic.

  • Matt

On 8/1/06, Tom A. [email protected] wrote:

BigDecimal type and map it to a decimal type in the database.

I’m curious to see how you think a framework (Ruby or .NET) can address
the relatively ancient problem of floating point errors that have been
with us since pre-PC days. I was always under the impression that you
have to painstakingly do this via sprintf functions.

See
http://www.ruby-doc.org/stdlib/libdoc/bigdecimal/rdoc/classes/BigDecimal.html

On 7/31/06, Guest [email protected] wrote:

Thanks for all the responses to my post.
My general feeling is that Rails is not the most suitable for my type
of application at the moment although I wish it were.

Why do you think that?

Joe

On Jul 31, 2006, at 10:25 am, Guest wrote:

Thanks for all the responses to my post.
My general feeling is that Rails is not the most suitable for my type
of application at the moment although I wish it were.
Happy Railing!

Simon,

If it’s any use to you, the company I work for
( www.codeweavers.net ) produces almost exclusively financial
applications, and we are now starting to switch to Rails. The lack
of proper fixed decimal support was a killer so I wrote a patch, that
is now incorporated with someone else’s code in Edge Rails. In the
mean time, you might be interested in the plugin version of the
original code, at www.ashleymoran.me.uk . You can use this in the
mean time with gem Rails 1.1.

Incidentally we have a vacancy for a Rails developer if anyone is
interested :slight_smile:

Ashley

On 8/2/06, Joe Van D. [email protected] wrote:

On 7/31/06, Guest [email protected] wrote:

Thanks for all the responses to my post.
My general feeling is that Rails is not the most suitable for my type
of application at the moment although I wish it were.

Why do you think that?

I mean, to avoid floating point errors, use the BigDecimal class.
See
http://www.ruby-doc.org/stdlib/libdoc/bigdecimal/rdoc/classes/BigDecimal.html

I don’t see how static typed languages (like in .NET) help at all for
avoiding floating point errors.

Joe

On 8/3/06, Guest [email protected] wrote:

If it’s any use to you, the company I work for
issues :).

I thought that rails might not be good for number crunching apps because
I saw some stats on the web that suggest it was quite slow in comparison
(when it comes to doing math) and also because of the decimal types
thing. I don’t claim to be an expert so I could be wrong.

You don’t have to write a patch to support decimal types. The latest
versions (the trunk) of Rails already include it.

Guest wrote:

I’m looking at more the language than the framework to solve floating
point errors but providing a facility to use something other than
floating points (such as decimal datatypes) so that these errors don’t
occur.
Can sprintf solve this problem with floating point types? If so I’d like
to know how.
Thanks.

Well the floating point errors that I am familiar with always fall into
a
pattern of rounding errors. For example 2.00 becomes 1.99999999999…
or
similar. sprintf("%.2f", var) will always return 2.00 or even convert
1/3 to
.33 or 2/3 to .67.

You could expirement with the use of the database to address this as
well. If
you create a field numeric(9,2) then it will only store two decimal
points of
the number. I do not know if this will store a truncated or rounded
value but
it might be worth knowing.

Getting back to the floating point errors, I have routinely run
applications in
the past through a cleanup function that simply applies a rounding to
the
variable. Archaic as it may sound to some, this was the recommended
practice
back in the heady days of Fortran and Pascal.

I supposed you could add your own method to Float to provide a “cleanly
rounded”
value like: balance = calculation().clean

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs