示例#1
0
class Player(BasePlayer):

    time_on_speed = models.IntegerField(initial=0)
    exchange_host = models.StringField(initial='127.0.0.1')
    exchange_port = models.IntegerField()
    role = models.StringField(initial='out')
    speed = models.BooleanField(initial=False)
    spread = models.IntegerField()
    channel = models.CharField(max_length=255)
    cost = models.IntegerField(initial=0)
    fp = models.IntegerField()
    endowment = models.IntegerField()
    prev_speed_update = models.BigIntegerField(initial=0)
    speed_on = models.IntegerField(initial=0)
    speed_unit_cost = models.IntegerField()
    max_spread = models.IntegerField()
    design = models.CharField()
    consent = models.BooleanField(initial=True)
    inventory = models.IntegerField(initial=0)
    market_id = models.StringField()
    best_bid = models.IntegerField()
    best_offer = models.IntegerField()
    bid = models.IntegerField()
    offer = models.IntegerField()
    distance_from_bid = models.IntegerField(blank=True)
    distance_from_offer = models.IntegerField(blank=True)
    latent_bid = models.IntegerField(blank=True)
    latent_offer = models.IntegerField(blank=True)
    sliders = models.StringField()
    orderstore = models.StringField(blank=True)
示例#2
0
class HFTInvestorRecord(Model):

    timestamp = models.DateTimeField(auto_now_add=True)
    exchange_timestamp = models.BigIntegerField()
    subsession_id= models.StringField()
    market_id = models.StringField()
    order_token = models.StringField()
    status = models.StringField()
    buy_sell_indicator = models.StringField()
    price = models.IntegerField()

    def from_event(self, event):
        self.subsession_id = str(event.attachments['subsession_id'])
        self.market_id = str(event.attachments['market_id'])
        self.status = event.event_type
        self.order_token = event.message['order_token']
        if 'buy_sell_indicator' in event.message:
            self.buy_sell_indicator = event.message['buy_sell_indicator']
        else:
            self.buy_sell_indicator = event.message['order_token'][4]
        if 'price' in event.message:
            self.price = event.message['price']
        else:
            self.price = event.message['execution_price']
        self.exchange_timestamp = event.message['timestamp']
        return self
