from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) author = 'Simon Obexer' doc = """ Lets try some stuff """ class Constants(BaseConstants): name_in_url = 'Test_Master_Experiment' players_per_group = None num_rounds = 3 endowment_cash = c(1000) endowment_stock = 10 class Subsession(BaseSubsession): def creating_session(self): players = self.get_players() if players.round_number() == 1: self.stock_price = c(100) if players.round_number() == 2: self.stock_price = c(130) if players.round_number() == 3: self.stock_price = c(160) class Group(BaseGroup): pass class Player(BasePlayer): beliefs = models.IntegerField( choices=[-4, -3, -2, -1, 0, 1, 2, 3, 4], widget=widgets.RadioSelectHorizontal, min=-4, max=4, doc='''Beliefs of participants''') buy = models.IntegerField( blank=True, min=0, max=10, doc="""stocks willing to buy""" ) sell = models.IntegerField( blank=True, min=0, max=10, doc="""stocks willing to sell""" ) stock_price = models.CurrencyField() cash = models.CurrencyField() stock = models.IntegerField() def cash_amount(self): self.cash = (self.sell - self.buy) * self.stock_price + Constants.endowment_cash return self.cash def stock_amount(self): self.stock = self.buy - self.sell + Constants.endowment_stock return self.stock