Accessing security fields in Python Scripts

priggall's Avatar

priggall

09 Apr, 2019 05:58 AM

I have a Python Script that extracts Investment account, Security and Transaction data for analysis by MS Excel/Access.

I want to include Security fields such as Security Type, Sub-Type, Face Value etc into the exported data but cannot find anywhere in the MD Object Model methods that will give me access.

Can you provide a Python script example and object references that I may use.

Thanks and regards

Peter Riggall

  1. 1 Posted by hleofxquotes on 11 Apr, 2019 05:59 PM

    hleofxquotes's Avatar

    Something like this

    from com.infinitekind.moneydance.model import AccountUtil, CurrencyType
    
    book = moneydance.getCurrentAccountBook()  
    currencies = book.getCurrencies();
    
    for c in currencies:  
      if (c.getCurrencyType() != CurrencyType.Type.SECURITY):
        continue
    
      print("s=%s, n=%s, ur=%d" % (c.getTickerSymbol(), c.getName(), c.getUserRate()))
    

    You might also want to take a look at Mike Bray codes on the security priceloader which can provide some hints on various "fields" that you can access via getter

    https://bitbucket.org/mikerb/moneydance-2015/src/master/src/

    For example, see https://bitbucket.org/mikerb/moneydance-2015/src/master/src/com/mon...
    and look for getUserRate()

    Best,

  2. 2 Posted by Mike Bray on 11 Apr, 2019 06:49 PM

    Mike Bray 's Avatar

    The best source for fields is the Javadoc documentation in the developer's toolkit. For MD 2019 look at version 5.1 at https://infinitekind.com/developer.

    I have attached the toolkit for MD 2015/17 (version 4.0)

  3. 3 Posted by priggall on 30 May, 2019 01:28 AM

    priggall's Avatar

    Hi Mike

    Thanks for the tips, one particular field that I am struggling to access is the Security's Currency.

    When I run your File Display utility on my account book I can see in the Security entry an item that you title Security Currency which contains the correct currency code for the item. The only MD method that I can find that seems to relate is "getCurrencyChoice" however this returns null.

    Can you point me in the right direction please.

    Regards

    Peter

  4. System closed this discussion on 29 Aug, 2019 01:30 AM.

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