Saturday, August 30, 2014

Suggested Reads

I don't get to read as often as I'd like, but I do make time every now and then for a good finance-related book. Here is a list of books I've read, and I'll update it periodically to reflect any new works I've completed. I'd recommend every book on this list, so no need to worry about if I liked it or if I didn't. If I ever feel super strongly one way or the other about a book I may write a post discussing my thoughts on it.

Behavioral Finance

  • Irrational Exuberance
  • Beyond Greed and Fear
  • Ethics in Finance

Economics

  • Freakonomics
  • The Return of Depression Economics
  • The Housing Boom & Bust

Investing

  • The Only Three Questions That Count
  • A Random Walk Down Wall Street

Quantitative Finance

  • Mark Joshi's On Becoming a Quant (not a book, but definitely a suggested read)

Currently on the shelf (next in line)

  • Predictably Irrational
  • Reminiscences of a Stock Operator
  • Superfreakonomics
  • Liar's Poker
  • My Life As A Quant

Sunday, August 24, 2014

Getting started in R

Many of my posts related to programming will include discussion on the R statistical programming language. I thought I would put out a short-and-sweet guide to getting started in R from a mathematical finance perspective. This guide will get you off the bench and into the game! ...meaning I'll help you get things set up properly for you to begin some analysis.

Installation

First thing you need to do is to install R from here. Those download servers will always have the latest version available for your operating system. *Speaking of which, I primarily run Windows unless I'm doing HPC on the supercomputer, so this guide will be heavily Windows-biased. 

That will install the R language, core packages and libraries, and a simple GUI interface to use. I've found that RStudio is a much better GUI, so the next step will be to immediately install the RStudio IDE from here.

Packages

The beauty of R is that there are thousands of packages that can be easily installed. These packages are created by other R users to add functionality that the base install of R doesn't have or to make it simpler to perform certain tasks. There are a number of core packages that are installed with the R language. Huge numbers of packages have been created to that will be useful for this type of analysis.

To install a new package, open up RStudio and look towards the bottom right of the window. You'll see a window with tabs along the top (as shown in the screenshot below). As the red arrow indicates, click on the tab titled Packages. Then, as the green arrow shows, click the button labeled Install.


A window will pop up that lets you install packages from the online repositories or from a downloaded zip file (see below).


Leave everything at the default setting unless you have some reason to change it. List packages separated by commas as it says. The box even autocompletes sometimes, which is a nice feature for when you don't know the exact name of the package.

Here I'll break down the packages that I'd recommend if you were going to start doing some mathematical and/or statistical analysis on financial data.

Finance

quantmod is a great package that can download data straight from Yahoo Finance, Google Finance, and a few other sources. [See my post on freely available data sources.] Quantmod also contains a number of cool functions for analysis of times series.

RQuantLib is the R counterpart to the QuantLib project. The QuantLib project is trying to bring a steady library of useful quant functions to popular programming languages like C++.

tseries is a package with lots of functions for creating and dealing with time series.

TTR is a package that makes it possible to create trading rules as functions.

forecast adds the ability to forecast time series using a variety of methods.

To install these packages, copy and paste this line in the Packages text box in the window shown in the screenshot above: quantmod, RQuantLib, tseries, TTR, forecast

There are many other packages available under the finance heading at http://www.rdocumentation.org/domains/Finance.

Bayesian Methods

LearnBayes is a package I've found to contain some helpful Bayesian functions.

MCMCpack will be very useful to empirical Bayesians.

bnlearn implements Bayesian networks.

To install these packages, copy and paste this line in the Packages text box in the window shown in the screenshot above: LearnBayes, MCMCpack, bnlearn

LaplacesDemon is a package full of Bayesian methods. It has been really useful in some of my recent work. This package is not available on CRAN (the online repository), so you will have to download the file from the website and install it separately. To do that, just change the dropdown from Repository to Package Archive File and navigate to where you downloaded the package.

As always, there are many more packages available on http://www.rdocumentation.org/domains/Bayesian, especially for users familiar with BUGS.

High-Performance Computing

foreach is a package that adds the common foreach method from many other programming languages into R, except it can handle parallel processing.

