First we import all necessary files.
In [ ]:
from math import isclose
from models.fmarket import set_up
We then initialize global variables.
In [ ]:
from indra.agent import Agent
from indra.composite import Composite
from indra.display_methods import BLUE, RED
from indra.env import Env, UNLIMITED
from indra.registry import get_env, get_prop
from indra.utils import gaussian
from indra.utils import init_props
MODEL_NAME = "fmarket"
DEF_NUM_TREND_FOLLOWER = 10
DEF_NUM_VALUE_INVESTOR = 10
DEF_CAPITAL = 1000
DEF_PRICE = 8 # a starting point
DEF_PERIODS = 3
DEF_NUM_ASSET = 10
DEF_MIN_PRICE_MOVE = .2
DEF_MAX_PRICE_MOVE = .4
INF = 1000000000 # just some very big num!
DEF_REAL_VALUE = 10
DEF_DISCOUNT = .002
DEF_SIGMA = .8
Next we call the set_up function to set up the environment, groups, and agents of the model.
In [ ]:
set_up()
You can run the model N periods by typing the number you want in the following function and then running it.
In [ ]:
Env("fmarket",
.runN()
You can view the position of all of the agents in space with the following command:
In [ ]:
Env("fmarket",
.scatter_graph()
You can view the line graph through the following command:
In [ ]:
Env("fmarket",
.line_graph()