Tech Skills Crash Course

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 63

TECHNICAL SKILLS

CRASH COURSE
October 5, 2011
October 5, 2011
Jonah Hu, AFSA Finance Focus
Presenter Background
Thank you
Terrance
Kwok!
Presenter Background
Jonah Hu
Managing Director, hEDGE Finance Conference
Managing Director, AFSA Finance Focus

Electronic Trading Services at CIBC World Markets
Coverage of Direct Market Access, Algorithmic Trading,
High Frequency Trading in (mainly) equities & options.
VBA, Microsoft SQL, Oracle, Access, Excel, PowerPoint,
Word, Batch scripting, Bloomberg, IRESS, (X)HTML,
Java, C++, PHP

2010-2011 VP External, AFSA
A founder of AFSA Finance Focus
Agenda
1. Excel
2. Pivot Tables
3. VBA
4. Bloomberg
5. Databases (SQL / Access)
Goals of this workshop
To give a general idea of what can be accomplished with the
various technical tools that are commonly used in the world of
finance (and industry / accounting!)
Provide direction on where you need to learn more technically, so
you are most prepared for co-op work terms
See how different pieces of technology (VBA / Access / Excel / SQL
/ Bloomberg) integrate together
EXCEL
Please refer to ExcelExample.xlsm.
We are using an Excel 2010 environment, which is very similar
to Excel 2007, but materially different from Excel 2003.
Basic Excel Shortcuts
Shortcut What it does
CTRL/SHIFT+Arrows CTRL: Moves around the worksheet. SHIFT: Selects cells.
CTRL+SHIFT+Up/Down Selects up/down to the next instance of an empty cell
CTRL+ R/D Autofill right or down
CTRL+A Select all cells
CTRL+Home Moves to cell A1
CTRL+End Moves to the right-most bottom cell
ALT+F11 Launches Visual Basic Editor for VBA programming
CTRL+Page Up/Down Moves between sheets
CTRL+Tab Move between different open workbooks
Shift+F11 Insert new worksheet in current workbook
F2 Edit currently selected cell
CTRL/SHIFT+Space CTRL: selects current column; SHIFT: selects current row
See Wall St. Training Excel Shortcuts Package
Copy / Paste
Regular copy & paste in Excel will copy over formulas and
formatting.
Sometimes, this isnt the desired result.
Copy & paste as text
Copy & paste link
Copy & paste formatting
Copy & paste + mathematical
operation
Absolute / Relative References
Preceding the row and/or column designators with a dollar sign ($)
specifies an absolute reference in Excel.

=A1 Complete relative reference
=$A1 The column is absolute; the row is relative
=A$1 The column is relative; the row is absolute
=$A$1 Complete absolute reference

Demo
Filtering
Given a dataset, Excel has the ability to filter the data.








1. Select the header.
2. In the Data ribbon tab, click on the Filter button.
3. You can also freeze pane your data at the header so that the
header always displays.

Special Selections
Problem: You have rows of data but there are blank rows. How
do we easily get rid of these blank rows?

Special Selections
Solution: Select cell A1. Hit F5 to bring up the Go To window.
Click the Special button. This will allow you to make special
selections. Select Blanks and hit OK. Excel selects all blank
cells.

Demo: Graphing
Excel works on the concept of series, which allows each graph to
have one or more set of (Xn, Yn) points.
Demo: Graphing data on Canadian Interest Bearing Debt
See CDN. Debt Graphs worksheet in ExcelExample.xlsm
Demo: Named Ranges
Excel allows you to give names to certain ranges of cells. These
are called named ranges. Functionally, they dont do anything
new, but they add clarity to a user of the spreadsheet.
Access named ranges in Formulas > Name Manager
Demo

Demo: Conditional Formatting
Excel has a functionality called conditional formatting that allows it
to automatically format cells based on their content.
Demo
Basic Functions to Know
Mathematical: count, sum, average, max, min, sumproduct
Conditional: if, iferror, countif, sumif
Lookup: vlookup (and less used, hlookup)
Conversion: int
Time: now, today
String functions: left, right, mid, concatenate, replace, lower,
upper, proper, len

Will not cover in detail up to you to figure out what each of them do!


