foquant.com

quantitative methods, computational finance, trading and programming

Corporate Finance Modeling

I return bearing gifts. After a short and well-used break from the site, I am glad to post a working version of a capital budgeting model. This model is straightforward, and focuses on corporate finance in terms of project analysis.

It incorporates all of the standard features, such as IRR and NPV calculations, but it adds a bit more. These special features include:

Scenario Analysis The user can compare multiple scenarios (3) side by side.
Sensitivity Analysis The user can manipulate inputs with slide bars to immediately see the impact on profitability.
SML Hurdle Rate The user can follow the SML methodology to develop a project specific hurdle rate.
Equivalent Annual Annuity The user can use the EAA method to compare projects with varying lives.
Multiple Depreciation Method The user can select straight line, or use a custom (commonly accelerated or MACRS) depreciation schedule.
Graphics The model automatically creates presentable 3D graphics to showcase the results based upon the selected inputs. These can quickly be copied and pasted into other MS software, such as PowerPoint.

As usual, the model has been uploaded to the Models page of the foquant.com site. The “Terms” tab has not been completed, but once uploaded that will share additional insight into the inputs and outputs of the model. Also, as usual, the user assumes any and all risk - I partake in model creation for recreation; if any reliance is placed upon these models it is at the assumption of risk of the user.

The Models page at foquant.com now features a binomial bond valuation tool. This is a crude first run at this, limiting the valuation to a bond with four periods to maturity.

I wanted to get this thrown together so I can expand upon the periods and the ability to value options on bonds. For now, though, the user can input their own rate tree, or choose a constant rate, and also dictate whether or not the bond has a coupon rate. The math that goes into the binomial tree is quite simple, so if a user needs to add additional periods it should not be exceptionally difficult.

Update 1: I have now also uploaded the same model but allowing for a callable bond with a user-defined call schedule.

Can least squares regression be used if we are creating a model that includes more than one time series? An example of a model with more than one time series would be as simple as a model that includes a dependent variable and a single independent variable that are both time series. Such as:
\small y_t=b_0+b_1x_t+\epsilon_t

Working with that example, there are five possible outcomes that dictate whether or not least squares is an appropriate method. Generating these outcomes begins by testing each variable, again the dependent variable and the single independent variable, for a unit root. This can be done by using the Dickey-Fuller test.

Outcome 1:
Neither variable has a unit root. In this case, least squares can be used to estimate the model.

Outcome 2:
The dependent variable has a unit root while the independent variable does not. This occurs by failing to reject the hypothesis of a unit root for the dependent variable. If this is the case, the error term is not covariance stationary and least squares is not appropriate for that specific model.

Outcome 3:
The dependent variable does not have a unit root while the independent variable does. Opposite of Outcome 2, this occurs by failing to reject the hypothesis of a unit root for the independent variable. Similar to Outcome 2, the error term is not covariance stationary and least squares is not an appropriate method.

The next two outcomes occur when both the dependent variable and independent variable have a unit root. In these cases, the next step would be to test for cointegration between the two time series. This can also be performed using a Dickey-Fuller test. The time series are said to be cointegrated if their divergence has some boundary.

Outcome 4:
Both variables have a unit root but they are not cointegrated. As in Outcome 2 and Outcome 3, the error term will not be covariance stationary and thus least squares is not an appropriate method.

Outcome 5:
Both variables have a unit root and they are cointegrated. In this case, the error term is covariance stationary so the model may be valid. However, this relationship models the long term, and short term results may not be as expected. That is primarily the cause of the fall of LTCM. While there may be boundaries to a divergence in the two time series, there are not necessarily natural rules in all models that dictate maximum time frames for desired changes in the divergence. In other words, if a trader is hoping for a wide divergence to narrow with the two time series meeting, there is not necessarily a time frame in which that must happen.

This is a quick overview of testing the quality of a model with two time series variables using least squares. The intent was to build upon my prior post, Test for Random Walk in Time Series. In an upcoming post, I will provide the results (and excel spreadsheets) that result in one of the five outcomes, and will provide additional detail and connection within the method.

Altman’s Z-Score Model

Using multiple discriminate analysis, Edward Altman created a model that provides guidance regarding a company’s credit health. The model is named The Z-Score Model. Upon providing measures from a company’s financial statements, the model would yield a single variable that is designed to be compared to a pre-specified scale. The placement of the Z-score on the scale would indicate whether a company was likely to head toward bankruptcy.

I implemented the model in Excel, and it can now be accessed through the Models page of the foquant.com website.

This model was also covered in the Fixed Income curriculum for the CFA Level 2 exam.

