Book Image

Clojure for Finance

By : Timothy Washington
Book Image

Clojure for Finance

By: Timothy Washington

Overview of this book

<p>Clojure is a dynamic programming language with an emphasis on functional programming. Clojure is well suited to financial modeling as it is a functional programming language. Such languages help developers work with high-level mathematical abstractions without having to implement low-level code that handles the arithmetic operations.</p> <p>Starting with the importance of representing data and calculations effectively, this book will take you all the way to being competent in financial analytics and building financial applications.</p> <p>First, we introduce the notions of computation and finance, which will help you understand Clojure's utility to solve real-world problems in many domains, especially finance. Next, we will show you how to develop the simple-moving-average function by using the more advanced partition Clojure data transformation function. This function, along with others, will be used to calculate and manipulate data.</p> <p>You will then learn to implement slightly more complicated equations, how to traverse data, and deal with branching and conditional dispatch. Then, the concept of side-effecting and its various approaches are introduced, along with the strategy of how to use data as the interface to other systems. Finally, you will discover how to build algorithms while manipulating and composing functions.</p>
Table of Contents (16 chapters)
Clojure for Finance
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Notions of finance


It's useful to think of capital as a store of time and labor. Let's consider money outside our current banking system. In The Ascent Of Money: A Financial History of the World by the Penguin Group, Niall Ferguson discusses the history of money and credit in human civilization (you can find it at http://www.amazon.com/The-Ascent-Money-Financial-History/dp/0143116177). This approach lets us consider how societies use capital to distribute wealth. Among other things, he argues that the evolution of credit and debt is as important as any technological innovation in the rise of a civilization. I've mentioned this to highlight the purpose of finance and the fact that money and finance have existed across many banking systems, including before our current one. It's important that this approach not be ideological. I want to frame the core purpose and function of a bank and flesh out the mechanics of money flows.

When programming (computers), the first task is to build an understanding of the systems we're trying to model and the problems that we are trying to solve. As such, let's distill some central notions of money and how it fits into the banking function. This is written in the spirit of banks simply becoming information processes and looking more like software companies. Technology produces alternative mediums of capital, such as cryptocurrencies, for example, bitcoin (you can find more about this at http://en.wikipedia.org/wiki/Cryptocurrency). But this concept is outside the scope of the book. I make the point to emphasize the seismic effect that software is having on finance and all modern professions. I will try to describe the context and constraints within which such banking software must operate.

Money is a medium of exchange, unit of account (divisible, fungible, or of a specific measure or size), store of value, and a standard of deferred payment. In economics, money creation is the process by which the money supply of a country or a monetary region (for example, the EU) is increased. Changes in the quantity of money may be caused due to the actions of a central bank, depository institutions (principally commercial banks), or the public. However, the major control rests with a central bank. The actual process of money creation takes place primarily in banks (refer to https://archive.org/details/ModernMoneyMechanics and http://upload.wikimedia.org/wikipedia/commons/4/4a/Modern_Money_Mechanics.pdf). In the U.S., the money creation process centers around the US Federal Reserve. So, a central bank may introduce new money into an economy by purchasing financial assets or lending money to financial institutions or governments. The majority of money in our modern economy is created by commercial banks who give loans or demand deposits.

There's much more to take into account. However, this context allows us to begin considering how to faithfully represent credit levels and flows within and between bank and bank-like entities. We can also start thinking about a commercial bank's core functions and constraints, and the systems it should implement to perform all of these.