• No results found

Group decision making in the Internet A Case of Social Finance platform using Agent-Based Modelling and Simulation

N/A
N/A
Protected

Academic year: 2021

Share "Group decision making in the Internet A Case of Social Finance platform using Agent-Based Modelling and Simulation"

Copied!
44
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

Janusz Kukla (10890017)

20-08-2015

MSc. Information Studies – Business Information Systems University of Amsterdam

Master Thesis

Group decision making

in the Internet

(2)

Page 1

Introduction

In 1965, George F. Moore introduced his famous “Moore’s Law” which forecasted that the number of components found on a single silicon chip would double each year (Moore, 1998). Even though he had to revise his law a decade later changing the doubling period from a year to two years (Moore, 1975), the computing hardware industry has been following that law ever since. Its impact on the world that surrounds us is clearly visible as the technology is affecting more and more parts of our lives. And since according to the “Moore’s Law”, the costs of additional components are increasing on the order of magnitude slower than the number of those components (Moore, 1975), the electronic devices have become available to masses on a large scale. What is more, it is estimated by International Telecommunication Union (ITU) that by the end of year 2015 the number of Internet users will have reached the 3.2 billion (ITU Telecommunication Development Bureau, 2015). It means that not only does technology affect more parts of our lives, but it also has the power to do so on an even greater scale than ever, whether we like it or not.

When at work, people spend great amount of time in meetings whose main purpose is to make a group decision on a given subject (Romano Jr & Nunamaker Jr, 2001). As people tend to spend most of the time during the day at work (Bureau of Labor Statistics, 2015) it is natural to expect technology has affected the way people conduct meetings as well as make group decisions. However, at work it is more likely for people to know other meeting members or at least quickly judge them and establish their position and power in the meeting (Kiesler & Lee, 1992). Unlike at work, in the technologically advanced world where people engage socially via Internet it is often that an individual may end up as a part of a team of strangers. Usually motivated to cooperate by having the same goals and scarce means to achieve them.

Working out the group decision when group members do not physically meet and do not possess any knowledge must be a different process and according to Kiesler & Lee (1992) it actually differs in case of decision making inside the company, but they also pointed out important issues which such a decision making process brought to their attention. Although, the decision making process inside companies has been in a spotlight of social scientists as the natural evolution of business in the light of ICT advancements it is quite vital to further research the field that has emerged as a result of development in social networking – Group Decision Making (GDM) in the Internet social setting.

(3)

Page 2

The need to research that area arose during author’s own design process of the “Trading system for packages of financial instruments” (Kukla, 2014). The purpose of the system is to empower people to gather in groups in order to buy portfolios of financial instruments. The GDM problem in that Internet social setting occurs when members of the group have to make management decisions regarding the portfolio owned by them – namely, selling current or buying new financial instruments.

The following master thesis is trying to investigate which of the GDM models would help investors reach best outcomes out of their group investments. In order to conduct such an investigation on the system that remains a theoretical model at the time of writing this master thesis, computer simulation techniques are employed to obtain vital insights. The mindset of Agent-Based Modelling is used as the simulation. Moreover, as the hereto undertaken research is exploratory, during its course efforts have been made to determine directions in which further developments could be made in order to deepen the knowledge of the subject.

The text consists of 5 chapters. Chapter 1 is the literature review of the GDM models. In the following chapter (Chapter 2) the GDM case is introduced and the research question is firmly stated. Next chapter, Chapter 3, focuses on the method – Agent-Based Modelling / Simulation – as well as on the development process of the simulator used to obtain relevant results. Then, the results are presented in the Chapter 4 and discussion is held in Chapter 5 which also contains the part on further development of the given field.

1. Chapter 1: Group Decision Making models

Over the years researchers in the field of management as well as psychology had developed many theories on group decision making. Ranging from the formal procedures for decision-making in groups to group composition, to different decision support systems.

When it comes to procedures, or else known as decision rules, the most frequently adopted one is the rule of majority in which the alternative supported by the majority of members is chosen. The reason why majority is so popular is partly because it offers all of the group members the ability to share their own beliefs during the decision-making process, not holding back as the consensus seeking process would require. And partly due to the easiness of handling such a group-decision process. According to Hastie and Kameda (2005) the majority rule is popular across

(4)

Page 3 multitude of different groups ranging from tribal societies to ad hoc Western groups. It is worth noticing that there are numerous variations of majoritarian rules. From that subset of rules clearly stand out two of them - the Condorcet majority and majority-plurality. The Condorcet majority mainly differs from majority-plurality rule in case of multiple alternatives votes in which the majority votes are being held among all the possible pairs of alternatives and the final winning alternative is chosen as the one that wins all the pairwise votes (Bolland, 1989).

This may lead to a situation in which under Condorcet majority the winning alternative does not exist. Arrow (1963) explains why there may be no winning alternative using the example in which in a group the first individual prefers A to B and B to C, second individual prefers B to C and C to A, and third individual prefers C to A and A to B. It would be possible to say that all three members prefer A to B and B to C, but deriving from that that they prefer A to C would be wrong as most of them prefer C to A. Such group-decision making under Condorcet majority rule would end up in a cycle in which picking the winning alternative is impossible.

Unlike Condorcet majority, the majority-plurality’s winner is the alternative that raises the most votes for in a single voting rather than in a set of alternatives’ pairs. It is easy to spot that the Condorcet majority rule and majority-plurality both pick the same winning alternative in case of double-element alternatives’ set.

The majority-plurality rule is the example of simple majority. It means that the alternative that gets most votes during the voting process is chosen, but there are also different types of majority votes, for example: supermajority or unanimity. Supermajority is the rule often found in constitution agreements in democratic parties regarding the amendments to said agreements. Supermajority differs from the above introduced rules in that it requires more than 50% of votes in favor for the alternative to become winning (Holden, 2004). The prominent example is appointment of a federal judge in United States in case of which the majority of 60% in Senate is required. However, the supermajority requirements may differ quite substantially from one another and are described by the decision-makers beforehand or are set by the law (Holden, 2004). The special case of the supermajority is unanimity. Unanimity is when the 100% of votes in favor of an alternative is required. According to research done by Miller (1985) it is harder to reach the final decision under unanimity than supermajority – in his case the 2/3 majority reached the final decision every single time while under unanimity they failed in 21% of the cases.

(5)

Page 4

Undoubtedly, the abovementioned rules for GDM are the ones that are most widely used in a large variety of decision-making processes, ranging from the given example of federal judge appointment to presidential elections. However, there is a number of other rules which have been gathered by previous researchers of the subject area. Scandurra et al. (1986) focus on the group-decision model with the clear leader role. They point autocratic group-decision, minimal group-decision involvement, consultation, collaboration and delegation. However, as this classification focuses on the manager-member dynamic it emphasizes the flow of information in the group rather than the decision process itself which is of less importance in the hereto undertaken research.

On the other hand, the list of group decision rules formed by Hastie and Kameda (2005) reveals the most important ones. Naturally it contains Condorcet majority and plurality, but apart from that the most important are: average/median winner – individuals assign the value of each alternative, and the group computes average/mean value of all alternatives and chooses the highest average/mean alternative; best member rule – individual that achieved best results so far is selected and makes the decision for the whole group; random member rule – random individual is selected and he/she makes the decision for the group; group satisficing rule – the alternatives are considered in random order and the first alternative on which all the group members agree becomes the final decision.