One of my most-viewed posts concerns the Dickey Fuller test, and the most downloaded document is the Dickey Fuller example.

So, I thought I’d expand on that in a series of posts as it is an area of interest for me, and obviously many others out there.

Let’s start with the idea of a Random Walk. A time series is a random walk if it is explained by the equation x_t=x_{t-1}+\epsilon_t. This requires that the error term \epsilon_t has a constant variance and is uncorrelated with previous error terms.

This equation states that the best predictor for any x is x_{t-1} for any period after t-1. So, let’s start by testing a set of financial time series to see if it is a random walk.

If you go to the Federal Reserve website, you can download data for a number of currencies. I downloaded the data for the Pound, and opted to use the dates Jan 01, 2007 to Dec 31, 2007. The spreadsheet used is attached here.

Notice that the t-value for the intercept is 1.72, meaning the intercept is not significantly different than zero. Also, the lagged variable slope coefficient is .977, which is very close to the value of 1 we would expect for a random walk. However, a random walk is not covariance stationary, meaning it does not have a fixed mean and variance, thus the t-test for this variable is unreliable.

So, how can we confirm out suspicion that this time series is a random walk? We can regress the first differences of the series. Essentially, we look at the equation:
y_t=b_0+b_1y_{t-1}+\epsilon_t where y_t=x_t-x_{t-1}\small.

If the series is indeed random, we would expect that b_0 and b_1 would be equal to zero. The results of that test are attached here. Notice that both regression coefficients are not statistically significantly different from zero. Also, I added an autocorrelation measure and t-test to go with the error terms. These measures show that there is no first lag autocorrelation in the model.

Thus, we can conclude that the exchange rate for the Great British Pound followed a random walk in 2007. That’s a good starting point.

Relative Volatility

Most academic papers refer to relative volatility as one of two things:
1. The volatility of a security compared to that of an appropriate index.
or, closely related
2. The volatility of a security explained by an appropriate index.

Then there are technical factors such as the Relative Volatility Index, available for review here, although that isn’t really what I’m talking about.

I read Curtis Faith’s new book, and one thing that he mentions is something I’ve found interesting for a while: market regimes. He refers to them as market states and the info is available on pages 25 and 26 if you have the book. While this area of study has received some coverage, Faith breaks it down into a simple system that I like: Volatility and Trend (he uses the terms stable/trending and quiet/volatile). This creates four market regimes:

Low Volatility, Trending High Volatility, Trending
Low Volatility, Not Trending High Volatility, Not Trending

The volatility component that describes the regime is what I call (and he may have called too, don’t remember exactly) relative volatility. My interpretation differs from the academic, in that I would like to compare the volatility of a security to its volatility at some point in history.My first foray into this was simply to create two series, the volatility xx periods back and a moving average xx periods back of the previously defined volatility. Standard deviation measures could be added to the moving average, I suppose, to determine relatively high and relatively low volatility - but I haven’t gone that far yet.This initial measure has shown some interesting results in individual futures contracts when combined with basic time-dependent always-in order techniques. My continuous contract transformation may be suboptimal though (linear instead of logarithmic, switch period, maybe?), because the results can be quite interesting when on high volume time periods for given individual contracts, but when testing on long-term continuous contracts the results aren’t nearly as interesting/profitable. Still, this measure may provide a very slight edge if partnered with correct money management and order entry rules.

I’ll post more as this volatility measure develops. A quick Google, JSTOR, and Blackwell Synergy search didn’t pull up too much in this vein, rather the aforementioned definitions, so I plan to look more. But, if anyone has any ideas or has come across similar work, please comment and let me know!

SMS Order Confirmation

No posts for a few days as I have been busy working on a couple of projects, plus I’ve started studying for the CFA L2 exam. One project is relative volatility, which I’ll get to in my next post; the second is an SMS trade confirmation system. This last one has really been getting to me.

So far, I’ve been able to get the system to work as long as it is attached to a trading strategy. The code is written in EasyLanguage and therefore amateurish at best, although I did review the methods for implementing it using C++. Still, I can’t get the program to run on its own without a strategy attached. However, when it works, it is very nice: I get a text message sent to my phone in the following structure:

1035 Short 1 ESH08 at 1345.25

where 1035 is the time, in this case 10:35a exchange time.

The first response coming to anyone’s mind, I’m sure, is:

Why would you want this? And please don’t say its because you leave your computer unattended while a system runs!

Yes, I do. I constantly monitor the system and have controls as best possible in place, but at times it is unattended. As a backup, I do maintain contact via remote access, which I can connect to if necessary. Also, my computer is set with back up resources (ie power).

