The Grand Canonical Minority Game could be regarded as a simple extension of the basic version of Minority Game, by allowing the users to not play the game when they feel it is too risky. Here is the documentation for the codes used in the project. The focus of this documentation will be on introducing the parameters in the core file (Sec. 2), and on GCMG with delay (Sec. 5).
Table of contents
- The core file
- Case studies
- Measuring the distribution of the intensities of the extreme events
- GCMG with delay
- Study the predictability of extreme events
- Study the prevention of extreme events and the influence of delay
Download the folder “projects/GCMG”, and then run the following bash command in the GCMG folder:
pip install -r requirements.txt
2. The core file
The core file is called “GCMG.py”, which is an extension of the code for the “basic Minority Game”. There are three key parameters: “R_min”, “rp”, and “mode”.
R_min: the threshold of strategy score only above which when the score of a user’s best strategy is will the user participate in the game.
rp: the rebellion probability (see the description for “mode” below for more explanations).
mode: can have three modes, “sr”, “fr”, and “combined”.
a) When mode=”sr”, it means we allow the users to have a small probability “rp” not to play the game even when their best strategy’s score is above “R_min” (When below “R_min”, the users will not play);
b) when mode=”sr”, it means we allow the users to have a small probability “rp” to play the game even when their best strategy’s score is below “R_min” (When above “R_min”, the users will surely play);
c) when mode=”combined”, it means we combine a) and b): we allow the users to have a small probability “rp” not to play the game even when their best strategy’s score is above “R_min”, and allow the users to have a small probability “rp” to play the game even when their best strategy’s score is below “R_min”.
3. Case studies
Run “casestudy.py” you are expecting to get the evolution of the price and the strategy scores for a simulation under the folder “figs/GCMG/” (e.g., the figure blow).
4. Measuring the distribution of the intensities of the extreme events vs the rebellion probability (rp).
Run “extreme-events-intensity.py” you are going to get the following figures showing the rebellion probability vs. the maximum amplitude (see the function max_amp() in utils.py for definition) or extremeness (see the function p_extreme() in “utils.py” for definition) of the extreme events. (Note: these measures are abandoned due to that there could exist some better measures. )
5. GCMG with delay
The core file for this part is “GCMG_delay.py”, which is a modification of the “GCMG.py” file by introducing a probability “pd” with which a user will get delay by “dT” days when System.delay is set to be True (if False, it will not get delayed).
“GCMG-delay-sim.py” is an example of the simulation showing how the delay impact the system. It will generate the following figures, showing the evolution of the prices, strategy scores, and the FFT (fast Fourier transform) of the strategy scores.
6. Study the predictability of extreme events
Running “GCMG-prediction-cone.py” you are going to get the following figure showing the “cones” representing the standard deviation of 50 possible future trajectories with the same historical trajectory.
7. Study the prevention of extreme events
Running “GCMG-extreme-event-prevention.py” you are going to get the following figure showing how the delay and the increase of conservative rate would prevent/modify the occurrence of an extreme event.
If you have any technical question, you may comment below or send me an email.