The research in the field of group decision-making, decision rules, decision-making schemes or procedures, and similar, is still ongoing and rapidly developing as the technology enables novelties to be introduced. However, the provided review should be treated as sufficient as it investigates recognizable methods, known and common to the potential users. What is more, simulation and case restrictions (introduced in the following chapters) would make it impossible to probe them in the testing environment.

(6)

Page 5

2. Chapter 2: The Group Decision Making Case and Research Question

2.1. The GDM Case

For the purpose of this research the case has been carefully prepared in order to initially investigate the topic of group decision making in the Internet social setting. It is founded on the case that was presented in the introduction and originates from the design for “Trading system for packages of financial instruments” (Kukla, 2014).

The abovementioned system was designed in order to empower individuals to diversify their investment portfolio. As the ability of young individuals to diversify is highly diminished as their savings and earnings combined do not allow them to own a variety of financial products. One could argue that these needs may be satisfied by the investment funds, but investment funds offer less flexibility when it comes to the composition of the instruments inside them. Namely, there is a limited number of investment funds which do not contain all the possible combinations of financial instruments. Moreover, investment funds are managed by other financial institutions and single unit owner does not possess any ability to influence the ratio of said instruments inside the portfolio or decide to invest in new ones.

The designed system basic and most important term is the “package of financial instruments” (PFI). Users are able to create, advertise and trade said PFIs. In its foundation single PFI is mostly similar to the micro investment fund created by the system’s user, but managed by all the users that decided to become a part of group buying the said PFI. As in investment funds, financial instruments are bought by the system’s owner rather than by users themselves. Users buy only units which give them rights to the profits made by the PFI. Moreover, users can further trade their units of PFIs in order to end the investment or extend overall investment portfolio. The example of creation process and later division is shown in Figure 1.

PFI

XXX Company s shares

YYY Company s shares ZZZ Company s shares U se r 1 . U se r 2 . U se r 3 . U se r 4 . U se r 5 . U se r 6 .

(7)

Page 6

Package of financial instruments is first created by the user – in the initial design version it is only created out of shares traded on stock exchange markets – in the next step the user is advertising his/her PFI in order to find other users who would like to make a similar investment. When the capital needed to buy the financial instruments of which the PFI is built is secured – the needed capital is raised among the users who decided to invest in said PFI – the financial instruments are bought automatically by the platform as long as the buy limits are satisfied. It is possible to say in terms of PFIs that they all follow a specific lifecycle (Figure 2.).

START Creation of PFI by user Offering of PFI to other users Capital raised.

Decision to buy YES

Buying process for PFI NO Withdraw the offering of PFI Incomes/losses END

Figure 2. PFI lifecycle

The GDM problem arises when the users in the given group bounded by the shared ownership of PFI start to manage said PFI. Common purpose of all users should be to maximize their return on investment. It means that there will (or may) be moments in which a single group member could want to sell shares of a given company if his/her forecasts/analysis/gut feeling told

(8)

Page 7 him/her that the position was going to drop in its value. That is the exact moment in which he or she could either decide to sell the position, or call for a vote, or do absolutely nothing if not given authority to act beforehand. If there is a need to raise 2/3 of the votes or the decision has to be made by a designated manager picked out of the group members, the method in which that decision will be made will undoubtedly affect it.

2.2. Research question

It is vital to clearly understand what questions the following research is trying to answer. The attempts have already been made to name the method that is returning the best results when it comes to making decisions (Hastie & Kameda, 2005), but it remains unclear if the same method could be applied for decision making in a setting introduced in the case above. The setting in which the members of the group do not know each other and have limited communication.

This paper is addressing the following main question – is there any group decision method for a group of strangers on the Internet that generates the best outcomes? However, this is exploratory research into the area and results should be treated as clues for further scientific investigations.

(9)

Page 8

3. Chapter 3: Method

3.1. Agent-based modelling and simulation

The problem at hand required to employ a method that would allow for the different decision-making schemes to be tested in the given environment. Since the system does not actually exist and the research here undertaken is considered exploratory, the method to facilitate it had to be able to cope with those restrictions.

The method that has been given more credit lately – still insufficient amount according to Richiardi et al. (2006) – is agent-based modelling and simulation (ABMS). ABMS is in words of Macal and North (2010) an “approach to modelling systems composed of autonomous, interacting agents”. They also emphasize that it is still considered a new approach, but it’s clear that more and more attention is given to it as the topic gained a lot of time during conferences on simulation. Moreover, even independent conferences on agent-based modelling are now being held.

It is clear that agent-based modelling and simulation, in the age of ever growing computational power of nowadays computers, is becoming more common and better understood. What is more, not only practitioners focus on it, but a variety of papers focusing on different aspects of this discipline show that it is scientifically a proven and developed method (Macal & North, 2010). In their article, Farmer and Foley (2009), even suggest that ABMS is the right – and better – solution for policy makers as it does not need assumptions about perfect world nor create forecasts which will stay true as long as the forecast environment remains rather unchanged. The sheer potential is uncovered when the number of areas in which ABMS was already employed is revealed by Macal and North (2010) – they named the following: modelling agent behavior in the stock market, modelling supply chains, epidemics spreading, modelling of adaptive immune system, understanding consumer purchasing behavior and even understanding the fall of ancient civilizations and modelling engagement of forces on the battlefield. Not only is ABMS becoming a recognized research tool, but it also seems to be an extremely universal tool which has already been proved its usefulness already in a large variety of disciplines.

What makes agent-based modelling so useful and entrenching to researchers comes from the fact that it is relatively easy to translate real life problems into the simulation process. There is no need to employ the sophisticated quantitative models and formulas. The simulation is built from

(10)

Page 9 the ground up – from the smallest part of the process, agent, to the complex, often artificially evolving, interconnected systems (Janssen, 2005).

Why exactly was this method chosen to the research at hand? It is because ABMS allows to quite easily transfer the problem at hand – decision-making among group members in a given case – straight into an actual simulation. It is extremely important to stress at that point that, although ABMS allows to translate the problem into investigative simulation, providing valuable insight into the research, it does require to introduce a number of simplifications – which will be explained when introduced.

3.2. Simulator

The ABMS method requires the researcher to create the adequate simulation environment. For the purpose of the research at hand the decision has been made to develop the simulator from the ground up. The idea behind that decision was to use the initial simulator to let other researchers develop further research using it. On top of such simulators new ideas can be tested. Moreover, the ability to look into the code itself gives the readers an opportunity to better understand simulation process. The simulator’s code can be found in Appendix 1.

The simulator has been written in the Python programming language (version 3.4) with the additional packages:

‘os’ – allowing to interact with the computer’s operating system, ‘datetime’ – time and date manipulation package,

‘csv’ – manipulation functions for Comma-Separated Values files,

‘numpy’ – scientific computing for Python, contains important array objects, ‘pandas’ – statistics package, contains TimeSeries objects,

‘random’ – contains a random number generator.

It was developed in Microsoft® Visual Studio 2013 with addition of PyTools – the suite that empowers python programming in Visual Studio – running on top of the Windows 8.1 Pro 64-bit operating system. The computer on which the simulator was running was equipped with Intel® Core™ i7-2630QM CPU. Further specifications of workstation are considered irrelevant for the future developments of the simulator’s code and therefore omitted in here.

(11)

Page 10

The simulator is built on top of three main classes, namely ‘Agent’, ‘Horizon’, and

‘Simulation’. The ‘Horizon’ class represents the time horizon. It contains the time horizon to which

