Take or leave all of this...
I'd love to see one of two growth paths:
1. Ability to choose your leverage amount, between say 1x and 10x, when you enter a trade.
2. The existing game remains unchanged, but a second, quarterly competition is added, wherein leverage can either be chosen within the aforementioned range, or at a fixed value to diversify the pack more rapidly for the shorter timeframe. (Also no/smaller market fee, or no fee for limit orders, also to promote action)
The remainder are technical thoughts:
In thinking about a lowest-impact way to implement leverage...there are two jobs - one easy, one more tricky.
1. Calculate gains/loss at time of trade exit, multiplying effect of leverage.
2. Liquidation check.
1 is easy. Later, an 'interest charge' can be calculated. There's all sorts of things you could simulate, including letting players lend instead of leverage, but that is for later.
2 - I've been thinking on it awhile. You need a way for it to be accurate, but not resource intensive. For example: If someone goes 10x long at $1000, if the price hits $900, even for one second, you should be liquidated. It would be grossly inaccurate to only do an hourly check of price, for example. But you don't want to have to check every price for liquidation, every price check. Here's what I came up with:
Two single, game-wide values - liquidationLow, liquidationHigh. (These are cleared when exiting leveraged trades)
Every time a player makes a trade of newValue, two additional UPDATEs occur:
a) MAX(liquidationLow, newValue)
b) MIN(liquidationHigh, newValue)
I assume that no centralized job processing currently occurs.
This would need to occur with the same frequency as the price updates.
In the common case, CURRENT_PRICE will be neither below the liquidationLow, or above the liquidationHigh.
When it is, a SELECT can retrieve the players whose liquidationAmount is above/below the price update.
They can be liquidated appropriately, when-and-only-when a liquidation price occurs.
(Once you have a central source determining price, you could always, later, update the clients to just get AJAX updates from source rather than having each ping CoinDesk, but I once again digress :-) )
Each player can store its liquidation value, and a select can retrieve those players above/below the liquidation value.
TL;DR - Two games - the existing long-term, plus a quarterly with either fixed leverage or the ability to choose. Secondary option, still only one game, but ability to choose leverage per-trade. Gratuitous technical dreaming ensues.
Love the game, looking forward to continuing to play.
Actually checking for fl's on every price update would probably be fine and fairly easy. We would store liquidation points in the db and it is as simple as adding a new column. We already check for limit order executions on every price update, so it's as simple as call8ng a second function during that check. It could even return all three on one query. I'd have to look closer.
Sorry I haven't been around much. I am very busy running a business and work is piling up, so I apologize. I haven't forgotten about this or your (chainsaw) other ideas, I simply haven't been around.
And thanks to secousa for keeping things rolling and doing the whole pr thing when I can't be around.