fidoandfido / blackswan

Blackswan Stock Game
Other
2 stars 0 forks source link

AI misbehaving - hoarding shares #21

Closed fidoandfido closed 13 years ago

fidoandfido commented 13 years ago

Value AI have been buying shares, and seem in no hurry to sell.

As a result, I have introduced code to liquidate AI holdings; the hope is that this will create more fluidity in the market as AI stop constantly going really long on any companies that are doing well.

Will update this issue when I have a change to see if this fix resolves the strange behaviour.

fidoandfido commented 13 years ago

Depending on the utility of the liquidating behaviour, I may look at changing the way the value AI prices shares; that is allowing it to make offers that are much much higher than the previous sale price, to allow corrections to occur.

Also might look at increasing the default share count from 100,000 to a few more.

fidoandfido commented 13 years ago

Also added the random AI - this should add some extra movement and help with liquidity.

fidoandfido commented 13 years ago

Seems this has not helped - random ai are a bit too exuberant for my liking - share prices seem to bubble too much.

fidoandfido commented 13 years ago

Okay, so I further tweaked, and now the dominating factor seems to be the liquidations. To fix this, I have changed the AI trading pattern so that now when an AI Trader makes a trade, it has to specify the delta change, rather than just having two options - 5 or 10 percent. This seems to be helping; the 'default' values are currently 2, 5, and 10 percent, but these could change if an AI really wants to buy or sell - for instance if the book value was half the share value, rather than selling off at 10 %, it could make a much larger movement.

Further to this, I am considering another AI that will sell based on previous patterns seen - ie get the last 20 issued trades and trade in reaction to them. But first off, I will monitor the current system to see if prices stabilise sensibly.

fidoandfido commented 13 years ago

Hopefully have this sorted with last commit.

Now have two AIs - one buying and selling based on earnings per share (comparing return on current share price to the global insterest rate) the other is concerned only with the book value of the shares (paying a premium for good earnings). With some minor bugs ironed out hopefully these two AI will create some interesting dynamics, with the random AI trader mixed in for good measure.

Will see how it goes in the morning!

fidoandfido commented 13 years ago

Looks like the AI is now working out pretty well; shares seem to be tracking their book value; companies returning less than the current cash rate are below the line (including companies making losses) and companies making more are considerably higher.

This seems to appropriatish behavour.

fidoandfido commented 13 years ago

Okay, so there sare still some issues that have been identified; possibly corrected...

  1. Frequency of liquidation was too great; this led to problems with shares not being able to be sold when they were over valued (since noone but the market maker owned them!)
  2. Buying shares was slightly broken; when shares got expensive, instead of buying as many as they could afford, the AIs always tried to buy 1000; even when they couldn't afford it.
  3. AI trading code needs to be revisited; it is too complex / expensive (in terms of performance) at the moment.
  4. AIs didn't have enough money to make meaningful trades - this has been fixed by upping starting money significantly.
fidoandfido commented 13 years ago

Have updated and committed new code; current run should indicate if the code is stable or not.

fidoandfido commented 13 years ago

Trading code looked stable(ish) until the trading ceased - at around 5am (ie after about 5 periods). I imagine this is from an exception occuring in the AI thread, crashing the thread hard. This could be from a mathematical error (perhaps a divide by 0 in a company that is insolvent?) This should probably be handled more better.

Further investigation required.

fidoandfido commented 13 years ago

Okay, further investigation indicates that the AI is still trading, possibly even in a good way, but the graphs are not being rendered properly.

Will open new issue for this.

fidoandfido commented 13 years ago

Okay, the Company data looks pretty good, share value is tracking the book value plus or minus a bit depending on the profitability of the company. There are enough fluctuations to make the graphs look interesting and the prices seem to meander a little bit - I am happy enough to close this issue off for the moment.

In time, with better AIs, it would be cool to introduce 'runs' on the stock, but this will be a bit further down the track. For now it is relatively stable, which is a good thing.