what if 3 users want to share 2 gpus -- a worked example
suppose there are 3 users, A, B, and C, each starts with 10 credits, and owns 0.7, 0.7, and 0.6 of the next PGPUh. and suppose they all want to run a job at 5 pm today. what happens?
well first suppose the historical price is 1 credit per PGPUH, which means there are already 3 autosell orders on the market for 0.7, 0.7, and 0.6 credits. furthermore, suppose A, B, and C have their hard-sell price at 2, 5, and 8 credits resp, so they're willing to sell their PGPUH no matter what for 1.4, 3.5, and 4.8 credits resp.
then, suppose A, B, and C are willing to pay 1, 1.5, and 2 credits to run the job in that one hour block.
so here's the order book, ordered by the issue date
1. A: sell @ 2, all
2. B: sell @ 5, all
3. C: sell @ 8, all
4. A: sell @ 1, amount 0.7
5. B: sell @ 1, amount 0.7
6. C: sell @ 1, amount 0.6
-- (below: didn't happen yet) --
7. A: buy @ 1, amount 0.3
8. B: buy @ 1.5, amount 0.3
9. C: buy @ 2, amount 0.4
when order 7 comes out, that cancels order 4, and suppose A buys from B, so the book looks like this
1. A: sell @ 2, all
2. B: sell @ 5, all
3. C: sell @ 8, all
5. B: sell @ 1, amount 0.4
6. C: sell @ 1, amount 0.6
-- (below: didn't happen yet) --
8. B: buy @ 1.5, amount 0.6
9. C: buy @ 2, amount 0.4
now A has 1 PGPUH in the bank and 9.7 credits, and B has 0.4 PGPUH and 10.3. B adjusts order amount up from 0.3 to 0.6, cause it needs to buy more now.
next B executes. i don't know how exchanges actually do this, but i'll go with the convention that the trade price is determined by the first order, so C sells at 1 instead of 1.5, leaving us with
1. A: sell @ 2, all
2. B: sell @ 5, all
3. C: sell @ 8, all
-- (below: didn't happen yet) --
9. C: buy @ 2, amount 1
B has now 1 PGPUH and 9.4 credits as well, and C has 10.6 credits
note that order 3 and 6 was cancelled, since C can't sell anymore, and C adjusted it's order amount
next, C buys from A, which basically clears the book.
2. B: sell @ 5, all
3. C: sell @ 8, all
Now A has 0 PGPUH and 11.7 credits, B has 1 PGPUH and 10.3 credits, C has 1 PGPUH and 8.6 credits, so GPUs were properly allocated.
but wait, what if C's order went first. let's rewind a bit...
1. A: sell @ 2, all
2. B: sell @ 5, all
3. C: sell @ 8, all
5. B: sell @ 1, amount 0.4
6. C: sell @ 1, amount 0.6
-- (below: didn't happen yet) --
8. C: buy @ 2, amount 0.4
9. B: buy @ 1.5, amount 0.6
C fills B's order
1. A: sell @ 2, all
2. B: sell @ 5, all
3. C: sell @ 8, all
-- (below: didn't happen yet) --
9. B: buy @ 1.5, amount 1
C ends up with 1 PGPUH and spends 0.4, B now has 10.7 credits
Now A has 1 PGPUH and 9.7 credits, B has 0 PGPUH and 10.7 credits, C has 1 PGPUH and 9.6 credits, again we have success