Adding Securities from Extension

Quercus47's Avatar

Quercus47

24 Feb, 2022 11:00 PM

Is it possible to add a new security from an extension, or call MD's add security dialog from within an extension?

Is it possible to list securities that are not attached to an investment account?

Thanks.

  1. 1 Posted by Stuart Beesley ... on 24 Feb, 2022 11:47 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Both are easy. An extension can do anything at all with the data.

    I’ll respond more fully tomorrow.

  2. 2 Posted by Stuart Beesley ... on 24 Feb, 2022 11:57 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    For example:

    See here:
    https://infinitekind.com/dev/apidoc/com/infinitekind/moneydance/mod...

    A security is really a currency type record.
    CurrencyType​(CurrencyTable table) Is the constructor
    obj.setCurrencyType​(CurrencyType.Type newType) with SECURITY
    set all the right fields
    obj.syncItem() to save

    I’ll send an example in the morning…

  3. 3 Posted by Stuart Beesley ... on 25 Feb, 2022 08:30 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Example script to show you how to find unassigned securities

  4. 4 Posted by Stuart Beesley ... on 25 Feb, 2022 10:06 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Example script showing how to create a Security(Currency)

  5. 5 Posted by Stuart Beesley ... on 25 Feb, 2022 10:09 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    The following will pop up the Security screen. Use the UUID of a Security:

    moneydance.showURL("moneydance:showobj?id=f83c8f99-85f0-4c42-9edf-7ec7c7d03498")

  6. 6 Posted by Quercus47 on 25 Feb, 2022 03:26 PM

    Quercus47's Avatar

    Stuart,

    That helps much, thank you.

    What about the security sub-type (Large Cap, Small Cap, etc.) list? Do you know where I can access that list of user-defined items?

    Thanks.

  7. 7 Posted by Stuart Beesley ... on 25 Feb, 2022 03:51 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    On the Account Object.
    You need to get the Security sub account hanging off the Investment Account... Then

    Probably:
    .getSecurityType() .getSecuritySubType()

    https://infinitekind.com/dev/apidoc/com/infinitekind/moneydance/mod...

  8. 8 Posted by Quercus47 on 25 Feb, 2022 04:10 PM

    Quercus47's Avatar

    Thanks. If I follow correctly, that would give me the sub-type assigned to the security. I'm looking for the list of sub-types that are available. Is that list accessible or do I need to iterate through all accounts and build the list?

    The list must be stored somewhere, because I can create a sub-type (i.e. Commodity) and never use it. But it remains an option in the security sub-types list.

  9. 9 Posted by Stuart Beesley ... on 25 Feb, 2022 04:41 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    These are hard coded:
    CD("sec_cd"), BOND("sec_bond"), MUTUAL("sec_mutual"), STOCK("sec_stock"), OPTION("sec_option"), OTHER("sec_other"); com.infinitekind.moneydance.model.SecurityType

    Pointers:

    from com.infinitekind.moneydance.model import SecurityType
    from com.moneydance.apps.md.controller import SecuritySubtypeManager
    book = moneydance.getCurrentAccountBook()

    The technical method...

    types = book.getItemForID("security_subtypes")
    print types.getSyncInfo().toMultilineHumanReadableString()

    A better method...

    prefs = moneydance.getPreferences()
    stm = SecuritySubtypeManager(book, prefs, moneydance.getUI());
    print stm.getSubTypeList(SecurityType.MUTUAL)

  10. 10 Posted by Quercus47 on 25 Feb, 2022 05:09 PM

    Quercus47's Avatar

    Thanks. Not familiar with some of those aspects of the MD model, so going to take me some time to figure out all the details of implementation. But I have my direction now. Thanks!

  11. 11 Posted by Stuart Beesley ... on 25 Feb, 2022 05:16 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    I think the security sub types were a later (after thought) addition and therefore just "stuffed" into the dataset under a miscellaneous ID... In fact, Sean is now adding more new items this way rather than create new Objects.....

    For example, when you retrieve an Account object, you are really grabbing it from the dataset, but it's wrapped in a nice Account class.... This is probably the only bit of data that you would need to get this way (for now)....

  12. 12 Posted by Quercus47 on 08 Mar, 2022 10:51 PM

    Quercus47's Avatar

    Stuart,

    I've tried looking into the methods above but find no documentation to review. In particular, getPrefrences and SecuritySubtypeManager. Where did you get these from and where can I get more information?

    Thanks.

  13. 13 Posted by Stuart Beesley ... on 08 Mar, 2022 11:05 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    .

  14. 14 Posted by Stuart Beesley ... on 08 Mar, 2022 11:06 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    .

  15. 15 Posted by Stuart Beesley ... on 09 Mar, 2022 06:36 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    MD Preferences() can be very useful. For example:

    .getPreferences().getDecimalChar() for the user set decimal point character.

    and for reading other settings stored in config.dict. E.g.
    .getPreferences().getSetting("my_setting_name", None)

  16. 16 Posted by Stuart Beesley ... on 09 Mar, 2022 06:49 AM

    Stuart Beesley (Mr Toolbox)'s Avatar
  17. 17 Posted by Stuart Beesley ... on 09 Mar, 2022 06:51 AM

    Stuart Beesley (Mr Toolbox)'s Avatar
  18. 18 Posted by Mike Bray (Quot... on 09 Mar, 2022 03:30 PM

    Mike Bray (Quote Loader Author)'s Avatar

    To understand MD API you need to delve into the code. The only way to get this is to recompile moneydance.jar. You have to appreciate that this could breach TIK's copyright so you should only do this to understand the API not copying code. Stuart has done a great deal of work with his toolbox that could help you, also I have written a short Wiki with information about MD, see https://bitbucket.org/mikerb/moneydance-2019/wiki/Home. There is no reference manual other than the Javadoc entries available via the Development Kit.

  19. System closed this discussion on 08 Jun, 2022 03:30 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