Currency Converter
Last updated 2004-06-28 by Roedy
Green ©2002-2004 Canadian Mind Products.
Introduction
FX stands for Foreign Exchange. CurrCon
stands for Currency Converter.
The currency converter lets you display prices/amounts in the native currency of
the visitors to your website. The currency converter automatically selects the
default currency to display based on the locale country setting of the browser.
It currently supports 169
different currencies.
Unlike most currency converters, with this one, the user does not enter amounts
to be converted. The values come from your web page. All prices on your web
pages are instantly displayed in the user's favourite currency without him
having to do anything.
Benefits
It lets you sell to an international market on the web. You quote prices in your
native currency, and CurrCon deals with automatically converting all the prices
on a page to the user's favoured currency. If the user wants, he can flip all
the prices on the page instantaneously into any other currency.
If you write essays that mention amounts of money, you can use CurrCon so that
all these amounts are automatically converted to the currency the reader is most
familiar with. That ensures your readers fully understand what you are saying.
How It Works
Unlike most currency converters, this one requires no server-side support. It
does not require JavaScript. However, it does require Java in the user's browser.
Each value displayed is a tiny Java Applet. All that is required is you upload
the currcon.jar file to your website. It contains the latest exchange rates in
compressed form and also the Java code to do the conversions.
If you change the currency choice anywhere on a page, automatically all the
other displays on the page instantly follow suit. Try using the up down arrow to
cycle through the possible currencies. Try it below:
To get a display like this:
You need to code some HTML that looks like this:
<!-- macro CurrCon C$AcN USD 70.00 -->
which expands to:
<applet archive="currcon.jar" code="com.mindprod.currcon.CurrCon.class"
width="280" height="20" alt="70.00 USD">
<param name="currency" value="USD">
<param name="amount" value="70.00">
<param name="show" value="C$AcN">
</applet>
Normally you might display something simpler such as this:
To get that you code some HTML like this:
<!-- macro CurrCon cA USD 70.00 -->
which expands to this:
<applet archive="currcon.jar" code="com.mindprod.currcon.CurrCon.class"
width="120" height="20" alt="70.00 USD">
<param name="currency" value="USD">
<param name="amount" value="70.00">
<param name="show" value="cA">
</applet>
or even simpler like this:
To get that you code some HTML like this:
<!-- macro CurrCon A USD 70.00 -->
which expands to this:
<applet archive="currcon.jar" code="com.mindprod.currcon.CurrCon.class"
width="70" height="20" alt="70.00 USD">
<param name="currency" value="USD">
<param name="amount" value="70.00">
<param name="show" value="A">
</applet>
Details of the Applet Tags
Typically to produce a CurrCon display, you need something like this in your
HTML:
<applet archive="currcon.jar" code="com.mindprod.currcon.CurrCon.class"
width="120" height="20" alt="70.00 USD">
<param name="currency" value="USD">
<param name="amount" value="70.00">
<param name="show" value="cA">
</applet>
What is all this gobbledgook? Happily most of it is just boilerplate. You can
copy/paste standard templates and just change the amount.
-
<applet says this is a Java Applet.
-
archive="currcon.jar" is the name of the
file where the exchange rates are kept.
-
code="com.mindprod.currcon.CurrCon.class" is
the name of the Java program that does the conversions.
-
width="120" tells how much screen width real
estate in pixels to use. You must calculate the width based on how many elements
you choose to include is your show parameter: c=50 C=30 N=120 A=70 $=10. More on
that later.
-
height="20" The height of the display in
pixels.
-
alt="70.00 USD" What to display if the user
does not have Java.
-
<param name="currency" value="USD">
the currency used to express the base amount, most commonly USD
for US Dollars, CAD for Canadian dollars, or EUR
for Euros or GBP for British pounds sterling. See this complete
list. Every price on the page can be expressed in a different base currency
if you want.
-
<param name="amount" value="70.00">
specifies the amount in some base currency.
-
<param name="show" value="cA">
Which types of display you want to see: any combination or order of the letters:
c C N A $. More on what they mean later.
-
</applet> marks the end of information needed to
generate the display.
Details of the show Parameter
| Letter |
What it looks like |
Changeable |
Width in Pixels |
Purpose |
| c |
|
yes |
50 |
Allows user to change the currency for all displays on the page. |
| C |
|
no |
30 |
Compactly let's user know what currency is being used with a three-letter
abbreviation. |
| N |
|
no |
120 |
Spells out the currency name being used in easy-to-understand words. |
| A |
|
no |
70 |
Show the amount, converted into the users's favoured currency. If
there is no A in the show parameter, you need not bother specifying the currency
and amount parameters. |
| $ |
|
no |
10 |
Put a lead $/euro symbol etc. on the following amount. |
You can use any combination of the letters c C N A $, in any order, leaving any
out. You need to add up the widths of each piece an put that in as the width of
the entire Applet. Unfortunately currCon can't add them up for you, since by the
time it starts the amount of screen real estate is already fixed. For example:
Yuchh, that's too Complicated!
Don't give up yet. There are several possible alternatives to manually coding
the <APPLET tags.
-
If you want, for no extra cost, I will write you an Java
Application to help with the show letter symbols. You fill in the blanks
to select which elements you want to display, the amount, the currency, and the
nesting level and it both shows you what it will look like, and pokes the
equivalent HTML <APPLET tags into clipboard where
you can paste them into your HTML document. I have not written this HTML
generator since no one has asked for it yet. It could have it ready in a day or
two.
-
You can just embed the short form static HTML macros in your HTML and have them
expanded for you. It this how I handle them on my own website. You can see the
macros I use on the my own website by using view source.
expands to:
The tricky part in doing it manually is getting
the right number of ../../ in the archive jar name,
and figuring out the exact width and height.
I run the macro processor on all my files just prior to any upload. I expand the
macros, generate an index, compact the HTML, and provide a mirror website via the
Replicator. The macro generator stripped down to handle just CurrCon macros
is optionally included, but not the Compactor
or the Replicator. I have not
prepared the stripped down version of the macro generator since no one has asked
for it yet. It could have it ready in a day or two at no extra cost.
-
You could also generate the <APPLET tags with JSP,
servlets or ASP. I have not yet written code to do that, but I could work with
you on developing it. I have no ASP experience at all, so all I could do in
provide you equivalent Java code. You might wonder why bother with CurrCon in
that case. Why not just generate the page with the conversions pre-expanded? The
advantage of using CurrCon is the user can switch every price on the page with a
click of a mouse. He does not have to wait for a whole new page to be generated
and delivered. However, you could do it that way, cannibalising some of CurrCon's
logic, giving you the advantage of no reliance of a working Java in the client
machine.
-
You could simplify the <APPLET tags by creating a
special version of CurrCon that used your usual Show tags and base currency as
the default. Further you could leave out the material for-non-Java users, and
put that somewhere on your page once.
Displaying Exchange Rates
You can also use CurrCon to display exchange rates like this:
| 1 Euro is |
|
|
| 1 British pound Sterling is |
|
| 1 US dollar is |
|
| 1 Canadian dollar is |
|
| 1 New Zealand dollar is |
|
Updates
Exchange rates change daily. I update the exchange rate tables daily and post
them on my website. You are free to download the latest versions every day and
upload them to your website. Alternatively, you can use your own source and add
the massaged serialized data to the jar yourself. I have written code to do this
the Bank of Canada, the source I use on my own website. I could write you an
automated extractor for other sources. Most likely I would charge
, but it depends on the complexity. In any case, I give you a fixed price ahead
of time. It is not hard to do yourself using the two sample extractors I have
written as models.
FX Sources
You need to pick a source for your exchange rates.
| Foreign Exchange Rate Currency Sources |
| Source |
Number Of Currencies |
Format |
Notes |
| Bank
Of Canada |
55 |
CSV downloadable file, very convenient. Relative to Canadian dollar. |
Official Government source, comes out 1 PM EST each day. Has last 7 days of
rates. This is the source I use at mindprod.com. Free. You can also pick them up
indirectly already massaged into a jar file from the mindprod.com website each
day. |
| oanda.com |
167 |
Requires licencing the feed. |
Makers of the FxCommerce product that competes with CurrCon. It is illegal
to use this site to feed data into CurrCon by screenscaping or copying from the
screen. Their lawyer explained this in series of emails. Apparently, it would be
legal if either you or I signed a licence agreement with them and paid a fee to
use a special feed they have.
If you curious about the history of how the US dollar (code USD) has been doing
relative to the Canadian dollar (code USD), the Euro (code EUR) even the Iraqi
Dinar (code IQD) see Oanda's
fxhistory. The US dollar is in deep trouble, but most Americans are unaware
of what is happening. Money is fleeing America causing the value of the dollar
to drop relative to other countries. The net effect is America has to pay more
for imported goods which puts her still deeper in debt in a vicious spiral of
debt. |
| Bank Of Montreal |
62 |
HTML table screenscrape |
listed with both country and currency. |
| Univerity of BC |
44 |
HTML table screenscrape |
Updated each noon Pacific Time |
| US Federal
Reserve Bank |
25 |
text in columns screenscrape |
Official government source. |
| CustomHouse |
26 |
HTML table screenscrape |
rates are one day behind. |
| Microsoft |
15 |
HTML table screenscrape |
Updated frequently |
| XE.com |
68 |
as an email in columns surrounded by extraneous text. |
Email would need to be extracted manually when it arrived. |
| newspaper |
? |
you type them in daily using a csv file. |
This is a lot of work. It is error prone. The main advantage is no issue of
paying royalties. |
Comparision of CurrCon with Oanda FxCommerce
Oanda makes a similar product to CurrCon
called FXCommerce.
| Feature |
CurrCon |
FxCommerce |
| Requires special Code on the server? |
no |
yes |
| Automatically selects user's currency |
yes |
no |
| Requires user to have JavaScript enabled |
no |
yes |
| Requires user to have Java enabled |
yes |
no |
| Requires user to reload page to see prices? |
no |
yes |
| Lets you control font, color etc. of prices with style sheets? |
no |
yes |
| Cost |
one time fee. |
per month. |
Configuring
The program is slightly customised for your website. I need to ask you a few
questions. This protects you from pirates pounding your website to provide them
with CurrCon services. I am opening to creating custom versions of the program
as well. I need to know which technique you will use to generate the Applet
tags and what source you plan to use for the exchange rates. To help you get
started quickly, I need to know which currency choices you want to offer.
The list of choices is limited by both what your source offers and by the list
of currency descriptions. A currency must be in both lists to show up on the web
page. The currency details list looks like this, with columns for abbreviation,
decimal places, unicode currency symbol, description:
Costs
All prices are in
, but of course, you now know how to change that.
for the Currency Converter and coaching you through installation and your first
few web pages. See details on how to
buy it. The price includes source, and your right to modify it and use it
throughout your company.