Wednesday, December 2, 2015

Implied volatility cont. (my processor hates you!)

Question of the day: What to do when implied volatility from Yahoo! Finance is 0.00% or is repetitive for a too long period of time????

I decided that I will go the hard way in obtaining its value. I could use any build in functions that uses the BS formula and solve it , but I thought to myself, why using the black-box if I can program it myself. So, I made use of the Newton-Raphson Methond. It took some time to realize how to apply it to my specific data, but once I was done with implementation a monster came out that is killing my poor processor. And the worst it will be that at the end of the process, there will be something wrong with calculations and the process will have to be repeated. Noooo.... it has been going for 20 minutes already, and I am just goofing off in the meanwhile since the rest of the things work extremely slow.

Doing some calculations, if such a thing has to be repeated over and over again for about 300 * 15 times.. how long it would take to compute a simple Implied volatility for values that are 0??? So please, dear Yahoo! Finance, be so kind and evaluate the IV for me otherwise I will melt my processor to do this project! If somebody would like to give me some help, here is what I have been strugguling with in python:

http://stackoverflow.com/questions/33988048/inneficient-loop-accesing-option-types

Saturday, November 28, 2015

Implied volatility vs delta

The clasification of options between out-of-the-money, in-the-money, and at-the-money will be a determining factor in properly applying the extraction methodology and obtain meaningful results for different options monsters. After some python experimentation, the dataset is ready to be analyzed and available for calculations. My question today revolves around the the mening of the obtained graf in delta vs. volatility space.

The shape from the graph makes sense, since delta values for calls and puts are positive and negative. Volatility is positive since is the percent change and is provided by the courtesy of Yahoo! finance. On this note, I will spend some time in finding out two things:

1. How does yahoo! finance calculate implied volatility? (probably BS!)

2. What Risk free rate do they use for calculations?

Literature and internet review showed that many people that deal with the BS formula omit the discussion about the risk free rate and its estimation or use. Given that IV is provided, one can extract the risk free rate from it. Once I compounded the BS formula with D-parameters, I came to find out that this will not be a simple task to do. The r parameter is found both in the original equation and in the proces of calculating the normal distribution. Have fun whomever will decide to figure this out!!! :)

Lastly.... from one paper where deltas and implied volatilities are plotted, only positive deltas are used for both calls and puts that are out-of-the-money. Were deltas put in absolute values to extract the estimation function?

Saturday, November 21, 2015

Python can keep you entertained all day!

It was about time. As the route in implementing probability density functions to option data is somewhat leghty, being as stubborn as I am, I continued with solving problems regarding data acquisition and preparation for further calculations and analysis.

Data from yahoo! finance is an excellent medium to observe options prices and doing simple quests and calculations for the unindexed parameters. The best part, that such data became freely available to the public (I do not know exactly where it comes from, but for studying and testing purposes is excellent). However, making use of the Black Scholes formula with the downloaded data is a total nightmare to obtain (yes, I can save you some time with my going around the bush script if you want to come up to speed with this development).

After a nice day with reading about python, I finally made a put-call graph that normally you do not see in any classes. I will polish it and make it more readable in the future.

Sunday, November 8, 2015

Life made simple

Learning new computer tools is always a challange and a new adventure to get your mind wrapped around a problem. With some useful links and online hints the desired algorithm may well one day come to life.

Automation of programming tasks using free data sources with simple calculations techiques and file exporting is made simple with python and no wonder why it is becoming a predominant laguage in the finance field. Just as an example, data from yahoo finance is downloaded with one simple command:

df = web.DataReader("SPY", 'yahoo', start, end)

as data is a time series of basic end of the day fields (High, Low, Open, Close, Volume), calculations are made extremelly simple since python interprets variables just like matlab. With one line of code a new column is added to the imported variable. And what is better yet, many stock indicators are already incorporated in different libraries, it is just a matter of finding the right one or all of them to incorporate them into the learning model. There are several hundred stocks published on yahoo and the end of the day approach can be easily transfered to other candle sticks with different time frames or windows. The found process on free resources has a great potential to become a state of the art trading tool its just a matter of focusing on the right set for troughtful analysis and back testing.

What is even cooler, is the simplicity of exporting manipulated data to a hard drive to use with other applications (not Excel tough). it is just a matter of one line of code:

df.to_csv('/home/t/Documents/Python/file.csv')

As an interesting observation of the day is a visualization of IBM and SPY stock once we plot for volume and price change between open and close prices. As noted, the volume on the IBM stock does not vary a lot, but the change in price does (vertical line) on the SPY stock instead, volume values are a complete big bang scattered on the plane meaning that given a high volume turnover, there will be equally likely that the price change between open and close will be high as well (be it positive or negative). I would like to know from a practical perspective, what does this means :)

Thursday, July 30, 2015

The normal approximation