the given Agent will have the vision of the future. Put simply, if the Agent’s time horizon is set to 30 days, 20 minutes and 10 seconds, it will be able to forecast to some extent the stock market fluctuations from the given point in time into the future of 30 days, 20 minutes and 10 seconds.

‘Horizon’ class initialize function takes as arguments days, hours and minutes. The time horizon is

shown in Figure 3.

2015-01-012015-01-04 2015-01-11 2015-01-18 2015-01-25 2015-02-01 2015-02-08 2015-02-15 2015-02-22 2015-03-01 2015-01-02 - 2015-02-01

Time horizon of 30 days, 20 minutes and 10 seconds 2015-01-02

Present

2015-02-01

Point to which Agent can predict future

Figure 3. Explanation of Horizon

The ‘Agent’ class contains Agent properties which are later used in the simulation itself. At the initialization stage the Agent experience is passed as an argument. There are 3 types of the experience that could be assigned to the Agent – PRO, SEMI and NEW – they mean respectively that the Agent (investor) is a professional investor, semi-professional or a non-specialized, but experienced investor, or a complete newcomer to the world of financial investments. The type of the Agent impacts the ranges of further properties of the given Agent. Those other properties are as follows:

horizon – each Agent has the instance of ‘Horizon’ class assigned to it in order to define its forecasting abilities;

randomizer – the random generator object is assigned to each Agent in order to diversify the outcomes of the random generator. Every single randomizer is seeded on its own when the object of ‘Agent’ class is created;

visionOfTheFuture – this property describes to what extent the Agent trusts its judgment about the future and how it affects the final decision made by a single Agent;

gutFeeling – this property describes to what extent the Agent trusts its so-called gut-feeling about the future and how it affects the final decision made by a single Agent;

(12)

Page 11 Instances of ‘Agent’ class are created during the initialization of ‘Simulation’ class and each of them represents a single Agent in the ABMS. The Agents are interacting with each other over the course of the simulation.

The final class, and the one that encapsulates all the others, is the ‘Simulation’ class. It contains the properties of the simulation as well as the set of the instructions to calculate the outcome of each type of GDM models tested in that simulation. The properties are as follows:

name – each of the simulations is has its name which is then used to distinguish the simulations among themselves;

randomizer – as in the case of ‘Agent’ class, each of the ‘Simulation’ objects contains random object that is used to provide randomly generated values and be reseeded without affecting other randomly generated values in the different objects;

startDate – the date in which the simulated process starts, namely, the beginning of the shared investment in the PFI;

endDate – the date in which the simulated process ends, namely, the end of the shared investment in the PFI;

numberOfAgents – the number of Agents involved in the simulated process;

agents – not a property, but contains all the ‘Agent’ objects and their properties;

numberOfTickers – the number of different financial instruments in the PFI that is being used for the simulated process. In the case brought here, it is the number of different shares in the PFI;

tickers – like agents it is not a property, but it contains the list of the tickers’ names used in the simulated process;

Each instance of the ‘Simulation’ class is used to conduct the simulation in which all the different GDM models are tested. At first, each of the instances of ‘Agent’ class are initialized with random types of investor (PRO, SEMI, NEW). After the Agents are initialized, the tickers are chosen to comprise the PFI.

The ‘Simulation’ class contains a method execute() which is called in the main class of simulator. This method is what changes ‘Simulation’ object into an actual simulation. When called for each moment – the tickers are quoted in the 15 minutes intervals – the vision of the future

(13)

Page 12

(VOTF) for each Agent and each ticker is calculated by the method. VOTF takes value 1 when in the time horizon Ti+time horizon (‘Horizon’ object assigned to given Agent) the given ticker’s quote

does not exceed or match the quote set in the time Ti, or value 0 in case it does. To better understand

it Figure 4. shows two cases, in case A the VOTF is 1 and in case B it takes 0 as a value.

06.01.2015 Time horizon begins

Price = 15

17.01.2015 Time horizon ends

Price never exceeds or reach same level (Price < 15)

06.01.2015 Time horizon begins

Price = 15

17.01.2015 Time horizon ends

Price exceeds value on 12.01.2015

Figure 4. Vision of the Future (VOTF) explained

VOTF is later multiplied by the visionOfTheFuture value from the Agent’s properties which reflects that different Agents put different levels of faith in their judgement. VOTF idea is a type

(14)

Page 13 of the simplification which has been mentioned above and which had to be introduced to optimize the simulator in order to conduct the simulations with scarce computing power. In the real life case, the investors use the means of technical analysis or fundamental analysis to predict the future value of shares. Implementing the VOTF idea by means of rolling maximum allowed for the quicker computation using built-in pandas matrix operations rather than by implementing complicated technical analysis algorithms to predict the future. One could rightfully argue that this may distort the whole simulation problem, but it is vital to remember that the main scope of the research is to investigate group decisions, not individual’s. The VOTF idea was therefore introduced to differentiate a professional investor from a new one, as the professionals tend to assess the future more precisely.

Simultaneously to VOTF, the gut-feeling variable is calculated. For each of the Agents in each moment in time and for each ticker there is a variable gut-feeling which takes as value 1 if the Agent has the feeling that the ticker’s position is not going to increase, and 0 if the Agent predicts otherwise. As in the case of VOTF, there is an Agent’s property which determines for each Agent to what extent it takes its gut-feeling into account.

The VOTF and gut-feeling adds up to become a probability of making by a given Agent, in the given moment of time and regarding given ticker, the positive decision to sell the ticker’s position. After combining gut-feeling and VOTF a random number is generated and if it falls into their combined value it means that at that specific moment the Agent wants to sell the position or would want to do so if the call for a vote were made at that moment.

With now created individual decisions it is possible to start to simulate group decisions. Being able to store all the previously computed individual decisions it is possible to quickly answer the question when the ½ majority has occurred or when the given person (call it leader) decides that the position is to be sold. At this place another simplification occurs. As it is hard to implement the time sensitive and statistically viable time of day when user would interact with the computer and would be able to make a decision to sell the position or call for a vote, the additional variable was added which takes 1 when such a moment could occur, or 0 if not. Those moments are generated using the random algorithm.

Most of the properties’ values are randomly generated to increase the heterogeneity of Agents, but to make it possible to draw any conclusions it is vital to put those values in certain

(15)

Page 14

limits. The limits for all the objects and procedures that occur in the simulator are set as a number of global variables at the beginning of the simulator’s code.

The first of global variables are focused on the number of agents involved in the simulation – the MIN_AGENTS and MAX_AGENTS set the limit. The variable MINIMAL_NUMBER_OF_TICKERS limits the simulation to the least number of tickers that has to be involved in the simulation. Note that there is no limit on maximum number of tickers as this was set by the data input – the maximum number of tickers is equal to the number of tickers file in the simulator’s file repository (stored in the global variable NUMBER_OF_TICKERS). Next global variables are associated with the time and they limit the earliest start of the simulated process as well as end (START_DATE, END_DATE and DURATION).

The second group of global variables limits the Agent’s properties. All of those variables specifies limits for each type of Agents – PRO, SEMI and NEW. The first is agentsHorizon which sets the minimal and maximal possible length of the given Agent’s horizon. The

agentsVisionOfFuture and agentsGutFeeling limits the values of respective properties in the

instances of ‘Agent’ class.

The reason to use global variables is driven by the experimental nature of the research at hand. It does allow the researcher to quickly change the environment of the simulation. What is more, it allows one to point out the properties of the simulation explicitly which makes the whole research process more transparent. It is important to understand the impact of the manipulation with global variables on the simulated processes.

