aboutsummaryrefslogtreecommitdiffstats
path: root/api/src
Commit message (Collapse)AuthorAgeFilesLines
* server: add a chat shared by everyone logged in Kostya2026-10-151-0/+4
| | | | | | | | | | | | | | | | Ex3 bonus. POST /api/chat says a line as the logged-in user and GET /api/chat?since=N returns the lines after id N, so a polling client only ever downloads what it has not seen. The last 500 lines are kept in memory. A chat line does not change the market, so the lock filter does not bump the market version for it; otherwise every line would make every client refetch all events. Also read form fields as UTF-8 in the filter rather than relying on Tomcat's default, since names and chat text may not be ASCII.
* api: share the user directory row with clients Kostya2026-10-121-0/+4
| | | | | | | | | | | The row GET /api/users and /api/sync send for each user was a record private to UsersServlet, so a client had nothing to deserialize it into. Move it to the api module as UserSummaryDTO. Make TestServer public as well, so client modules can test against a real embedded server.
* account: let users deposit cash into their account Kostya2026-10-091-0/+3
| | | | | | | | | | | | | | | | Exercise 3 replaces the fixed initial cash of Exercise 2 with accounts that users top up themselves. Add AccountContext.deposit, which credits a DEPOSIT entry through LedgerContext so it carries a timestamp and a running balance like every other ledger movement, and return the updated account. The amount crosses the api boundary as a string, like all money values. Reject anything that is not a positive number with at most two decimal places instead of rounding it, so a user is never credited a different amount than they asked for. A deposit can bring a negative account back above zero, which lifts the block.
* api: extend contexts and DTOs for order books and event creationKostya2026-09-069-3/+100
| | | | | | | | | | | | | | | | | | | | | | The desktop UI needs to create events, trade on both sides of an order book, and show who is participating in an event, none of which the api module could express so far. Add AccountContext for looking up ledger accounts by owner, and give CatalogContext an openEvent operation plus createEvent, taking either a CreateEventRequest or its fields spelled out. createEvent defaults to a "Not implemented" error so existing implementations keep compiling until they support it. Let GuessMarketContext.placeOrder take an explicit side, keeping the old signature as a default method that places a BUY so current callers are unaffected. Add OrderBookDTO and BookOrderDTO to describe per-option books with best bid, best ask and spread, and ParticipantDTO for a user's position, fees and P&L in an event. Carry the order books and participants on EventDetailDTO and the market maker's name on EventSummaryDTO.
* model: relocate market DTOs out of the flat api packageKostya2026-08-237-9/+9
| | | | | | | | | | | | | | | | | | Move AccountDTO/MarketDTO/MarketStateDTO/PurchaseReceiptDTO/TradeRowDTO out of the catch-all api package into model.market (and LedgerDTO into model.ledger), matching the existing model.event convention so DTOs live next to the domain they describe rather than in the interface package. Relocate LedgerMapper from mapper.v2 to infrastructure.adapter to match the module's established package layout, and update all call sites and imports accordingly. Also register the ui-desktop module in the build tooling: add it to MODULES, add openjfx to the shipped runtime libs, and generalize package.sh so each executable module (ui-console, ui-desktop) gets its own Main-Class/Class-Path manifest and run script instead of special-casing ui-console. Fold long Class-Path manifest lines at 72 bytes per the JAR spec, since adding ui-desktop's dependencies pushed the line past the limit.
* Move CommissionTiming and MechanismType into model.event packageKostya2026-08-204-4/+3
| | | | | Groups them with the other event-domain enums instead of the general api package, and updates all call sites accordingly.
* Break down purchase receipts by cost/commission, harden XML validation and ↵Kostya2026-08-181-1/+6
| | | | | | | | | state I/O Adds a full pre-load validation pass for GM XML seeds (ids, names, options, commission, LMSR liquidity), replaces IO.print with System.out, and surfaces detailed error messages across load/save commands instead of generic failures.
* Wire event ledger movements, show winning market by name, seed LMSR subsidyKostya2026-08-181-1/+1
| | | | | | | | | | | | | - Event ledger now grows on purchase and shrinks on payout, mirroring the exact amounts moved on the buyer's ledger (it previously had a Ledger object that nothing ever wrote to). - Settlement and event-detail views now show the winning market's display name instead of its raw key; event details are viewable for settled events too (the picker previously excluded anything not ACTIVE). - LMSR events seed their ledger with a SUBSIDY entry for the market maker's worst-case loss (b * ln(outcomes)), reusing the existing cost() function rather than recomputing the formula.
* Replace order matching with risk/matching/fulfillment/settlement pipelineKostya2026-08-175-10/+8
| | | | | | | | | Move XML loading infrastructure and models under service/catalog, and split order execution into a real pipeline: RiskEngine checks the order, MatchingEngine matches it, FulfillmentContext books the resulting trades, and SettlementContext resolves winning markets. GuessMarketContext.buyShares becomes placeOrder(price, quantity), and TradingMechanism.buy now returns matched trades directly instead of a single TradeExecution.
* Split DTOs into api/model, extract order matching into service/matchingKostya2026-08-1611-40/+38
| | | | | | | Moves Event/Ledger DTOs out of the flat api package into api/model/{event,ledger}, and moves LocalCatalogContext and order matching logic into dedicated service/catalog and service/matching packages, replacing TradingOperation/TradingOperationImpl.
* Rename Option/Account to Market/Ledger, add Result-based error handlingKostya2026-08-169-25/+75
| | | | | | Split GuessMarketContext into a separate CatalogContext for read-only event listing, wrap fallible operations in Result<T> instead of throwing, and wire load/save of events and users through a JSON Wrapper.
* Wire buyShares and menu commands, replace factory interfaces with DIKostya2026-08-141-1/+1
| | | | | | | | Implement LocalGuessMarketContext.buyShares/loadEvents via a new TradingOperation and Loader, backed by in-memory repositories. Replace the ConsoleInputProviderFactory/ConsoleOutputProviderFactory pattern with picocontainer-injected providers, and drive the menu from a list of MenuCommand implementations instead of a hardcoded printout.
* Add service module with stubbed LocalGuessMarketContextKostya2026-08-135-6/+48
| | | | | | | | | | GuessMarketContext gained a richer surface (loadEvents/listEvents/ buyShares/closeEvent/account/save-restoreState) backed by new EventDetailDTO, MarketStateDTO, OptionStateDTO and PurchaseReceiptDTO. The old engine-module provider implemented the previous shape and is removed; market.guess.service.LocalGuessMarketContext replaces it as a stub, each method throwing UnsupportedOperationException pending a real implementation.
* Replace EventDTO with richer EventSummaryDTO/TradeRowDTO view modelsKostya2026-08-137-14/+27
| | | | | | | Introduce MechanismType and rename CommissionChargeType to CommissionTiming to better describe LMSR vs order-book events. LocalGuessMarketContext.GetAllEventsAsync is stubbed pending the new mapping.
* Move I/O provider abstraction to ui-console, add ledger/account/problem DTOsKostya2026-08-1311-32/+37
| | | | | | | | InputProvider/OutputProvider were api-layer types only ever implemented by the console UI; relocate them there. Drop the unused GuessMarketEngine/LocalGuessMarketService pair, flesh out LoadResultDTO with success/failure variants, and make LocalGuessMarketContext.LoadAsync report real outcomes instead of an empty placeholder.
* Move engine contracts to api module, add I/O provider abstraction and ↵Kostya2026-08-107-0/+55
| | | | | | | | | | | PicoContainer wiring Relocates GuessMarketEngine/GuessMarketContext into market.guess.api so engine and ui-console depend on a shared contract instead of engine internals, and makes context loading async (CompletableFuture). Adds InputProvider/OutputProvider interfaces with console implementations, wires the console app's Menu through a PicoContainer, and adds the generated model classes plus vendored picocontainer jar needed to build it.
* flatten modules to repo root, vendor deps, repair Eclipse build pathsKostya2026-08-097-0/+45
Move api, engine, ui-console and ui-desktop out of modules/ up to the repo root and drop the empty exception project (GuessMarketException now lives in api). Vendor gson, jaxb, okhttp, openjfx and tomcat under lib/, and group the JUnit standalone jar into lib/junit/ alongside them. Rewrite every .classpath: drop the copy-pasted optional="true" that was masking real build path errors, point the library entries at ../lib/, and put the JUnit jar on the test source folders so the placeholder AppTest classes compile. ui-desktop: take the JavaFX jars off the modulepath (there is no module-info.java, so module="true" left the packages unresolvable) and add a Launcher that calls Application.launch, avoiding the "JavaFX runtime components are missing" check without VM arguments. engine: add LocalGuessMarketService and the GuessMarketContext provider interface, and give GuessMarketException the no-arg and cause constructors they need.