5 Minute Developer: How to Build a Currency Converter in 5 Minutes

First Published Tuesday, 9th March 2010 03:06 pm from Xand : ChasCooper

The opinions expressed by this blogger and those providing comments are theirs alone, this does not reflect the opinion of Automated Trader or any employee thereof. Automated Trader is not responsible for the accuracy of any of the information supplied by this article.


href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F02%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F">

/> src="http://api.tweetmeme.com/imagebutton.gif?url=?url=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F02%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F&source=xignite&style=normal"

height="61" width="51" />

Every five minutes, a business in the U.S. rel="nofollow"

href="http://crm.cr.nps.gov/archive/24-08/24-08-5.pdf"

target="_blank">catches fire, someone in the UK

href="http://www.telegraph.co.uk/news/uknews/6230569/Swear-words-heard-once-every-five-minutes.html"

target="_blank">swears, and a clock that took 5

years and £1 million to build before being unveiled by none

other than Stephen Hawking, finally

href="http://news.bbc.co.uk/2/hi/7625815.stm"

target="_blank">tells the time accurately for a

second or two.

What will you do with your next

5 minutes?

Here's a thought: Why not build a

href="http://www.xignite.com/forex/web-service/2000106.html">real-time

forex currency converter? Sound like fun? If so, give

it a try using the steps below. Or, if you'd rather

leave all the fun to someone else, why not just href="http://www.xignite.com/forex/web-service/2000106.html"

target="_self">watch a video of us doing

it?

Here's how

it's done:

Step 1: Start a new Windows

application project in Visual Studio.

Step 2: Create a Web

reference to http://www.xignite.com/xCurrencies.asmx?WSDL and

call it XigniteCurrenciesService.

Step 3: On the Form1

design, drag and drop 3 text boxes, 2 labels, and a button,

arranging them as shown in the picture. From left to right, give

the text boxes the following names and default text:

inputBaseAmount defaulting to 1000, inputBaseSymbol defaulting to

USD, inputQuoteSymbol defaulting to EUR. One label should have a

big equal sign in it and the other should have the name of

labelQuoteAmount and zero for its text property. The button

should read "Convert."

class="aligncenter"

src="http://cdn.xignite.com/blog/02_01_10/5min_currency_converter_v1a.png"

alt="Real-Time Forex Currency Converter Built in 5 Minutes"

/>

Step 4:

Double-click the button to create its click event

handler, and give it the following 3 lines of code:

XigniteCurrenciesService.XigniteCurrencies

XigniteCurrenciesWebService = new

XigniteCurrenciesService.XigniteCurrencies();

XigniteCurrenciesService.ExchangeConversion Quote =

XigniteCurrenciesWebService.ConvertRealTimeValue(inputBaseSymbol.Text,

inputQuoteSymbol.Text,

double.Parse(inputBaseAmount.Text));

labelQuoteAmount.Text =

Quote.Result.ToString();

Step 5:

Compile and run.

Authentication trouble? If

you get an authentication error, it means you're not

being authenticated from a cookie or your IP address.

Don't worry. Just add 3 more lines after the first line

of code to pass your authentication key through SOAP. Be sure to

replace MYAUTHENTICATIONKEY with your own Xignite account

authentication key. (Don't have an authentication key? Just href="http://www.xignite.com/forex/getting-started/2000111.html"

target="_self">sign up to get one. Your e-mail will

be your initial authentication

key.)

XigniteCurrenciesService.Header

objHeader = new XigniteCurrenciesService.Header();

objHeader.Username =

"MYAUTHENTICATIONKEY";

XigniteCurrenciesWebService.HeaderValue =

objHeader;

Congratulations!

You just spent the last five minutes far more

productively than one U.S. business, one citizen of the UK, and

one very expensive but very inaccurate clock.

Share and

Enjoy:

href="mailto:?subject=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes&body=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F02%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F"

title="email"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/email_link.png"

title="email" alt="email" class="sociable-hovers" />

href="http://twitter.com/home?status=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes%20-%20http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F02%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F"

title="Twitter"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/twitter.png"

title="Twitter" alt="Twitter" class="sociable-hovers"

/>

href="http://www.facebook.com/share.php?u=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F02%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F&t=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes"

title="Facebook"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/facebook.png"

title="Facebook" alt="Facebook" class="sociable-hovers"

/>

href="http://www.linkedin.com/shareArticle?mini=true&url=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F02%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F&title=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes&source=Financial+Market+Data+Web+Services+-+Xignite+Blog+It%27s+not+the+data.++It%27s+the+delivery.&summary=In%205%20minutes%2C%20build%20a%20real-time%20forex%20currency%20converter%20application%20using%20Visual%20Studio%2C%20C%23%20and%20Xignite%27s%20XigniteCurrencies%20web%20service."

title="LinkedIn"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/linkedin.png"

title="LinkedIn" alt="LinkedIn" class="sociable-hovers"

/>

href="http://digg.com/submit?phase=2&url=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F02%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F&title=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes&bodytext=In%205%20minutes%2C%20build%20a%20real-time%20forex%20currency%20converter%20application%20using%20Visual%20Studio%2C%20C%23%20and%20Xignite%27s%20XigniteCurrencies%20web%20service."

title="Digg"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/digg.png"

title="Digg" alt="Digg" class="sociable-hovers" />

href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F02%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F&title=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes"

title="StumbleUpon"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/stumbleupon.png"

title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers"

/>

href="http://technorati.com/faves?add=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F02%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F"

title="Technorati"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/technorati.png"

title="Technorati" alt="Technorati" class="sociable-hovers"

/>

href="http://twitter.com/home/?status=tip%20@Techmeme%20http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F02%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F%205%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes"

title="Suggest to Techmeme via Twitter"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/techmeme.png"

title="Suggest to Techmeme via Twitter" alt="Suggest to Techmeme

via Twitter" class="sociable-hovers" /> rel="nofollow" target="_blank"

href="http://delicious.com/post?url=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F02%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F&title=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes&notes=In%205%20minutes%2C%20build%20a%20real-time%20forex%20currency%20converter%20application%20using%20Visual%20Studio%2C%20C%23%20and%20Xignite%27s%20XigniteCurrencies%20web%20service."

title="del.icio.us"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/delicious.png"

title="del.icio.us" alt="del.icio.us" class="sociable-hovers"

/>

href="http://www.google.com/bookmarks/mark?op=edit&bkmk=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F02%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F&title=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes&annotation=In%205%20minutes%2C%20build%20a%20real-time%20forex%20currency%20converter%20application%20using%20Visual%20Studio%2C%20C%23%20and%20Xignite%27s%20XigniteCurrencies%20web%20service."

title="Google Bookmarks"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/googlebookmark.png"

title="Google Bookmarks" alt="Google Bookmarks"

class="sociable-hovers" />

target="_blank"

href="https://favorites.live.com/quickadd.aspx?marklet=1&url=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F02%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F&title=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes"

title="Live"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/live.png"

title="Live" alt="Live" class="sociable-hovers" />

href="http://www.friendfeed.com/share?title=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes&link=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F02%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F"

title="FriendFeed"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/friendfeed.png"

title="FriendFeed" alt="FriendFeed" class="sociable-hovers"

/>

  • Copyright © Automated Trader Ltd 2013 - The Gateway to Algorithmic and Automated Trading

click here to return to the top of the page