In [28]:
import numpy as np
import numpy.random as rnd
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
from comparablemodels.chiarellaIori import chilori_model
%matplotlib inline
Using this notebook, we replicate the 2002 model by Ciarelli and Lori (2002).
Based on code from agentFin website by Blake Lebaron.
In [6]:
# set default parameters
number_of_agents = 1000
init_time = 100
max_time = 500
av_return_interval_min = 5
av_return_interval_max = 50 # previously Lmax
fundamental_value = 1000. # previously pf
allowed_price_steps = 0.1 # deltaP
variance_noise_forecast = 0.01 # prev sigmae
order_noise_max = 0.5 # prev kMax
order_expiration_time = 50 # prev tau
runType = 0
if runType == 0:
fundamental_weight = 0. # prev sigmaF
momentum_weight = 0. # prev sigmaM
noise_weight = 1. # prev sigmaN
if runType == 1:
fundamental_weight = 1.
momentum_weight = 0.
noise_weight = 1.
if runType == 2:
fundamental_weight = 1.
momentum_weight = 10.
noise_weight = 1.
ticks_per_day = 100
In [ ]:
day_price, day_volume, day_return, price, returns, total_volume = ciarellilori2002(seed, max_time, init_time, number_of_agents, av_return_interval_min,
av_return_interval_max, fundamental_value, allowed_price_steps, variance_noise_forecast,
order_noise_max, order_expiration_time, fundamental_weight, momentum_weight, noise_weight,
ticks_per_day):