Tip: Working with Multiple Sheets / Excel Sessions
You will find it convenient to open multiple instances of Excel.
Each session of Excel can hold a number of open workbooks.
If you have a multi-monitor set up, to display Excel across two
screens, you need to have at least 2 sessions open.
Each session operates in separate memory space, so there is less
risk of messing up by keeping workbooks open in separate
instances.
PIVOT TABLES
Please refer to ExcelExample.xlsm.
We are using an Excel 2010 environment, which is very similar
to Excel 2007, but materially different from Excel 2003.
What are Pivot Tables?
Powerful tool to summarize large amounts of data. Data crunching.
Makes summary tables.
Example 1: you have thousands of rows of trade data, and want to
know the total shares of RIMM traded by each client.
Example 2: you have raw GDP data for multiple years, in multiple
countries. you want a yearly average GDP by region.
Demo: Analyzing some Bloomberg Market Data for the 500 largest
companies.

Demo: Pivot Data
Ticker
Short
Name
Last
Px
Market
Cap
52Wk High
Chg Pct
Dvd Est
Yld Ind Sector
AAPL US Equity APPLE INC 379.02 3.53518E+11 -9.8236 0 Technology
XOM US Equity EXXON MOBIL CORP 72.358 3.53135E+11 -17.681101 2.556 Energy
857 HK Equity PETROCHINA CO-H 9.43 2.76239E+11 -22.639999 4.666 Energy
IBM US Equity IBM 176.2 2.08843E+11 -5.7965 1.572 Technology
MSFT US Equity MICROSOFT CORP 24.93 2.08535E+11 -15.5126 2.677 Technology
601398 CH Equity IND & COMM BK-A 3.98 2.03803E+11 -19.159401 5.339 Financial
941 HK Equity CHINA MOBILE 75.2 1.93817E+11 -7.9952 4.255 Communications
RDSA LN Equity ROYAL DUTCH SH-A 1966 1.91589E+11 -14.7303 5.438 Energy
CVX US Equity CHEVRON CORP 91.183 1.85456E+11 -15.7813 3.369 Energy
NESN VX Equity NESTLE SA-REG 50.15 1.80211E+11 -11.9508 3.881 Consumer, Non-cyclical
WMT US Equity WAL-MART STORES 52.344 1.7888E+11 -10.3588 2.814 Consumer, Cyclical
BRK/A US Equity BERKSHIRE HATH-A 107137 1.76186E+11 -18.760401 0 Financial
JNJ US Equity JOHNSON&JOHNSON 63.1 1.74533E+11 -6.4071 3.585 Consumer, Non-cyclical
PG US Equity PROCTER & GAMBLE 63.13 1.73604E+11 -6.7041 3.316 Consumer, Non-cyclical
T US Equity AT&T INC 28.508 1.69009E+11 -10.7076 6.049 Communications
GOOG US Equity GOOGLE INC-CL A 502.91 1.66075E+11 -19.8955 0 Communications
GE US Equity GENERAL ELECTRIC 14.9 1.61337E+11 -29.6998 3.839 Industrial
BHP AU Equity BHP BILLITON LTD 34.15 1.61079E+11 -29.692801 3.314 Basic Materials
BLT LN Equity BHP BILLITON PLC 1710 1.6104E+11 -34.501598 4.035 Basic Materials
KO US Equity COCA-COLA CO/THE 66.03 1.55124E+11 -5.866 2.766 Consumer, Non-cyclical
NOVN VX Equity NOVARTIS AG-REG 50.85 1.51413E+11 -12.9392 4.518 Consumer, Non-cyclical
Demo: Pivot Data
How can we produce a summary that looks like this?












Pivot table on the previous data. Demo.


Basic Materials
8%
Communications
12%
Consumer,
Cyclical
8%
Consumer, Non-
cyclical
18%
Diversified
1%
Energy
15%
Financial
20%
Industrial
6%
Technology
8%
Utilities
4%
% Weight by Market Cap
VBA
Please refer to VBAExample.xlsm.
We are using an Excel 2010 environment, which is very similar
to Excel 2007, but materially different from Excel 2003.
What is VBA?
A language that allows you to programmatically interact with Excel,
and other applications.
Used most commonly to:
Automate repetitive tasks
Create dynamic spreadsheets with buttons, drop downs, etc.
Query & pull data from complex data sources (such as Oracle, SQL,
etc.) into Excel
Able to interact with other application. For example, VBA is able to
automatically print to PDF given a PDF printer / Adobe Acrobat. Or, VBA
is also able to create spreadsheet reports on the fly and then mail that
automatically as an email attachment in Outlook.
Extremely powerful, versatile and useful
But, can be slow especially dealing with large amounts of data.
Basically: powerful programming language to automate tasks in the
MS Office suite, especially Excel and Access.

