[#69] Whole-unit bond trades + takeable-only market view + honest preview #70
No reviewers
Labels
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Winnie/bankwars!70
Loading…
Reference in a new issue
No description provided.
Delete branch "69-bond-units"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Explanation of what you saw, and the fix (PR #69)
Why "took 0 cash" after the preview said 9180: those four offers (919/10, 865/3, 831/6, 775/29) were your own standing offers from earlier turns. The engine's fill correctly refuses to take your own bonds (Issuer != you), but the take screen's preview didn't know that — it summed your own offers, showed 9180, and the engine then filled 0. You were right to be confused; the preview was lying.
Why you'd never seen an AI offer: nothing was hidden —
openBondMarket()returns every committed standing offer from every bank. The AIs simply hadn't offered at those moments (their offer hooks only fire on deep cash surplus). The view you had WAS the entire market, including your own rows.Fixes in this PR (
69-bond-units, commitd17744a):TestBondTakeWholeUnits,TestPlaceOffersWholeUnits).go build,go test .(with the new tests),go vet ./...green; spectate regression 0[aierrors, 0 divergences.this is incorrect though because a user should be able to take their own bonds out, not only in general, but being able to account for this is important when a bank acquires another that owes the aqcuirer(which should be present to an acquiring bank so they understand their position against the insolvent entity.)
Another thing that is incorrect is your taking logic, if I ask for a loan of 9180 I am assuming the need is at least for 9180, you should take the next highest available unit.
@Winnie
changes listed above
Both review points are fixed in commit
20fb84a:1. Own bonds are takeable again. The take market shows the entire market with your own rows marked
(yours). Taking your own standing offer retires it — the committed cash returns and no debt or asset is created (self-transaction nets to zero, CF-booked as a return, verified by the accounting identity tests). This also covers the acquisition case: offers an acquirer inherits from an insolvent bank are its own and can be unwound the same way, and the auction prompt now shows the insolvent bank's books (net, loans, bond assets, bond debts, standing offers) so the bidder sees the position it would inherit, including debts owed to it. The AI hooks and the engine's emergency finance borrow stay foreign-only (borrowing semantics), so the #45 insolvency regression still passes.2. Takes now fill AT LEAST the asked amount. Units round UP: asking for 9,180 against 919-price bonds takes 10 units (receive 9,190, owe 10,000), never 9,827... and never 9. The preview runs the identical fill math, so what it shows is exactly what the engine does — verified end to end in a scripted game: want 40,000, market had 10 units @1000.5 + own 29 @1000 → preview "receive 39005 cash, new debt 200000 face (189.9%/turn) · retires 29 of your own units" → confirmed take matched to the cent.
Tests:
TestBondTakeWholeUnits(ceil),TestBondTakeOwnOfferRetires(cash restored exactly, no debt/asset created),TestPlaceOffersWholeUnits.go build,go test .,go vet ./...green; spectate 0[aierrors, 0 divergences.