How to add a security from a python script

md_oz's Avatar

md_oz

21 Jan, 2018 08:41 PM

I'm trying to add a security to the security master via a python script.

I know the 'New Security" dialog does this, but I want to read my security attributes from a file and add a new security from a python script. The information I would read from the file is the same as what is entered manually in the 'New Security" dialog, namely:
- Security ID
- Security Name
- Ticker Symbol
- Price
- Value Prefix
- Value Suffix
- Max. Decimal Places
- Show on summary page

Is there any way I can invoke the java program behind the 'New Security" dialog from python to add a security?

I can see how to delete an item (via the .getCurrencyByID(symbol_id).deleteItem() method), but I can't determine how to add an item.

Can you share an example of how to do this please?

Thank you.

  1. 1 Posted by whitedavidp on 23 Feb, 2018 12:28 AM

    whitedavidp's Avatar

    Have not actually tried this but I think the pseudo code for this would be

    import from com.infinitekind.moneydance.model import CurrencyTable, CurrencyType

    book = moneydance.getCurrentAccountBook()
    currencies = book.getCurrencies().getAllCurrencies()
    newCurrency = CurrencyType(book)
    newCurrency.setTickerSymbol("symbol")
    newCurrency.setName("name")
    newCurrency.setIDString("id")
    ...

    and so forth. Or it seems maybe faster/better to use:

    book = moneydance.getCurrentAccountBook()
    currencies = book.getCurrencies().getAllCurrencies()
    com.infinitekind.moneydance.model.CurrencyType.newCurrency = currencyFromFields(id, id_string, name, rate, decimalPlaces, prefix, suffix, tickerSymbol, effectiveDate, currencyType, currencies)

    See the CurrencyType class in those within the com.infinitekind.moneydance.model package documented here <https://infinitekind.com/dev/apidoc/index.html>.

    Good luck.

  2. System closed this discussion on 25 May, 2018 12: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