yogi1967 / MoneydancePythonScripts

My collection of Python(Jython) extensions (*.mxt) and scripts (*.py) for Moneydance (via the MoneyBot console).
https://yogi1967.github.io/MoneydancePythonScripts/
MIT License
14 stars 6 forks source link

Custom Balances: Formula (FOR) field does not work with tickers that have a dot in it #31

Open rndpsn opened 2 months ago

rndpsn commented 2 months ago

This is regarding Custom Balances: v1051.

Thanks for this awesome extension!

An issue I'd like to report is that the Formula (FOR) field does not work with tickers that have a dot/period (".") in it.

For example, when I try use this formula below to calculate the number of shares I own of the Canadian stock Shopify on the Toronto Stock Exchange (SHOP.TO on Yahoo Finance) by dividing the value of my holdings with the stock price:

@this / @shop.to

I get an error message:

Formula error: NameError: 'name 'curr00000shop' is not defined

I think this issue affects mostly Canadian stocks, because in order to make the Quote Loader extension (by Mike) pulls the prices of Canadian stocks from the Yahoo source, the stock tickers need to have the ".TO" suffix.

One workaround is to save the stock ticker as "SHOP" in the properties for the security (instead of SHOP.TO), and put "SHOP.TO" in the "Alt Ticker" column in the Quote Loader extension. That way both Custom Balance and Quote Loader work.

Another workaround is to use the US prices for stocks that are listed on both US and Canadian exchanges (such as Shopify).

Thanks for your attention!

yogi1967 commented 1 month ago

Thanks for the bug report and workaround.. This is unfortunate and somewhat (accidentally) deliberate... In simple terms, python variables cannot contain dots.. So the internal replacement to curr00000shop.to would never work.. I would have to change the engine to pre-transform tickers to replace dots with and then find @tickers with dots and change to .. The REGEX formula would be very tricky... I would love to address, and I will ponder. I have added to my todo list, but I cannot easily fix it for now.....

I'm glad you like it.....!