I will put the completed code for the messaging system up as soon as I get all of the bugs worked out. It will be featured in the Models section.

And, while I certainly don’t encourage it, if anyone else leaves moderate- to high-frequency systems unattended, I’d be interested to hear your experiences - including the horror stories.

Update: I uploaded version 1.1 of the SMS system to the Models page. The code output is dependent upon the order type, but really this version is designed for a single contract system. I will add additional versions that accommodate multiple contract/share positions as well as partial/ladder sells/buys.

  • 0 Comments
  • Filed under: Coding, Diary, Trading
  • Local Predictability

    Inductive reasoning in trading may be the preferred method for developing systems. One reason, as argued by Doyne Farmer in Cracking Wall Street, is due to Local Predictability. The concept is based in chaos theory, and references the idea that there may be an underlying order in the short term that enables prediction of events that are not equally predictable, if at all, in the long term.

    Farmer was a founder of Prediction Company, which was purchased by UBS. There is an interesting presentation Prediction Company created a few years back, titled The Business of Model Based Trading. Both the article and the attached .pdf are worth a quick read.

    In the referenced article, there are a number of analogies and layman interpretations of the interaction between physics, math, and finance. Below are two passages that I enjoyed:

    He likes to use a favorite example when explaining the anatomy of a prediction. “Here, catch this!” he says, tossing you a ball. You grab it. “You know how you caught that?” he asks. “By prediction.” Farmer contends you have a model in your head of how baseballs fly. You could predict the trajectory of a high fly using Newton’s classic equation f=ma, but your brain doesn’t stock up on elementary physics equations. Rather, it builds a model directly from experiential data. A baseball player watches a thousand baseballs come off a bat, and a thousand times lifts his gloved hand, and a thousand times adjusts his guess with his mitt. Without his knowing how, his brain gradually compiles a model of where the ball lands — a model almost as good as f=ma, but not as generalized. It’s based entirely on a collection of hand-eye data from past catches.

    And:

    While running from lions, or investing in stocks, the tiniest edge over raw luck is significant.

    Bond Valuation and GGM

    Two new models have been added to the Models page at foquant.com.

    The first is the Gordon Growth Model, which is a very simple equity valuation tool. This model features a chart that shows the difference in price dependent upon the dividend growth rate. This is important, because as the growth rate approaches the required rate of return, the value of the equity approaches infinity.

    The second is a C++ calculator for a standard coupon bond. The user is asked for inputs concerning the bond, and the value is printed to the screen. Similar to the GGM, this file will also show a range of prices depending upon discount rates, providing almost a high to duration and convexity.

    On the topic of the Models page - this page will soon be redesigned. It will be laid out by topic model type, making it easier to view. While this may not seem necessary now as there are only a handful of models, this will be useful as the page grows and the models increase in complexity.

    I’ve completed about half of the book on Einstein, and it is very apparent that he prefers deductive reasoning over inductive reasoning. Simons, in 2000, made the opposite argument regarding his Medallion Fund:

    We don’t start with models. We start with data. We don’t have any preconceived notions. We look for things that can be replicated thousands of times. A trouble with convergence trading is that you don’t have a time scale. You say that eventually things will come together. Well, when is eventually?

    This identifies a divide between the methods of trading strategy creation.

    First, you have those who believe that trading methods should be created through the analysis of existing characteristics. Behavioral finance and much of market microstructure theory are based upon this type of reasoning.

    Second, you have those who believe that any pattern or anomaly derived from data is just as substantiated. Medallion’s historic returns are based upon this type of reasoning.

    I thought this was interesting after reviewing ASTA, which seems to have capabilities of supporting both approaches. Perhaps, the solution to the question of which method is more appropriate is based upon what the trader believes they are looking for. Einstein was looking for underlying laws, and from a prior post we already know that Simons doesn’t believe in underlying laws in the financial marketplace, even if the principles that underpin his systems don’t change.

    [Update] This post brings to mind a newsletter I received a number of months back from Mike at Breakout Futures. You can access the main article here. He provides simple code for TradeStation that will develop automated systems for the user, based upon the type of price pattern system the trader dictates.

    While I haven’t used this type of system, I think it warrants further review with caution - it is likely similar in concept, although more rudimentary, to those systems developed at aiQUANT and Neural Market Trends.

    Personally, I have used deductive reasoning to develop frameworks for money management methods, and then tested data in a similar, inductive method, to create the details.

    Sponsored By

    Create Equations

    Equation Builder Google Ads benefit Sitmo

    Browser

    Best viewed using

    My Bookshelf

    See additional texts at my Amazon.com store:
    foquant.com Bookshelf
    or search:

    Sponsored By