# \[ANN\] ExchangeRates.jl

**URL:** <https://discourse.julialang.org/t/ann-exchangerates-jl/129317>\
**Category:** Package Announcements\
**Created:** [May 25, 2025, 2:19pm UTC](https://discourse.julialang.org/t/ann-exchangerates-jl/129317 "2025-05-25T14:19:42Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![tp2750](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tp2750/32/207806_2.png) [@tp2750](https://discourse.julialang.org/u/tp2750)\
**Post date:** [May 25, 2025, 2:19pm UTC](https://discourse.julialang.org/t/ann-exchangerates-jl/129317/1 "2025-05-25T14:19:42Z")

</div>

I often need to convert prices in webshops to my local currency to better understand it.  
This small package [ExchangeRates.jl](https://github.com/tp2750/ExchangeRates.jl) does this with a (in my opinion) slick interface:

```julia
julia> using ExchangeRates
[ Info: Fetching rates from https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml

julia> 100€/DKK
746.02

```

I hope this will also be useful for others.

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [May 25, 2025, 4:25pm UTC](https://discourse.julialang.org/t/ann-exchangerates-jl/129317/2 "2025-05-25T16:25:12Z")

</div>

The interface appears to be a bit backwards if you consider the currencies to be units, i.e., you use €/DKK to produce a result in DKK, rather than DKK/€.

Does DKK/€ not translate to the number of Danish crowns per euro?

* * *

Edit, turns out I’m the one getting it backwards

---

<div class="post-metadata">

**Author:** ![tp2750](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tp2750/32/207806_2.png) [@tp2750](https://discourse.julialang.org/u/tp2750)\
**Post date:** [May 25, 2025, 7:34pm UTC](https://discourse.julialang.org/t/ann-exchangerates-jl/129317/3 "2025-05-25T19:34:53Z")

</div>

`100EUR/DKK` is the amount of DKK needed to get 100 EUR.  
You can read the “/” as “in”.

---

<div class="post-metadata">

**Author:** ![JoshuaLampert](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joshualampert/32/205964_2.png) [@JoshuaLampert](https://discourse.julialang.org/u/JoshuaLampert)\
**Post date:** [May 25, 2025, 7:54pm UTC](https://discourse.julialang.org/t/ann-exchangerates-jl/129317/4 "2025-05-25T19:54:11Z")

</div>

To me the easiest way to see that this interface makes sense is the following: If you multiply the equation 100 €/DKK = 746.02 by DKK, you obtain 100 € = 746.02 DKK, which makes total sense to me. Thanks for the package!

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [May 25, 2025, 8:02pm UTC](https://discourse.julialang.org/t/ann-exchangerates-jl/129317/5 "2025-05-25T20:02:45Z")

</div>

You know that you could overload the `in` operator?

---

<div class="post-metadata">

**Author:** ![Krastanov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krastanov/32/6817_2.png) [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Post date:** [May 25, 2025, 9:15pm UTC](https://discourse.julialang.org/t/ann-exchangerates-jl/129317/6 "2025-05-25T21:15:31Z")

</div>

Seems consistent to me: `1 m / mm = 1 m / (1 mm) = 1000`. To me `100€/DKK` reads as 100 Euros divided by 1 DKK, not as 100 Euros multiplied by the ratio EUR/DKK (that would be `100 €^2 / DKK`).

> Does DKK/€ not translate to the number of Danish crowns per euro?

No, just like `mm/m` is 0.001, i.e. the number of meters in a millimeter, not 1000 (the number of millimeters in a meter).

Overloading the `in` operator is a bad idea here – it is not the usual semantic meaning of `in` (set inclusion). That type of overload is frequently called “punning” and is discouraged similarly to how piracy is discouraged.

---

<div class="post-metadata">

**Author:** ![BambOoxX](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bambooxx/32/22179_2.png) [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Post date:** [May 25, 2025, 9:38pm UTC](https://discourse.julialang.org/t/ann-exchangerates-jl/129317/7 "2025-05-25T21:38:34Z")

</div>

> [@Krastanov](#):
>
> No, just like `mm/m` is 0.001, i.e. the number of meters in a millimeter, not 1000 (the number of millimeters in a meter).

That’s funny, I would have said exactly 1000 😉 , but you are right.

---

<div class="post-metadata">

**Author:** ![tecosaur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tecosaur/32/23206_2.png) [@tecosaur](https://discourse.julialang.org/u/tecosaur)\
**Post date:** [May 26, 2025, 8:04am UTC](https://discourse.julialang.org/t/ann-exchangerates-jl/129317/8 "2025-05-26T08:04:43Z")

</div>

Neat!

> [@tp2750](#):
>
> ```julia
> [ Info: Fetching rates from https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml
> 
> ```

I’m sure this is pretty quick, but I wonder if you’ve considered using a cached file that automatically refreshes when it’s \>age old?

Disclaimer: this comes to mind because it’s [one of the things that DataToolkit does](https://tecosaur.github.io/DataToolkit.jl/store/plugin_store/) (but it won’t be a good dep for other packages until the next minor release).

---

<div class="post-metadata">

**Author:** ![tp2750](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tp2750/32/207806_2.png) [@tp2750](https://discourse.julialang.org/u/tp2750)\
**Post date:** [May 26, 2025, 7:09pm UTC](https://discourse.julialang.org/t/ann-exchangerates-jl/129317/9 "2025-05-26T19:09:33Z")

</div>

> [@tecosaur](#):
>
> I wonder if you’ve considered using a cached file that automatically refreshes when it’s \>age old?

I have considered that, and Scratch.jl looks like a way to do it. I’ll also look into DataToolkit.jl.  
It may come in a later release, but for now I prioritized the simplicity of just fetching at load time.

---

<div class="post-metadata">

**Author:** ![Mastomaki](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@Mastomaki](https://discourse.julialang.org/u/Mastomaki)\
**Post date:** [May 30, 2025, 7:04am UTC](https://discourse.julialang.org/t/ann-exchangerates-jl/129317/10 "2025-05-30T07:04:04Z")

</div>

Can I use the average exchange rate in 2024?

---

<div class="post-metadata">

**Author:** ![tp2750](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tp2750/32/207806_2.png) [@tp2750](https://discourse.julialang.org/u/tp2750)\
**Post date:** [May 31, 2025, 5:27am UTC](https://discourse.julialang.org/t/ann-exchangerates-jl/129317/11 "2025-05-31T05:27:22Z")

</div>

It is using the European Central Bank [reference rates](https://www.ecb.europa.eu/stats/policy_and_exchange_rates/euro_reference_exchange_rates/html/index.en.html), but other sources might be possible.  
I do not know a source of average exchange rates.