During the execute() method the perfect outcome is calculated – the maximum return from the investment possible to achieve – to be used as a benchmark for other GDM models tested.

For convenience the simulator is equipped with reporting functions which shall be used for debugging or to reach a greater insight into how the simulator works.

To sum up, in Figure 5. the algorithm is presented as the diagram which provides the overview of the sub processes that create the whole simulator as well as the logic in which the results are generated.

(16)

Page 15 START Preparing simulation Creating Agents, Time Horizons Simulating Calculate individual decision Reading stock data from files Calculate group decision NO

Has the number of simulations been reached? Increase the number of finished simulations and store outcome in memory YES

Prepare data for saving Selecting tickers Save the outcomes of simulations END

Figure 5. Simulator's algorithm flowchart

The most vital step of the algorithm is the “Simulating” which has been divided into two threads, however, they cannot be executed simultaneously. The first one – calculating individual decisions – consists of the set of instructions that create the pandas DataFrame object which for the single Agent stores following information:

priceMAX_{num} – the maximum price of the given stock seen by the Agent of number {num} in the horizon set for that Agent;

priceMAX_{num}_bool – takes value 1 if the priceMAX_{num} is smaller than price (if the price of the stock viewed in the Agent’s horizon is not going to exceed the price at the moment), 0 if not;

(17)

Page 16

gutFeeling – random variable which says if Agent will take in that moment into account his/her gut feeling;

POSD – probability of sell decision for the Agent in the given moment. POSD equals

gutFeeling multiplied by gutFeeling property of the Agent (introduced above) plus priceMAX_{num}_bool multiplied by visionOfFuture property of the Agent;

finalDecision_{num} – contains the final decision of Agent {num} in the given moment. It equals 1 if the random generated value (values generated are between [0;1]) is smaller than POSD, and 0 if not.

Having created such a DataFrame object, it is possible to quickly look for the moments in which the criteria set by the given GDM rule are satisfied. This is where the second thread of “Simulating” takes place – calculating group decisions. For example, to calculate when the decision is made to sell the stock in case of ½ majority the sub DataFrame object is found that satisfies the following criteria that the sum of finalDecision_{num} must be greater than the number of Agents in the simulation divided by 2. Similar applies for every majority rule. The exception falls for single Agent decisions in case of which the first occurrence of their corresponding finalDecision_{num} set to 1 and the simplified definition of moments when the user is in front of computer (mentioned above), is taken under consideration.

3.3. Data

The data used for the purpose of the research contains the shares quotes from the Warsaw Stock

Exchange (WSE) from the index known as Warszawski Indeks Giełdowy 20 (WIG20) which

consist of the top 20 largest companies listed on WSE. The intraday quotes for WIG20 listings was provided by the Bank Ochrony Środwiska SA (BOSSA). The files format was PRN format which follows the CSV format. The format of data is MetaStock, which means that each of the quotes is reported by the number of columns describing it, inter alia: the ticker name, date, time, open, high, low, close and volume. The oldest data originates from 17th of November, 2000 for PEKAO and KGHM and the latest quotes for all of the tickers are dated 15th of April, 2015.

Tickers from the WIG20 were chosen as they have the most dynamic value changes as the volume tends to be higher than other listed shares. The companies which are included in WIG20

(18)

Page 17 are listed in the Table 1. along with their market capitalization value and percentage share in the volume.

No Ticker Market cap (PLN) Market cap (EUR) Share in volume during the session (%) 1 PKOBP 24 587 191 310 5 930 239 305 9,60 2 PKNORLEN 23 907 045 760 5 766 193 488 15,98 3 PZU 23 338 239 000 5 629 001 722 8,18 4 PEKAO 20 300 660 000 4 896 361 293 8,12 5 PGE 13 740 875 140 3 314 192 207 2,56 6 KGHM 12 372 387 000 2 984 123 512 20,35 7 PGNIG 10 176 762 500 2 454 555 960 2,78 8 LPP 9 720 400 000 2 344 484 875 2,00 9 BZWBK 8 589 899 000 2 071 816 827 3,17 10 ORANGEPL 5 217 697 420 1 258 468 034 1,07 11 CYFRPLSAT 4 930 441 000 1 189 184 020 0,69 12 MBANK 4 655 519 700 1 122 875 141 1,14 13 ALIOR 4 563 892 600 1 100 775 397 1,51 14 ASSECOPOL 4 304 730 820 1 038 267 592 0,69 15 ENERGA 4 014 800 000 968 338 533 0,52 16 TAURONPE 3 913 462 500 943 896 716 0,48 17 EUROCASH 3 286 536 500 792 687 041 3,19 18 ENEA 3 106 271 780 749 208 593 0,37 19 SYNTHOS 2 369 211 300 571 435 338 0,42 20 BOGDANKA 1 883 299 810 454 237 266 0,53 188 979 323 140,00 45 580 342 860,19 83,35

Table 1. WIG20 companies. Source: own work based on GPW.pl, 23.07.2015

The MetaStock files were reworked in order to decrease the size of the files and therefore decrease the read speed of the simulator. Resulting files contained only the DateTime object (easily recognized by the pandas’ DataFrame object’s built-in read method) and open quoted price for the given time slot. What is more, the data was resampled into 15 minutes time intervals in order to further decrease the size of the files and to affect the speed of calculating individual decisions as well as group one in the simulator’s body. The abovementioned treatment of data allowed the reduction of input data from slightly over 1 GB to 132 MB.

(19)

Page 18

Sadly, the data file for ASSECOPOL came corrupted and turned out to be impossible to read. As the reported issue was not solved in timely manner from the provider’s side, the research had to be conducted on 19 other quote data.

Table 2. shows the first dates of stock quotes for each of the tickers used later in the simulations. It is visible that the dates widely differ from one another, therefore there was no point in plotting all of the quotes on one diagram as it would not provide any insight in what the data looked like. However, in the Appendix 2. to this thesis, the plot for each of the tickers is provided.

The analysis of the data, showed that in the years following the global financial crisis all of the tickers tend to increase in their value over time. However, first impacts of the financial crisis are visible as early as in 2007, and are connected to the real estate crisis in the Polish market. After the first round of stabilization countermeasures to the crises (as early as the beginning of 2010), the stock market started to increase in its value, but due to the global situation it does show the significant inclination to fluctuate over time.

Therefore, even in the long term, the overall increase in value is hardly visible. The index value of WIG20 remains currently near the same levels in the longer term, even though, the spikes do occur.

Ticker name First stock quote

ALIOR 14.12.2012 09:00 BOGDANKA 22.07.2009 09:00 BZWBK 25.06.2001 10:00 CYFRPLSAT 06.05.2008 09:30 ENEA 30.01.2009 09:00 ENERGA 11.12.2013 09:00 EUROCASH 04.02.2005 10:00 KGHM 17.11.2000 10:00 LPP 16.05.2001 10:00 MBANK 26.11.2013 09:00 ORANGEPL 14.01.2014 09:00 PEKAO 17.11.2000 10:00 PGE 15.12.2009 09:00 PGNIG 20.10.2005 09:30 PKNORLEN 17.11.2000 10:00 PKOBP 10.11.2004 09:00 PZU 12.05.2010 08:45 SYNTHOS 02.11.2007 09:30 TAURONPE 30.06.2010 09:00

(20)

Page 19

