Video Of Day

Breaking News

Comments On Structuring An Agent-Based Economic/Financial Simulator

One of the problems amongst criterion stock-flow consistent (SFC) models is that cost determination is somewhat hard to model. (In fact, the sfc_models framework has non fifty-fifty attempted to practise hence at the fourth dimension of writing.) One possible way of dealing amongst this number would hold upwards to add together cost determination inward flex-price markets (such equally fiscal in addition to futures markets) laid yesteryear agents. Such models could create quite believable behavioural patterns. The work is that it is hard to check such models to existent reason data. However, the fact that the conduct is believable makes such simulations a useful education tool -- or economical engine inward a video game.

The give-and-take hither almost exclusively reflects my thinking on the topic. One of my hobbies is writing video games, in addition to I built similar simulators almost a twosome of decades ago. From what I receive got seen of the academic agent-based modelling literature, it is roughly compatible amongst my thinking, but my goals were somewhat different.

High Level Model Description

It should hold upwards noted that I am describing what I meet equally the minimal, interesting simulator of this type. It would hold upwards possible to extend this construction inward whatever number of directions.

The work amongst creating believable conduct amid agents inward a model is that it is hard to model the varying types of relationships betwixt firms. It is extremely unlikely that 2 competing soft gulp manufacturers would collaborate on an investment project, nevertheless they would both happily antechamber politicians for a taxation interruption together. H5N1 human tin lavatory sympathise such behaviour, but it is hard for an algorithm to emulate it.

The way to eliminate such considerations from a model is to receive got inter-firm transactions done on arms-length footing through a marketplace mechanism. I volition assume that these transactions are done on an exchange.

When nosotros switch to transactions amongst households, nosotros switch to to a greater extent than aggregated behaviour, in addition to pricing is done on an administered basis. Retail prices are laid equally a markup over wholesale (exchange) prices, in addition to motility relatively infrequently. Most workers receive got a fixed wage charge per unit of measurement that is periodically re-negotiated. Since the wage neb appears to hold upwards largely fixed inward the brusk term, manufacturers receive got a footing to cost outputs using a markup over costs.

Exchanges: Hyper-Fast

The kickoff chunk of the model are the exchanges, in addition to firms that utilisation those exchanges. All wholesale transactions for goods are done on the footing of boundary orders through an exchange; nosotros tin lavatory receive got multiple exchanges to allow merchandise over a distance.

For now, nosotros ignore the being of a existent economic scheme in addition to merely assume that nosotros receive got a grouping of firms amongst an initial allotment of commodities, in addition to they receive got algorithms they utilisation for portfolio allocation.

What nosotros should await to scope off is that at that spot volition hold upwards an initial outburst of trading, until trading finally ceases. If nosotros burn downwards off trades every microsecond (of simulation time), the outburst may finally a millisecond or so. (It may receive got a lot longer to run the simulation.)

Why does trading receive got to cease? Take the simplest case, i where a unmarried theatre acts equally a marketplace maker, in addition to every other theatre is a cost taker. Unless the marketplace maker is run yesteryear idiots, at that spot is a non-zero bid-offer spread at all times. This way that whatever firms that merchandise are taking a loss versus mid-market pricing, in addition to they would eventually larn bankrupt if they continue trading. (There may hold upwards some foreign corner cases I am omitting, but it is hard to vanquish this principle.)

If nosotros receive got multiple marketplace makers, trading could theoretically oscillate forever -- the marketplace makers would lose coin on some classes of transactions, piece gaining on others. However, to continue the wheel going, it would require the theatre administration non pulling the plug on losing strategies -- which is implausible.

In summary, the markets volition motility to an "equilibrium" seat where everyone is staring at each other across bid-offer spreads.

The Real World: Slow

The existent economic scheme does non operate at a microsecond frequency. Since it is somewhat rare for employees to modify jobs inside the same working day, the shortest effective frequency is daily.

Let us aspect at the typical flow of cash for households. They larn paid every twosome of weeks, in addition to hence purchase goods at retail stores at diverse points during the day.

This volition affect the previous model yesteryear having periodic cash outflows for wages, in addition to retailers accumulating modest sales increments during the day. Once the retailers receive got sold plenty goods retail, they volition demand to replenish their inventories yesteryear buying inward the wholesale market. This kicks the marketplace residuum inward i administration or some other -- possible causing a flurry of trading activity equally portfolios are adjusted.

(We could also receive got aggregated statistics available at a lower frequency -- monthly, say. Any agents that utilisation economical information inward their pricing algorithms would adjust their portfolios inward reply to this news.)

If the existent economic scheme simulation staggers aggregate flows to in addition to from the "real economy" appropriately, the marketplace simulation would start to resemble real-world trading patterns.

Generating the aggregate flows to in addition to from the diverse sectors of the existent economic scheme is straightforward: nosotros tin lavatory conform existing behavioural functions from SFC models.The only existent fob is to switch from simultaneous end-of-period small town to coming upwards amongst rules to interruption upwards aggregate flows to diverse discrete points inward fourth dimension inside larger accounting periods.

Credit -- H5N1 Casualty of the Strategy

Simulating credit relationships inward such a framework is difficult, since everything is arm's length. (The existent economic scheme part of the model tin lavatory characteristic aggregated lending, such equally banks having portfolios of identify mortgages.)

