Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

esl project logo

ESL

The Economic Simulation Library (ESL) provides an extensive collection of high-performance algorithms and data structures used to develop agent-based models for economic and financial simulation. The library is designed to take advantage of different computer architectures. In order to facilitate rapid iteration during model development the library is developed to be used from Python, and is written in C++.

Features

Models

Market mechanisms

The library provides multiple market mechanisms that use the same messaging framework, meaning market mechanisms can to a limited extended be swapped and compared within the same economic model. We aim to provide simple models that allow, for example, to convert directly supply- and demand functions to an execution strategy, so that a Walrasian price-setters can be compared to order-driven markets such as limit order books.

  • Walrasian price-setter, supporting market clearing for multiple assets using a numerical scheme, accelerated by automatic differentiation.

  • Multiple Limit order books with different performance characteristics.

  • Shapley-Shubik trading-posts. Trade Using One Commodity as a Means of Payment. Shapley, L. and Shubik, M. Journal of Political Economy 1977 vol: 85 (5) pp: 937-968.

  • Common types of auctions

Getting the library

:warning: ** The python bindings are currently under development, and are not at parity with the C++ code.

Python package download and installation

We aim to provide optimized packages for Linux, MacOS and Windows for Python 3.6 and later. These are automatically delivered to Pypi, and can be downloaded and installed using pip.

    pip3 install eslpy

Linux

For linux, we build packages for the manylinux2014 platform, which provides compatibility with a large number of recent versions of popular distros. We test on Centos 7 and Ubuntu 20.04.

MPI-enabled Cluster

Precompiled packages are built without MPI support, as there are several implementations available and in practice the desired MPI implementation is imposed by the computing environment. Therefore, MPI users are encouraged to build the package from source code, and compiling for a specific computing environment may yield performance gains that are not available from a generic package.

macOS

Python packages are developed for macOS deployment version 10.9 and newer. Note that upon installation from inside a graphical interface, the installer will request the installation of the relevant Apple XCode developer tools through a dialog menu if not yet installed. This process may repeat multiple times depending on which development tools are already installed. These dialogs may be accompanied by the following message in the terminal:

xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.

Windows

Build configuration supports both Microsoft Visual C++ and Mingw-w64 based builds. We recommend cmake-gui to generate project files for Visual Studio. For Mingw-w64 based builds, we recommend MSYS2 to install boost and gsl dependencies.

From source code

Users can also build the Python package from source and install it directly. For this, the following dependencies need to be satisfied:

  • C++17 compiler
  • CMake >= 3.12
  • GSL >= 2.3
  • Adept >= 2.05
  • Optional: any Boost.MPI compatible MPI development library, such as OpenMPI
  • Python >= 3.6 development headers, libraries, and optionally binaries to run unit tests.
  • Boost >= 1.65, with Boost.Python configured (mandatory) and Boost.MPI (optional)

Once the dependencies are satisfied one can build install with pip (provided PEP 517 is supported, which is the case for recent updates of pip)

    pip3 install .

C++ library

Build with N processes:

mkdir build
cd build
cmake ../
make -jN
make test

Examples

Before releasing a first version, we do not maintain detailed documentation. Usage examples can be found in the test cases. Python examples to follow.

Example taken from: https://github.com/INET-Complexity/ESL/blob/master/example/order_book.cpp

// import the order book
#include <esl/economics/markets/order_book/book.hpp>

// import currencies, because we will be trading the stock against USD
#include <esl/economics/currencies.hpp>

// we will fix the namespace mess once the API stabilises
using namespace esl;
using namespace esl::economics;
using namespace esl::economics::markets::order_book;
using esl::economics::markets::order_book::limit_order_message;
using namespace esl::economics::markets::order_book::statically_allocated;

// trades in this market are in multiples of the lot size
// e.g. a lot_size of 100 means that a buy order for a quantity of 3 buys 300 shares
// A larger lot size enables small tick sizes
constexpr size_t lot_size = 100;

// helper function to create limit orders submitted to an exchange.
// note that ESL uses fixed-precision for prices internally, and that the use of
// a floating point type here relies on the developer understanding the
// conversion.
limit_order_message create( double p
                          , size_t q = 1000
                          , limit_order_message::side_t side = limit_order_message::side_t::sell)
{
    // substitute your own stock ticker type here
    esl::economics::markets::ticker ticker_dummy_;

    // substitute your agent id
    identity<agent> owner_dummy_;

    return limit_order_message
        ( ticker_dummy_
            , owner_dummy_
            , side
            , markets::quote(price(p, currencies::USD), lot_size * currencies::USD.denominator)
            , q
            ,limit_order_message::lifetime_t::good_until_cancelled
        );
}

