Python for finance (I). Remote data access

With this one I begin a series of posts related to explore the link between Python and finance that I expect to be of interest for both professionals and students. Python is an interpreted, object-oriented, high-level programming language that it is simple and easy to learn. Ok, but why Python? First, because it is open source; and second, because in many application domains, such as business or finance, spreadsheets are not enough. Decision-making is no longer a soft science based on opinions or visions about the future. It must be based on data. Descriptive analytics is not enough and a new kind of technology is required, that is, predictive analytics. In this sense, any available tool that can be used to make things happen (data mining, data analysis, predictions, optimizations, simulations, visualizations, … ) in an easier has to be added to the executive’s toolbox. Before going on, a warning remark must be done. Not every data scientist needs to know the secrets of management science, but every manager has to know the power of data science. Otherwise they will be condemned to be shadowed by a long tail of underperformance.

Let us start with the proposed framework to begin learning Python. No doubt that the winner is IPython Notebook, or Jupyter Notebook, if you like. A notebook is an application that allows you to create and share documents that contains code, visualizations and explanatory text that makes data analysis easier to understand and reproduce. Its utility has been recently highlighted by Helen Shen in Nature where even an interactive demo is available. If you are now discovering notebooks this demo is a good starting point.

For those who Python or any other programming language is something familiar, I hope that the following lines of code represent a good example of the utility of Python in making data analysis easier. Assume you are responsible for monitoring foreign exchange rates in your company. One of your common daily tasks is accessing some finance web site in order to get the required information. You will later add the data achieved to your database and begin with analysis tasks. What if we look for an easier way to get the data? Can we somehow automatize this task? The answer is yes, and the implication is great. We can dedicate our time to data analysis rather than to data fetching. A few lines of code do the hard work for us:
RDA2

CUR

This is only an example of accessing finance data from Quandl’s API but many other data providers are available (Google Finance, Yahoo Finance, St. Louis Fed, …) for your data analysis projects. Portfolio optimization, economic analysis and many other data-driven decisions processes are easier when some simple instructions are given to the right API.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s