VBA What Can It Do?
Example 1: you want to add some buttons into your spreadsheet
that will allow the user to click and go to a different place in the
spreadsheet.
Example 2: you have a report that needs to be customized for
different clients using different sources of data. The report is in a
spreadsheet and needs to be saved to PDF and emailed. VBA can
automate this entire process.
Example 3: you have thousands of rows of data, and need an
algorithm to go through the rows and keep only certain ones.
Example 4: you need to pull complex data sources (maybe a book
of accounts in an Oracle Database, or a list of equity trades in a
SQL Database). You can use VBAs ActiveX Data Objects model
and a Recordset to pull in data.


Launching Visual Basic
Ensure you have the Developer tab visible. If not, you need to go
into Excel Options to enable it.
Visual Basic Editor
Alt + F11 to open the VBE.
Visual Basic Editor
Properties Window
Project Explorer
Visual Basic Editor
Immediate Window
Put your code here!
Recording & Using Macros
Excel allows you to record a macro (VBA code) of your actions in Excel.
This is often the place to start writing your VBA code, but a lot of actions cannot
be accomplished with only the Macro Recorder.

In the Developer ribbon, click Record Macro
Demo: Recording & Using Macros
Record a macro that will turn Column A green. Then create a button to activate
that macro.
Programming Concepts Declaring Variables
Option Explicit
- Forces declaration of all variables
- Use Dim to begin variable declarato

Dim A, B, C As Integer
Dim D, E, F As Double
Dim J, K, L As Long
Dim M As Range
Dim Arr(1) As Integer
Dim Arr(1 to 10) As Integer
Dim myVar(1) As Variant
Programming Concepts Subs and Functions
Subroutines no return value
Sub AddToCells(i As
Integer)
Code Here
End Sub

Calling:
Call AddToCells(1)
Functions returns something
Function SumMinus (dNum1
As Double, dNum2 As
Double, dNum3 As Double)
As Double
SumMinus = dNum1 +
dNum2 - dNum3
End Function

Calling:
Dim i as Double
i = SumMinus(1.00, 2.00,
3.00)
Programming Concepts Control Structures
If-Elseif-Else
If (n = AFM101) Then
MsgBox(Financial Acct.)
Elseif (n = AFM102) Then
MsgBox(Manag. Acct.)
Elseif (n = AFM271) Then
MsgBox(Finance)
Else
MsgBox(Other AFM)
End If


Switch
n is a string
Select Case n
Case AFM101"
MsgBox(Financial Acct.)
Case AFM102
MsgBox(Manag. Acct.)
Case AFM271
MsgBox(Finance)
Case Else
MsgBox(Other AFM)
End Select
Programming Concepts Looping
For loop
For i = 1 to 10
MsgBox(i)
Next
While loop
Dim i as Integer
i = 1
Do While (i <= 10)
MsgBox(i)
i = i + 1
Loop
Programming Concepts Referring to the Spreadsheet
Workbooks(MySpreadsheet.xlsx).Sheets(Sheet1
). Range("A1:B5")

Worksheets("Sheet1").[A1:B5]

Dim myCell, myCell2 as Range
myCell = ActiveSheet.Range(A1)
myCell2 = myCell.Offset(0, 1) Refers to A2

Range("MyBook.xls!MyRange")

Worksheets("Sheet1").Cells.ClearContents
VBA Code Execution
To execute code, go into the VBE, select the desired function and
hit F5 to execute all or F8 to execute line-by-line.
Use the Immediate Window to debug
Demo
Buttons and Other Objects
Buttons can be added into the spreadsheet, triggering specific VBA
macro actions.
This will be part of the
demo later.
Demo: Spreadsheet Iteration
Idea: List of numbers: 1, 2, 3, , 1400
We want to highlight all numbers that are multiples of 4
We want to highlight numbers in row A that also exist in row H
Demo Code execution
Demo: CAPM Calculator
Idea: A simple calculator for the CAPM model.
More Resources for Learning VBA
For more intro Excel VBA tutorials, check out VBA tutorial materials
from the Double Degree Club:
http://www.ddclub.uwaterloo.ca/excel_tutorials.php
Their intermediate package has around 10 solid intro VBA practice
tutorials.
If you want a good resource for learning VBA, take a look at
ProgrammingInExcelVBA_AnIntroduction.pdf.
Weve laid the framework, but for you to become a master of VBA,
practice makes perfect!
BLOOMBERG
We wont go into too much detail there is a
separate Bloomberg training session next week!