4. Chapter 4: Results

At first the testing was focused on majority and supermajority GDM rules as these were found by Hastie and Kameda (2005) to be the most effective way to make a group-decision in their case. And so the first round of simulations (number of simulations = 1000, MIN_AGENTS = 2, MAX_AGENTS = 20, MINIMAL_NUMBER_OF_TICKERS = 1, START_DATE = 2001-01-01 00:00:00, END_DATE = 2015-03-30 18:00:00) was held which lasted for 2h 38mins and tested the outcome of ½ majority, ⅔ majority, ¾ majority, and total majority, against the perfect outcome (best income rule). In 523 cases the total majority returned the closest outcome to the perfect one, whereas for ½ it was 333, for ⅔ it was 280 and for ¾ it was 339. Further analysis of residual sum of squares also favored the total majority (½ majority RSS = 13274252745 > ⅔ majority RSS = 10741374072 > ¾ majority RSS = 7733104020 > total majority RSS = 3673863777). Moreover, superiority of total majority rule is visible on the graph (Figure 6.) representing all the rules as the rolling means (period set to 10). Simulations on the graph were sorted in ascending order of value achieved using best income rule.

Figure 6. Rolling means for the first round of simulations

0 2000 4000 6000 8000 10000 12000 14000 1 28 55 82 109 136 163 190 217 244 271 298 325 352 379 406 433 460 487 514 541 568 595 622 649 676 703 730 757 784 811 838 865 892 919 946 973 1000

Rolling means for first round of simulations

Rolling mean (best income) Rolling mean (1/2 majority) Rolling mean (2/3 majority) Rolling mean (3/4 majority) Rolling mean (total majority)

(21)

Page 20

The second round of simulations was still focused on the differences between the same rules as the first round, but was designed to test whether the same outcomes would be reached in the environment after the financial crisis struck Poland (START_DATE = 2010-01-01 00:00, other parameters remain as in first round of simulations). This also resulted in the shorter investment periods as the longest investment could last only between 2010-01-01 and 2015-03-30. The simulation lasted for 1 hour 58 minutes. At first glance, the results were entirely different than in the first round of simulations. The ½ majority rule returned the outcome closest to the best income rule in 482 cases. The best outcome was generated by other rules in the following quantities: for ⅔ majority it was 364, for ¾ majority it was 335 and for total majority 330. However, further analysis of both, diagram (Figure 7.) and residual sum of squares (½ majority RSS = 9499567149 > ⅔ majority RSS = 5215635330 > ¾ majority RSS = 3507734649 > total majority RSS = 2361386148) revealed that even though there are more single cases in which ½ majority rule provides the outcome closest to best, in fact it is the rule that generates the outcomes of the highest variability among the rules.

Figure 7. Rolling means for the second round of simulations

0 2000 4000 6000 8000 10000 12000 14000 1 28 55 82 109 136 163 190 217 244 271 298 325 352 379 406 433 460 487 514 541 568 595 622 649 676 703 730 757 784 811 838 865 892 919 946 973 1000

Rolling means for second round of simulations

Rolling mean (best income) Rolling mean (1/2 majority) Rolling mean (2/3 majority) Rolling mean (3/4 majority) Rolling mean (total majority)

(22)

Page 21

The third round of simulations remained still oriented on the same scope of time as the second round, however, the number of Agents involved in the investment process was adjusted (MIN_AGENTS = 10, MAX_AGENTS = 25, other parameters remained unchanged in comparison to the second round of simulations). The simulation took 2 hours 53 minutes. Again, the number of outcomes closest to the best income rule was generated by the ½ majority rule – 503. Others were 310, 230 and 231 for ⅔ majority, ¾ majority and total majority respectively. However, as in the previous round of simulations, the visual analysis (Figure 8.) and analysis of residual sum of squares (½ majority RSS = 7989723217 > ⅔ majority RSS = 3150070262 > ¾ majority RSS = 1474066237 > total majority RSS = 1309224527) showed that the disperse between best income rule and total majority is the least variable.

Figure 8. Rolling means for the third round of simulations

The fourth round of simulations, and the last one testing majority rules against each other, is similar to the third round in having the same limits set on number of Agents involved in the simulated process. However, the time scope was reverted to the one from the first and the second round of

0 2000 4000 6000 8000 10000 12000 14000 1 28 55 82 109 136 163 190 217 244 271 298 325 352 379 406 433 460 487 514 541 568 595 622 649 676 703 730 757 784 811 838 865 892 919 946 973 1000

Rolling means for third round of simulations

Rolling mean (best income) Rolling mean (1/2 majority) Rolling mean (2/3 majority) Rolling mean (3/4 majority) Rolling mean (total majority)

(23)

Page 22

simulations (START_DATE 2001-01-01 00:00, other parameters remained as in the third round of simulations). This resulted in the great increase of time needed for the simulations to finish – 4 hours 53 minutes. The outcome closest to the best income rule was generated by the total majority 421 times. The second best rule in terms of the generation of best outcomes was ½ majority rule (292 times) while ⅔ majority and ¾ majority rules generated very similar results (256 and 266 respectively). In this round of simulations total majority proved to be again the most consistent having generated the least residual sum of squares (½ majority RSS = 14062265121 > ⅔ majority RSS = 9579796613 > ¾ majority RSS = 5079081642 > total majority RSS = 1240734233) which is also visible in the Figure 9.

Figure 9. Rolling means for the fourth round of simulations

In the next, fifth round of simulations, which took 2 hours 25 minutes to conclude, the Total majority rule was contested against the Best agent rule (the rule, in which, from the Agents’ pool the one with the longest time horizon is chosen as a leader and this Agent makes the decision on its own) and Random agent rule (random Agent is chosen from Agents’ pool). The parameters were similar to the first round of simulations (number of simulations = 1000, MIN_AGENTS = 2,

0 2000 4000 6000 8000 10000 12000 14000 1 28 55 82 109 136 163 190 217 244 271 298 325 352 379 406 433 460 487 514 541 568 595 622 649 676 703 730 757 784 811 838 865 892 919 946 973 1000

Rolling means for fourth round of simulations

Rolling mean (best income) Rolling mean (1/2 majority) Rolling mean (2/3 majority) Rolling mean (3/4 majority) Rolling mean (total majority)

(24)

Page 23 MAX_AGENTS = 20, MINIMAL_NUMBER_OF_TICKERS = 1, START_DATE = 2001-01-01 00:00:00, END_DATE = 2015-03-30 18:00:00). The analysis of the scores closest to the best possible income revealed that Total majority produced the best score among others 667 times. Best agent rule produced the best outcome 209 times, while Random agent rule produced it 146 times. Further analysis of residual sum of squares advocates for what is visible on the Figure 10. The great differences in the disperse between single agent based rules and the total majority rule (random agent RSS = 14021754963 > best agent RSS = 13556989841 > total majority RSS = 3427763698).

Figure 10. Rolling means for the fifth round of simulations

The last, sixth round of simulations, was conducted in the similar environment to the fifth round, however the time scope was altered to the one after the financial crisis (START_DATE = 2010-01-01 00:00, other parameters remain as in the fifth round of simulations). The sixth round of simulations lasted for 2 hours 22 minutes. The flexibility of single agent decision making was expected to generate more outcomes closest the best income rule since the market became more dynamic during the crisis. However, total majority rule proved again to be better and produced the

