gtg922r / obsidian-numerals

An obsidian plugin which turns a math code block into a full featured calculator
Other
389 stars 7 forks source link

feature request: currency conversion #44

Open kaushikgopal opened 1 year ago

kaushikgopal commented 1 year ago

Wonder if it's possible to add this. For e.g.

$100 to INR
gtg922r commented 1 year ago

Thanks for the suggestion!

Theoretically yes its possible to add, but two primary issues come to mind:

  1. I would need a source for up-to-date currency rates. In order to keep this plugin free that API would need to be free (and easily accessible). It also turns an otherwise offline plugin to an online one which I don't love, but perhaps is OK with user opt-in

  2. This would be the first function that has a dynamic result, which means the notes contents would change even if the user didn't change anything. Or it would mean that the data was out of data and technically wrong. This is the biggest issue for me as it leads to unpredictable results either way.

Issue 1 is possibly surmountable. 2 is a shift in the overall plugin philosophy.

I agree this would be a great feature, but due to these challenges, it's definitely further out on the roadmap.

Mirsario commented 1 year ago

If anyone comes here looking for a workaround to use before this is implemented (or in case it won't be), MathJS' createUnit function allows overriding default units:

createUnit('EUR', '1.0801906 USD', { override: true, aliases: [ '€' ] })
createUnit('AUD', '0.64623444 USD', { override: true, aliases: [ 'A$' ] })

This was quite sufficient for me, one just has to remember to update conversion rates from time to time. image

filipstachura commented 6 months ago

Nice workaround @Mirsario, thank you.

I just want to add that an example of free and accessible API is one from the European Central Bank: http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml

I believe that's the one that SoulverCore uses.

gtg922r commented 6 months ago

@filipstachura / @Mirsario - any thoughts on my comment above?

This would be the first function that has a dynamic result, which means the notes contents would change even if the user didn't change anything. Or it would mean that the data was out of data and technically wrong. This is the biggest issue for me as it leads to unpredictable results either way.

Supporting @Mirsario's solution through a simple version of #47 avoids this issue of the values changing over time. Would it be a sufficient solution to support easy definition of static conversion rates that can be used and updated at user request?

filipstachura commented 6 months ago

I completely understand your point, and I think it's valid. Reproducibility is important. Your proposal has also clear advantage of straightforward User Experience when offline.

From the user perspective:

  1. easy definition of static conversion rates would work for me 👍
  2. it would be great to have a way to update it with current rates easily (from European Central Bank or elsewhere). Some ideas: (a) button next to definition to fetch current rates and/or (b) a shortcut to refresh directly from notes