Professional Documents
Culture Documents
System Architecture
On picture 2.1 you can see how different components and packages are
interconnected. This is a UML diagram, big rectangles are packages, small rectangles
inside them are modules. Puncture lines show how packages and modules are
connected.
and Engine) that works with graphics, sound, physics and user input. T is used
in game and simulation development and other projects that require 3D
Graphics.
most popular scripting systems for Delphi. It helps make the system flexible
and convenient.
allocate and free memory more effectively. It also detects memory leaks and
access violations.
Application Specific – all those components that were created specially for the
«Financial Market Simulation» project, but were separated from the main
application to be able to use them in future projects.
On picture 2.2 you can see how different classes are interconnected inside the
FMSWorld module. Main class in the diagram is TFMSWorld, all other classes
represent various world settings, classificators and time.
Trader (TFMTrader) – Buys and sells market shares via his broker, his
actions are based upon his current active strategy.
Broker (TFMSBroker) – Acts as a link between a market and a trader. Broker
receives buy/sell requests from traders, processes them, and either makes the deal
using its own shares, either redirects them to the market.
Transactions play a crucial role in the system. In order to succeed, there need
to be two transaction requests (orders) on this share with the same price. Of course,
one request should be a sell order and the other – a buy order.
1. Trader
sends a
request to a 2. Broker processes his request
broker and either completes it himself,
or sends it to the share market
4. Broker receives a
reply from the market
and redirects it to the
trader
Transaction requests can be sent from any market participant, but the most
popular route is shown on picture 2.5:
1. Trader uses his currently selected strategy to think, makes a decision and sends
a transaction request to the broker.
2. Broker processes his request and either rejects it (not enough money on the
account), or completes it himself, or sends it to the share market.
3. Market finds matching requests and commits transactions. Each order has a
certain life time. If it hasn’t been completed during this time, it is returned to
the sender with a “failed” tag.
4. Broker receives a reply from the market and redirects it to the trader
5. Trader analyzes this information and makes conclusions based on his strategy.
As you can see, all economic parameters including share prices and trade
volumes are calculated without using special statistical formulas, mathematical
models or random number generators. They are based only on the information about
the transactions that agents make on the virtual market.
Part III. Experiments with the virtual market
You can find detailed manual inside the package of the program. In this section
I will only describe the basics. On picture 3.1 you can see a screenshot of the
program. It displays all types of editors and unities that are available to the end-user.
1) The ratio of share type, broker and trader numbers on the market.
2) Visual similarity of the trend.
3) Share price patterns: head and shoulders, topping patterns, etc.
During the coarse of my research I will compare virtual and real markets based
on these criteria and make a conclusion whether the virtual market is adequate.
I needed to compare the virtual and the real market. So first I decided to
analyze the Russian stock market. I compared average, maximum, minimum, open,
close prices and trader volumes for companies RAO EES, UCOS and Kamaz during
different time periods: from one month to three years. Companies are very different
which in some way guaranteed that I will be able to find criteria that are similar to all
of them. Share prices of RAO EES were very stable all the time, UCOS’s and
Kamaz’s shares were in some periods quite unstable.
It’s quite obvious that such parameters as average, dispersion and covariation
were completely different in these cases. The only parameter that was almost the
same is share price distribution (picture 3.2). It has a noticeable peak in the middle
that can be closer to one or the other edge. The peak can also lean to the right side, so
this side can appear edgier then the left side. I also noticed that the less elements in
the input array, the lower the peak (picture 3.3).
Note: in this work when I speak about share price or volume distribution, I
actually mean the distribution of changes. So for every input array X which has N
elements I create a new array Y that has (N-1) elements. In this new array for every
element index “i” (0 < i < n – 1) I put values (x[i + 1] – x[i]). And after that I find the
distribution of the new array Y. This is a standard way to analyze stock and FOREX
markets. Sometimes every element of the resulting array is also run through a log()
function, but that does not change how the array visually looks, only the values. So I
won’t be doing it in this work.
Distribution chart looks almost the same for prices as well as trade volumes, so
I will be paying a lot of attention to it during this research. Note, that I will only
analyze its appearance, so my opinion will be subjective.
At first we need to determine the initial parameters of the system. You can
view them in table 3.1 (is market data is based on the New-York and Thailand stock
markets.
In a virtual market each trader can own 0 to 2 share portfolios, each one costs 2
to 4 thousand dollars. Also everybody can have 2 to 7 thousand dollars on their
broker’s account. Also a trader has 500 to 5000 dollars on his own account, which
can be used in extreme circumstances.
The choice of initial parameters of a virtual market makes sure that the virtual
market is a reduced copy of an average real market. This in some way guarantees that
virtual market will behave similar to the real market during the experiments.
Table 3.1
On picture 3.8 we can see how minimal, maximum and average price changed.
At first the price rises, then falls at about the same rate. In the end it rises again. So in
general the price behaves just like we expected, i.e. it follows the fundamental price.
But the changes in market price were less than changes in fundamental price. Market
price turned out to be more predictable and stable than the real value of companies.
This may be how things really are in real markets too, despite the common belief that
company values tend to be constant and prices jump up and down because of major
traders’ games. Also this fact can have a simpler explanation: market-makers don’t do
their job too good and can’t update share prices fast enough. Also the virtual market
consists of about 15% newbie traders that don’t care at what price they will buy or
sell shares.
Picture 3.9. Last transaction price and fundamental price change
in the «FundamentalTraders.fms» scenario
On picture 3.9 you can see both last transaction price and fundamental price
change (placed on the same chart to make the spread more clear). You can see how
the spread dramatically decreases after fundamental price became less than market
price. As soon as fundamental price became more than the market price, spread again
increased. This phenomenon is caused by the absence of short orders in the system.
In the real market tradercan and most likely will loan shares from the broker,
promising to buy them back if he is sure that their price will fall. He sells these shares
at a current high price, waits some time and buys them back at a lower price thus
making profit. As you can see on the real market traders can influence market price
changes even if the price is going down.
Currently, the developed system does not support short orders, so the only way
traders can influence drop of share price is to just stop buying it. As you can see, this
mechanism is not working too well: share price is lowering not as fast is it was rising.
I believe this is the fault of market-maker traders; their algorithm of “thinking” is not
flexible enough. Я это считаю недостатком, прежде всего, алгоритма работы
маркет-мейкеров.
Share price distribution (picture 3.10) is very close to distributions on the real
markets. Only the average price distribution has a rather low peak value. Not sure
what could have caused it. Also the last transaction price has a very high peak. It may
have been caused by high spread value or a very high number of transactions (around
1000). It’s a well known fact – the longer the initial array, the higher peak on it’s
distribution. Almost flat distribution of fundamental price is an expected result,
because it is generated from company’s assets, which change based on a simple
algorithm that uses the standard Delphi random number generator.
Picture 3.11. Change of trade volume
in the «FundamentalTraders.fms» scenario
On the trade volume chart (picture 3.11) everything is like expected. It starts at
a rather high level, because the fundamental price begins to grow quickly and all
traders start buying them at once. This trend slows down and close to the middle you
can see a peak – all fundamental traders try to get rid of overpriced share at once.
Then the trade volume is quite low, because no one wants to invest in this share.
Closer to the end, the share again becomes attractive and at this point we can see the
biggest peak of trade volume – all traders want to invest in it. The chart of
distribution of trade volume (picture3.12) is ideal – just like on real markets, so I
don’t have any comments to add about it.
Picture 3.12. Distribution of trade volume
in the «FundamentalTraders.fms» scenario
The most interesting part in this experiment to me is that the fundamental price
could have been any value. We could take short-term assets and debt into account like
traders do during fundamental analysis, or we could just randomly guess it. The main
conclusion of this experiment is that if all traders believe that company costs some
amount of money – it’s shares eventually will cost that amount. So the real market
price of shares always follows traders’ expectations with a certain time gap.
Also you can notice that the spread is too big compared to real market
(pictures 3.7, 3.8). I believe it is due to the small relative number of market makers or
a fault of their algorithm of thinking. In any way, this problem theoretically can be
fixed during further development of the application. It does not prove that the system
is inadequate, but rather not tuned correctly.