0 2000 4000 6000 8000 10000 12000 14000 1 28 55 82 109 136 163 190 217 244 271 298 325 352 379 406 433 460 487 514 541 568 595 622 649 676 703 730 757 784 811 838 865 892 919 946 973 1000

Rolling means for fifth round of simulations

Rolling mean (best income) Rolling mean (best agent) Rolling mean (random agent) Rolling mean (total majority)

(25)

Page 24

best outcome 538, while best Agent rule did it 295 and random Agent only 195 times. As in the previous rounds of simulations, the total majority was again the least dispersed (Figure 11.) with the smaller value of residual sum of squares than other challenged rules (random agent RSS = 11709123927 > best agent RSS = 10991375458 > total majority RSS = 2269611063)

Figure 11. Rolling means for the sixth round of simulations

0 2000 4000 6000 8000 10000 12000 14000 1 28 55 82 109 136 163 190 217 244 271 298 325 352 379 406 433 460 487 514 541 568 595 622 649 676 703 730 757 784 811 838 865 892 919 946 973 1000

Rolling means for sixth round of simulations

Rolling mean (best income) Rolling mean (best agent) Rolling mean (random agent) Rolling mean (total majority)

(26)

Page 25

5. Chapter 5: Discussion and further development

After conducting the simulations in various cases it was possible to come to the following conclusions. The goal of the research was to determine if there may be a group decision making rule / scheme that would lead the group to achieve better outcomes and in the given environment, described by the case, it has been achieved.

At first, the investigation focused on the set of the group decision making rules which was pointed by previous researchers – Condorcet majority and supermajority rules. However, while in the previous research (Hastie & Kameda, 2005) the Condorcet majority of ½ members of the group was chosen as the one that generates in general better results, during the simulations for the given case, the total majority returned more consistent outcomes that tend to be better than those generated by other group decision models.

Even though, after changing the time scope to the post-financial crisis time span, and having ½ majority rule generate more outcomes closest to the best possible scenario, it is extremely important to stress that ½ majority rule outcomes were far more dispersed than those generated by the total majority rule. This means that ½ majority rule can often lead to the best outcomes, however, it also can lead to far worse outcomes. The much smaller value of residual sum of squares for total majority rule should be considered as the mark that this rule generates, on average, better results than the ½ majority. So as far as for the case at hand, it does satisfy the need for the group decision making scheme that would increase the probability of achieving best outcomes as well as diminish the possible losses.

After increase in the number of Agents it was expected that changes would occur in the results received from simulations. However, after third and fourth round of simulations, the total majority rule again showed most consistency in generating results closest to the best income rule. Even if in the third round the ½ majority rule generated more outcomes closest to the best income rule, its results were highly dispersed and therefore would not prevent groups from making “bad” decisions.

Moreover, other group decision making rules based on the majority principle – ⅔ majority and ¾ majority – were slightly worse than ½ majority and total majority in either of criteria. They

(27)

Page 26

never produced the maximum number of outcomes closest to the best possible income and they always generated more dispersed results than total majority rule.

Having all that in mind, it is fair to determine that among the rules that follow majority principle, the one that is satisfying the needs of the case at hand is the total majority rule. It produces “good” results with the highest consistency and even though it may lead to the generation of slightly worse solutions in several cases than ½ majority, it still is more likely to prevent members from major investment disappointments.

After deciding which of the majority rules works best in the given case, the other rules possible to implement were tested. These single Agent decision rules were: random Agent leader and best Agent leader. The random Agent leader is the rule in which the random member of the group is chosen as a leader and makes decision for the group and similarly in best Agent leader the best of Agents in the given group is set to be a decision maker for all members.

At first, the total majority rule versus the single Agent decision rules were examined in the environment similar to the one used for the first test of the majority principle rules. The results show that single Agent decision rules tend to return highly random outcomes which extremely vary from simulation to simulation. What is more, both those rules never generated the outcome closest to the best income rule in more than 75% of the simulations (209 times and 146 times for best Agent and random Agent rule respectively). That means that using those rules the groups are unlikely to achieve the best results and taking under the consideration the analysis of residual sum of squares, most of the outcomes are placed far from the best income.

Following that initial comparison, the research focused on the time scope after the financial crisis struck Polish markets. Since, the single Agent decision rules should be more agile, they should cope better with the quick changes in the stock values. However, yet again, total majority proved to be the better solution, having generated far more outcomes closest to the best income rule, as well as, generating outcomes less dispersed and less varying from that rule.

The research concludes, that for the case at hand, the total majority rule should be considered as the one that highly fits the needs put on it during the designing process of the system for trading the portfolios of financial instruments (PFIs). Being the method that is less likely to produce outcomes far from the best income rule than other, and proving that in the stable growth

(28)

Page 27 conditions and long term it is more likely to produce the most outcomes closest to the best income rule, it is the rule that could help groups of members in the given case achieve best results. Therefore, it is advised to utilize this group decision making method in the further development of the system introduced in the case.

However, as the purpose of the research was to explore if there may be a group decision making model that helps groups achieve better results, especially when the groups are created of people who do not know each other – Internet setting of the group, it is important to point that the research allowed to show that such models may occur. It is not possible on this stage to jump into any conclusions that total majority rule is the one that would serve all the purposes of the groups created over the Internet, but it is a vital indicator that for each of the cases there may be a suiting rule. The further research could focus not only on which of the group decision making models are best suiting for the given decision making problem, but also could determine which decision making problem properties determine the best suiting group decision making models. Be it the number of group members or the type of the decision being made.

What is more, the research shows the usefulness of the agent-based modelling and simulation method in the tryouts to find such a rule. It does allow the creator of the Internet based service to test the model before implementing it in the live version of the service which leads to higher probability of acceptance of said service.

At last, the outcomes of the research must be put in the right spot of the knowledge base – as the exploration into the research area. Especially, having used the case introduced in this research, it is important to consider the data used to conduct it (Warsaw Stock Exchange trading quotes data) as a factor that can largely impact the final outcome. It is not exclusively for the WSE stocks to increase the value over time, it is the trend that occurs in a long term in most highly tradable stocks all over the world. Having that in mind and the fact that in case of total majority it is harder to reach the consensus than in case of ½ majority, we may conclude that more restrain in selling stocks led to better outcomes in the case being investigated in this research. That would mean that further extrapolation of total majority use in other applications would be incorrect. This also represents one of the decision making problem properties – long term increases – that determines the use of total majority GDM model.

(29)

Page 28

It cannot be concluded that total majority rule will work in the given case in the live setting. The simulations would suggest that, however, the complexity of the human being behavior may affect the final outcomes. Simulations are being carried out in order to minimize the risk of rejection, but there is always a gap for a mistake. It is not possible to fully imitate the real life setting as not all the variables and objects are clearly visible for the researchers. What is more, the computing power limits the number of variables and objects that can be used in simulations. Due to those limitations the simplifications must be made in order to make carrying out the simulation possible.

To increase the value of the research at hand additional surveys and observations could have been carried out. Mainly, the creation of the prototype of the system introduced in the case, with the right reporting system, could help understand how people act using social finance services. Especially, how they interact with each other – whether it is an open discussion or rather individual decisions made without any input of the fellow group members. The testing in the real setting could be handled also by implementing various group decision making rules and allowing users to choose their rule while creating the PFI. Not only would it allow the analysis of the outcomes of each of the rules, but it would also empower the analysis on which of the GDM models are preferred by the users.

