23
7
The stock market is all about the speed of knowledge. Unlike previous challenges, the current stock price is not random: it is determined by those playing the game. If you can identify an under-priced stock before anybody else, then you've written yourself a money-making program.
Price refers to the how much people are trading the stock for, while Value refers to the amount the stock is worth at the end of the game.
Each player starts with 1000 of each stock, and 0 relative net worth. Each stock has a secret value, and your score at the end of the game is (stockValue for each ownedStock) + netWorth
. Your net worth can be negative. In an N-player game, there are N stocks.
Steps:
The game follows the following steps:
- You are given the secret value of a single stock.
- You make an offer to sell X of Y stock for $Z
- All players are given the offers, and each may choose one to accept
- All players are informed of accepted offers
- Go back to step 2
Each of the steps are given in detail below:
void secretValue(int stockType, int value)
:- The value you learn is not revealed to any other player.
- The value is between
0
and1000
- Low values are more like to occur than high values (squared uniform distribution)
Offer makeOffer(List<Stock> currentStock)
- You can return
null
to make no offer.
- You can return
Offer acceptOffer(List<Offer> offers)
- You can return
null
to accept none of them - If there are no available offers, this will not be called
- If you accept, your net worth goes down by $Z (can go negative) and receive X of Y stock. The opposite occurs with the seller.
- If you accept an offer, the exchange will occur immediately, and the offer will be removed so additional players cannot accept it.
- You can return
void acceptedOffers(List<Offer> offers)
- Includes your accepted offers as well
Static variables or writing to files is not allowed. (No persistent data from game to game) Non-serious contenders are allowed.
Interfaces:
public final class Stock {
public Stock(int stockType, int amount);
public int getType();
public int getAmount();
public Stock minus(Stock other);
public Stock plus(Stock other);
public Stock minus(int amount);
public Stock plus(int amount);
public Stock setAmount(int amount);
}
public class Offer {
public Offer(Stock offer, int payment);
public Stock getOffer();
public int getPayment();
}
Non-Java submissions:
- All calls consist of two lines: The first line is the function being called:
SecretValue
,MakeOffer
,AcceptOffer
,AcceptedOffers
,SetRandom
, and the second line containing the actual data. - Stocks are formatted with a
:
delimiter:stockType:stockAmount
. - Offers are formatted with a
@
delimiter:offer@price
- Lists are formatted with a
;
delimiter SecretValue
is formatted with a:
delimiter:stockType:value
RandomSeed
is used to make your submission deterministic. If your submission uses randomness, please use the integer value passed as the seed!- All function calls need a response. If the response is
null
orvoid
, return an empty string. - Please include a
command.txt
that gives the command line arguments to run your submission
Scoring
Games consisting of 1000 turns will be run multiple times. Players will be scored according to the ELO system, and paired with players of similar skill levels. The player with the highest final ELO score wins! (I've modified the system so that each game, ELO scores are updated for each player pairing)
The controller includes an autodownloader, so please start your submission with a header: Name, Language
. If your submission is not in Java, each code block should start with the name of the file. (excluding the command file, which should be the first block in your post)
Running
There are 2 ways to run this project:
Download the source code, compile and run. You can find the source on Github. Run
git clone --recursive https://github.com/nathanmerrill/StockExchange.git
Download the JAR executable. Submissions should be placed in your current working directory in the
/submissions
folder. You can download just the JAR, just the submissions, or both
Pass in run
to run the project (default option), or pass in download
to download all submissions so far from this question.
Scoreboard
1. 1308.1220497323848 Cheater
2. 1242.0333695640356 InsideTrader
3. 1158.3662658295411 UncleScrooge
4. 1113.8344000358493 BlackMarket
5. 1051.8370015258993 DartMonkey
6. 983.0545446731494 WarGamer
7. 939.457423938002 Spammer
8. 901.4372529538886 DumbBot
9. 859.0519326039137 ShutUpAndTakeMyMoney
10. 852.9448222849587 VincentKasuga
11. 718.2112067329083 Profiteer
stock properties aren't public, instruct to use getter methods – noɥʇʎԀʎzɐɹƆ – 2016-08-29T22:30:06.373
@AgentCrazyPython better? – Nathan Merrill – 2016-08-29T22:36:31.820
are current prices correlated to previous prices? – noɥʇʎԀʎzɐɹƆ – 2016-08-29T22:38:55.910
The "price" is simply the amount people are selling stock for. Values of stock change from game to game. – Nathan Merrill – 2016-08-29T22:44:58.960
Btw, trueskill is a better ranking system than the elo system. You can find an implementation here.
– TheNumberOne – 2016-08-29T23:10:33.060ability to accept multiple offers, please. – noɥʇʎԀʎzɐɹƆ – 2016-08-29T23:13:31.780
API to get number of turns. – noɥʇʎԀʎzɐɹƆ – 2016-08-29T23:19:39.363
@Accepting Accepting multiple offers won't be supported. To get number of turns,
StockExchange.NUM_EXCHANGES
– Nathan Merrill – 2016-08-29T23:23:41.8501A chat room would be appreciated. – TheNumberOne – 2016-08-29T23:25:01.030
"Published formulas for Trueskill are not complete" – Nathan Merrill – 2016-08-29T23:25:12.913
2http://chat.stackexchange.com/rooms/44660/stock-exchange – Nathan Merrill – 2016-08-29T23:26:07.127
Wikipedia is wrong. A full implementation is here. A full description of the formulas used is here.
– TheNumberOne – 2016-08-29T23:27:01.580I need to know when it ends to help my new bot... – noɥʇʎԀʎzɐɹƆ – 2016-08-29T23:41:51.693
@AgentCrazyPython you can use a member variable to keep track of the number of turns. MakeOffer() will be called exactly 1000 times – Nathan Merrill – 2016-08-29T23:44:22.400
if nobody makes an offer for a stock, then what's the price at the end? Critical to my bot. – noɥʇʎԀʎzɐɹƆ – 2016-08-29T23:48:46.627
The value at the end is determined randomly, and is independent of the prices being offered. You get to know the end value of exactly 1 stock. – Nathan Merrill – 2016-08-29T23:51:16.497
So, if nobody buys a stock, what's it's value? Average of offers? – noɥʇʎԀʎzɐɹƆ – 2016-08-29T23:56:59.910
It is determined by the controller and not shown to your program. – TheNumberOne – 2016-08-29T23:57:42.873
@NathanMerrill OH I GET IT! Value is different. Then my market corner strat doesn't work.............. – noɥʇʎԀʎzɐɹƆ – 2016-08-29T23:58:52.680
Exact formula is
Math.ceil(Math.pow(random.nextDouble(), 2) * 1000)
– TheNumberOne – 2016-08-29T23:59:03.047Well it might work because of dumb bots... but not as well... – noɥʇʎԀʎzɐɹƆ – 2016-08-30T00:02:02.897
something that can work is a program that make averages on stock market shares (=="azioni") for find if there are unusual buy or sale of these stock market shares. If there are many buy on one stock share: computer has to buy that stock market share. if there are many sale on one stock market share: sale that one. this is because I as the program computer not have enought info for sale or buy, no sure info, no true info or important info on what is going on in the market. Yes it is better if one have some info true on that market and use these. i don't know translation is right... – RosLuP – 2016-08-30T18:28:22.467
@RosLuP if I understand you, you are saying to sell when others are selling, and buy when others buy. This sounds like a good strategy! – Nathan Merrill – 2016-08-30T18:31:22.603
@Nathan: yes if i have no good info: selling what other people sell, buy what they are buying (if there are big evidence on these). But i'm not an expert so i can make it wrong... – RosLuP – 2016-08-30T18:34:26.007
@TimmyD 1000 turns. Added, thanks. – Nathan Merrill – 2016-08-30T19:18:35.023
Quick clarification: when accepting offers, the end value of that stock will be (stock.amount * stock.secretValue) yes? – Socratic Phoenix – 2016-08-30T19:21:28.630
@SocraticPhoenix correct – Nathan Merrill – 2016-08-30T19:22:23.277
In the controller,
StockExchange.nextStep
, you shuffle the players before making offers to them, but I think you should also shuffle the offers (either once or before each call togiveOffers
). – Peter Taylor – 2016-08-31T10:20:42.237@PeterTaylor You're right. The order of offers matters (only slightly), but good catch. – Nathan Merrill – 2016-08-31T12:06:11.887
poking question – noɥʇʎԀʎzɐɹƆ – 2016-09-12T19:25:21.163