treatment "double-auction.ztt"{ background{ table globals{ } table subjects{ } table summary{ } table contracts{ } table clients{ } table treatments{ } table sessionglobals{ } table participations{ } numsubjects = 8; numgroups = 1; numpracticeperiods = 0; numactualperiods = 2; exchangerate = 1; startendowment = 0; showupfee = 0; noAutoscope = FALSE; firstBoxesOnTop = FALSE; showupfeeawaytext = "You are making losses. Do you want to invest the showupfee in order to continue?"; showupfeeawayyestext = "Yes"; showupfeeawaynotext = "No"; moneyawaytext = "You are making losses. Do you want to continue?"; moneyawayyestext = "Yes"; moneyawaynotext = "No"; bancruptwaittext = "Please wait until the experimenter unlocks your PC."; program{ table = globals; do{ TradingTime = 120; } } program{ table = subjects; do{ // Unit k is worth Values[k] to a buyer, and costs a seller Costs[k]. array Values[4]; Values[1] = 400; Values[2] = 300; Values[3] = 200; Values[4] = 200; array Costs[4]; Costs[1] = 20; Costs[2] = 120; Costs[3] = 220; Costs[4] = 220; MaxUnits = 4; MaxPrice = 1000; UnitsTraded = 0; } } program{ table = contracts; do{ // An offer: a bid has Buyer (its maker) and Seller = -1; an ask the other way round. // A trade has both; a withdrawn offer has -2 for the side it lacked. Buyer = 0; Seller = 0; TradePrice = 0; } } screen action{ usesbg = TRUE; withalertscreen = FALSE; noalertscreen = FALSE; headerbox "Header"{ hasframe = TRUE; height = 10%; top = 0p; cuttop = TRUE; showPeriods = TRUE; showNumPeriods = TRUE; periodtext = "Period"; periodoftext = "of"; practiceperiodprefix = "Trial "; showtime = TRUE; timestr = "Remaining time [sec]:"; pleasedecidetext = "Please reach a decision."; } } screen wait{ usesbg = TRUE; withalertscreen = FALSE; noalertscreen = FALSE; standardbox "Text"{ hasframe = TRUE; buttonposition = BOTTOMRIGHT; buttonsequence = HORIZONTAL; item{ label = "Please wait until the experiment continues."; } } } } stage "Buyers"{ startwaitforall = TRUE; startConditionStr = ""; singleentry = FALSE; singleentrycontinuation = FALSE; timeouttype = always; timeout = TradingTime; program{ table = subjects; do{ // Players 1 to 4 buy, 5 to 8 sell. IsBuyer = if(Player <= 4, 1, 0); Participate = IsBuyer; } } screen action{ usesbg = TRUE; withalertscreen = FALSE; noalertscreen = FALSE; standardbox "You"{ hasframe = TRUE; width = 30%; left = 0; cutleft = TRUE; buttonposition = BOTTOMRIGHT; buttonsequence = HORIZONTAL; item{ label = "You are a buyer."; } item{ label = "Units traded"; variable = UnitsTraded; format = "1"; input = FALSE; } item{ label = "Your next unit is worth"; variable = Values[UnitsTraded + 1]; format = "1"; input = FALSE; } item{ label = "Profit so far"; variable = Profit; format = "1"; input = FALSE; } } makecontractbox "Make an offer"{ hasframe = TRUE; width = 40%; table = contracts; buttonposition = BOTTOMRIGHT; buttonsequence = HORIZONTAL; emptyallowed = FALSE; allemptyallowed = FALSE; numrecords = 1; tablelayout = VERTICAL; item{ label = "Price"; variable = Price; format = "1"; input = TRUE; showdefault = FALSE; emptyallowed = FALSE; min = 0; max = MaxPrice; } button "Bid"{ clearinputafterok = FALSE; norecordmadeorselected = FALSE; terminatestage = FALSE; donotterminatestage = FALSE; specialbuttoncolor = FALSE; buttoncolor = 0; checker{ condition = :UnitsTraded < MaxUnits; message = "You have traded all your units."; yesButtonStr = ""; noButtonStr = "OK"; } checker{ condition = contracts.count(Seller == -1 & Buyer > 0) == 0 | Price > contracts.maximum(Seller == -1 & Buyer > 0, Price); message = "Your bid must be higher than the best bid."; yesButtonStr = ""; noButtonStr = "OK"; } program{ table = contracts; do{ Buyer = :Subject; Seller = -1; } } } } selectcontractbox "Asks"{ hasframe = TRUE; width = 30%; table = contracts; buttonposition = BOTTOMRIGHT; buttonsequence = HORIZONTAL; emptyallowed = FALSE; allemptyallowed = FALSE; condition = Buyer == -1 & Seller > 0; sortfields = "Price"; tablelayout = LIST; scrollatstart = FALSE; scrollatEnd = FALSE; selectbest = TRUE; item{ label = "Ask"; variable = Price; format = "1"; input = FALSE; } button "Buy"{ clearinputafterok = FALSE; norecordmadeorselected = FALSE; terminatestage = FALSE; donotterminatestage = FALSE; specialbuttoncolor = FALSE; buttoncolor = 0; checker{ condition = :UnitsTraded < MaxUnits; message = "You have traded all your units."; yesButtonStr = ""; noButtonStr = "OK"; } program{ table = contracts; do{ Buyer = :Subject; TradePrice = Price; subjects.do { if (Subject == :Buyer) { UnitsTraded = UnitsTraded + 1; Profit = Profit + Values[UnitsTraded] - :Price; } if (Subject == :Seller) { UnitsTraded = UnitsTraded + 1; Profit = Profit + :Price - Costs[UnitsTraded]; } } // The traders' other offers are withdrawn. contracts.do { if (Seller == :Seller & Buyer == -1) { Buyer = -2; } if (Buyer == :Buyer & Seller == -1) { Seller = -2; } } } } } } selectcontractbox "Bids"{ hasframe = TRUE; width = 30%; table = contracts; buttonposition = BOTTOMRIGHT; buttonsequence = HORIZONTAL; emptyallowed = FALSE; allemptyallowed = FALSE; condition = Seller == -1 & Buyer > 0; sortfields = "-Price"; tablelayout = LIST; scrollatstart = FALSE; scrollatEnd = FALSE; selectbest = FALSE; item{ label = "Bid"; variable = Price; format = "1"; input = FALSE; } } selectcontractbox "Trades"{ hasframe = TRUE; width = 30%; table = contracts; buttonposition = BOTTOMRIGHT; buttonsequence = HORIZONTAL; emptyallowed = FALSE; allemptyallowed = FALSE; condition = Buyer > 0 & Seller > 0; sortfields = ""; tablelayout = LIST; scrollatstart = FALSE; scrollatEnd = FALSE; selectbest = FALSE; item{ label = "Price"; variable = TradePrice; format = "1"; input = FALSE; } } } screen wait{ usesbg = TRUE; withalertscreen = FALSE; noalertscreen = FALSE; } } stage "Sellers"{ startwaitforall = FALSE; startConditionStr = ""; singleentry = FALSE; singleentrycontinuation = FALSE; timeouttype = always; timeout = TradingTime; program{ table = subjects; do{ IsBuyer = if(Player <= 4, 1, 0); Participate = 1 - IsBuyer; } } screen action{ usesbg = TRUE; withalertscreen = FALSE; noalertscreen = FALSE; standardbox "You"{ hasframe = TRUE; width = 30%; left = 0; cutleft = TRUE; buttonposition = BOTTOMRIGHT; buttonsequence = HORIZONTAL; item{ label = "You are a seller."; } item{ label = "Units traded"; variable = UnitsTraded; format = "1"; input = FALSE; } item{ label = "Your next unit costs"; variable = Costs[UnitsTraded + 1]; format = "1"; input = FALSE; } item{ label = "Profit so far"; variable = Profit; format = "1"; input = FALSE; } } makecontractbox "Make an offer"{ hasframe = TRUE; width = 40%; table = contracts; buttonposition = BOTTOMRIGHT; buttonsequence = HORIZONTAL; emptyallowed = FALSE; allemptyallowed = FALSE; numrecords = 1; tablelayout = VERTICAL; item{ label = "Price"; variable = Price; format = "1"; input = TRUE; showdefault = FALSE; emptyallowed = FALSE; min = 0; max = MaxPrice; } button "Ask"{ clearinputafterok = FALSE; norecordmadeorselected = FALSE; terminatestage = FALSE; donotterminatestage = FALSE; specialbuttoncolor = FALSE; buttoncolor = 0; checker{ condition = :UnitsTraded < MaxUnits; message = "You have traded all your units."; yesButtonStr = ""; noButtonStr = "OK"; } checker{ condition = contracts.count(Buyer == -1 & Seller > 0) == 0 | Price < contracts.minimum(Buyer == -1 & Seller > 0, Price); message = "Your ask must be lower than the best ask."; yesButtonStr = ""; noButtonStr = "OK"; } program{ table = contracts; do{ Seller = :Subject; Buyer = -1; } } } } selectcontractbox "Asks"{ hasframe = TRUE; width = 30%; table = contracts; buttonposition = BOTTOMRIGHT; buttonsequence = HORIZONTAL; emptyallowed = FALSE; allemptyallowed = FALSE; condition = Buyer == -1 & Seller > 0; sortfields = "Price"; tablelayout = LIST; scrollatstart = FALSE; scrollatEnd = FALSE; selectbest = FALSE; item{ label = "Ask"; variable = Price; format = "1"; input = FALSE; } } selectcontractbox "Bids"{ hasframe = TRUE; width = 30%; table = contracts; buttonposition = BOTTOMRIGHT; buttonsequence = HORIZONTAL; emptyallowed = FALSE; allemptyallowed = FALSE; condition = Seller == -1 & Buyer > 0; sortfields = "-Price"; tablelayout = LIST; scrollatstart = FALSE; scrollatEnd = FALSE; selectbest = TRUE; item{ label = "Bid"; variable = Price; format = "1"; input = FALSE; } button "Sell"{ clearinputafterok = FALSE; norecordmadeorselected = FALSE; terminatestage = FALSE; donotterminatestage = FALSE; specialbuttoncolor = FALSE; buttoncolor = 0; checker{ condition = :UnitsTraded < MaxUnits; message = "You have traded all your units."; yesButtonStr = ""; noButtonStr = "OK"; } program{ table = contracts; do{ Seller = :Subject; TradePrice = Price; subjects.do { if (Subject == :Buyer) { UnitsTraded = UnitsTraded + 1; Profit = Profit + Values[UnitsTraded] - :Price; } if (Subject == :Seller) { UnitsTraded = UnitsTraded + 1; Profit = Profit + :Price - Costs[UnitsTraded]; } } // The traders' other offers are withdrawn. contracts.do { if (Seller == :Seller & Buyer == -1) { Buyer = -2; } if (Buyer == :Buyer & Seller == -1) { Seller = -2; } } } } } } selectcontractbox "Trades"{ hasframe = TRUE; width = 30%; table = contracts; buttonposition = BOTTOMRIGHT; buttonsequence = HORIZONTAL; emptyallowed = FALSE; allemptyallowed = FALSE; condition = Buyer > 0 & Seller > 0; sortfields = ""; tablelayout = LIST; scrollatstart = FALSE; scrollatEnd = FALSE; selectbest = FALSE; item{ label = "Price"; variable = TradePrice; format = "1"; input = FALSE; } } } screen wait{ usesbg = TRUE; withalertscreen = FALSE; noalertscreen = FALSE; } } stage "Results"{ startwaitforall = TRUE; startConditionStr = ""; singleentry = FALSE; singleentrycontinuation = FALSE; timeouttype = ifnoinput; timeout = 30; screen action{ usesbg = TRUE; withalertscreen = FALSE; noalertscreen = FALSE; standardbox "Results"{ hasframe = TRUE; buttonposition = BOTTOMRIGHT; buttonsequence = HORIZONTAL; item{ label = "Units you traded"; variable = UnitsTraded; format = "1"; input = FALSE; } item{ label = "Your payoff"; variable = Profit; format = "1"; input = FALSE; } button "Continue"{ clearinputafterok = FALSE; norecordmadeorselected = FALSE; terminatestage = FALSE; donotterminatestage = FALSE; specialbuttoncolor = FALSE; buttoncolor = 0; } } } screen wait{ usesbg = TRUE; withalertscreen = FALSE; noalertscreen = FALSE; } } roles{ role "S 1"{ } role "S 2"{ } role "S 3"{ } role "S 4"{ } role "S 5"{ } role "S 6"{ } role "S 7"{ } role "S 8"{ } } period "1"{ prompt = ""; subject 1{ name = ""; group = 1; do{ Player = 1; } } subject 2{ name = ""; group = 1; do{ Player = 2; } } subject 3{ name = ""; group = 1; do{ Player = 3; } } subject 4{ name = ""; group = 1; do{ Player = 4; } } subject 5{ name = ""; group = 1; do{ Player = 5; } } subject 6{ name = ""; group = 1; do{ Player = 6; } } subject 7{ name = ""; group = 1; do{ Player = 7; } } subject 8{ name = ""; group = 1; do{ Player = 8; } } } period "2"{ prompt = ""; subject 1{ name = ""; group = 1; do{ Player = 1; } } subject 2{ name = ""; group = 1; do{ Player = 2; } } subject 3{ name = ""; group = 1; do{ Player = 3; } } subject 4{ name = ""; group = 1; do{ Player = 4; } } subject 5{ name = ""; group = 1; do{ Player = 5; } } subject 6{ name = ""; group = 1; do{ Player = 6; } } subject 7{ name = ""; group = 1; do{ Player = 7; } } subject 8{ name = ""; group = 1; do{ Player = 8; } } } }