On the other hand, the ABMS method used in this research could be further developed and even deeper explored. First, by introducing randomly generated stock quotes that do not contain all the characteristics of the specific market (e.g. increase over long term). Furthermore, the ABMS algorithm used in this research has the potential to utilize the multiprocessing programming in order to decrease the time needed to handle a single simulation. That would allow the researcher to include more variables and therefore increase the mirroring of the real life on simulation.

ABMS algorithm can also be further developed to incorporate the more sophisticated communication among Agents. That would allow researchers to test more complex GDM models in which the open debate among the group members occurs. Moreover, single Agents could be equipped with automatic technical analysis algorithms to better reflect the real life estimation process of the value of stocks. Adding those features to the algorithm utilized in this research would refine the simulation environment and therefore magnify the value of the results.

(30)

Page 29 It is visible that there is a room for further development and improvement, however the pure exploratory insight provided by the research at hand shouldn’t be omitted. It is supposed to create the foundation to the area which is likely to play an important role in the lives of many and shows the way in which that area could be further delved into.

(31)

Page 30

Bibliography

Arrow, K. (1963). 1951. Social choice and individual values. New York: John WIley & Sons, Inc.

Bolland, P. J. (1989). Majority systems and the Condorcet jury theorem. The Statistician , 181-189.

Bureau of Labor Statistics. (2015). American Time Use Survey - Results 2014. Washington, D.C.: U.S. Department of Labor. Retrieved from http://www.bls.gov/news.release/pdf/atus.pdf

Farmer, J. D., & Foley, D. (2009). The economy needs agent-based modelling. Nature, 685-686.

Hastie, R., & Kameda, T. (2005). The robust beauty of majority rules in group decisions.

Psychological review, 494-508.

Holden, R. (2004). Supermajority voting rules. SSRN ELECTRONIC JOURNAL.

ITU Telecommunication Development Bureau. (2015). ICT Facts & Figures: The world in

2015. Telecommunication Development Bureau, ICT Data and Statistics Division. Geneva:

International Telecommunication Union. Retrieved from http://www.itu.int/en/ITU-D/Statistics/Documents/facts/ICTFactsFigures2015.pdf

Janssen, M. A. (2005). Agent-based modelling. Modelling in ecological economics, 155-172. Kiesler, S., & Lee, S. (1992). Group decision making and communication technology.

Organizational behavior and human decision processes(52), 96-123.

Kukla, J. (2014). Projekt systemu handlu pakietami instrumentów finansowych. Szkoła

Główna Handlowa.

Macal, C. M., & North, M. J. (2010). Tutorial on agent-based modelling and simulation.

Journal of simulation, 151-162.

Miller, C. E. (1985). Group decision making under majority and unanimity decision rules.

(32)

Page 31 Moore, G. E. (1975). Progress in digital integrated electronics. IEDM Tech. Digest(11). Moore, G. E. (1998). Cramming more components onto integrated circuits. Proceedings of the

IEEE, 1(86), 82-81.

Richiardi, M. G., Leombruni, R., Saam, N., & Sonnessa, M. (2006). A common protocol for agent-based social simulation. Journal of artificial societies and social simulation, 16-31.

Romano Jr, N. C., & Nunamaker Jr, J. F. (2001). Meeting analysis: Findings from research and practice. System Sciences, 2001. Proceedings of the 34th Annual Hawaii International

Conference.

Scandurra, T. A., Graen, G. B., & Novak, M. A. (1986). When managers decide not to decide autocratically: An investigation of leader–member exchange and decision influence. Journal of

(33)

Page 32

Appendix 1.

from os import walk

from datetime import date, time, datetime, timedelta import csv

import numpy as np

import matplotlib.pyplot as plt

import pandas as pd import random " GLOBAL VARIABLES " MIN_AGENTS = 2 MAX_AGENTS = 20 MINIMAL_NUMBER_OF_TICKERS = 1 START_DATE_YEAR = 2001 START_DATE_MONTH = 1 START_DATE_DAY = 1 START_DATE_HOUR = 0 START_DATE_MINUTE = 0 START_DATE_SECOND = 0 END_DATE_YEAR = 2015 END_DATE_MONTH = 3 END_DATE_DAY = 30 END_DATE_HOUR = 18 END_DATE_MINUTE = 0 END_DATE_SECOND = 0 THE_MOMENTS = 666 " date variables "

START_DATE = datetime.combine(

date(START_DATE_YEAR,START_DATE_MONTH,START_DATE_DAY), time(START_DATE_HOUR,START_DATE_MINUTE,START_DATE_SECOND)); END_DATE = datetime.combine(

date(END_DATE_YEAR,END_DATE_MONTH,END_DATE_DAY), time(END_DATE_HOUR,END_DATE_MINUTE,END_DATE_SECOND)); DURATION = (END_DATE - START_DATE).total_seconds();

" Horizon values for different types of Agents "

agentsHorizon={'PRO': [30,60], 'SEMI': [14,30], 'NEW': [1,14]}

agentsVisionOfFuture={'PRO': [0.3,0.5], 'SEMI': [0.2,0.35], 'NEW': [0,0.6]} agentsGutFeeling={'PRO': [0,0.2], 'SEMI': [0,0.5], 'NEW': [0,1]}

def printTime(toprint): resstr="";

if(toprint.seconds >= 60): resstr="Time {minutes:.0f}m

{seconds}s".format(minutes=abs(toprint.seconds/60),seconds=abs(toprint.seconds%60)); else:

resstr="Time {seconds}s".format(seconds=abs(toprint.seconds)); print(resstr);

return resstr; def listTickerFiles(): allTickerFiles=[];

(34)

Page 33 allTickerFiles.extend(filenames)

break

return allTickerFiles; def tickerName(filename): return filename[:-4];

""" getting ticker data """

tickerFiles = listTickerFiles(); NUMBER_OF_TICKERS = len(tickerFiles) results={};

for each in tickerFiles:

theTicker=tickerName(each); print(theTicker);

results.update({theTicker:pd.read_csv("./IntradayGPW/latest/{filename}".format(filename=each), header=None, parse_dates=[0])});

results[theTicker].columns=['dt','price']; results[theTicker] =

results[theTicker].set_index(pd.DatetimeIndex(results[theTicker]['dt'])); """ results[theTicker] = results[theTicker].drop(['dt'], axis=1); """

print(results[theTicker]['dt'][0])

""" klasa Horyzontu czasowego """

class Horizon:

def __init__(self,days,hours,mins): self.days = days

self.hours = hours

self.mins = mins

self.dt=timedelta(days=self.days,hours=self.hours,minutes=self.mins) def giveTimedelta(self):

return self.dt

def giveDateOffset(self):

return pd.DateOffset(self.dt.total_seconds()); def giveSeconds(self):

return self.dt.total_seconds();

""" klasa Agenta

Agent zawiera horyzont czasowy i wszystkie swoje parametry koniec opisu klasy """

class Agent:

def __init__(self,agentExperience): self.experience=agentExperience

self.randomizer=random

self.randomizer.seed()

self.horizon=Horizon(self.randomizer.randint(agentsHorizon[self.experience][0],agentsHorizon[se lf.experience][1]),

self.randomizer.randint(0,23), self.randomizer.randint(0,59)); """ attributes """

self.gutFeeling = self.randomizer.uniform(agentsGutFeeling[self.experience][0], agentsGutFeeling[self.experience][1]);

(35)

Page 34

agentsVisionOfFuture[self.experience][1]);

" prints settings of the Agent "

def printSettings(self):

