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

Perception and representation


A big part of building working systems is the ability to correctly and fully abstract the problem we're trying to solve. In our case, this abstraction means quantifying all the input data that a problem involves, knowing the precise result data we need, and any processes or transformations that affect these inputs to get your desired output. This is what I'll describe as fully perceiving a problem. Let's take Clojure data structures, functions, and FP approaches as a way of representing our problem and solving it.

We ultimately need to gauge how close our perception and representations are to actual stock price data. However, for now, we have an infinite stream of price and time points. Apart from this stream of data, we want to calculate a moving average of prices. So, an average is just the sum of a collection of things divided by the length of the collection. This sounds easy enough. However, the moving qualifier only means that the average is calculated at...