master thesis for mathematics on financial mathematics and advanced statistics (daniel antunes,...
TRANSCRIPT
Stock Market for Popularity of InternetSites
Daniel Guimarães de Lemos Antunes
Stock Market for Popularity of InternetSites
Daniel Guimarães de Lemos Antunes
Dissertação para a obtenção do Grau de Mestre em Matemática
Área de Especialização em Estatística, Optimização e Matemática Financeira
Júri
Presidente: José Augusto Mendes Ferreira
Orientador: Luís Daniel Moura de Abreu
Vogal: Luís Nunes Vicente
Setembro de 2008
Resumo
Palavras Chave:
AbstractThis text is part of the site www.derivatives.com.pt. It reports essen-
tial aspects of the implementation of a computer financial managementsystem which permits the trading of securities via a computer network.The securities traded are the web-clicks generated by any web-site, timesa cost per click (c.p.c.), based on a certified log statistics file (e.g. GoogleAnalytics).
The server computer generates a market price using the Black-Scholesmodel. The buy and sell orders for the derivative financial instrumentsare made from a plurality of client computers, to a server computer whichstores every transaction in a database.
This Stock Market for Popularity of Internet Sites is hosted at thedomain: www.derivatives.com.pt.
Keywords: Popularity, Stock Market, LongTail, Derivatives, Online Auctions,
web-clicks
i
AgradecimentosTo GOD and father Cruz, for helping me in second chances.To my family, namely: my dear father and mother and brothers, for
being there for the better or worst.To the Mathematics Department of the University of Coimbra teach-
ers for their sympathy and availability.To my three Statistic teachers, Maria de Nazaré Mendes Lopes, Maria
Esmeralda Gonçalves and Ana Cristina Martins Rosa, for their kindness.To my Game Theory teacher, Artur Soares Alves, for the broadened
perspective on the presented subjects.To my coordinator, Luis Daniel Moura de Abreu for giving liberty of
action and creation.To my colleagues for the companionship and good moments together,
either in studies or relaxing.To the company Rianda-Research, for their equipments and installa-
tions.To the company Enaco, for the statistical data.To the Foundation of Science and Technology (FCT) for the financial
support, given by the partial grant, refering to the project: MatemáticaFinanceira Computacional (PTDC/MAT/64838/2006)
iii
Conteúdo
1 Introduction 11.1 Vision and Initial Considerations . . . . . . . . . . . . . . . . . . . . 1
2 Derivatives Stock Market 32.1 The Long Tail for the Popularity . . . . . . . . . . . . . . . . . . . . 32.2 How to take advantage of the Crowdsourcing . . . . . . . . . . . . . 42.3 The Stock Market for Popularity. . . . . . . . . . . . . . . . . . . . . 52.4 Trade Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.5 Stock Market Technical Specifications . . . . . . . . . . . . . . . . . 62.6 The Black-Scholes Formula . . . . . . . . . . . . . . . . . . . . . . . 72.7 Volatility Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.8 Total volume of options and it’s Distribution . . . . . . . . . . . . . 102.9 The Derivatives Auction System . . . . . . . . . . . . . . . . . . . . 11
3 Final Considerations 19
A Used Symbols 21
B Used Formulas 23
C Banners 25
D Fluxogram 29
v
Capítulo 1
Introduction
1.1. Vision and Initial Considerations
This thesis reports the implementation of a computer financial management system,
which permits the trading of securities via a computer network. The securities traded
are the web-clicks generated by any web-site, times a count per click (c.p.c), based
on a certified log statistics file(e.g. Google Analytics).
Popularity or visibility always was an objective intended by many but reached
by few. Which factors influence popularity? Can we adjust them? How to measure
popularity?
The objective of this work was to build a mechanism that would allow us to
collect enough data to try and answer some of these questions. But sometimes,
with some answers come more questions than the one’s initially made, and thus the
inevitability of making the scope more broadened. So, in order to simplify the scope,
we have limited the study of the popularity to the specific case of internet web-sites.
Besides the academic interest, there’s potentially a commercial interest, from
many sectors of the media companies, namely the advertisement one’s, in knowing
more about these subjects.
Up until very recently, the number of printouts served as basis for a rough esti-
mate on the number of readers. However, with the shifting of the advertisement from
the traditional media (e.g. newspaper, magazines) to the online advertisement, the
study of rigorous and exact mechanisms became mandatory to measure the popular-
ity generally speaking, or for example, the specific impact of certain advertisement
campaign. For such, we chose a stock market in which the securities traded are
the number of web-clicks that a web-site can generate in a month. Note that, we
considered for security the number of clicks instead of the number of visits. Two
reasons justified our choice: on one hand, the number of clicks is associated to a
direct and repeatable action per visitor (similar to a magazine reader, exposed to
different advertisements). And, on the other hand, with the number of visits, the
1
Capítulo 1 Introduction
maximum session time per browser is 30 minutes, and a user might be accounted
two times, which would compromise a rigorous analysis.
Our objective was defined. However it was necessary to attribute a economic
meaning to the number of clicks.
In national sites, the cost per click (c.p.c.) changes between 0.5 euros and 1 euro.
In some international sites this cost can go up to 5 euros. Defined as a variable,
the cost per click was fixed at 0.01 euros, which makes this stock market a business
opportunity to whoever wishes to make online advertisements, comparing to current
prices. Certainly sites of big media companies won’t be interested on selling their
clicks at lower price than the ones they already charge. However, a vast number of
small commercial sites, blogs, discussion boards and others, generate less monthly
clicks, but when added altogether, are in a much bigger number, because they are in
the long tail of popularity.
Many programming languages where used, namely php, for the calculus of the
Black-Scholes formula, and xml for the Google Analytics Statistics files. For the
online auctions, we used Ajax, and for the databases we usedMySQL. All the project,
including the Derivatives site (www.derivatives.com.pt) has more than 10000 code
lines.
2
Capítulo 2
Derivatives Stock Market
2.1. The Long Tail for the Popularity
The economic model of the long tail (or the economy of the abundance) is changing
the traditional business models. According to the new proposed paradigm, the future
of the commerce isn’t the selling of big quantities of few products (current situation),
but the selling of small quantities of many products. The scarcity of the offer demands
sales successes or hits and inversely, the abundance of offer scatters choices through
various niches.
But what if this offer was infinite? What if all sites could sell their own clicks?
Chris Anderson [1] says: “Weťre still obsessed with the hits, but they are not
the economic force they once were. And this because the markets fragmented into
uncountable niches, defying the conventional logic of the media and marketing.“
Figura 2.1: The long tail of Popularity.
From the analysis of figure 2.1, the volume of clicks on the tail is much bigger
3
Capítulo 2 Derivatives Stock Market
than the volume of clicks in the head. Our site defines categories by type and
area, allowing the click buyer, to manage his advertisement in a more precise way,
reaching the niches, as opposed to a massified advertisement. The more the access
to the niches, the more thickened the tail will be, shifting the business from the hits
to the niches.
Figura 2.2: The long-tail of Popularity Shifted.
It’s in this Long-Tail of Popularity that our stock market wishes to operate,
exploring a larger market completely ignored.
2.2. How to take advantage of the Crowdsourcing
The idea took his form, but imagine that thousands of sites would supply us their
log-statistics file. We would require a full-time team of people just to manage the
flow of information, and also require some form of validation for the data supplied.
Therefore, we chose as principal data supplier, Google Analytics the most popular
(and free) tool of site statistics analysis. Any site webmaster would only be required
to enter our e-mail ([email protected]) so we could receive a validated copy
of the number of clicks monthly produced.
The problem of validation solved, but still remained the management of the infor-
mation flow. This was our first obstacle. Initially the calculus was done using data,
that had to be manually imported, but soon we implemented a real-time solution.
4
2.3 The Stock Market for Popularity.
The objective was to make this stock-market as autonomous as possible. For that,
we used a recent web-technology, Ajax (a requester) that communicates with the
server in background to make the transactions simultaneously.
On the upload of the statistics file of a certain site, the mathematical calculus
are processed automatically and in real time, as long as we had previously assigned
a symbol to the security.
So we were able to build a mechanism that with the proper controls would work
in real-time and maintained autonomy, taking advantage of a recent concept which
is Crowdsourcing or collaborative work.
Eric Schmidt, Google’s CEO, as a comment on Don Tapscott book, Wikinomics:
How Mass Collaboration Changes Everything [7], says: “Wikinomics defends the
biggest change so far in collaborations-method. Thanks to the Internet, masses of
anonymous people, marginal to the traditional hierarquies, can innovate in content
production, goods and services.“
So we managed to transfer the weight of data management to the potential clicks-
sellers. Each site becomes responsible for the upload of the statistics files, trough
our webpage, receiving the Derivatives staff always a copy for future validation.
2.3. The Stock Market for Popularity.
The stock market for Popularity of Internet sites is hosted at the domain www.derivatives.com.pt
(Derivatives) and used statistical data from some web-sites graciously provide by the
company Enaco (www.enaco.pt).
Derivatives contemplates two types of users, those who have web-sites and wish
to sell clicks and those who don’t have websites and wish to buy/sell clicks, however
both type of users can buy/sell these securities.
After a simple registration, the user with sites identifies the type of site(s) he
owns (if it’s a commercial one, a blog, a discussion board or other) and in which
area it belongs to. Followed by a validation from the Derivatives staff to confirm the
type of site and to check if the html code supplied by Derivatives site is visualized
in the costumer’s site(s). For more details see Apendix C (Banners). Only after this
confirmation, the symbol is created, which starts the previously described process.
This html code main purpose is to allow a user, who owns a trading option over a
security, and wishes to execute it (after the expiration date), to automatically submit
the advertisement, for the corresponding number of clicks bought.
5
Capítulo 2 Derivatives Stock Market
When the number of clicks bought is reached, the Derivatives banner automati-
cally reappears.
2.4. Trade Security
The trading security, St, is defined as monthly average number of clicks of a site
times a cost per click (c.p.c = 0,01 euros).
On the expiration date for the security (28th day of each month), the monthly
average is calculated for each security and the corresponding transactions are exe-
cuted.
2.5. Stock Market Technical Specifications
Here we present Derivatives’s Stock Market Technical Specifications.
• Symbols
The option’s symbol is the same as the traded security.
• Stock and Options
Each option is with 100 clicks of the traded security (of the corresponding site).
• (Strike Price) Intervals
Increments of 2.5 euros up to the 25 euros.
Increments of 5 euros between 25 euros and 200 euros.
Increments of 10 euros between 200 euros and 300 euros.
Strike prices over 300 euros were not considered.
• (Strike Prices)
8 strike prices are calculated, 4 above the monthly average and 4 below.
A new set of options is created when the maximum and minimum of the strike
prices is reached.
• Expiration Date
The 28th of each month (this may change without prior notice).
• Exercise Style
Asian Style. The options can only be executed after the maturity.
6
2.6 The Black-Scholes Formula
• Delivery
Options are traded automatically traded after the maturity, through theDeriva-
tives banners.
• Payments
Payments should be made by electronic transfer to the bank acount XXXXXXXX:
Bank transfer (PT) - NIB XXXXXXXXXXXXXXXXXXXXX;
Bank (Rest of the World) - IBAN PTXXXXXXXXXXXXXXX;
or via Paypal.com (with a 1,5 euros tax penalty).
• Margins
Puts or Calls with 9 months or less have to be fully paid.
• Last Day for Trading
The 28th of each month was the day chosen for the Stock Market closing.
• Hours for trading
24 hours a day, 365 days per year.
2.6. The Black-Scholes Formula
The results obtained using the Black-Scholes formula differ from real life on account
of the model’s initial simplification. An important handicap of the Black-Scholes
models, is when the securities prices don’t follow a log-normal stationary process.
However, Black-Scholes is often used, as it’s easy to calculate and models very
well the relations between the variables.
Even without the constant volatility hypothesis, the results from the model are
very useful in practice and serve as a very good approximation, from which adjust-
ments can be made.
An option value on a certain instant t, given by the Black-Scholes formula, de-
pends on the time t, the security price, the maturity T , the Exercise Price E and
the volatility σ
C(t, S, T,E, σ). (2.1)
τ =T − basedate
365, (2.2)
7
Capítulo 2 Derivatives Stock Market
where basedate is the current date, with a fixed tax rate r = 0.02, we implemented
in php the calculus of the d1 and d2 given by:
d1 =ln(S/E) + (r + 0.5 ∗ σ2) ∗ τ
σ√τ
(2.3)
and
d2 = d1 − σ√τ . (2.4)
Afterwards, we calculate for the Call and Put options:
C = S ∗Normdist(d1)− e−rτ ∗ E ∗Normdist(d2), (2.5)
P = e−rτ ∗ E ∗Normdist(−d2)− S ∗Normdist(−d1). (2.6)
Being Normdist(x) [10] a numerical polynomial approximation for the Normal
distribution function (with 6 digits decimal precision), implemented in php code.
For more details check Appendix A (Used Symbols) and B (Used Formulas).
And, finally, when τ = 0, we calculate the final value of the Call and Put options:
max{S − It, 0} (2.7)
max{It − S, 0} (2.8)
For Calls and Puts respectively. Where It =∫ Tt Stdt.
2.7. Volatility Estimation
From all the previous parameters, the one that isn’t observable is the (annual) volatil-
ity σ of the active. And so, it has to be estimated. This estimation is obtained from
the historical data of the actives Time Series. So, for each new statistic file, the
average and the standard deviation, is calculated rendering the statistics graphics
also in real-time.
Given n + 1 consecutive observations S0,S1, ..., Sn of the financial active value,
their returns are calculated by:
ut =St − St−1
St−1. (2.9)
8
2.7 Volatility Estimation
Figura 2.3: Average and Standard Deviation Graphics.
It’s possible to estimate the average and the standard deviation of these returns:
u =1n
m∑i=1
(ui) (2.10)
and
S2 =
1m
m∑i=1
(ut−i − u)2. (2.11)
The previous quantities are used to define the volatility σ. We considered
σ ≈ S√∆t
.
Let V (∆S(t)) be the variance of ∆S(t) given by:
∆S(t) = S(t+ ∆t)− S(t). (2.12)
note that
V (∆S(t)) = σ2 ∗ S(t)2 ∗∆t (2.13)
On the hipothesis of S(t) being deterministic comes:
V (∆S(t)S(t)
) =1
S(t)2∗ V (∆t) =
1S(t)2
∗ σ2 ∗ S(t)2 ∗∆t = σ2 ∗∆t (2.14)
9
Capítulo 2 Derivatives Stock Market
so √V (
∆S(t)S(t)
) =√σ2 ∗∆t = σ ∗
√∆t. (2.15)
There for, the standard deviation of ∆S(t)S(t) is σ ∗
√∆t, so S ≈
√V (∆S(t)
S(t) ) =
σ ∗√
∆t.
Finally we reach the relation between the daily volatility σt and the annual volatil-
ity σ,
σt = σ√
∆t. (2.16)
Considering the square of the volatility σ2t , as being a simple moving average
with m squares of the daily standard deviation of the returns ui in relation to the
average u, in other words:
σ2t =
1m
m∑i=1
(ut−i − u)2 (2.17)
If the time is measure in years, and assuming 365 trading days, comes:
∆t =1
365= 0.04877 (2.18)
2.8. Total volume of options and it’s Distribution
As the quantities of the securities are in finite number, what would be the volume
of available options each site could generate?
The solution we used was to use the last 30 days average and to multiply this by
28 (minimum number of days any given month can have).
This value would supply an approximate total volume of option a certain site
could produce. This value would then be placed between the two closest strike
prices, and we would fixate 4 strike prices up and 4 down. If the maximum strike
price (300 euros) or the minimum strike price (2.5 euros) is reached, it will continue.
We decided to use a normal distribution for the options around this average
value, subtracting each strike price one by one, to the approximate total value until
it reaches a value inferior to 2.5 euros.
Consider the example of the Figure 2.4:
As an example, take an average monthly value of 8.3 euros (830 daily clicks).
The considered strike prices will be 4 up: 10 euros, 12.5 euros, 15 euros and 17.5
euros; and only 3 down: 7.5 euros, 5 euros and 2.5 euros (because there isn’t a strike
10
2.9 The Derivatives Auction System
Figura 2.4: Options Normal Distribution.
price lower than 2.5 euros). To the total volume 28× 8, 3 euros, we first subtract 10
euros, then 7,5 euros, again 10 euros, than again 7,5 euros, then 12,5 euros, then 5
euros until the remaining total value is lower than 2,5 euros.
We present in Appendix D the fluxogram of the developed algorithm.
2.9. The Derivatives Auction System
The calculus of the options value with various strike prices and respectively quan-
tities, for each site was implemented, reaching the final phase of the stock market:
the options trading.
In order for this implementation to be has real as possible, we had to include
various types of protections, we will only refer a few.
Besides allowing trading with real money, we allowed the use of virtual money,
where each user has an initial fixed plafond to allow in a controlled academic envi-
ronment, the study of buying behaviors and the creation of a league to determinate
daily top winners and top losers.
Also, a certain user cannot buy if he has no money, and whenever he buys this
amount of money is automatically updated.
11
Capítulo 2 Derivatives Stock Market
We considered 4 types trading actions: Buy, Sell, Buy Offer and don’t do
nothing (No Sell). We’ll explain this with an example:
On a first stage, suppose that a userA buys (Buy) 10 options Call EOL at 7,5
euros with expiretion date JUN (Call EOL 7,5 JUN). This quantity of available Calls
would have to change its status from open to closed, so that no other user could buy
them. This cost 10×7,5 euros=75 euros would then be subtracted to the amount of
the money userA would have.
Figura 2.5: User A buys (BUY).
On a second stage, userA has 3 available actions. First one: not to sell (No
Sell) and to execute his right to buy after the maturity (in this case in Jun). The
second action is: to sell (Sell) his 10 options CALL EOL at 8,3 euros, for example,
changing their status from closed to open being imediatly available for other users
who wish to buy. The third action could be placing a buy offer: (Buy Offer) for
options that aren’t available.
In the following figure, are some screenshots from Derivatives Site, where we
show the previous proceeding.
Broker, interface that controls all available actions for each user.
Portfolio History, history of all successful actions.
Buy Offers, list of all available buy offers.
My Buy Offers, list of all buy offers from the user.
My Buy Offers Delete, the deletion of a buy offer.
Stock Portfolio, the portfolio of available options, with the possibility of filtering
the search parameters.
Buy Options Call EOL, list of available EOL options and other information.
12
2.9 The Derivatives Auction System
Figura 2.6: User A don’t sell (No Sell)/ sells (Sell) / buys (BUY) from user B (Buy
Offer).
Figura 2.7: Broker.
13
Capítulo 2 Derivatives Stock Market
Figura 2.8: Portfolio History.
Figura 2.9: Buy Offers.
14
2.9 The Derivatives Auction System
Figura 2.10: My Buy Offers.
Figura 2.11: My Buy Offers Delete.
15
Capítulo 2 Derivatives Stock Market
Figura 2.12: Stock Portfolio.
Figura 2.13: Buy Options Call EOL.
16
2.9 The Derivatives Auction System
In this stock market, all option transaction rights pass from the site owners, to
the Derivatives site, after adding a 0.01 euros transaction cost (under revision!).
17
Capítulo 2 Derivatives Stock Market
18
Capítulo 3
Final Considerations
The markets lack of liquidity, might be a commercial problem, but not a academic
one. However it’s still an important indicator, because it allows us to infer a real
interest. We are very keen on using this platform as market research tool, and that’s
why we also allowed the use of virtual money.
With this thesis, we also provide two logins and two passwords for trading testing
purposes.
We hope that the adhesion is big and that the stock market Derivatives might
usufruct from the securities it wishes to explore: the Popularity!
19
20
Apêndice A
Used Symbols
cpc = 0.01 euros (cost per click)
St− Financial Active (number of daily clicks of a Internet site *cpc)
E− Exercise Price of the financial active
M− Maturity of the financial active
r = 0.02 (Tax rate without risk 0.02%)
∆t = 1365 (Assuming trading 365 days)
π = 4 ∗ arctan(1.0)
e = 2.71828182845904
γ = 0.2316419
k = 11+γx
a1 = 0.2316419
a2 = −0.356563782
a3 = 1.781477937
a4 = −1.821255978
a5 = 1.330274429
21
Apêndice A Used Symbols
22
Apêndice B
Used Formulas
ut = St−St−1
St−1(Return of the active between the day t and the day t− 1)
u = 1n
∑ut−i (Return Average)
σ =√
1m
∑mi=1(ut−i − u)2 (Annual Volatility of the financial Active)
σt = σ√
∆t (Daily Volatility)
τ = T−basedate365
d1 = ln(S/E)+(r+0.5∗σ2)∗τσ√τ
d2 = d1 − σ√τ
C = S ∗Normdist(d1)− e−rτ ∗ E ∗Normdist(d2) (Call Option Value)
P = S ∗Normdist(−d1)− e−rτ ∗ E ∗Normdist(−d2) (Put Option Value)
C(t, S, T,E, σ) (Call Option Value or Put Option Value and its parameters)
Cumulative Normal Distribution Function:
N(x) = 1√2π
∫ x−∞ e
− 12s2ds
Polynomial Function used to calculate Distribution Function of Normal Law:
(with 6 digits decimal precision)
Normdist(x) = 1−Normdist′(x)(a1k + a2k2 + a3k
3 + a4k4 + a5k5), x ≥ 0
Normdist(x) = 1−Normdist(−x), x ≤ 0
Normdist′(x) = 1√2πe−
x2
2
23
Apêndice B Used Formulas
24
Apêndice C
Banners
25
Apêndice C Banners
Figura C.1: Banner Sizes.
26
C.0 The Derivatives Auction System
Figura C.2: Banners.
27
Apêndice C Banners
28
Apêndice D
Fluxogram
29
Apêndice D Fluxogram
Figura D.1: Fluxograma.
30
Bibliografia
[1] C. Anderson. The Long Tail: Why the Future of Business Is Selling Less of More.
Hyperion, 2006.
[2] A. Butcher. Sams Teach Yourself MySQL in 21 Days. Sams, 2002.
[3] E. R. Harold and W. S. Means. XML in a Nutshell. O’Reilly, 2004.
[4] J.C. Hull. Options, Futures, and Other Derivatives. Prentice Hall, 2005.
[5] R. Lerdorf, K. Tatroe, and P. MacIntyre. Programming PHP. O’Reilly, 2003.
[6] W. Paul, S. Howison, and J. Dewynne. The Mathematics of Financial Deriva-
tives: A Student Introduction. Cambridge University Press, 1995.
[7] A. D. Tapscott, D.and Williams. Wikinomics: How Mass Collaboration Changes
Everything. Reed Business Information, 2008.
[8] M. E. Tyler and J. Ledford. Google Analytics. Wiley, 2006.
BiBTEX [?, 6, 4, 1, 2, 3, 5, 7, 8]
31