-
Notifications
You must be signed in to change notification settings - Fork 2
/
zeroi.py
29 lines (24 loc) · 902 Bytes
/
zeroi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from base_agent import BaseAgent
import numpy as np
import random
class ZeroI(BaseAgent):
def __init__(self, id, budget, true_alpha, true_beta, noise, alpha, beta):
self.id = id
self.budget = budget
self.belief = random.betavariate(true_alpha, true_beta)
def name(self):
return 'ZeroI'
# def __repr__(self):
# return 'ZeroI id {} belief {} budget {}'.format(self.id, self.belief, self.budget)
def update_prior(self, signal):
pass
def cur_belief(self):
return self.belief
def calc_quantity(self, market):
buying = random.choice([True, False])
if buying and market.pos_price() < self.cur_belief():
return np.array([1.0, 0.0])
elif not buying and market.neg_price() < (1-self.cur_belief()):
return np.array([0.0, 1.0])
else:
return np.array([0.0, 0.])