from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) author: str = 'Simon Obexer' doc = ''' Framing in Bullish&Bearish markets ''' class Constants(BaseConstants): name_in_url = 'Master_Experiment_BEAR_POS' players_per_group = None num_rounds = 1 endowment_cash = c(1000) endowment_stock = 10 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): # Questions # Kursentwicklung T0-T1 Beliefs_1 = models.IntegerField( choices=[-4,-3,-2,-1,0,1,2,3,4], widget=widgets.RadioSelectHorizontal, min=-4, max=4, doc='''Beliefs of participants''') buy_1 = models.IntegerField( min=0, doc="""stocks willing to buy""" ) sell_1 = models.IntegerField( min=0, doc="""stocks willing to sell""" ) # T1 Tweet Beliefs_Tweet_1 = models.IntegerField( choices=[-4, -3, -2, -1, 0, 1, 2, 3, 4], widget=widgets.RadioSelectHorizontal, min=-4, max=4, doc='''Beliefs of participants''') buy_Tweet_1 = models.IntegerField( min=0, doc="""stocks willing to buy""" ) sell_Tweet_1 = models.IntegerField( min=0, doc="""stocks willing to sell""" ) # Kursentwicklung T1-T2 Beliefs_2 = models.IntegerField( choices=[-4, -3, -2, -1, 0, 1, 2, 3, 4], widget=widgets.RadioSelectHorizontal, min=-4, max=4, doc='''Beliefs of participants''') buy_2 = models.IntegerField( min=0, doc="""stocks willing to buy""" ) sell_2 = models.IntegerField( min=0, doc="""stocks willing to sell""" ) # Tweet_2 Beliefs_Tweet_2 = models.IntegerField( choices=[-4, -3, -2, -1, 0, 1, 2, 3, 4], widget=widgets.RadioSelectHorizontal, min=-4, max=4, doc='''Beliefs of participants''') buy_Tweet_2 = models.IntegerField( min=0, max=10, doc="""stocks willing to buy""" ) sell_Tweet_2 = models.IntegerField( min=0, max=10, doc="""stocks willing to sell""" ) # Kursentwicklung T2_T3 Beliefs_3 = models.IntegerField( choices=[-4, -3, -2, -1, 0, 1, 2, 3, 4], widget=widgets.RadioSelectHorizontal, min=-4, max=4, doc='''Beliefs of participants''') buy_3 = models.IntegerField( min=0, max=10, doc="""stocks willing to buy""" ) sell_3 = models.IntegerField( min=0, max=10, doc="""stocks willing to sell""" ) # Price_path # Tweet_1 stock_price_1 = models.CurrencyField(initial=(100.00)) cash_1 = models.CurrencyField() stock_1 = models.IntegerField() def cash_amount_1(self): self.cash_1 = (self.sell_1 - self.buy_1) * self.stock_price_1 + Constants.endowment_cash return self.cash_1 def stock_amount_1(self): self.stock_1 = self.buy_1 - self.sell_1 + Constants.endowment_stock return self.stock_1 # Kursentwicklung T1_T2 cash_t1 = models.CurrencyField() stock_t1 = models.IntegerField() def cash_amount_t1(self): self.cash_t1 = (self.sell_Tweet_1 - self.buy_Tweet_1) * self.stock_price_1 + self.cash_1 return self.cash_t1 def stock_amount_t1(self): self.stock_t1 = (self.buy_Tweet_1 - self.sell_Tweet_1) + self.stock_1 return self.stock_t1 # Tweet_2 stock_price_2 = models.CurrencyField(initial=(70.00)) cash_2 = models.CurrencyField() stock_2 = models.IntegerField() def cash_amount_2(self): self.cash_2 = (self.sell_2 - self.buy_2) * self.stock_price_2 + self.cash_t1 return self.cash_2 def stock_amount_2(self): self.stock_2 = (self.buy_2 - self.sell_2) + self.stock_t1 return self.stock_2 # Kursentwicklung T2_T3 cash_t2 = models.CurrencyField() stock_t2 = models.IntegerField() def cash_amount_t2(self): self.cash_t2 = (self.sell_Tweet_2 - self.buy_Tweet_2) * self.stock_price_2 + self.cash_2 return self.cash_t2 def stock_amount_t2(self): self.stock_t2 = (self.buy_Tweet_2 - self.sell_Tweet_2) + self.stock_2 return self.stock_t2 # Ergebnis stock_price_3 = models.CurrencyField(initial=(40.00)) cash_3 = models.CurrencyField() stock_3 = models.IntegerField() final_wealth = models.CurrencyField() def cash_amount_3(self): self.cash_3 = (self.sell_3 - self.buy_3) * self.stock_price_3 + self.cash_t2 return self.cash_3 def stock_amount_3(self): self.stock_3 = (self.buy_3 - self.sell_3) + self.stock_t2 return self.stock_3 def final_wealth_3(self): self.final_wealth = self.cash_3 + self.stock_3 * self.stock_price_3 return self.final_wealth