Refer to BloombergManual.pdf
What is Bloomberg for?
Live market data across multiple asset classes
Equities, bonds, mortgages, foreign exchange, commodities, derivatives
Financial data
Historical income statements, balance sheets
Projected earnings
Trading platform
Access to research and news

Introduction to Bloomberg
GREEN keys are action keys. Hitting them will activate a
command.
YELLOW keys are market sector keys. For now, youll probably
be using EQUITY a lot.
RED is for logging / out / exiting.
Equity Functions
First, enter the company you want to look up by typing into the top
black input bar in the following format: AAPL US <EQUITY><GO>

MA<GO> displays current and historical M&A details for public and
private transactions.
ECDR<GO> monitors IPOs and SEOs
ECO<GO> displays an economic calendar by region/country/event
BBEA<GO> displays earnings analysis related news
EE<GO> displays earnings estimates from analysts
EQS<GO> is the equity screening tool to help you find securities
based on specified parameters
RVP<GO> performs a customized peer group analysis to
benchmark the companys financial performance against industry


Equity Functions
GUID<GO> displays a companys corporate financial guidance
FA<GO> to display financial analysis tools (financial statements,
etc.)
DVD<GO> displays dividend information
GPO<GO> displays a stock price chart
GPI<GO> displays an intraday graph.

Also:
Market monitors
Options monitor, OMON<GO>
News
Grab tool
Help Desk through <HELP><HELP> (press it twice)
Excel Plugin
In the lab, install the plugin by going into Start > All Programs >
Bloomberg > Install Excel Add-In.
There should now be an Bloomberg tab in Excels ribbon.
You can use wizards (click Import Data) to pull in Bloomberg data.
You can also use the BDP and BDH functions to do this manually.


Bloombergs BDP Excel Function
BDP (Bloomberg Data Point) returns data to a single cell in your
Excel spreadsheet. This formula contains only one ticker and only
one field. BDP formula syntax: =BDP(Security,Field).
For example: =BDP(IBM US Equity,Px_Last) retrieves the price
of the last trade on IBM
Look up field names (i.e. Px_Last) in FLDS<GO>


Bloombergs BDH Excel Function
BDH (Bloomberg Data History) returns the historical data for a
selected security. BDH formula syntax: =BDP(Security,Field,Start
Date,End Date).
For example: =BDH (IBM US
Equity,Px_Last,01/01/01,12/31/01) retrieves the closing
prices on IBM from 01/01/01 to 12/31/01
Look up field names in FLDS<GO>

See BloombergManual.pdf for a much more detailed description of
how the Excel plugin works.



Looking for More?
Come to AFSAs Bloomberg Terminal Training Session.

Date: Tuesday, October 11, 2011
Time: 6:00 PM to 8:00 PM
Location: Hagey Hall 280

www.uwafsa.ca for details and to register.
DATABASES
SQL and Access
We are only going to cover pulling data from a
database (no inserts / updates / creation)
What are Databases? / Types of Databases
Organize large volumes of data.

Oracle
Access
SQL

Tables
Columns
Rows
Keys

Queries

Database Design 101
ID Timestamp Ticker Side Price Volume Client
1 91423 RIM BUY 23.00 100 CPPIB
2 93000 ABX SELL 60.02 150 HSBC
3 121430 BMO BUY 59.88 200 OTPP
4 142857 K SELL 29.71 2000 TDAM
5 153829 U SELLSHORT 40.12 1500 MANU
6 160123 LUN BUY 95.90 50 OMERS
7 161002 SLF BUY 37.82 100000 GLDCRP
ID Name Type City Contact
1 CPPIB PENSION TORONTO John
2 HSBC BROKER_DEALER HONG KONG Betty
3 OTPP PENSION TORONTO Amanda
4 TDAM ASSET_MANAGER MONTREAL Craig
5 MANU INSURANCE VANCOUVER Chris
6 OMERS PRIVATE_EQUITY TORONTO Matthew
7 GLDCRP CORPORATION CALGARY Jessica
T
R
A
D
E
S

C
L
I
E
N
T
S

