New Forum

Visit the new forum at http://godelsmarket.com/bb
Showing posts with label educational. Show all posts
Showing posts with label educational. Show all posts

Friday, August 17, 2012

Wheat Prices, Sunspots, and One-Dimensional Theories

I meant to post a link to this article on the increase in grain prices a couple weeks ago. It is still an important article especially from a critical thinking point of view. The author begins by noting the assertions by many in the media that the reason for higher grain prices is drought caused by global warming. He then goes on to say:
A better explanation for the drought, and the ensuing spike in grain prices, is that this is all part of the normal 11-year sunspot cycle.  But to find that relationship in the data is what the story is about. 
Given the data presented in the article, I would have to say the information is compelling. But, that is not the point of my post. I have little knowledge of what causes grain prices to fluctuate. In fact, that lack of knowledge is my point. So often people are willing to hurriedly, lazzily, and/or sloppily accept what sounds good. This, of course, can lead to an imperfect idea as to what will happen. What you think may happen, might happen for some time; but then, when the premise on which you built your theory continues to hold (e.g. global warming, drought, etc) but the underlying asset fails to continue its path, you will find that your single loose premise is not much help. Yes, global warming may be a cause, but perhaps it is merely an auxiliary cause of some greater impetus.

Abstract lessons learned in one area and apply to other investments and trades. Grow and profit.

Saturday, August 4, 2012

Non-Linearity

Here's an interesting video on the non-linearity of risk with Nassim Taleb.

Sunday, July 15, 2012

Put-Call Parity Calculator

If you enjoy the following, consider signing up for the Gödel's Market Newsletter.

I've been reading "Numerical Methods in Finance and Economics, A MATLAB Based Introduction 2nd Edition". They obviously go into put-call parity early on. It's an extremely fascinating concept that given the risk free interest rate (r), the distance until expiration (t), the initial stock price (s), and the strike price (k), that you can then solve for the price of the call (c) given you have the price of the put (p) or vice versa.

No arbitrage financial pricing is extremely interesting (and practical). Here's a MATLAB script I wrote that you can use to look for "arbitrage" opportunity in the put-call parity sense. It'll ask you for several inputs (r,t,s,k,c,p) and tell you what the "call side value" (c + k*e(-r*t)) is and what the "put side value" (p + s) is. You can then compare.

(Example with current SPY options; first part is entry, second is output:)



 % arbitrage; put-call parity checker  
   
 %risk free interest rate  
 r = input('What is the risk free rate? ');  
   
 %time period  
 t = input('How long until expiration? ');  
   
 %stock price, initially  
 s = input('What is the initial stock price? ');  
   
 %strike price  
 k = input('What is the strike price? ');  
   
 %grab call price  
 c = input('What is the call price? ');  
   
 %grab put price  
 p = input('What is the put price? ');  
   
 fprintf('Risk free rate: %d \n', r);  
 fprintf('Time period: %d \n', t);  
 fprintf('Initial stock value: %d \n', s);  
 fprintf('Strike price: %d \n', k);  
 fprintf('Call price: %d \n', c);  
 fprintf('Put price: %d \n', p);  
   
 call_side_value = c + k*exp(-r*t)  
 put_side_value = p + s  

(Edit: fixed an error in call_side_value calculation. Should be good to go.)

(If you've enjoyed this article, consider signing up for the Gödel's Market Newsletter.)

Wednesday, July 11, 2012

Matlab Stock Correlation Matrix

If you enjoy the following, consider signing up for the Gödel's Market Newsletter.

So, maybe you used the Python Yahoo! data importer script I posted; or, maybe, you have your own price data. And, perhaps you want to run a script to see what the correlation is among the stocks in your database. This code will do just that.

You need to download the MySQL JDBC connector and go through the hassle of adding the .jar file to your Matlab java path. It's worth the struggle, though.

