This will be an agent-based model of the Havven system.
Before it can be run, you will need Python 3.6 or later and to install the pre-requisites with pip:
pip3 install -r requirements.txt
To run the simulation, invoke:
python3 run.py
If it is your first time running the simulation, a settings.ini
file will be generated, that will give you control over how the simulation will run.
The first settings cached = True
determines whether the data will be pre-generated before spawning a server, or whether the data will be generated in real time.
More info about the settings and caching can be found in the relevant sections.
To open the experiments notebook:
jupyter notebook experiments.ipynb
To run the tests:
python3 -m pytest --pyargs -v
Note: Running pytest through python3 is more consistent (global pytest install, other python versions). The -v flag is for verbose, to list every individual test passing.
Settings are contained in settings.ini
, the file will be generated on the first run of the simulation using the python3 run.py
command, individual setting descriptions can be found in settingsloader.py
.
Changing the caching setting changes how the data will be generated before being displayed on the local webpage. If caching is true, the data will be generated beforehand, and will be sent to the client at a rate only limited by connection speed (the fps_default
setting controls this).
Otherwise, data will be presented in real time, being generated by the server as quickly as the client can request the next step.
Another difference between the two is the changing of model settings. If caching is true, settings are determined by dataset settings found in cache_handler.py
. With caching being false, settings can be changed on the client side, and then generated by the server with the new settings.
There are three major components to this simulation:
- The currency environment of Havven itself;
- A virtual exchange to go between nomins, havvens, and fiat;
- The agents themselves. possible future players:
- random players
- arbitrageurs
- havven bankers
- central bankers
- merchants / consumers
- market makers
- buy-and-hold speculators
- day-trading speculators
- cryptocurrency refugees
- attackers
It runs on Mesa, and includes the following files and folders:
run.py
- the main entry point for the programreset.py
- script to clear and reset settings to default, and regenerate cacheserver.py
- the simulation and visualisation server are instantiated heremodel.py
- the actual ABM of Havven itselfcore/orderbook.py
- an order book class for constructing markets between the three main currenciescore/stats.py
- statistical functions for examining interesting economic properties of the Havven modelcore/settingsloader.py
- loads and generates settings filescore/cache_handler.py
- cached datasets are generated and loaded by this modulemanagers/
- helper classes for managing the Havven model's various partsagents/
- economic actors who will interact with the model and the order booktest/
- the test suitevisualization/
- facilities for producing a live visualization web pageexperiments.ipynb
- an environment for exploring system dynamics and scenarios in a more-efficient offline fashion.