//
int main(int argc, char** argv) {
    // create the range of valid prices for the order book (inclusive)
    // quote is a generic type which can be a price, interest rate, etc
    auto  min_ = markets::quote(price( 0.01, currencies::USD), lot_size * currencies::USD.denominator);
    auto  max_ = markets::quote(price(10.00, currencies::USD), lot_size * currencies::USD.denominator);

    // define the maximum number of open orders
    // as the statically_allocated::book maintains a fixed-size memory pool
    constexpr size_t max_orders_ = 1'00'000;

    // creates the order book
    auto book_ = std::make_unique<book<max_orders_>>(min_, max_);

    book_->insert(create(4.75, 500, limit_order_message::side_t::buy));
    book_->insert(create(4.75, 750, limit_order_message::side_t::sell));

    // use book_.reports to view the output generated by the order book, which contains
    //  1. the placement of the buy order
    //  2. matching 500 of the buy and sell order (confirmed for each agent)
    //  3. placement of the remainder 250 of the sell order
}

Testing

The library uses unit testing on both the native library (Boost.Test) and the Python bindings (pytest and Hypothesis).

Acknowledgements

This open-source project is organized by the Institute for New Economic Thinking at the Oxford Martin School. Work on this open-source project is in part funded by the J.P. Morgan AI Faculty Awards 2019 and 2020.

Metadata

Release files for eslpy 0.0.23rc454229

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for eslpy 0.0.23rc454229
File
eslpy-0.0.23rc454229-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
eslpy-0.0.23rc454229-cp39-cp39-manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
eslpy-0.0.23rc454229-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details
eslpy-0.0.23rc454229-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
eslpy-0.0.23rc454229-cp38-cp38-manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details
eslpy-0.0.23rc454229-cp38-cp38-macosx_10_9_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.9+ x86-64 Details

Total release size: 70.2 MB

Release files / eslpy-0.0.23rc454229-cp39-cp39-win_amd64.whl

Download URL eslpy-0.0.23rc454229-cp39-cp39-win_amd64.whl
Size 3.9 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
71ef2b15ca899bcf8dd60bfa0143500e29a27e81aca482d7b40ff88e6e47f210
BLAKE2b-256 checksum
How to use checksums
0cf2267bbde3416ad4483104106db40e365f680dc5c4290348bc0a7f5648a5cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / eslpy-0.0.23rc454229-cp39-cp39-manylinux2014_x86_64.whl

Download URL eslpy-0.0.23rc454229-cp39-cp39-manylinux2014_x86_64.whl
Size 19.1 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
bb5a9fd44a7489c2bedab5b8c0fce04e5dda534a8a094a9ac7173f9b45937da4
BLAKE2b-256 checksum
How to use checksums
408a3ef0333b644b05876f0ba98aa50968e7db70aa70aed44456fe04a8df3a20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / eslpy-0.0.23rc454229-cp39-cp39-macosx_10_9_x86_64.whl

Download URL eslpy-0.0.23rc454229-cp39-cp39-macosx_10_9_x86_64.whl
Size 12.1 MB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
1529e5f6f00e3a9055448bc1a13eb5af2feeec0ea2fc42a6160360e5b500b9b4
BLAKE2b-256 checksum
How to use checksums
cceaecd94e29b4f1cc77a9456b97f6ecceca6befff115fae522f7c75fa7f2036
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / eslpy-0.0.23rc454229-cp38-cp38-win_amd64.whl

Download URL eslpy-0.0.23rc454229-cp38-cp38-win_amd64.whl
Size 3.9 MB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
b022db5cde041576806cc3eb8f5c92750c41c560cebd87e76ada34a92455b00e
BLAKE2b-256 checksum
How to use checksums
2fa5eb705a8efe34450d7d2df0576efe79f2ffa51cbbc99e75a8ccfd890cd49e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.6

Release files / eslpy-0.0.23rc454229-cp38-cp38-manylinux2014_x86_64.whl

Download URL eslpy-0.0.23rc454229-cp38-cp38-manylinux2014_x86_64.whl
Size 19.1 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
ec389c5b20fe929c8b20b0f6252ece5ea19c2fa37fce5501eb9d0abf24dbbd73
BLAKE2b-256 checksum
How to use checksums
bf93e0c5b508bfcca0f4a0ac27bc984da9ef4672c8ab5d997bc32befdf0ce74c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.6

Release files / eslpy-0.0.23rc454229-cp38-cp38-macosx_10_9_x86_64.whl

Download URL eslpy-0.0.23rc454229-cp38-cp38-macosx_10_9_x86_64.whl
Size 12.0 MB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
21f4b9668e009ff37a3e591ae135517ec429a306f55fe7eabf14d00c4e39606b
BLAKE2b-256 checksum
How to use checksums
fa342cd0ad257e1ac08051438d5ef5f4132b2d9cea6293d9cb2bd82bbda59cd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.6

Release history Release notifications | RSS feed

0.0.38

6 release files

0.0.37

4 release files

0.0.36

4 release files

0.0.35

4 release files

0.0.33

6 release files

0.0.32

6 release files

0.0.31

6 release files

0.0.30

6 release files

0.0.29

6 release files

0.0.26

6 release files

This release

0.0.23rc454229 This release

6 release files

0.0.20

3 release files

0.0.19

3 release files

0.0.4

4 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page