Stock Market
by Robert Levinson
Game Rules This game sets up a stock market with only one stock. Agents can place buy and sell orders.

Each player has two balances:
  • money (initially $100) and
  • shares in stock MBI (initially a single share worth $100 see below)

The price of a share fluctuates each turn based on the (number of legal shares bid (to buy) - number of legal shares asked (to sell) ).

The Monitor passes in a preturn price to each agent.

However, the price actually will be filled at the post turn price of preturn + sharesbid - sharesasked. Orders may only get partially filled if agents do not have enough money (after the markup). [price is not allowed to fall below 1.0 but theoretically could go to infinity.]

On each turn players may place an order to buy or sell shares (no short selling) at the preturn market price and they must maintain a nonnegative balance of money and shares at all times.
Players can buy fractional shares in 0.1 share increments, but not smaller.

The game should play 10,000 turns and then all shares are liquidated at the preturn price. At that point the player with the most money wins. The game can end before 10,000 turns if there’s only one agent remaining in which case that agent will be declared the winner.

Players are terminated for either failing to maintain a positive balance or making an illegal buy or sell order (for example trying to buy without having enough money to cover the purchase, or trying to sell more stocks than one possesses.)

The monitor should output a message and a list of all current agents and holdings whenever any agent is terminated.

 

Agent Requirements An agent is a program that accepts one list and one scalar and outputs a single integer representing a buy or sell order. Important: because we will be running tournaments with tens of players, we need unique name spaces. It's absolutely crucial that you follow this naming convention for your agents.

Lastname1Lastname2

where each Lastname is the last name of team members capitalized. If there's only one person in the team, then there will be only one Lastname. If there are more, then list them alphabetically.

The declaration for the agent function should be like the following example:

(defun KhosmoodLevinson (holdings price)

....

)

  • holdings is a list of lists. Each internal list is made up of two elements: balance and shares which represent the state of a single agent. The outer list, thus represents the holdings of everybody still in the game starting with the agents own holdings. So to summarize, holdings should look like this:
    • ((ownBalance ownShares) (balance1 shares1) (balance2 shares2) ....(balanceN sharesN))
  • price is a single floating point number representing the pre-turn per/share price.

example: An agent being called in a 3-agent game.

(KhosmoodLevinson '( (250.556 12.1)(110.2 14.4)(24.92 55.8) ) 120.8579)

Such a call should return a single integer. A positive integer represents a buy order and a negative order means a sell order for that amount. Example:

123.2

-33.3

Important: An agent must have enough funds to cover any buy request. The preturn price, passed in to the agent, is used to calculate this. If the agent does not have enough funds, this constitutes and illegal order and that agent is eliminated.

Monitor Requirements The Monitor is a program that executes 10,000 rounds of Stock Market. The naming convention for Stock Market monitor is the same as agents plus the string "Monitor" added to it. For example

LevinsonKhosmoodMonitor

The monitor has a responsibility of running 10,000 rounds where every round is a market wide buy/sell opportunity. It only accepts a number of agents and returns a sorted list of agents. Any agents eliminated will have no holdings (0 money and 0 stocks) and thus would be at the last of the list.

Declaration of the monitor is the following:

(defun LastNameMonitor (agents)

...

)

  • output: the monitor will output an ordered list of all agents, sorted by the order of liquidated balance (all the money + all the stocks sold).

example 1: ( (agentx 300) (agenty 425) )

example 2: ( (agentx 175) (agenty 425) (agentz 425) )