Giter VIP home page Giter VIP logo

Comments (7)

greyblake avatar greyblake commented on May 19, 2024 1

@lukesneeringer Hi.
This question was already raised in #15 .
I tend to say that we do not need it and close the issue, but I'd like to hear from you what is the necessity to have Decimal support?

from ta-rs.

greyblake avatar greyblake commented on May 19, 2024 1

Decimals important for storing money and making operations with money, I do agree. But this does not apply to technical analysis.
I would argue that precision of f64 is more than needed for TA, and it's not enough, then you're probably fooling yourself, thinking that being super precise gives an advantage to your trading strategy.
As Warren Buffet once said: "It is better to be approximately right than precisely wrong."

meaning if I give my users a f64 in some places and a decimal in others, comparing them or manipulating them is more difficult than it ought to be.

You can implement a wrapper around the existing indactors, that would convert f64 -> Decimal. But generally I would suggest.. just convert the values where you want to do comparison. Moving averages, is probably the only case when you actually want to compare prices with indicator values.

from ta-rs.

greyblake avatar greyblake commented on May 19, 2024 1

@lukesneeringer Hi, thanks for reaching me.
I still hold the same opinion as before (decimal is MUST for prices, money amounts in bookkeeping, but not for TA indicators).

Unfortunately I don't have much spare time at the moment to dedicate to ta.
I am not sure what to suggest. Maybe you can do it a for 2-3 indicators and ask me to take a look?

from ta-rs.

lukesneeringer avatar lukesneeringer commented on May 19, 2024 1

That's fair. I think I know how this should be done that would work well. I'll send you a PR.

from ta-rs.

lukesneeringer avatar lukesneeringer commented on May 19, 2024

My reason is basically the same as the one in #15: I am trying to avoid the use of floats; every number in the project is an integer or a decimal.

I agree that for many of the outputs of ta, precision is less important, but it is not unimportant. Also, a lot of the folks writing against the API I am writing are less technical and I do not want to give them one sub-integer type consistently. This is also important because decimals support all the arithmetic operators with each other, but not with f64s -- meaning if I give my users a f64 in some places and a decimal in others, comparing them or manipulating them is more difficult than it ought to be.

I also expect this can be done in a reasonably generic way to not add very much code duplication. rust_decimal::Decimal supports all the arithmetic traits, after all.

from ta-rs.

lukesneeringer avatar lukesneeringer commented on May 19, 2024

then you're probably fooling yourself, thinking that being super precise gives an advantage to your trading strategy.

It is not so much that I think the precision of decimals is critical in this case. I am much more interested in API simplicity. I want my folks to work with decimals all the time rather than having to take on converting between decimals and floats.

from ta-rs.

lukesneeringer avatar lukesneeringer commented on May 19, 2024

@greyblake Following up on this, because it's still something I am hoping for. I'm willing to implement it myself, but I don't want to do it if you're going to reject the PR. :-)

I'd do it behind a feature gate, so it won't affect anyone who doesn't want it.

from ta-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.