Code Monkey home page Code Monkey logo

intelligent_fund_via_rl's Introduction

A model of intelligent behavior in agent-based financial systems

This repository contains the code used in the paper I wrote as contribution to a research seminar as part of my Master in Banking and Finance Program at the Uni of St. Gallen.

Abstract:

We propose a novel approach to model the behavior of institutions in agent-based financial systems. To achieve this, reinforcement learning techniques are used to continuously improve the demand decision of a fund during episodes of interaction with other agents in a simulated environment. It is shown that after training, the learning agent displays a sophisticated demand behavior. Also, it is not able to learn a dominant strategy. Lastly, the learning fund does not follow the dynamics of other, simpler agents, but displays more complex behavior. The results indicate a potential for similar methods in the analysis of macroprudential stress scenarios.

Thurner Model

Is is an implementation of the model described by Thurner, Farmer & Geanakoplos: Leverage causes fat tails and clustered volatility, 2012.

Contains the main classes for agents which populate the environment, as well as the mechanism to determine the equilibrium price in the market.

I strongly rely on Luzius Meisser's well documented implementation of the model, which was written for the Santa Fe Institute Complexity Economics MOOC and can be found here.

Here, the basic environment described by Thurner et al. is implemented similar to an OpenAI gym environment. It uses the classes in thurner_model.py. We can check the functionality by running simulations and compare the results to the ones obtained by Thurner et al.

Learning Fund

This is the heart of the model. Here, a new LearningFund class is introduced, which does not have a static demand function, but learns it via the actor-critic method.

The code for the actor-critic learning mechanism is based on an implementation by Denny Britz, which he uses to solve the Continuous Mountain Car problem. It can be found here.

I make adjustments to his code to make it compatible with the model described by Thurner et al.

The environment now consists of the basic agents and mechanisms described by Thurner et al., including 10 normal Funds with static demand functions. Also we add one additional Learning Fund.

To run the simulation and let the Learning Fund learn:

python learning_fund.py experiment_name

The default number of episodes and time steps per episodes are set to 30 and 5000 respectively, and can be specified like so:

python learning_fund.py experiment_name -ep 30 -ts 5000

Evaluations

Contains different visualizations of one long learning period (100 episodes).

Uses a pre-trained LearningFund (which learned for 100 episodes) and lets us run different kinds of scenarios with it.

intelligent_fund_via_rl's People

Contributors

sertainly avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.