5 Minute Developer: How to Build a Real-Time Precious Metal Quote Application in 5 Minutes

from Xand : ChasCooper - 31st December 1969

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.

It takes 5 minutes to beat cream into butter, write half of your name in Elvish, or create a homemade tattoo gun. Or if you want to get really wild, you could spend your next 5 minutes creating a Windows application to get real-time precious metal quotes. If that's a little too wild for you, you could also live vicariously through us by watching a video of us doing it. But if you're ready to throw caution to the wind and give it a try for yourself, here's how:

Step 1: Start a new Windows application project in Visual Studio using VB.NET as the language. (You can use any language, but this example just happens to use VB.NET.)

Step 2: Create a web reference to http://www.xignite.com/xMetals.asmx?WSDL and call it XigniteMetals.

Step 3: On the Form1 design, drag and drop 2 text boxes, 3 labels, and a button, arranging them as shown in the picture. Give the left-most text box a name of tbMetal and default text of XAU. Give the right-most text box a name of tbCurrency and a default text of USD. From left to right, the labels should be given the following names and default text values: lIntro defaults to "Right now ", lCosts defaults to " costs ", PriceLabel defaults to "0.00." The button should have a default text value of "Get Quote."

Step 4: Double-click the button to create its click event handler. Then add the following lines of code inside the event handler:

Dim xHeader As New XigniteMetals.Header()

xHeader.Username = "MYAUTHENTICATIONKEY"

Dim XigniteMetalsWebService As New XigniteMetals.XigniteMetals()

XigniteMetalsWebService.HeaderValue = xHeader

Dim Quote As XigniteMetals.MetalQuote = _

XigniteMetalsWebService.GetRealTimeMetalQuote(_

DirectCast([Enum].Parse(GetType(XigniteMetals.MetalTypes), tbMetal.Text), XigniteMetals.MetalTypes), _

DirectCast([Enum].Parse(GetType(XigniteMetals.MetalCurrencyTypes), tbCurrency.Text), XigniteMetals.MetalCurrencyTypes))

PriceLabel.Text = Quote.Rate.ToString("#,###.00″)

Step 5: Replace "MYAUTHENTICATIONKEY" in the second line of code with your Xignite authentication key. Don't have one? Just sign up for a free trial and use your e-mail address as your initial authentication key.

Step 6: Compile and run.

Congratulations! You might make a lousy tattooed elf chef, but you'll be the life of the party with precious metal traders.

Share and Enjoy: email Twitter Facebook LinkedIn Digg StumbleUpon Technorati Suggest to Techmeme via Twitter del.icio.us Google Bookmarks Live FriendFeed

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

click here to return to the top of the page