Rcpp integrates the R language with C++, so that C++ programs can call R functions and R programs can call C++ functions.

doParallel creates the clusters used in packages like foreach.

plyr brings many of the standard R functions into HPC territory by adding the ability to parallel process.

To install these packages, copy and paste this line in the Packages text box in the window shown in the screenshot above: foreach, Rcpp, doParallel, plyr

There are many other packages available under the finance heading at http://www.rdocumentation.org/domains/HighPerformanceComputing.

General


xtable creates tables that are LaTeX-ready. I've yet to use this one, but I'm pretty excited it exists.

shiny is the package that allows you to create awesome R web apps. See this for examples. This is another package I haven't yet had the opportunity to try out, but I can't wait to get to work with it.

To install these packages, copy and paste this line in the Packages text box in the window shown in the screenshot above: pso, xtable, shiny

Tutorials

Now you got it all installed and ready, the only *minor* thing left is how to use it. There are a number of books available, as well as many online tutorials. The built in help is really quite extensive, and that is usually what I consulted first. As with many other programming languages, looking at code is the best way to learn it, so that's what I did. Go online and find examples of what you are trying to do - there are bound to be some out there. Searching "r [package name] tutorial" should bring up many results for any of the packages I've given here because they are all widely used. Another great place to start is this StackExchange question on the very same topic. 

I'll make a post from time to time detailing how to perform some type of analysis in R. Also, I'll try to include somewhat detailed instructions if I'm discussing some analysis I did in R, even if it isn't a "How To" type of post.

That's it for this guide! You should be all set to begin learning R and performing some mega-awesome data analysis.


From Financial Analyst to Data Scientist

With the recent article on the Wall Street Journal about data scientists being rock star high-tech workers, I've seen many people questioning whether they should have went into Big Data rather than finance. I think the answer to this second-guessing is simple: do both. Having data analysis skills will get you just as far in finance as it will in tech. It could even be a back-up plan if finance doesn't work out.

The financial analyst position (or quantitative analyst, etc) is more and more becoming a data analyst position. It is up to the analyst to discern whatever can be learned from the data that is available and to make predictions and forecasts using those analyses. Financial analysts need to know how to use and interpret data.

Additionally, if finance doesn't pan out, the skills of data analysis are transferable to a large number of other industries - like tech, healthcare, and marketing, to name a few. Do some of these industries offer higher salaries than others? You bet. I'll remind you, though, that if you are picking one career path over another simply based on a small subset of highly paid individuals within that field..."you're gonna have a bad time."

you're gonna have a bad time.jpg


To sum it up, you're missing the point if you're asking this question. You should be a data scientist first and foremost. Where you choose to work, however, is up to you.

Friday, August 22, 2014

Freely Available Financial Data

Have you heard the phrase "Data is cheap"? Well, that may be true on average, but good sources are hard to find for free in finance. There are many paid options ranging from a few dollars per month to thousands of dollars per year. When you don't have the money to shell out to get a DataStream subscription or a Bloomberg Terminal, it can be frustrating finding the data that you need. I've compiled a list here of freely available sources of financial and economic data that I frequently use in my own work.

YAHOO FINANCE

Yahoo Finance is a great place to go for historical stock data. The best part, in my opinion, about Yahoo Finance is using the URL to download stock prices into a CSV file

GOOGLE FINANCE

Google Finance is very similar to Yahoo Finance in regard to what data is available. I think Google does a good job of letting you compare a company's chart against its competitors though. Potentially a little easier to use and more appealing, but I'm not really concerned with petty things like that when I'm hunting for data.

FRED

The Federal Reserve Bank of St. Louis maintains a huge database of economic data called FRED (Federal Reserve Economic Data). This is my first choice when looking for anything financial or economic related that is on a macro level. The FRED Excel Add-in makes it super easy to download data series as well.

QUANDL

Quandl is something I've just recently stumbled upon. Its website currently states that it has over 10 million free data series available for download. The interface is easy to use. There are also a number of packages to make it easy to connect with statistical languages like R and MATLAB.

FINRA

Looking for fixed income data has always frustrated me. FINRA is one place that has bond data available. Unfortunately, there is no super simple way to get the trade history for a bond because they don't provide download links. This can be useful when examining corporate bonds.

