Giter VIP home page Giter VIP logo

kalaspuff / stockholm Goto Github PK

View Code? Open in Web Editor NEW
56.0 3.0 4.0 1.55 MB

๐Ÿ’ต Modern Python library for working with money and monetary amounts. Human friendly and flexible approach for development. 100% test coverage + built-in support for GraphQL and Protocol Buffers transports using current best-practices.

License: MIT License

Makefile 0.69% Python 99.31%
fintech money python library currency package stockholm monetary python3 finance

stockholm's People

Contributors

dependabot[bot] avatar kalaspuff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

stockholm's Issues

Questions about Pydantic and Unicode symbols

Hello, first of all, I want to say thanks for the great library! It is very well explained with a lot of examples and it is very feature rich.
I have 2 questions and I couldn't find a wiki or a discord or any other discussion forum so I guess I will open an issue to ask.

First is what is the most intended way to use this library with Pydantic 2?
It would have been cool if the Money object was a Pydantic BaseModel or supported Pydantic schemas for serialization, but since that is not the case am I supposed to convert it to a dict, parse it as a Pydantic model and store it like that? And then when I want to do money operations I am supposed to convert it back and forth?
Or is working with Pydantic models just not a considered aspect of this library? If you are interested I could try to contribute this functionality.

My second question is does this library support formatting money using Unicode symbols?
For example: โ‚ฌ5.00, -โ‚ฌ4.21, $50, -$7
And is this a feature that you are interested in getting a contribution for?

Stockholm money objects does not support deepcopying

from copy import deepcopy
from stockholm.money import Money

>>> deepcopy(Money(100, "SEK"))

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.10/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/usr/local/lib/python3.10/copy.py", line 283, in _reconstruct
    setattr(y, key, value)
  File "/usr/local/lib/python3.10/site-packages/stockholm/money.py", line 550, in __setattr__
    raise AttributeError("Attributes of monetary amounts cannot be changed")
AttributeError: Attributes of monetary amounts cannot be changed

Friendly Formatting

Firstly, this is a fantastic library.

I have a few questions relating to readability of the string output:

  • Is it possible to print 1000000.00 USD as 1,000,000.00 USD? (humanize.intcomma module does this)
  • Is there a way to print $1000.00 instead of 1000.00 USD?
  • Is there a way to strip nanos if they're zeroes? 1000.00 USD -> 1000 USD?

Initialising `Currency` from ticker string does not set correct `decimal_digits`

We're using version 0.5.1

from stockholm import Currency

c1 = Currency("RWF")
c1
# <stockholm.Currency: "RWF">
c1.decimal_digits
# 2

c2 = Currency.RWF
c2
# <stockholm.Currency: "RWF">
c2.decimal_digits
# 0

This causes a bug for us where 100x as much money was passed as intended

from stockholm import Money

t = Money("1673861354.00", "RWF")
t
# <stockholm.Money: "1673861354.00 RWF">

t.sub_units
# Decimal('167386135400')

int(t.sub_units)
# 167386135400

Workaround:

c3 = getattr(Currency, "RWF")
c3
# <stockholm.Currency: "RWF">
c3.decimal_digits
# 0

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.