SQL Query: Basic Syntax
SELECT * FROM TRADES
ID Timestamp Ticker Side Price Volume Client
1 91423 RIM BUY 23.00 100 CPPIB
2 93000 ABX SELL 60.02 150 HSBC
3 121430 BMO BUY 59.88 200 OTPP
4 142857 K SELL 29.71 2000 TDAM
5 153829 U SELLSHORT 40.12 1500 MANU
6 160123 LUN BUY 95.90 50 OMERS
7 161002 SLF BUY 37.82 100000 GLDCRP
T
R
A
D
E
S

SQL Query: Basic Syntax
SELECT TICKER, SIDE FROM TRADES
Ticker Side
RIM BUY
ABX SELL
BMO BUY
K SELL
U SELLSHORT
LUN BUY
SLF BUY
T
R
A
D
E
S

SQL Query: Aliasing and Concatenation
SELECT CONCAT(TIMESTAMP, TICKER) AS TIMETICK FROM
TRADES
TIMETICK
91423RIM
93000ABX
121430BMO
142857K
153829U
160123LUN
161002SLF
T
R
A
D
E
S

SQL Query: Where, In, Between, Logical Operators
SELECT * FROM TRADES WHERE (TIMESTAMP = 93000) OR
(SYMBOL IN(LUN,SLF)) OR (TIMESTAMP BETWEEN 140000
and 150000)
ID Timestamp Ticker Side Price Volume Client
2 93000 ABX SELL 60.02 150 HSBC
3 121430 BMO BUY 59.88 200 OTPP
4 142857 K SELL 29.71 2000 TDAM
5 153829 U SELLSHORT 40.12 1500 MANU
6 160123 LUN BUY 95.90 50 OMERS
7 161002 SLF BUY 37.82 100000 GLDCRP
T
R
A
D
E
S

SQL Query: Unique, Ordering
SELECT UNIQUE SIDE
FROM TRADES
ORDER BY SIDE ASC

Side
BUY
SELL
SELLSHORT
T
R
A
D
E
S

SELECT UNIQUE SIDE
FROM TRADES
ORDER BY SIDE DESC

Side
SELLSHORT
SELL
BUY
T
R
A
D
E
S

SQL Query: Summing and Grouping
SELECT SIDE, SUM(VOLUME) FROM TRADES
ORDER BY SIDE ASC
Side SUM(Volume)
BUY 100250
SELL 2150
SELLSHORT 1500
T
R
A
D
E
S

Our Tables
ID Timestamp Ticker Side Price Volume Client
1 91423 RIM BUY 23.00 100 CPPIB
2 93000 ABX SELL 60.02 150 HSBC
3 121430 BMO BUY 59.88 200 OTPP
4 142857 K SELL 29.71 2000 TDAM
5 153829 U SELLSHORT 40.12 1500 MANU
6 160123 LUN BUY 95.90 50 OMERS
7 161002 SLF BUY 37.82 100000 GLDCRP
ID Name Type City Contact
1 CPPIB PENSION TORONTO John
2 HSBC BROKER_DEALER HONG KONG Betty
3 OTPP PENSION TORONTO Amanda
4 TDAM ASSET_MANAGER MONTREAL Craig
5 MANU INSURANCE VANCOUVER Chris
6 OMERS PRIVATE_EQUITY TORONTO Matthew
7 GLDCRP CORPORATION CALGARY Jessica
T
R
A
D
E
S

C
L
I
E
N
T
S

Advanced SQL Queries: Table Joins
SELECT TRADES.TIMESTAMP, TRADES.TICKER, TRADES.SIDE,
TRADES.VOLUME, TRADES.CLIENT, CLIENTS.CONTACT
FROM TRADES JOIN CLIENTS ON TRADES.CLIENT =
CLIENTS.NAME
WHERE CLIENTS.TYPE = PENSION

Timestamp Ticker Side Volume Client Contact
91423 RIM BUY 100 CPPIB John
121430 BMO BUY 200 OTPP Amanda
T
R
A
D
E
S

J
O
I
N

C
L
I
E
N
T
S

Example: Connecting into Excel
You can connect a data source into Excel using the Data
Connections tool.
Data > Connections
After setting up, click Existing Connections, select the connection
and click OK. It will populate into the spreadsheet at the specified
cell.


Using MS Access Database
Were going to build the previous database in MS Access and run
some queries off of it.
Demo

You might also like