Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Using Financial Market Data APIs in Microsoft Excel
1. USING FINANCIAL
MARKET DATA APIS IN EXCEL
Stephane Dubois
CEO & Founder, xignite
sdubois@xignite.com
@sdubois
2. AGENDA
• Excel and APIs: A Little History
• From Basic to Cool: Options for
Pulling Data Into Excel
• Opening a CSV or XML API URL
• Using Data From Web
• Using WebService()
Open a
CSV or XML
API URL
Use Data
From Web
Use
WebService()
Audience
If you have no clue on how to
pull data from APIs via Excel,
this presentation is for your.
But even if you are an
advanced user, you may learn
a thing or two.
3. • With 1 billion copies sold, Excel is
arguably the most successful business
tool in history.
• More of our economy runs on Excel
than we would dare to admit.
• Yes it’s not cloud. And yes it’s not
shared. But it’s quite flexible.
• It used to be based on 100% manual
data entry but with API support, it is
no longer the case.
• Excel added APIs in three steps:
• XML support started with 2003
• Data From Web was added in 2007
• WebService() was added in 2013
EXCEL AND APIS: A LITTLE HISTORY
1985
Excel 1.0
First Spreadsheet
with a GUI
1987
Excel 2.0
First Windows version
1990
Excel 3.0
Added Toolbar,
Drawing, Charts…
1992
Excel 4.0
Better Mouse, Filling
and Shortcuts
1993
Excel 5.0
Multi-Sheet
Workbooks, VBA
1995
Excel 95
32 Bit. Faster and
more Stable.
1997
Excel 97
Assistant, Validations
and New VBA
1999
Excel 2000
Improved Clipboard
and Self-Repair
2001
Excel 10.0
Formula Auditing,
Crash Recovery
2003
Excel 2003
XML and List Ranges
2007
Excel 2007
Ribbon Menu and xlsx
2010
Excel 2010
Conditional format,
Sparklines, etc.
2013
Excel 2013
PowerView, Flashfill
and more
Added XML Support
Added Data From Web
Added WebService()
4. OPEN A CSV FILE
• This is the most basic way to get data in Excel.
• This is akin to opening a regular CSV file.
• It’s kinda lame really.
• Excel opens CSV files natively.
• Most APIs support a CSV output*.
• All you need to do is open the URL in Excel and
your are done.
• This works best for APIs that are time series like
historical data or large files like master data sets.
* If they don’t, well it probably means they suck.
Did You Know?
Comma-Separated
Values is a data
format that pre-dates
personal computers by
more than a decade:
the IBM Fortran
compiler under
OS/360 supported
them in 1967.
List-directed ("free
form") input/output
was defined in
FORTRAN 77 (the 77
means 1977).
List-directed input
used commas and/or
spaces for delimiters,
so unquoted character
strings could not
contain commas or
spaces.
Wikipedia
5. • Let’s use Xignite’s Global Historical
Equity service as an example.
https://www.xignite.com/product/
XigniteGlobalHistorical/api/
GetGlobalHistoricalQuotesRange/
• And let’s pull a year of adjusted stock
prices for GOOG by entering the right
criteria.
• Then click the CSV tab option
• Check Download File
• And click on the colorful URL
• Your browser will download the file for
you automatically.
OPEN A CSV API URL WITH XIGNITE APIS
6. • You then click on the download link to
open the file.
• You can delete the columns of data you
don’t want and otherwise manipulate
the data as you wish.
• But there are a lot of things you cannot
do with this approach:
• You can’t refresh the data automatically
• You can’t mix data from one API with
data from another API.
• You can’t format the data set and then
update it.
• In short, this is pretty lame.
OPEN A CSV API URL WITH XIGNITE APIS
7. OPEN AN XML API URL
• You can kick things up a notch by pulling the data in XML.
• There are two great advantages of doing so:
This means you get
built-in formatting,
filtering and
sorting.
The data
comes up as
an Excel
Table.
You can refresh it
automatically from
within Excel and if
the source data
changed, so will
yours.
The data is
automagically
bound to the
API.
8. • Let’s see how we can do this with an
Xignite API.
• This time we will use an API that updates
continuously, intraday bar data which
you can find here:
http://www.xignite.com/product/
global-stock-quote-data/api/GetBars/
• We will pull and update intra-day bars as
they become available.
• Start by copying the URL of the call*.
OPEN AN XML API URL WITH XIGNITE APIS
* You also need to append your authentication token to the URL in the form of &_token=<yourtoken>.
9. • Then you can use that API URL and call it
from Excel:
• To open the API from Excel you need to:
• Click the File Open menu options.
• Click Other Web Locations and Browse.
• Paste the fully qualified REST URL of your
API call in the File Name field.
• Click Open.
• Before opening the file, Excel will throw
this little pop-up box at you.
• Choose As an XML table
(which is the default)
• Click OK.
OPEN AN XML API URL WITH XIGNITE APIS
10. • What you get here is quite a bit more
interesting than the CSV file.
• The data comes up as a Table.
• This means you get built-in formatting,
filtering and sorting and all kinds of
other goodies.
• You can also easily delete the columns
you don’t want and rename those you
want to keep.
• But the best part is that the data is
automatically bound to the API.
• You can refresh it automatically.
• Just right click on a cell on the table
and chose XML and Refresh XML Data.
• You can even drag and drop the
columns you want using XML Source.
OPEN AN XML API URL WITH XIGNITE APIS
11. • Warning: Code Alert! If coding gives
you jitters, skip to the next page!
• If you are not afraid of a little VBA*, 3
lines of code will suffice to let you
dynamically change the parameters of
your API and refresh the data:
• Simply create input fields on your
worksheet and use them to re-build the
URL of your API. For instance, here we
are just changing the Symbol.
• Add those 2 lines of code** to link your
table to the new URL and refresh it.
• So now you can pick any symbol, click
the button and pull the data for that
symbol.
OPEN AN XML API URL WITH XIGNITE APIS
* Here we assume you know what VBA is, how to pop the developer tab, insert a button, and edit a macro.
** Note that you get the name of your table by right-clicking the table and clicking XML and XML Map Properties
12. • So using XML is quite cool. But there are
limitations. Merely that since you are opening
a single URL, you can only integrate data
from one source.
• What if you wanted to mix and match things
on a worksheet?
• This is where Data From Web comes in.
• Data From Web works just like opening an
XML API but you can do it as many times as
you want in a spreadsheet.
• First Click From Web on the Data menu.
• Enter the complete URL of your API request
(with authentication) in the Address field.
• Click Import.
USING DATA FROM WEB
13. • By doing Data From Web multiple
times, deleting the columns you do not
want, and formatting the results, you
can create some cool spreadsheets.
• For example the worksheet on the right
pulls data from our News, Economic
Calendar, Earnings Calendar and IPO
Calendar APIs and combines them in a
single page.
• It took about 10 minutes to build it. And
it updates dynamically.
• To learn more about our available APIs,
check here:
https://www.xignite.com/Products/
USING DATA FROM WEB WITH XIGNITE
14. • So now let’s take it home.
• Most people don’t know that Excel has a
WebService() function*.
• It’s quite a powerful little tool.
• It simply pulls the results of an API call in
a cell.
• It takes the URL of the REST call as its
only input parameter.
• It throws the whole result in the cell so if
the output is XML or JSON, it’s actually
not so cool:
• This is an XML call result.
• This is a JSON call result.
• Not much you can do with that!
• So you need to get smart using it.
USING WEBSERVICE()
15. • One way you can get smart using WebService() is by
using it with another powerful function: FilterXML()
• FilterXML() lets you call an XML API returning many
different fields, filter the field you want and throw
it into a cell.
• In this case we will call our real-time Forex API
which you can find here:
https://www.xignite.com/forex
• The API returns many fields like Bid, Mid and Ask.
• Here, we can pull the EURUSD Mid quote only by:
• Calling WebService() and passing the URL of the API
• Filtering the result by adding “//Bid” as a filter.
• The result is simply thrown into a cell.
• And it recalculates as the workbook recalculates*!
USING WEBSERVICE() WITH XIGNITE APIS
* Use CTRL-ALT-F9 to refresh the workbook
16. • But Xignite APIs make things even simpler!
• You can call any of our APIs using the WebService() function directly.
• All you need to do is pass the proper API URL and you can return a single value in a single cell.
• We call this XigniteOne: One Function, One Cell, One Parameter, One Value.
• Here is an example of such an API call. It works the same for all our APIs:
USING WEBSERVICE() WITH XIGNITE APIS
http://globalquotes.xignite.com/xGlobalQuotes.csv/GetGlobalDelayedQuote?
IdentifierType=Symbol&Identifier=AAPL&_token=mytoken
&_fields=Last&_noheader=y&_notrailer=y
Use a CSV
Extension
The one field you want
to get in your cell.
These two system
parameters.
Using this URL with
WebService()
simply fills out the
cell with value!
17. • That’s it! Now you can see that
WebService() and Data From Web are
incredibly powerful tools that let you
truly combine the advantages of cloud
APIs with the power of Excel.
• Let’s see a couple example of what can
be done using those features.
• First, look at the screens on the right.
The top is Yahoo!Finance. The bottom
is Excel on Xignite APIs. Both update
real-time. Can you tell the difference?
USING WEBSERVICE() WITH XIGNITE APIS
18. • As a final example, the sheet
on the right updates and
recolors in real-time as
exchange rates for more than
100 countries fluctuate in
comparison to the US dollar.
• It uses and integrates 6 types
of API calls. And it’s all done
in Excel using what we
showed you and very limited
VBA code.
• Using APIs inside Excel opens
up a world of possibilities. So
sharpen your Excel skills and
get started!
PUTTING IT ALL TOGETHER
USDGBP
480.1839
482.9154 USDEUR
Gold USDJPY
1286.5
1288
USDCAD USDHKD
Silver
19.44
19.54
Platinum USDBRL
1416.7
1426.7
Palladium
903.9
909.9
Currency Converter
Currency Pair Price Change Percent Change One Month Ago One Year Ago Chart
481.09
136.97
Majors European Crosses Yen Crosses Asia Pacific
2.2439
1.08738
0.76170
5.45%
0.60213
Start
0.051%
-0.424%
0.532%
1287.25
19.49
1421.7
906.90
0.1814
(0.0089)
0.0428
113.4403
87.43
97.4
83.487
9.772143
0.3529
0.3200
0.2178%
-0.0914%
0.3191%
-0.0245%
-0.1385%
0.1011%
0.4053%
0.3296%
13.46061
95.965
(0.0335)
(0.1573)
0.0969
-0.358%
USDAUD
138.01
104.350
1.0713
7.75017
Emerging Markets Skandi Metals
6.14480
Update All
9.606932
13.23725
USDCNY
129.726
105.6731
93.14012
75.80792
87.38354
77.02358
9.596737
12.65747
113.8148
93.98562
87.30718
95.53695
82.26947SGDJPY
AUDJPY
ZARJPY
HKDJPY
Update
EURJPY
CHFJPY
CADJPY
NZDJPY
1.63
1.64
1.65
1.66
1.67
1.68
1.69
1.7
1.71
07/27/2014 08/04/2014 08/12/2014 08/20/2014
GBPUSD
19. For additional information click on the links below.
APIS Used in this Presentation
https://www.xignite.com/Products/ FULL CATALOG
https://www.xignite.com/product/XigniteGlobalHistorical/ GLOBAL HISTORICAL EQUITY QUOTES API
https://www.xignite.com/product/global-stock-quote-data/ GLOBAL DELAYED EQUITY QUOTES API
https://www.xignite.com/product/forex/ REALTIME FOREX QUOTES API
https://www.xignite.com/product/gold-metal/ REALTIME PRECIOUS METAL PRICING API
https://www.xignite.com/product/company-financial-news/ GLOBAL NEWS API
https://www.xignite.com/product/XigniteCalendar/ GLOBAL ECONOMIC CALENDAR API
https://www.xignite.com/product/XigniteEarningsCalendar/ US EARNINGS CALENDAR API
https://www.xignite.com/product/us-stock-IPO-calendar/ US IPOs API
THANK YOU
Questions? Contact Me.
Stephane Dubois
CEO & Founder, xignite
sdubois@xignite.com
@sdubois