Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Price Precision Config #86

Closed
enescakir opened this issue Feb 9, 2021 · 3 comments · Fixed by #122
Closed

Price Precision Config #86

enescakir opened this issue Feb 9, 2021 · 3 comments · Fixed by #122
Labels
bug Something isn't working

Comments

@enescakir
Copy link
Contributor

Thanks for great tool.

Number of the digits after the decimal point isn't enough especially for cryptocurrencies. Currently, precision is set to 2 in ticker/internal/ui/util/format.go >> ConvertFloatToString(f float64) string file. It's very small. precision configuration might be great.

I thought to open a PR, but I couldn't find a way to access config value in ConvertFloatToString. I didn't want to add precision as parameter to lots of places such as ConvertFloatToString, ValueText, watchlist.NewModel, watchlist.item etc.

@enescakir enescakir added the feature request New feature or request label Feb 9, 2021
@achannarasappa achannarasappa added this to the future-release milestone Feb 9, 2021
@achannarasappa achannarasappa added bug Something isn't working and removed feature request New feature or request labels Feb 9, 2021
@achannarasappa
Copy link
Owner

I wonder if there is a sensible default that could be applied here.

If we were to expose an option to set precision globally, stocks with high and low value per unit may look odd e.g. (100000.00000 and 0.00013).

This issue warrants a solution but what the solution is is not yet clear to me.

@enescakir
Copy link
Contributor Author

enescakir commented Feb 10, 2021

Maybe we can decide it for each stock automatically. Yahoo Finance shows max 4 digits min 2 digits after dot.
It might me something like that

       stock < 10       --->   precision: 4     i.e.: 0.4375, 1.5436
 10 <= stock < 100      --->   precision: 3     i.e.: 10.543
100 <= stock            --->   precision: 2     i.e.: 100.30, 49435.97

If it makes sense to you, I can open a PR for it. https://play.golang.org/p/KeT4xrw4p6n

image

image

image

image

@achannarasappa
Copy link
Owner

Your suggestion looks sensible to me. A PR would be very much welcome :)

enescakir added a commit to enescakir/ticker that referenced this issue Feb 16, 2021
enescakir added a commit to enescakir/ticker that referenced this issue Feb 16, 2021
achannarasappa pushed a commit that referenced this issue Feb 20, 2021
* Add adaptive precision for values

Fixes #86

* Handle negative values and fix summary tests

* Fix watchlist tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants