Location: PHPKode > projects > Uniform Price Markets > UPmarkets-0.1.0/new_markets.php
<html>
<meta http-equiv=pragma content=no-cache>
<head><title>LinuxFutures.com Game - New Market</title></head>
<body>


<?php

// (C) 2000 LinuxFutures.com, Inc.
// 
// Part of UPmarkets - the software behind the LinuxFutures game site
//                     visit www.LinuxFutures.com to play
//
//  We are making the software available to you under the GNU General Public License,
//  a copy of which should accompany this software in the file LICENSE.
//
// A web-based copy of the LICENSE is located at http://www.gnu.org/copyleft/gpl.txt
//
// While there is no charge for using this software, there are important restrictions.
//
// This LICENSE does not allow, in general, proprietary modifications or proprietary derivative works.
//
// This software carries ABSOLUTELY NO WARRANTY. It is offered AS-IS, and may not work at all
//  or may have harmful or hazardous side effects.
//
// 
// -------------------- what this file does ---------------------
// STEP 1 of when a user wants to create a NEW MARKET
// handles initial insertions into the markets database as raw proposals.
//
// also reserves a market symbol in symbols and sets some defaults in policies
//
//
 


$allowedtags = "<a></a><b></b><br><p><hr><i></i><u></u><table></table><td></td><ul></ul><ol></ol><li></li>";

require('inc.d/db_connect_m.inc');