The simplest way to contain leverage is to receive got a margin organization on the exchange. We tin lavatory assume that the authorities backs the telephone commutation (levying a transaction tax), in addition to hence nosotros practise non receive got to worry nearly the whole affair collapsing financially. However, it would hold upwards possible to receive got a debt deflation -- firm's collateral value is marked down, in addition to hence their borrowing capacity is cut, forcing commodity sales to rebuild liquidity. Such forced selling drops prices, in addition to hence nosotros larn a self-reinforcing deport market.

How Feasible Is Building Such a Model?

Although such a model appears extremely complex, it would genuinely hold upwards straightforward to build. The strategy is to utilisation a client-server model, next the pattern of how real-time strategy games are designed. (Note that yous would non demand a dedicated machine running equally a server; the customer in addition to server tin lavatory run on the same machine. If packaged correctly, most users would non realise it is client-server, unless their firewalls complain nearly the intra-process communication.)

The server implements the telephone commutation rules, in addition to runs the existent economic scheme simulation. We hence receive got customer programs that copy the firms. The clients communicate amongst the server, getting marketplace prices, in addition to generating trades, equally good equally doing things similar fixed investments in addition to hiring workers.

You merely demand to ensure that yous receive got firms that are active inward every income loop inward the model. For example, if yous receive got firms that create energy, but at that spot are no unloose energy consumers, those firms volition merely fail. The background simulation also has to ensure that flows practise non drib out of the system; for example, reward demand to hold upwards largely consumed, in addition to identify savings eventually returning equally well.

The beauty of a client-server architecture is that it is good suited for opened upwards source collaboration. People tin lavatory write their customer programs inward whatever estimator linguistic communication they similar (as long equally the linguistic communication supports socket communication).

Application to the Real World

I receive got my doubts that nosotros tin lavatory create such a model in addition to utilisation it to generate forecasts. However, it volition generate plausible economical simulations amongst pretty much all of the information yous could maybe want. We could calculate simulation aggregates, in addition to utilisation them equally "experiments" for validating statistical techniques.

This would hold upwards useful for naysayers similar myself. We could run tests to meet whether it is possible to invalidate statistical techniques. For example, it may hold upwards possible to generate simulations that appear to receive got an r* that has nearly the same predictive value equally r* inward the existent reason -- fifty-fifty though involvement rates practise non appear inward whatever agent's decision-making process.

It's a Video Game!

The higher upwards construction would piece of work equally the economical engine of a video game. In fact, I built a similar game dorsum unopen to the twelvemonth 2000. The key divergence from the higher upwards description is that I was non hence familiar amongst SFC models, in addition to hence the existent economic scheme part of the engine could only hold upwards described equally terrible. In fact, I got interested inward macro modelling largely equally a final result of wanting to amend that engine. (I worked inward fixed income, but my modelling piece of work was largely criterion marketplace economist analysis.)

This sense partly explains my aversion to mainstream economics. If yous seek to apply the insights of mainstream macro to this task, yous rapidly discovery that it is completely useless. Where's my representative household? No where to hold upwards found. Even though SFC models are hardly perfect, yous tin lavatory stick a version of them into the engine.

For most programmers, working amongst a client-server architecture is difficult. However, I am non concerned yesteryear this, equally I already worked through most of the issues. I receive got a client-server architecture that I pose upwards on GitHub that could easily hold upwards re-purposed for this task:  https://github.com/brianr747/Simple4Xpygame. The game inward the bundle itself is non hugely interesting, but the client-server code could hold upwards used inward a infinite trading game. (I used this code inward some other carte du jour game I wrote, but I cannot release because it is based on someone else's intellectual property.) My primary destination inward the 4X projection was getting a create clean debugging framework laid up, which is the biggest work yous confront inward development.

I volition in all likelihood stick some pattern notes into that GitHub package, to explicate farther my thinking nearly the architecture. What mat appear to hold upwards arbitrary decisions are genuinely the final result of a lot of consideration.

If I always receive got spare time, I could in all likelihood convert it to a bare bones economical simulation fairly quickly. If anyone were interesting inward pursuing such a project, they could fork the project, in addition to I could aid out. (One of the questions to hold upwards looked into is what software license to use. I used Apache since it had the shortest licensing files.)

One obvious inquiry some readers mightiness receive got is: could someone brand coin selling such a game? They could try, but based on my experience, it would in all likelihood hold upwards a lot to a greater extent than fun puttering unopen to amongst the trading algorithms than playing the game. H5N1 pure economical simulator does non receive got a lot of character; blowing upwards pixel monsters is a lot to a greater extent than fun. It mightiness hold upwards possible to pose the actor inward the role of a primal banker, inward which instance they practise non receive got to worry nearly the rather bland personality of the firms inward the simulation.

Use equally a Teaching Tool (?)

The projection would straddle 2 roles: a possible base of operations for enquiry simulations, in addition to equally a opened upwards source game engine that hobbyists similar myself could putter unopen to with. One possible way to kickstart involvement would hold upwards to receive got a competitor for developing trading in addition to investment algorithms, which is the hardest part of the projection to laid up; without rules for every activity loop, the simulation breaks down. However, i time all aspects of the simulation are covered, it is slowly to start extending it inward whatever administration i wishes.

I could aid seed an initial contest, in addition to piece of work amongst educators to laid upwards a framework hence that students without much programming skills would hold upwards able to implement mathematical trading rules into the framework. (For example, I could post the winning pupil a signed re-create of all my books -- the losers larn 2 copies!) 

(c) Brian Romanchuk 2017

No comments