# Source
All code and material is drawn from http://artstkmkt.sourceforge.net
This repo is a conversion of the CVS repository available at that address.
# Purpose
SFI-ASM is a captivating, enigmatic thing. My interest is first the preservation of the historical artifact, second the understanding of them model, and third the understanding of the academic-historical context of the model's creation.
To that end, this repository tracks the source code through all of the releases I can find, and will try to modify the code and codify its environment sufficiently s.t. it can be built on a well specified VM.
# SFI-ASM
The Sante Fe Institute Artificial Stock Market is a description of a agent-based model of a stock market. It has been realized in a few different implementations, which this repository aims to collect and enhance.
The model itself was first described by Palmer et al. (1994)
## Artstkmkr
```
Group/Project Resource Page lists all resources available for this project.
Several articles* have been published using the Artificial Stock Market model. The model simulates prices & trade levels in a market made up of "artificial adaptive agents." This is a prototype example of a "complex system" and is thought to illustrate the benefits of simulation modeling.
This page is dedicated to the revision/updating/enhancement of the Swarm version of the ASM. The first objective was to bring the ASM code--as released in April, 2000, with the version label 2.0--up to date and into conformance with Swarm programming style and recommendations for Swarm 2.1. That was achieved with ASM-2.2, which represents a substantially reworked and enhanced version of the model. Actually, ASM-2.2 went a bit further than that, because it (optionally) uses some hdf5 data storage features that were supported only in Swarm after 2.1.1 (prerelease snapshots of Swarm-2.2). The next step, ASM-2.4, includes the addition of a number of new features, including serialization (ability to stop and restart a model). ASM-2.4 now performs, as far as Thomas Badegruber and I can tell, in a way that replicates the original Santa Fe Stock Market. See the Swarm community links page for release info.
In case you wonder what a Swarm program looks like while it runs, I have a directory of screenshots!, such as screenshots/asm-20000530.gif . The newest version, ASM-2.4, looks like this: screenshots/asm-20030606.png on my RedHat Linux system.
```
# References
Arthur, W. Brian, John H. Holland, Blake LeBaron, Richard G. Palmer, and Paul Tayler. "Asset pricing under endogenous expectations in an artificial stock market." Available at SSRN 2252 (1996).
Ehrentreich, Norman. "A corrected version of the santa fe institute artificial stock market model." Complexity (2003).
Ehrentreich, Norman. Agent-based modeling: The Santa Fe Institute artificial stock market model revisited. Vol. 602. Springer Science & Business Media, 2007.
LeBaron, Blake, W. Brian Arthur, and Richard Palmer. "Time series properties of an artificial stock market." Journal of Economic Dynamics and control 23, no. 9 (1999): 1487-1516.
LeBaron, Blake. "Building the Santa Fe artificial stock market." Physica A (2002).
Palmer, Richard G., W. Brian Arthur, John H. Holland, Blake LeBaron, and Paul Tayler. "Artificial economic life: a simple model of a stockmarket." Physica D: Nonlinear Phenomena 75, no. 1 (1994): 264-274.
# Original Readme (ASM-2.4):
```
Swarm ASM notes. If you are looking for highlights, this
is the right spot.
Paul Johnson <pauljohn@ku.edu>
ASM-2.4 June 2003
This version requires Swarm-2.1.143 or newer. If you don't have
that, you will have to disable serialization features and compile
without using HDF5 data output.
Thomas Badegruber <thomas.badegruber@uni-graz.at> visited here in
Kansas in March and then went to Boston to work with Blake
LeBaron. That re-energized me on this project. Thomas is now a full
contributor to the CVS archive on Sourceforge. We have made changes
to improve functionality, fix bugs, and make the genetic algorithm
code more easy to read and extend. And, perhaps most importantly, we
can now re-produce the finding that there is a major difference in the
usage of technical and fundamental bits when the agent use of the
genetic algorithm is made more frequent. That is to say, when agents
use the GA every 250 periods, they are substantially more likely to
use technical trading information than if they update every 1000
periods. Because this behavior is now reproduced, we are confident
that the Swarm-ASM behaves in the same way in all substantial ways as
the Next/Objective-C models presented in the literature.
Functionality enhancements
* Graph showing usage of funamental bits, technical bits, and dummy
bits full model serialization.
* Serialization: Simulation can be saved in a "snapshot" and restarted.
* Parameter values have been reset to match the ones used in
publications.
* Uses enhancements in Swarm's EZGraph (changes introduced since
Swarm-2.1.1) to save output data as vectors in HDF5 files. This
significantly enhances usage of output data files in statistical
analysis programs.
Bug fixes / code changes (see ChangeLog for details, or persue
the patch from ASM-2.2 to ASM-2.4.)
* closed memory leakes caused by use of probes in the getDouble()
function in BFParams.m.
* revised some of the scheduling apparatus to make the model run
faster.
* Fixed a misplaced bracked in BFagent's MakePool method. This
was discovered and corrected by Thomas Badegruber. It significantly
affects the performance of the genetic algorithm over the long run.
* Coding for graphs and data output of hdf5 vectors for time plots
was reorganized, significanly simplifying the shift from GUI to nonGUI
models. Look in Output.m
ASM-2.2 November 2001
This work was mainly aimed at documentation, inserting Autodoc markers
so I can build nicer looking documentation.
The only big substantive cleanup was in ASMModelSwarm. I had been
avoiding this for a long time because the scheduling that was used was
very complicated and hard to understand. I succeeded in a major
simplicification and cleanup and have verified the numerical results
are identical. This is explained in the beginning of ASMModelSwarm.m
There was also a "procedural" cleanup of the code in World.m. The old
version had a lot of callocs and other memory magic because it was
keeping moving averages "by hand". This has been changed. There is
now a MovingAverage class that is used to do that magic, so the code
in World.m is much easier to read.
There is much less low level math floating around.
SNAP3: ASM 20011024 October 2001
The aim has been to bring this model into convenient Swarm standards.
Actually, the real aim has been to make ASM an effective teaching tool
and an example of good simulation coding practice. Part of that is a
modernization of the data handling, both the input of parameter
values, and record keeping of parameter values, as well as the saving
of data. One of my pet peeves about Swarm is that we do not have a
standard, idiot proof way to keep records on the settings and results
are for a particular run. We also don't have fool proof ways to
interate models and run simulations over again. The first problem is
dealt with here in the Output class, and the second one is dealt with
by the creation of a Parameter class, where we could manage command
line parameters if we wanted to.
1. Inputting Parameter Values.
First, note the big parameter input file "asm.scm". This has the
initial values for three classes, bfParams, asmModelParms, and
asmBatchParams. This data is "called" to create the classes, you have
to stare at it a while to get used to it. Where we used to have the
createBegin/createEnd routine for a class, now we've got this
different thing that creates a class and initializes its ivars for us,
like so
asmModelParams =[lispAppArchiver getWithZone: self key: "asmModelParams"])
The asmModelParms cla