FINVIZ

If I'm just looking at price charts, FINVIZ is my first choice. It has a great stock screener allowing you to screen by many different things including fundamentals, technicals, patterns, and trends.

These are my favorite free data sources, but of course there are many more out there. I consider these to be reliable sources, both in terms of availability and legitimacy. For many common projects, these sources should be enough to satisfy your needs.


Tuesday, August 19, 2014

Coding is one of the most important skills to have in finance;

There are many other articles saying this in one way or another, a simple Google search will show that. Why am I pushing out another one?

Because it is needed.

I see many people, especially business students, who still think they don't need to learn to code (same thing with math, but I'll make that another post...or 50). Well, that's complete nonsense. My experiences alone prove otherwise.

Internship #1: As a young intern, I became the Excel VBA and automation guru of the main office of a publicly-traded insurance company full of actuaries and other people already proficient in Excel. I completed major projects that lead to immediate results for the company. They would have kept me around as long as I wanted, but classes and extracurricular activities got in the way.

Internship #2: I became the Excel VBA and automation guru (...sound familiar?) of a division of one of the largest international manufacturing companies in the world. The Excel automation projects I completed saved the financial analysts several hours of manual work during monthly reporting. I also completely remade the product pricing model using Excel, which would directly impact profitability. Since leaving, this company has asked me multiple times to return in a couple of different roles.

Extra Project #1: I was part of a team working with a group of financial advisors who had little coding ability, but found themselves in need of a few automated tasks and other things that required programming knowledge to get done. Can't speak much about this one due to NDA, but knowing the R language was a big plus.

Extra Project #2: I scored a contracting/consulting gig as a freelance programmer with another financial advisor. Much like the above project, this advisor needed someone who understood finance, but could work with languages like Excel VBA and R.

Obviously, not everyone will have these experiences like these....but they could if they knew how to code. Coding in finance is not just limited to high frequency trading, hedge funds, prop shops, and investment banks. I encountered it first-hand in insurance, manufacturing, and financial advising. Because I knew how to do it when others didn't, I had an advantage. Is it possible to get a job without this knowledge? Yes, but you better have something else about you that stands out.

It may not be necessary to put in the time to become an expert programmer, but being at least somewhat well-versed in something like Excel VBA, R, or SPSS doesn't take much time and has many benefits. More complicated projects may require an object-oriented language like C++, C#, or Java. To deal with the core issues, randomness and uncertainty, knowing a programming language is key.

To make it easier and put my suggestions out there, if I was starting from scratch and wanted to learn one of these languages, I'd learn R. Why? Because it is free, open-source, used by millions of statistical professionals, and has thousands of add-in packages available. I use Rstudio, which is a great and painless way to work with R. I've written a short-and-sweet guide to help you Get Started in R.

The CORE

Why did I choose CORE? Simple. Cores are at the center. Cores are important. The finance CORE is no different. These are things that are at the center of financial world.

CORE is:
  • Coding
  • Objectivity
  • Randomness
  • Estimation

To deal with that, financial professionals use:
  • C++/C#
  • Object-oriented Programming
  • R
  • Excel
Thus, that is the topic of this blog. These posts will discuss topics that are central to finance - at its core.

At a somewhat deeper level, I view much of what is discussed about finance, be it on the news or in the classroom or in the workplace, to be mostly superficial. Just look at the headlines "Dow 17,000 and why you should sell now!" etc. These topics litter the landscape, and, truthfully, I find them quite boring. You won't see me spouting doom-and-gloom unless I've got some serious factual support to back it up. Make-believe milestones don't lie at the heart of finance. Uncertainty is at the core of finance. Randomness is at the core of finance. These are the topics that need discussed, and that is exactly what I plan to do.

Sunday, August 17, 2014

Hello World.

I'm excited to get this blog started! I've had this in mind for quite some time. I intend to post at least once a week on several topics within finance, such as

  • Statistics
  • Mathematics
  • Programming
  • Data Mining & Analysis
  • Econometrics
  • Econophysics
  • Stochastics
  • Optimal Control
and whatever else comes up. I'll also talk about current events as I see them related to this blog. 

Hope you will find it useful and enjoyable!