示例#3
0
文件: models.py 项目: manumunoz/8003
class Player(BasePlayer):
    # Treat. 1: FRST3, 2: NO3, 3:EXO3, 4:ENDO3, 5:vctm5 11: VCTM5
    treat = models.IntegerField() # Treatments from 6 to 10
    rnum = models.IntegerField(min=Constants.min_report, max=Constants.max_report)
    pnum = models.IntegerField(min=Constants.min_report, max=Constants.num_blocks)
    report_1 = models.IntegerField(min=Constants.min_report, max=Constants.max_report) # Choice player 1
    report_2 = models.IntegerField(min=Constants.min_report, max=Constants.max_report) # Choice player 2
    report_3 = models.IntegerField(min=Constants.min_report, max=Constants.max_report) # Choice player 3
    exo_click = models.IntegerField() # Player 3 verifies
    endo_click = models.BooleanField() # Player 3 verifies
    random_show = models.IntegerField() # Randomly generated number
    inst_show = models.BooleanField(blank=True,)
    correct = models.IntegerField() # Use it as conditional to show or skip screens and end the game
    belief1 = models.IntegerField(min=Constants.min_report, max=Constants.max_report) # Reported belief on P1's choices
    belief2 = models.IntegerField(min=Constants.min_report, max=Constants.max_report) # Reported belief on P2's choices
    belief3 = models.IntegerField(min=Constants.min_report, max=Constants.max_report) # Reported belief on P3's choices
    belief_endo= models.BooleanField() # Reported belief on P3's verification
    random_group = models.BigIntegerField()
    player_role = models.IntegerField()
    duplicate = models.IntegerField()

    def assigning_values(self):
        self.random_group = int(Constants.data_player1[self.id_in_group][4])
        self.rnum = int(Constants.data_player1[self.id_in_group][5])
        self.report_1 = int(Constants.data_player1[self.id_in_group][6])
        self.report_2 = int(Constants.data_player1[self.id_in_group][7])
        self.player_role = 3
        self.duplicate = int(Constants.data_player1[self.id_in_group][8])

    def random_display(self):
        self.random_show = random.randint(1, 100)
        if self.random_show <= Constants.exo_prob_show:
            self.exo_click = 1
        else:
            self.exo_click = 0

    gender = models.PositiveIntegerField(
        choices=[
            [1, 'Male'],
            [2, 'Female'],
            [3, 'Other']
        ],
        widget=widgets.RadioSelect
    )

    ethnicity = models.PositiveIntegerField(
        choices=[
            [1, 'Hispanic / Latino / Latina'],
            [2, 'Not Hispanic / Latino / Latina'],
        ],
        widget=widgets.RadioSelect
    )

    race = models.PositiveIntegerField(
        choices=[
            [1, 'White'],
            [2, 'Black / African American'],
            [3, 'Asian'],
            [4, 'American Indian / Alaskan Native'],
            [5, 'Middle Eastern / North African'],
            [6, 'Native Hawaiian / Pacific Islander'],
            [7, 'Other']
        ],
        widget=widgets.RadioSelect
    )

    age = models.IntegerField (min=18, max=100)

    education = models.PositiveIntegerField(
        choices=[
            [1, 'Less than high school'],
            [2, 'High school diploma or equivalent (e.g., GED)'],
            [3, 'Some college'],
            [4, 'College diploma'],
            [5, 'Masters degree'],
            [6, 'Professional post-secondary degree or doctoral degree (e.g., JD, MD, PhD etc.)'],
        ],
        widget=widgets.RadioSelect
    )


    state = models.PositiveIntegerField(
        choices=[
            [1, ' Alabama '],
            [2, ' Alaska '],
            [3, ' Arizona '],
            [4, ' Arkansas '],
            [5, ' California '],
            [6, ' Colorado '],
            [7, ' Connecticut '],
            [8, ' Delaware '],
            [9, ' District of Columbia '],
            [10, ' Florida '],
            [11, ' Georgia '],
            [12, ' Hawaii '],
            [13, ' Idaho '],
            [14, ' Illinois '],
            [15, ' Indiana '],
            [16, ' Iowa '],
            [17, ' Kansas '],
            [18, ' Kentucky '],
            [18, ' Louisiana '],
            [19, ' Maine '],
            [20, ' Maryland '],
            [21, ' Massachusetts '],
            [22, ' Michigan '],
            [23, ' Minnesota '],
            [24, ' Mississippi '],
            [25, ' Missouri '],
            [26, ' Montana '],
            [27, ' Nebraska '],
            [28, ' Nevada '],
            [29, ' New Hampshire '],
            [30, ' New Jersey '],
            [31, ' New Mexico '],
            [32, ' New York '],
            [33, ' North Carolina '],
            [34, ' North Dakota '],
            [35, ' Ohio '],
            [36, ' Oklahoma '],
            [37, ' Oregon '],
            [38, ' Pennsylvania '],
            [39, ' Rhode Island '],
            [40, ' South Carolina '],
            [41, ' South Dakota '],
            [42, ' Tennessee '],
            [43, ' Texas '],
            [44, ' Utah '],
            [45, ' Vermont '],
            [46, ' Virginia '],
            [47, ' Washington '],
            [48, ' Washington DC'],
            [49, ' West Virginia '],
            [50, ' Wisconsin '],
            [51, ' Wyoming '],
        ],
    )

    income = models.PositiveIntegerField(
        choices=[
            [1, 'Less than $10,000'],
            [2, '$10,000 - $19,999'],
            [3, '$20,000 - $29,999'],
            [4, '$30,000 - $39,999'],
            [5, '$40,000 - $49,999'],
            [6, '$50,000 - $59,999'],
            [7, '$60,000 - $69,999'],
            [8, '$70,000 - $79,999'],
            [9, '$80,000 - $99,999'],
            [10, '$100,000 - $119,999'],
            [11, '$120,000 - $149,999'],
            [12, '$150,000 - $199,999'],
            [13, '$200,000 -'],
            [14, 'I do not wish to report my income.'],
        ],
        widget=widgets.RadioSelect
    )

    distribution = models.IntegerField(
        choices=[
            [0, '10'],
            [1, '4'],
            [2, '25'],
            [3, '18'],
            [4, '20'],
        ],
        widget=widgets.RadioSelect
    )

    infop2  = models.PositiveIntegerField(blank=True,
        choices=[
            [0, "P2 will see the number reported by P1, and with {}% chance will also see the hidden number".format(Constants.exo_prob_show)],
            [1, 'P2 will see the number reported by P1 and will see the hidden number if he/she clicks on a button so that it shows on the screen'],
            [2, 'P2 will see the number reported by P1 but not the hidden number'],
            [3, 'P2 will not see the number reported by P1, only the hidden number'],
            [4, 'P2 will not see any messages, he/she is a passive player'],
        ],
        widget=widgets.RadioSelect
    )

    infop3  = models.PositiveIntegerField(blank=True,
        choices=[
            [0, "P3 will see the number reported by P2, and with {}% chance will also see the hidden number".format(Constants.exo_prob_show)],
            [1, 'P3 will see the number reported by P2 and will see the hidden number if he/she clicks on a button so that it shows on the screen'],
            [2, 'P3 will see the number reported by P2 but not the hidden number'],
            [3, 'P3 will not see the number reported by P2, only the hidden number'],
            [4, 'P3 will not see any messages, he/she is a passive player'],
        ],
        widget=widgets.RadioSelect
    )

    earnings1 = models.IntegerField(
        choices=[
            [0, ' 24x5 = 120 cents'],
            [1, '  6x5 = 30 cents'],
            [2, ' 12x5 = 60 cents'],
            [3, ' 18x5 = 90 cents'],
            [4, 'It cannot be determined from this information alone'],
        ],
        widget=widgets.RadioSelect
    )

    earnings2 = models.IntegerField(
        choices=[
            [0, ' 24x5 = 120 cents'],
            [1, '  6x5 = 30 cents'],
            [2, ' 12x5 = 60 cents'],
            [3, ' 18x5 = 90 cents'],
            [4, 'It cannot be determined from this information alone'],
        ],
        widget=widgets.RadioSelect
    )

    earnings4a = models.IntegerField(blank=True,
        choices=[
            [0, ' (2x12)x5 = 120 cents'],
            [1, ' (2x12-18)x5 = 30 cents'],
            [2, ' (2x12-12)x5 = 60 cents'],
            [3, ' (18x5) = 90 cents'],
            [4, 'It cannot be determined from this information alone'],
        ],
        widget=widgets.RadioSelect
    )

    earnings4b = models.IntegerField(blank=True,
        choices=[
            [0, ' (2x12)x5 = 120 cents'],
            [1, ' (2x12-18)x5 = 30 cents'],
            [2, ' (2x12-12)x5 = 60 cents'],
            [3, ' (18x5) = 90 cents'],
            [4, 'It cannot be determined from this information alone'],
        ],
        widget=widgets.RadioSelect
    )

    pretest1 = models.LongStringField()
    pretest2 = models.IntegerField(
        choices=[
            [1, '1. Extremely Positive'],
            [2, '2. Very Positive'],
            [3, '3. Positive'],
            [4, '4. Neutral'],
            [5, '5. Negative'],
            [6, '6. Very Negative'],
            [7, '7. Extremely Negative'],
        ],
        widget = widgets.RadioSelect
    )
    pretest3 = models.LongStringField()

    def set_payoffs(self):
        self.payoff = (self.report_3)