if (count($HTTP_POST_VARS)){

  while (list($key, $value) = each ($HTTP_POST_VARS) ) {
    $value = addslashes($value);
    $f[strtolower($key)] = trim($value);
  }

// the if persists through this entire section, because POST means data is being returned from the form


require('inc.d/f_login.inc');
login($f["userid"],$f["password"],"user"); // if login fails, we'll be dead

$f["description"] = trim(addslashes(strip_tags($HTTP_POST_VARS["description"], $allowedtags)));

$query = mysql_query("INSERT INTO symbols (symbol) VALUES ('".$f["symbol"]."');",$db_link);

if ( mysql_errno($db_link) ) { 
	echo "<br>new_markets.php symbol table:".mysql_error($db_link)."<BR>";
	echo "If it says duplicate key, you have tried to create a previously registered symbol.<br>";
	echo "If it says something else, then it is probably a bug.<br>"; 
	echo "<A HREF=".$PHP_SELF.">Back.</A>";
	exit();
	}  

$symbolid = mysql_insert_id($db_link);

$sql = "INSERT INTO markets ";
$sql .= "(symbolid,status, created, modified, description, price_floor,";
$sql .= " price_ceiling, trading_opens, trading_closes, future_type, referees, traders, finale_days, summary, ";
$sql .= "thinking_interval) values (";
$sql .= "'".$symbolid."',";
$sql .= "'raw_proposal',"; // status
$sql .= "now(),"; //created
$sql .= "now(),"; //modified
$sql .= "'".$f["description"]."',"; //description 
$sql .= "'".$f["price_floor"]."',";
$sql .= "'".$f["price_ceiling"]."',";
$sql .= "'".$f["trading_opens"]."',";
$sql .= "'".$f["trading_closes"]."',";
$sql .= "'".$f["future_type"]."',";
$sql .= "'".$f["referees"]."',";
$sql .= "'".$f["traders"]."',";
$sql .= "'".$f["finale_days"]."',";
$sql .= "'".$f["summary"]."',";
$sql .= "'".$f["thinking_interval"]."');";

$query = mysql_query($sql, $db_link);

if( mysql_errno($db_link) ) { 
	echo "<br>new_markets.php table MARKETS :".mysql_error($db_link)."<BR>"; 
	echo "<A HREF=".$PHP_SELF.">Back.</A>";
	exit();
	}

$sql = "INSERT INTO policies (symbolid,posted,commission,signup_bonus,chairperson,maxspread,rationale) VALUES ( ";
$sql .= "'".$symbolid."',";
$sql .= "now(),";
$sql .= "'0',";
$sql .= "'0',";
$sql .= "'".$f["userid"]."',";
$sql .= "'".$f["maxspread"]."',";
$sql .= "'Default initial settings. Can be changed later.');";

$query = mysql_query($sql, $db_link);

if( mysql_errno($db_link) ) { 
	echo "<br>new_markets.php table POLICIES :".mysql_error($db_link)."<BR>"; 
	echo "<A HREF=".$PHP_SELF.">Back.</A>";
	exit();
	}


?>

Proposal submitted. <p>
<b>Remember</b>, the next step is getting your market approved. Go to the Proposed Markets section
of the weblog and see if you can find another market chairperson willing to approve your offering. 
<P>
On the weblog, people may offer tips and advice. Sometimes they are rude.  Whatever happens,
at least give some thought to the changes other experienced players propose. <P>
Who knows, it may even help speed the approval process.
<P>
If your market proposal is abusive in nature, it may be rejected. Negative feedback may be entered
on your record, preventing any future proposals. Oh, well, guess it is too late now...


<? } else { ?>

<b>LinuxFutures.com Game - New Market form</b>
<br>
<HR>
<form method=post action="<?php echo $PHP_SELF ?>">
The LinuxFutures.com Game is about promoting free speech through
free futures markets. Topics may involve open source, individual rights
online, or whatever else interests you (e.g. the US elections).
<br><b>Thanks</b> for your interest in volunteering to create and manage a
new market. Please RTF(Read The Form!) before hitting submit. Once again,
<b>thanks!</b>
<P>
<ol><li><b>If this is your first time here: </b> Hit PRINT and go
read. Grab a pencil, sit, and think about the answers and your plans
 to add to our game site -- some of this stuff requires thought --
and then come back when you are ready to post. Posting a new market has
serious consequences for the game, and involves a continued commitment --
it is similar in concept to creating a new, moderated, usenet newsgroup
back in the good old days. </li>
<li>If you need help or have questions before submitting the form, or just
want to discuss your ideas with people, post to the "proposed
markets" forum from the box on the right of the main page.
</li>
<li>Your new market is going to be a HUGE timesink! Luckily, we have a
partner feature where you can share management duties with your
friends.  They need to become users and you need to know their userid
numbers. You can add more partners later (so you dont have to decide
now). If you don't have any friends on this site ... well, maybe you could
make some with the forum mentioned above. If you get in over your head you
can quit, abandoning your market for some random person to pick 
up and manage. But we'd prefer you didn't do that. Hand it off to
friends/partners instead.</li>
 <li>
We do not condone spam or other advertising either in email, postings,  or
as descriptions of markets. The markets here are part of a game,
involving play money (Tux Nuggets) - they are not for selling actual 
goods! Potential site  advertisers are encouraged to write us at
<mailto:hide@address.com>hide@address.com</mailto>
 , as we are interested in selling legitimate and tasteful paid
advertising to fellow members of the Linux and Open Source communities.
</li>
<li>Designing a successful market is difficult. Not only will you need to
have 
a good topic, but you need to attract interest to it and tell people 
how to find it. Post around on other game sites (tastefully). Prominence
on this site does not come cheap -- you have to do a better job than
other market creators! By requiring a bid in TuxNuggets to get onto
the featured spots, you have to beat the other market creators in
quality and audience! A commission schedule can 
bring in TuxNugget revenues from the people who trade in your market. But
if you charge too much in TuxNugget trading commissions no one will play.
</li>
<li>Try to avoid the temptation to scum and cheat your way to the top. A
very thorough and public database is made of market creations, trading
activity, and finale refeeeing. As you rise in the rankings, that 
allnighter you spent creating a stream of new users to make bad trades
with will probably become rather obvious to a number of others who did not
cheat and they will start to complain and discuss the matter. We reserve
the right to ban abusive users from all or portions of the site
for any reason, or no reason. Eventually, we hope to build democratic 
community features to deal with  complaints, discussion, and
voting/resolution.
</li> 
</ol>
<P>
<hr>
<b>WARNING: If you make a mistake, all your efforts filling out the form will be lost. You have been warned! </b><br>
The big mistakes are bad password, a non-unique trading symbol, and violating type (integer vs. chars).
<br>
<hr>
<table columns=2 cellspacing=1 border=1>
<tr>
<td><b>Your userid number:</b></td>
<td><input type=text name=userid></td>
</tr><tr>
<td><b>Your Password: </b></td>
<td><input type=text name=password><br>Warning: password will show in clear text on this form.<br> 
<b>A bad password results in a rejected form, losing your work filling it out. </b>
Sorry. </tr>
<tr>
<td><b>Trading symbol:</b></td>
<td><input type=text name=symbol></td>
</tr><tr>
<td>Limit: 40 characters. Be creative. A symbol is the unique identifier
that people will use to find your LinuxFutures market. On NASDAQ, the 
stock symbols are only 3 or 4 letters, but you have much more
room. Try to be reasonably descriptive. Spaces are fine, don't feel
compelled to use _ or -.</td>
<td>Example: Google linux SEP</td>
</tr>
<tr>
<td><b>Summary:</b></td>
<td><input type=text size=80 length=80 name=summary></td>
</tr><tr><td>Limit:255 chars  You need to explain what the symbol
represents and
how its value can be quickly determined. Dont forget scale/units!</td>
<td>Example: www.google.com search count for "linux" pages, in thousands
</td>
</tr>
<tr>
<td><b>Type:</b></td>
<td><input type=radio name=future_type value=dayofyear>Day of year
(timing of a future event)<br><input type=radio name=future_type
value=amount CHECKED>Amount calculated at market closing (most things are
amounts)<br><input type=radio name=future_type value=boolean>Boolean (if
False at closing, value=Price floor; if True at closing value=Price
ceiling)</td>
</tr><tr>
<td>Most markets involve <i>amounts</i> that are calculated during the
finale
stage after the market has permanently closed. Markets about a feature
or existence of something can be set up as <i>boolean</i> -- with booleans
most people use a price floor of 0 and a price ceiling of 100 (using 0/1
for the floor and ceiling will not work as prices are integers, not 
reals). Markets for predicting a <i>day of year</i> are like
amount markets, except that they close
when the event has been reported and verified. Currently day of year
markets are not allowed because the computer code still needs work.
</td>
<td>
Example: AMOUNT
</td>
</tr>
<tr>
<td><b>Minimum Price:</b></td>
<td><input type=text name=price_floor></td>
</tr><tr>
<td>A price floor. No one may quote a price below the floor. This is
the lowest the market can ever go. If the facts or basis of
the market indicaes a lower value, the value may not go below the floor.</td> <td>Example: 0 </td> </tr>
<tr><td><b>Maximum Price:</b></td>
<td><input type=text name=price_ceiling></td>
</tr><tr>
<td>A price ceiling. No one may quote a price above the ceiling. This 
is the highest the market can ever go.  If the facts or basis 
of the market indicates a higher value, the value is clipped at the
ceiling.</td>
<td>Example: 50000.  Given the scale of units chosen in our summary above,
the ceiling price of 50000 would correspond to 50
million "linux" web pages found at google. </td>
</tr>
<tr>
<td><b>Allowed spread on traders' quotes:</b></td>
<td><input type=text name=maxspread></td>
</tr>
<tr>
<td>Markets at LinuxFutures.com work a bit differently than at some other
trading gamesites you may have seen.  Here, each trader must quote both a
BUY and a SELL price and maintain BUY/SELL quotes for as long as they
have holdings (+ or -) in the market. For example, userid#1 might quote
Buy 55 Sell 70. The requirement for dual persistent quotes changes
the dynamics of the game considerably. Many trading games lose their
punch because quotes are used up as they are executed, and then 
no one wants to be the first back in or the only one with an outstanding
quote (and we just flat out refuse to add robots or artificial ways of
determining price. as you'll see later, price is firmly rooted in supply
and demand as expressed through traders' quotes). As a result trade drys
up, people come and stop by and look , notice nothing is happening, and
move on. The dual, persistant quote requirement fixes a lot of
this. Another thing, a trader who knows they are right about forecasting
the final value, could enter one quote and walk away, confident they will
always buy when the price is too low and sell when it is too high. For
instance, suppose userid#1 knows, for
sure, the answer will be 62 when the market closes. Then his/her quote Buy
55 Sell 70 should,
subject to avoiding cash flow problems, always make money. <P>
OK, enough rant. The maximum allowed spread is the maximum separation
allowed between a traders BUY and SELL quotes. A user entering Buy 55 Sell
70 is using a spread of 70-55=15. If you think that is too much spread,
you could restrict them, to, say 10. Setting maxspread too narrow or too
wide may discourage traders.  Think about it and take a guess. You can
change it later. 
</td>
<td>Example: 100, which allows traders to express uncertainties of up to
100 000 web pages in our Google "Linux" search example.
</td>
</tr>

 <tr>
<td><b>Allowed traders:</b></td>
<td><input type=radio CHECKED name=traders value={anyone}>Anyone<br><input
type=radio name=traders value={anyone}-{partners}>Anyone except the
sponsor(you) and partners<br><input type=radio name=traders
value={partners}>Only sponsor/partners<br></td>
</tr><tr>
<td>Anyone is probably the most fun, and we realize that many
markets won't get created if their sponsor can't play too.
However, choosing to exclude yourself and your partners can aid in
credibility of the market, by making you appear more impartial. Closed off 
partner-only markets are not really in the spirit of the site, but may be
appropriate in special situations. They will only be allowed if your
feedback exceeds 1 million points. 
</td> 
<td>
Example: ANYONE
</td>
</tr>
<tr>
<td>
<b>Date/Time Trading Opens:</b>
</td>
<td><input type=text name=trading_opens></td>
</tr><tr><td>Format: YYYY-MM-DD HH:MM:SS <br>All fields required!. Time
zone is
Mountain Standard Time, Western USA. </td>
<td>Example: 2000-07-01 00:00:00</td>
</tr>
<tr>
<td><b>Guaranteed Thinking Interval:</b> </td>
<td><input type=text name=thinking_interval> hours</td>
</tr>
<tr>
<td>After your market officially opens, you must regularly log into market
management
and run  pricing session for your market, which will calculate
prices and
trades for the participants based on current quotes. Traders then update
their quotes and you price again...and again... and again....Market
pricings are manual, not automatic -- remember that or your traders
will hate you! Also remember, the schedule is up to you, not them.
Should you forget to logon for 30 days, we'll consider your market 
abandoned.
<P> Specifying a Thinking Interval gives the traders an
assurance of the minimum possible time between pricings. This way they
have time to research their rationale before posting new quotes.
It also establishes a speed limit and reduces the abuse a password thief or
disgruntled  partner can accomplish. Similarly, it keeps you from pricing the
market 100 times in 10 minutes because you are bored.  
</td>
<td>Example: 24 hours</td>
</tr>
<tr>
<td>
<b>Date/Time Trading Closes:</b>
</td>
<td><input type=text name=trading_closes></td>
</tr><tr><td>Format: YYYY-MM-DD HH:MM:SS <br>All fields required!. Time
zone is
Mountain Standard Time, Western USA. </td>
<td>Example: 2000-09-30 23:59:59<br>Recall in our symbol we used
SEP. We did this to indicate that the market would close in
September. Here we actually make that official.</td>
</tr>
<tr>
<td><b>Finale Period:</b></td>
<td><input type=text name=finale_days> day(s)</td>
</tr>
<tr>
<td>After the market close date above, the market goes into a finale
period where referees will determine the market's final value for
liquidating positions people still had when the market closed. See
"referees", below, for more information. The minimum length for the finale 
is one day.
</td>
<td>
Example: 3 days
</td>
</tr>
<tr>
<td><b>Referees:</b></td>
<td><input type=radio name=referees
value="{anyone}">Anyone<br><input type=radio CHECKED name=referees
value="{traders}">Our market's traders<br>
<input type=radio name=referees value="{partners}">Only the sponsor &
partners (you)
</td>
</tr><tr>
<td>A complicated decision! Let me explain:<br>
People who can participate in the finale
judging are called referees. 
Each referee posts a final value estimate, a
feedback/approval rating for the sponsor and partners, and any rationale
he has for these decisions (or no rationale).  The system will liquidate
the market
at the end of the finale at a price equal to the _median_ (middle value,
sorted, not the average) of the referees
estimates, and the sponsor/partners will receive feedback points for
their role as market manager, equal to the _sum_ of feedback. There are 
problems with each of the choices offered -- but hey!, such is life.
"Anyone" reduces the self-interest factor, but creates opportunities for
nonsense estimates. "Traders only" gives incentives for non-responsive
answers from some people -- such as the price floor (people at short
positions) or ceiling (people who are long). "Partners" puts the decision
in your hands, but then people may be afraid to trust you, either not
entering the market or leaving to avoid the risk of a bad finale judgment.  
</td>
<td>Example:Traders only <br>In this example, finding the closing
value is so trivial that refereeing is not really necessary. <br>We could
have chosen sponsor/partners.  <P>However, trader refereeing may help 
build feedback points:-)</td>
</tr>
</table>
<P>
<b>Enter any additional description of your market below.</b><br>
You may wish to explain more of what it is about than could be stated
in the summary, how SPECIAL SITUATIONS will be treated. In our example
of futures over how many web pages contain "linux",  what would happen if
the Google search engine was renamed!? Would the answer be 0, or would
another search engine be substituted? That sort of thing should be
explained in this
area.<P>
<b>Additional Description</b><br>
Remember to punctuate with HTML tags.
<br>Allowed:<?php echo htmlspecialchars($allowedtags); ?>
<Br>
<TEXTAREA name="description" COLS=70 ROWS=20 WRAP=SOFT>
</TEXTAREA><br>
<input type=submit value='wow, you are really gonna do it'><br>
</form>
<hr>

<?php } ?>

Return current item: Uniform Price Markets