# Foreign Exchange Calculator Made With R & RShiny

in STEMGeeks2 months ago

Hi there. A few weeks ago, I made a Math Tools Web Application with the use of R programming and its RShiny library. This Math tools application contained graphing tools, geometry calculators, a quadratic formula calculator and a section for personal finance.

I have recently added a foreign exchange calculator as an add-on section for converting currency amounts from one currency to another. This forex app uses https://exchangeratesapi.io/ which is a free service for current and historical foreign exchange rates. These exchange rates is published by the European Central Bank.

This post will provide an overview on what this simple forex calculator does.

Pixabay Image Source

## Listed Currencies

The European Central bank list of currencies was larger than I thought. It just made the dropdown list longer to implement with all the typing. Not a big deal in the grand scheme of things. Here is a screenshot from ECB website that has a sample of the listed currencies.

Pixabay Image Source

## The Foreign Exchange Calculator Application

This Foreign Exchange Calculator is an add-on to my Math Tools application. It is a single page with four sections.

Top Left Area

The top left section is just a Pixabay image that has different currencies.

Top Right Section

In the top right area, I have a text box talking about what this foreign exchange rate calculator is about. I mention that this tool is linked with the Exchange Rates API Website and the list of currencies is from the European Central Bank as of January 2021.

The last sentence informs the user of the data and time of their visit. This date and time is updated in real time with the use of R's `Sys.time()` function along with the `format()` function. The format of the date and time is in dayofweek-month-daynumber format. There is also informtion for the user of what the base currency is. The default currency is the Euro set as EUR in this section and for the converter.

Bottom Left Section - Forex Calculator

This bottom left section is the main forex calculator. The user can select a base currency in the drop down menu at the top which is set as the Euro for the default base currency. A Base Currency amount can be set with the number input box. To determine how much of a base currency is worth in terms of a different currency, the user can select a desired currency to convert the base currency into.

Once the inputs are selected or modified, the sentence at the bottom will update according to the user's input. This sentence is of the format of "An amount of x Base Currency is equal to y in the desired currency."

In the screenshot below, I have the base currency as the Euro (EUR) with a base currency amount of 1. The desired currency is set as the Canadian Dollar (CAD) which is the default for the desired currency. The output sentence at the bottom says that `An amount of 1 EUR is equal to 1.53CAD.`.

This next screenshot shows how much 1000 Euros would be in Canadian dollars. Just simply change the amount in the base currency amount.

Bottom Right Section - Forex Reference Table

I thought of adding in a table of currency exchange rates given a base currency as an extra. This table lists all the currencies supplied by the API and the European Central Bank (ECB). The left column of the table is the currency and the right column lists how much of the currency for 1 unit of the base currency.

Referring to the screenshot above, I have the base currency the Euro In the table of the screenshot, one Euro is equal to 1.5346 CAD, one Euro is equal to 9.4033 Hong Kong Dollars (HKD) and so on.

Currencies from the table are in the three-letter abbreviated format. For currency codes that are not familiar, you would have to look them up for the corresponding country. You could use a website such as this one.

Pixabay Image Source

I did not feature too much code here. If you would like to see the code, you can check out the app and click on the source code button at the top right.

Posted with STEMGeeks

Sort:

I tried the Application and explored Currency Exchange Converter; works like a gem.. Tried USD to INR conversion and it showed up correct results.. Nice work mate. cheers

Thank you for trying it out. Nice that the USD to INR conversion worked. I wonder about all the other pairs. There are 33 x 32 = 1056 pairs (or 528 unique pairs). Too many to test.

I liked how this one turned out along with the whole Math Tools app in R & RShiny.

Congrats you were upvoted from this account because you were in Top 25 engagers yesterday on STEMGeeks .
You made a total of 1 comments and talked to 1 different authors .