print("Experience {exp}, timedelta

{dt}".format(exp=self.experience,dt=str(self.horizon.giveTimedelta()))); " prints the horizon of the agent in seconds "

def printSeconds(self):

print("Experience in seconds:

{exp}s".format(exp=self.horizon.giveTimedelta().total_seconds())); def get_horizon(self):

return self.horizon.giveTimedelta(); def get_dateoffset(self):

return self.horizon.giveDateOffset; class Simulation:

def __init__(self,name): self.name=name

self.randomizer=random

self.randomizer.seed() self.outcomes = {}

""" begin: Initialize start and end date for the Sim """

tempStartDiff = self.randomizer.randint(0,DURATION)

tempEndDiff = self.randomizer.randint(0,DURATION-tempStartDiff-1) tempStartDiff = timedelta(seconds=tempStartDiff)

tempEndDiff = timedelta(seconds=tempEndDiff) self.startDate = START_DATE + tempStartDiff self.endDate = END_DATE - tempEndDiff

""" end: Initialize start and end date for the Sim """

self.agents=[]

self.numberOfAgents=self.randomizer.randint(MIN_AGENTS,MAX_AGENTS);

for i in range(self.numberOfAgents):

agentType=self.randomizer.randint(1,3); if(agentType == 1):

self.agents.append(Agent('PRO')) elif(agentType == 2):

self.agents.append(Agent('SEMI')) else:

self.agents.append(Agent('NEW')) """ choose the best Agent """

bestAgent = 0;

self.bestAgentPos = -1; bestAgentIter = 0;

for agent in self.agents: if bestAgent:

if agent.get_horizon() > bestAgent.get_horizon(): bestAgent = agent;

(36)

Page 35 else:

bestAgent = agent;

self.bestAgentPos = bestAgentIter; bestAgentIter += 1;

bestAgent.printSettings(); """ begin: Choose tickers """

self.numberOfTickers =

self.randomizer.randint(MINIMAL_NUMBER_OF_TICKERS,NUMBER_OF_TICKERS); self.tickers = [];

tempCounter = 0;

tempArray = [0] * NUMBER_OF_TICKERS;

k=self.numberOfTickers;

while (k>0 and tempCounter<NUMBER_OF_TICKERS):

tempOpt = self.randomizer.randint(0,NUMBER_OF_TICKERS-1); if(tempArray[tempOpt] == 0):

tempArray[tempOpt]+=1; tempCounter+=1;

if(results[tickerName(tickerFiles[tempOpt])]['dt'][0] <= self.startDate): self.tickers.append(tickerName(tickerFiles[tempOpt]));

k-=1;

self.numberOfTickers = len(self.tickers); " every agent in simualtion and its settings "

def listAgents(self):

for agent in self.agents: agent.printSettings()

" returns the first Agent on the list "

def first(self): return agents[0];

" returns the last Agent on the list "

def last(self):

return agents[-1]; def simDates(self):

print(self.startDate, self.endDate) def get_tickers(self):

for ticker in self.tickers: print(ticker);

def execute(self):

# self.outcomes.update({'best':0, '1/2':0, '2/3':0, '3/4':0, 'Total':0}) self.outcomes.update({'best':0, 'Total':0, 'bagent': 0, 'ragent': 0}); mainDF = {};

for each in self.tickers:

mainDF.update({each:results[each][self.startDate:]}); # print(tempDF.head());

# print(results[each][self.startDate:self.endDate]['price'].max());

self.outcomes['best'] += results[each][self.startDate:self.endDate]['price'].max(); agentCount = 0;

(37)

Page 36

for k in self.agents:

windowSize = int(k.get_horizon().total_seconds() / (15*60)); # print("The windowSize is {wS}\n".format(wS=windowSize)); if (mainDF[each].empty):

continue else: tmp =

pd.DataFrame(pd.rolling_max(mainDF[each]['price'][:self.endDate+k.get_horizon()],window=windowS

ize,min_periods=1).shift(-windowSize),columns=["priceMAX_{agentnum}".format(agentnum=agentCount)]); mainDF[each] = mainDF[each].join(tmp);

mainDF[each]["priceMAX_{num}_bool".format(num=agentCount)] = mainDF[each]['price'] > mainDF[each]["priceMAX_{num}".format(num=agentCount)] del tmp;

tempLength = len(mainDF[each]); np.random.seed();

mainDF[each]["gutFeeling"] = pd.Series(np.random.randint(2,size=tempLength), mainDF[each].index)

mainDF[each]["POSD"] = (mainDF[each]["gutFeeling"] * k.gutFeeling) + (mainDF[each]["priceMAX_{num}_bool".format(num=agentCount)] * k.visionOfFuture); np.random.seed();

mainDF[each]["benchmark"] = pd.Series(np.random.random_sample(size=tempLength), mainDF[each].index)

mainDF[each]["finalDecision_{num}".format(num=agentCount)] = mainDF[each]["benchmark"] < mainDF[each]["POSD"];

#print(mainDF[each][ mainDF[each].priceMAX_0 < mainDF[each].price].head(10)); agentCount+=1;

mainDF[each] = mainDF[each][:self.endDate];

tmpList = ["priceMAX_{num}_bool".format(num=x) for x in range(agentCount)] tmpList2 = ["finalDecision_{num}".format(num=x) for x in range(agentCount)] tmpList3 = ["priceMAX_{num}".format(num=x) for x in range(agentCount)] mainDF[each] = mainDF[each].drop(tmpList3,axis=1)

mainDF[each]['numberOfMaxes'] = mainDF[each][tmpList].sum(axis=1); mainDF[each]['finalCount'] = mainDF[each][tmpList2].sum(axis=1); np.random.seed();

mainDF[each]['moments'] = pd.Series(np.random.randint(1001,size=len(mainDF[each])), mainDF[each].index)

# best Agent rule

outcome = mainDF[each][(mainDF[each].numberOfMaxes > 0) &

(mainDF[each]["finalDecision_{num}".format(num=self.bestAgentPos)] == 1) &

(mainDF[each].moments > THE_MOMENTS)].head(1); if(outcome.empty):

self.outcomes['bagent'] += float(mainDF[each]['price'].tail(1)); else:

self.outcomes['bagent'] += float(outcome['price'].head(1)); # random Agent rule

Referenties

GERELATEERDE DOCUMENTEN

Four empirical studies conducted among immigrants and majority group members in the Netherlands explain partially the interethnic differences and similarities in emotion

Keywords: Humanitarian Logistics, Migration Movement, Refugee Journey, Capacity Management, Temporal Network, Syrian Refugees, Agent-based

Copyright and moral rights for the publications made accessible in the public portal are retained by the authors and/or other copyright owners and it is a condition of

Tabel 4a: Ongunstige effecten van brivaracetam vergeleken met gabapentine, levetiracetam, lacosamide, pregabaline, perampanel, topiramaat bij patiënten met partiële epilepsie..

Voor de ongevallenanalyse moet bekend zijn wanneer het algemene niveau van het gebruik van MVO in de vóórperiode veranderd; een te onderscheiden stijging optreedt

The residential function and safety in built-up areas ask for enlarged traffic calming areas with diameter of about 4 km, which are then divided by urban arterials with

bevalling met epidurale pijnstilling worden niet rechtstreeks door de epidurale katheter veroorzaakt, maar zijn vermoedelijk eerder te wijten aan een langdurige

guilty of sexual crimes against children or mentally ill persons or even those who are alleged to have committed a sexual offence and have been dealt with in terms of