Here's the code with some comments to hopefully help you along (and remind me what I did later):

   
 %test variables to limit matrix sizes...  
 num_stocks = 500;  
 num_close_values = 20;  
 num_log_values = 19;  
   
 %connect to the database  
 conn = database('stocks','root','*****','com.mysql.jdbc.Driver','jdbc:mysql://localhost:3306/stocks');  
   
 %query the symbols in the database  
 str_query_symbols = 'SELECT distinct symbol FROM stock_prices_day';  
 symbol_cell = fetch(conn, str_query_symbols);  
   
 %create matrices to prevent matrix resizing when inserting cell values..  
 mat_log_change = zeros(num_log_values,num_stocks);  
 mat_values_adj_close = zeros(num_close_values,num_stocks);  
   
 %grab adj_close info for a each symbol; then cell2mat it into a larger  
 %matrix  
 for i = 1:num_stocks  
   symbol = cell2mat(symbol_cell(i));  
   str_query_adj_close = ['SELECT adj_close FROM stock_prices_day WHERE symbol = ''' symbol ''' and date > ''2012-06-01'''];  
   mat_values_adj_close(:,i) = cell2mat(fetch(conn, str_query_adj_close));  
     
   %use this to calculate natrual log changes as you move along  
   for j = 1: num_log_values  
     %mat_values_adj_close(j,i)  
     mat_log_change(j,i) = log((mat_values_adj_close(j,i))/(mat_values_adj_close((j+1),i)));  
   end  
 end  
   
 %next calculate correlation coefficients among the various columns  
 mat_correlations = zeros(num_stocks,num_stocks);  
 for i = 1:num_stocks  
   for j = 1:num_stocks  
     A = mat_log_change(:,i);  
     B = mat_log_change(:,j);  
     R = corrcoef(A,B);  
     mat_correlations(i,j) = R(2);  
   end  
 end  
   
 mat_correlations  

(If you've enjoyed this article, consider signing up for the Gödel's Market Newsletter.)

Sunday, June 17, 2012

Volatility Smile

I tried to find a good video on youtube explaining the "Volatility Smile" effect. This one is okay. Kinda long, but does a good job of going over inputs and the reasoning that explains the volatility smile. I wish it were a little more advanced, especially given its length; but, it's a good introduction nonetheless.


Friday, June 15, 2012

The Greeks

Here's a simple video explaining the "greeks" of options.


Binomial Options Pricing

I was looking into the binomial pricing model and came across this:

A brief introduction, but can definitely help you forward in understanding.

Thursday, June 14, 2012

Black-Scholes Option Pricing

I've been looking for some good videos on Black-Scholes options pricing on youtube. Here are some that I'd like to keep track of. Post more links if you find something. I'll try to add more info as I find it.


(the call version above, the put version below; very simple videos that explain the basic imputs)


Efficient

"A market in which prices at any time “fully reflect” available information is called “efficient”" (Fama, 1970, p 383)

I think this is a good place to start at deconstructing the problems behind the efficient market hypothesis.

Resources

Efficient Market Hypothesis: What are we talking about? Bernard Guerrien and Ozgur Gun [Université Paris 1, and Université de Reims, France]

Efficient-market hypothesis at Wikipedia.org

Efficient Markets Hypothesis: History (I think "“The mathematical expectation of the speculator is zero”, circa 1900, describes fairly well how many understand the efficient market hypothesis.

First Proof

This is going to be, or at least start as, a messy grouping of notes and ideas. However, I think it is important. My understanding of the efficient market theory can be summed up in this snippet from Wikipedia: "In finance, the efficient-market hypothesis (EMH) asserts that financial markets are "informationally efficient". In consequence of this, one cannot consistently achieve returns in excess of average market returns on a risk-adjusted basis, given the information available at the time the investment is made"


I want to prove otherwise. In fact, I want to prove that if it is not possible to achieve returns in excess of average market returns then participation in markets would subside. I'll be focusing on stock and derivatives markets, as those are my interests. I will try to dissect the various forms of market efficiency, but think that starting with the strongest form is perhaps the best. Of course, it has its uses in simplifying matters. I am  merely looking at it from a variety of perspectives to see when it aids and when it hampers research.