Getting of max. decimal places

Michal Šebesta's Avatar

Michal Šebesta

28 Dec, 2022 06:46 PM

Hello,
I have a python script to load stock purchases. However, each security has a differently defined maximum number of decimal places. Is there a method to get this value? I couldn't find it in the "Account" class.

  1. 1 Posted by Stuart Beesley ... on 28 Dec, 2022 07:34 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    It’s not on the account. Once you have a security sub account then you get the account’s currency (which is the security master) and the method is on there is .getDecimalPlaces()

  2. 2 Posted by Stuart Beesley ... on 28 Dec, 2022 07:40 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    So something like:

    from com.infinitekind.moneydance.model import Account, CurrencyType
    if secAcct.getAccountType() == Account.AccountType.SECURITY:
       security = secAcct.getCurrencyType()
       dpc = security.getDecimalPlaces()
       print secAcct, security, dpc
    else:
       raise Exception("Must be on a Security sub-account to do this! :->")
    
  3. 3 Posted by Michal Šebesta on 28 Dec, 2022 07:46 PM

    Michal Šebesta's Avatar

    it works, thanks a lot

  4. 4 Posted by Stuart Beesley ... on 28 Dec, 2022 07:52 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    👍 Anytime, just post any questions....

  5. 5 Posted by Stuart Beesley ... on 28 Dec, 2022 09:09 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    PS. The getDecimalPlaces() method should be rarely needed as the inbuilt CurrencyType methods of the Security will correctly decode / convert any security’s qty stored on an Account from a decimal long (int) value into a double (float). Eg .formatFancy(), .formatSemiFancy(), .getDoubleValue().

  6. System closed this discussion on 29 Mar, 2023 09:10 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

15 Apr, 2024 03:02 PM
15 Apr, 2024 01:56 PM
15 Apr, 2024 12:32 PM
15 Apr, 2024 12:20 PM
15 Apr, 2024 11:56 AM