Chapter 2. First Principles and a Useful Way to Think

We looked at central notions of computation and finance in the last chapter so that we could come up with the best approach to represent our financial data. In essence, you're learning how to fish. We're going to build on this knowledge right away and start developing an equation to generate price data. At each step, we're going to look more closely at core functional programming features. This should give you a solid understanding of important concepts in their immediate context.

In this chapter, we will cover the following topics:

  • Function evaluation
  • First-class functions
  • Lazy evaluation
  • Basic Clojure functions and immutability
  • Namespaces and creating our first function
  • The Read-Eval-Print-Loop (REPL)
  • Basic data structures
  • Macros and more in-depth data transformation

Let's begin by looking at the data we need to represent.

Modeling stock price activity

There are many types of banks. Commercial entities (large stores, parking areas, hotels, and others) that collect and retain credit card information are either quasi banks or farm out credit operations to bank-like processing companies. There are other well-known consumer banks, which accept demand deposits from the public, and a range of other banks, such as commercial banks, insurance companies and trusts, credit unions, and in our case, investment banks. As promised, this book will slowly build a set of lagging price indicators that follow a moving stock price time series. In order to do this, I think it's useful to touch on stock markets and crudely model stock price activity. A stock (or equity) market is a collection of buyers and sellers trading economic assets, usually companies (for more details on the stock market, visit http://en.wikipedia.org/wiki/Stock_market). The stock (or shares) of these companies can be equities that are listed on an exchange (the New York Stock Exchange, London Stock Exchange, and so on) or traded privately.

Earlier, we reviewed the nature of capital. This helped to frame the core purpose and function of a bank and flesh out the mechanics of money flows. From here on, we can create an imaginary investment bank. Chartering a bank would also involve plugging it into an imaginary central bank network. Once this is done, our bank would need to register to trade on one or more exchanges. Now, our bank can (among other things) buy and sell on a stock market.

Our next exercise will do the following:

  • Crudely model stock price movement, giving us a test bed to write our lagging price indicators
  • Introduce some basic features of the Clojure language
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.67.16