So I ran into the problem of proper normal approximation. Since it is highly advised to stay away from generalized implementations of the normal distribution in some softwares, I decided to implement an algorithm by myself to continue with the analysis of volatility and spot prices data. Why am I stuck? I used the Hart algorithm (which is extremelly precise to all the decimal places) that I found in Haug book. Not giving much thought that the algo will not run properly, I ran into a negative option value. And how is this possible?

Well, certanly there were several studies done on the mentioned topic and I then I decided to copy paste the algorithm from a different author (West) and came to find out that I obtain the same wrong number as I have with the Haug version. I still do not know where is the problem, but having negative values extremely disturbs me because then the rest of calculations will definitelly be wrong. Anyhow, I wanted to share a paper that was a critique on normal approximations and an analysis of different approaches.

http://www.codeplanet.eu/files/download/accuratecumnorm.pdf

Sunday, June 7, 2015

Some interesting papers

The mith of the black Scholes Merton formula. The question is, did really the right people recieved all the credit?

http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1012075

Is the propability distribution derived from a delta and strike price place a good indictor for other purposes than decision regarding monetary policy?

http://www.newyorkfed.org/research/staff_reports/sr32.pdf

https://www.ecb.europa.eu/pub/pdf/scpwps/ecbwp1391.pdf

The strenght of a correlation is important. But is it possible to observe the correlation strenght over time with some techniques or distributions?

https://www.bportugal.pt/en-US/BdP%20Publications%20Research/wp201001.pdf

Monday, June 1, 2015

Who sets the rate?

Since fund managers need to revalue their investments everyday and not all of their assets are in domestic currency, it is natural that they will need a rate to operate under fort he optimization of the portfolio. Such managers need to know the value of their assets on everyday basis. The used banckmark is the so called London 4PM fixing. One company calculates the rate based on a data sample used one minute before the fix in London. Within the sample, the median value is taken as the closing spot rate value and it becomes the rate of the value of the assets.

Fund manager salso trade currencies and it so happens that banks allow then to do their traiding at the best time for then, the 4PM London fix. The trading platforms are extensivelly overwellmed at that period.

To conclude, even tough central banks provide the rate at a convininet time on everyday basis, this is not the most precised rate to be used for activelly traded currencies like the dollar, the euro, swiss frank, …

The business cycle

Navarro found that the movement of stock prices and the stock exchange show changing expectations stock holders in future movement of corporate profits. The business cycle is a critical element in forming decisions over corporate profits, since the profits in the time of the extension of the economy, are much higher than in times of recession. When stock holders expect strong growing economy, will make sure that the stock prices start to rise and improve profits on stocks. If the investors notice the arrival of recession, the trading process shows its pattern in expecting low profits on stocks.

Burns and Mitchel were researching the business cycle at the beginning of the 20. century with observing different economic indicators and fount that the fluctuations of business cycle reflect repeated events with similar properties in different countries. In general it holds that the business cycle shows some periodical and nonregulary movement in economic activity that is the dace of fluctuations or changes in the gross domestic product, or other microeconomic indicators like: unemployment rate, inflation or stock indices. the business cycle is split in four phases:

1. economic expansion from growth to normal growth rate,

2. economic growth on non inflation phase,

3. the cyclical peak in growth till the holding of normal trend,

4. growth that falls below the trend and completes the cycle.

Each phase of the business cycle has its own relevant implications over the profits of different stock classes and sectors. Stock prices are really sensitive to each phase of the cycle. In the first phase offers ideal conditions to hold financial instruments, mainly stocks. In this phase begins the new growth of stock prices from the accumulation of holdings and business investments. In the early stage of economic growth expansion, the inflation rate is still dropping. Tough the economic activity has raised and it shows in the capital market. In the second phase of the cycle a warning sign is shown because on the raise in interest rates and additional interest in other investments. Supply is limited with capacity and demand accelerates at the rate of economic activity. In the third phase of the cycle the moderators start to control the excessive growth in making some wrong decisions and pushes the economy back in recession. Strong monetary policy and slow growth of the economy show on stocks like a phase of higher returns and high volatility on capital markets. The fourth phase is the most prominate phase for the stocks due to high liquidity and expectations of the new change in the economic growth.

Friday, May 29, 2015

Before complexity

After the second world war, the international monetary system consisted of a state of fixed exchange rates. Meaning, the system was established under the Bretton Woods agreement signed in 1944. The agreement required all central banks to keep their reserves in either gold, US dollars or pound Sterling. The dollar was pledged to gold backup at 35$ per ounce. The question arises, what happens if the dollar appreciate or devalues against gold?

The answer became evident throughout the years when several dollar crises resulted in a devaluation against gold to $38 per ounce. There were small modifications to the system but the system was doomed to collapse. In 1973 the entire structure of fixed exchange rates was scraped, resulting in loosing the fixed ties to gold and all major currencies against the dollar became floating.