From 13a221ffaefc169d028c7eab6f21ac88052d1d40 Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 17 Aug 2026 11:15:59 +0000 Subject: Replace order matching with risk/matching/fulfillment/settlement pipeline 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. --- .../guess/service/LocalGuessMarketContext.java | 53 +++-- .../guess/service/catalog/LocalCatalogContext.java | 21 +- .../catalog/infrastructure/MarketContext.java | 79 +++++++ .../infrastructure/adapter/InstantTypeAdapter.java | 19 ++ .../catalog/infrastructure/mapper/Mapper.java | 5 + .../infrastructure/mapper/v1/EventMapperV1.java | 56 +++++ .../infrastructure/mapper/v2/EventMapperV2.java | 69 ++++++ .../catalog/infrastructure/provider/Loader.java | 12 ++ .../infrastructure/provider/v1/XMLLoaderV1.java | 63 ++++++ .../infrastructure/repository/EventRepository.java | 5 + .../repository/InMemoryEventRepository.java | 32 +++ .../repository/InMemoryUserRepository.java | 32 +++ .../infrastructure/repository/Repository.java | 14 ++ .../infrastructure/repository/UserRepository.java | 5 + .../guess/service/catalog/model/v1/Comision.java | 77 +++++++ .../guess/service/catalog/model/v1/GMEvent.java | 173 +++++++++++++++ .../guess/service/catalog/model/v1/GMEvents.java | 67 ++++++ .../guess/service/catalog/model/v1/GMLMSR.java | 49 +++++ .../guess/service/catalog/model/v1/GMMethod.java | 59 ++++++ .../guess/service/catalog/model/v1/GMOptions.java | 67 ++++++ .../service/catalog/model/v1/GuessMarket.java | 59 ++++++ .../service/catalog/model/v1/ObjectFactory.java | 143 +++++++++++++ .../guess/service/catalog/model/v2/Commission.java | 77 +++++++ .../guess/service/catalog/model/v2/Event.java | 47 +++++ .../guess/service/catalog/model/v2/GMEvent.java | 161 ++++++++++++++ .../guess/service/catalog/model/v2/GMEvents.java | 67 ++++++ .../guess/service/catalog/model/v2/GMLMSR.java | 49 +++++ .../service/catalog/model/v2/GMMarketMaker.java | 67 ++++++ .../guess/service/catalog/model/v2/GMMethod.java | 81 ++++++++ .../guess/service/catalog/model/v2/GMOptions.java | 67 ++++++ .../service/catalog/model/v2/GMOrderBook.java | 90 ++++++++ .../guess/service/catalog/model/v2/GMUser.java | 96 +++++++++ .../guess/service/catalog/model/v2/GMUsers.java | 67 ++++++ .../service/catalog/model/v2/GuessMarket.java | 81 ++++++++ .../service/catalog/model/v2/ObjectFactory.java | 200 ++++++++++++++++++ .../guess/service/domain/BigDecimalOptions.java | 22 -- .../java/market/guess/service/domain/Event.java | 32 ++- .../java/market/guess/service/domain/Market.java | 13 +- .../market/guess/service/domain/MarketAction.java | 24 --- .../java/market/guess/service/domain/Order.java | 6 + .../market/guess/service/domain/Settlement.java | 6 - .../java/market/guess/service/domain/Trade.java | 8 +- .../java/market/guess/service/domain/User.java | 1 + .../service/fulfillment/FulfillmentContext.java | 10 + .../fulfillment/LocalFulfillmentContext.java | 51 +++++ .../guess/service/helpers/BigDecimalOptions.java | 22 ++ .../guess/service/helpers/InstantOptions.java | 16 ++ .../service/infrastructure/MarketContext.java | 79 ------- .../infrastructure/adapter/InstantTypeAdapter.java | 19 -- .../service/infrastructure/mapper/Mapper.java | 5 - .../infrastructure/mapper/v1/EventMapperV1.java | 55 ----- .../infrastructure/mapper/v2/EventMapperV2.java | 69 ------ .../service/infrastructure/provider/Loader.java | 9 - .../infrastructure/provider/v1/XMLLoaderV1.java | 59 ------ .../infrastructure/repository/EventRepository.java | 5 - .../repository/InMemoryEventRepository.java | 32 --- .../repository/InMemoryUserRepository.java | 32 --- .../infrastructure/repository/Repository.java | 14 -- .../infrastructure/repository/UserRepository.java | 5 - .../java/market/guess/service/ledger/Ledger.java | 3 +- .../market/guess/service/ledger/LedgerContext.java | 6 +- .../service/matching/LocalMatchingEngine.java | 20 ++ .../guess/service/matching/MatchingEngine.java | 11 + .../service/matching/OrderMatchingContext.java | 13 -- .../service/mechanism/LmsrTradingMechanism.java | 34 ++- .../mechanism/OrderBookTradingMechanism.java | 14 +- .../guess/service/mechanism/TradingMechanism.java | 7 +- .../market/guess/service/model/v1/Comision.java | 94 --------- .../market/guess/service/model/v1/GMEvent.java | 215 ------------------- .../market/guess/service/model/v1/GMEvents.java | 80 ------- .../java/market/guess/service/model/v1/GMLMSR.java | 60 ------ .../market/guess/service/model/v1/GMMethod.java | 70 ------- .../market/guess/service/model/v1/GMOptions.java | 80 ------- .../market/guess/service/model/v1/GuessMarket.java | 70 ------- .../guess/service/model/v1/ObjectFactory.java | 167 --------------- .../market/guess/service/model/v2/Commission.java | 94 --------- .../java/market/guess/service/model/v2/Event.java | 58 ------ .../market/guess/service/model/v2/GMEvent.java | 201 ------------------ .../market/guess/service/model/v2/GMEvents.java | 80 ------- .../java/market/guess/service/model/v2/GMLMSR.java | 60 ------ .../guess/service/model/v2/GMMarketMaker.java | 80 ------- .../market/guess/service/model/v2/GMMethod.java | 98 --------- .../market/guess/service/model/v2/GMOptions.java | 80 ------- .../market/guess/service/model/v2/GMOrderBook.java | 111 ---------- .../java/market/guess/service/model/v2/GMUser.java | 118 ----------- .../market/guess/service/model/v2/GMUsers.java | 80 ------- .../market/guess/service/model/v2/GuessMarket.java | 97 --------- .../guess/service/model/v2/ObjectFactory.java | 231 --------------------- .../market/guess/service/risk/LocalRiskEngine.java | 18 ++ .../java/market/guess/service/risk/RiskEngine.java | 9 + .../service/settlement/LocalSettlementContext.java | 50 +++++ .../service/settlement/SettlementContext.java | 8 + 92 files changed, 2582 insertions(+), 2738 deletions(-) create mode 100644 service/src/main/java/market/guess/service/catalog/infrastructure/MarketContext.java create mode 100644 service/src/main/java/market/guess/service/catalog/infrastructure/adapter/InstantTypeAdapter.java create mode 100644 service/src/main/java/market/guess/service/catalog/infrastructure/mapper/Mapper.java create mode 100644 service/src/main/java/market/guess/service/catalog/infrastructure/mapper/v1/EventMapperV1.java create mode 100644 service/src/main/java/market/guess/service/catalog/infrastructure/mapper/v2/EventMapperV2.java create mode 100644 service/src/main/java/market/guess/service/catalog/infrastructure/provider/Loader.java create mode 100644 service/src/main/java/market/guess/service/catalog/infrastructure/provider/v1/XMLLoaderV1.java create mode 100644 service/src/main/java/market/guess/service/catalog/infrastructure/repository/EventRepository.java create mode 100644 service/src/main/java/market/guess/service/catalog/infrastructure/repository/InMemoryEventRepository.java create mode 100644 service/src/main/java/market/guess/service/catalog/infrastructure/repository/InMemoryUserRepository.java create mode 100644 service/src/main/java/market/guess/service/catalog/infrastructure/repository/Repository.java create mode 100644 service/src/main/java/market/guess/service/catalog/infrastructure/repository/UserRepository.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v1/Comision.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v1/GMEvent.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v1/GMEvents.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v1/GMLMSR.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v1/GMMethod.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v1/GMOptions.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v1/GuessMarket.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v1/ObjectFactory.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v2/Commission.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v2/Event.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v2/GMEvent.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v2/GMEvents.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v2/GMLMSR.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v2/GMMarketMaker.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v2/GMMethod.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v2/GMOptions.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v2/GMOrderBook.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v2/GMUser.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v2/GMUsers.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v2/GuessMarket.java create mode 100644 service/src/main/java/market/guess/service/catalog/model/v2/ObjectFactory.java delete mode 100644 service/src/main/java/market/guess/service/domain/BigDecimalOptions.java delete mode 100644 service/src/main/java/market/guess/service/domain/MarketAction.java create mode 100644 service/src/main/java/market/guess/service/domain/Order.java delete mode 100644 service/src/main/java/market/guess/service/domain/Settlement.java create mode 100644 service/src/main/java/market/guess/service/fulfillment/FulfillmentContext.java create mode 100644 service/src/main/java/market/guess/service/fulfillment/LocalFulfillmentContext.java create mode 100644 service/src/main/java/market/guess/service/helpers/BigDecimalOptions.java create mode 100644 service/src/main/java/market/guess/service/helpers/InstantOptions.java delete mode 100644 service/src/main/java/market/guess/service/infrastructure/MarketContext.java delete mode 100644 service/src/main/java/market/guess/service/infrastructure/adapter/InstantTypeAdapter.java delete mode 100644 service/src/main/java/market/guess/service/infrastructure/mapper/Mapper.java delete mode 100644 service/src/main/java/market/guess/service/infrastructure/mapper/v1/EventMapperV1.java delete mode 100644 service/src/main/java/market/guess/service/infrastructure/mapper/v2/EventMapperV2.java delete mode 100644 service/src/main/java/market/guess/service/infrastructure/provider/Loader.java delete mode 100644 service/src/main/java/market/guess/service/infrastructure/provider/v1/XMLLoaderV1.java delete mode 100644 service/src/main/java/market/guess/service/infrastructure/repository/EventRepository.java delete mode 100644 service/src/main/java/market/guess/service/infrastructure/repository/InMemoryEventRepository.java delete mode 100644 service/src/main/java/market/guess/service/infrastructure/repository/InMemoryUserRepository.java delete mode 100644 service/src/main/java/market/guess/service/infrastructure/repository/Repository.java delete mode 100644 service/src/main/java/market/guess/service/infrastructure/repository/UserRepository.java create mode 100644 service/src/main/java/market/guess/service/matching/LocalMatchingEngine.java create mode 100644 service/src/main/java/market/guess/service/matching/MatchingEngine.java delete mode 100644 service/src/main/java/market/guess/service/matching/OrderMatchingContext.java delete mode 100644 service/src/main/java/market/guess/service/model/v1/Comision.java delete mode 100644 service/src/main/java/market/guess/service/model/v1/GMEvent.java delete mode 100644 service/src/main/java/market/guess/service/model/v1/GMEvents.java delete mode 100644 service/src/main/java/market/guess/service/model/v1/GMLMSR.java delete mode 100644 service/src/main/java/market/guess/service/model/v1/GMMethod.java delete mode 100644 service/src/main/java/market/guess/service/model/v1/GMOptions.java delete mode 100644 service/src/main/java/market/guess/service/model/v1/GuessMarket.java delete mode 100644 service/src/main/java/market/guess/service/model/v1/ObjectFactory.java delete mode 100644 service/src/main/java/market/guess/service/model/v2/Commission.java delete mode 100644 service/src/main/java/market/guess/service/model/v2/Event.java delete mode 100644 service/src/main/java/market/guess/service/model/v2/GMEvent.java delete mode 100644 service/src/main/java/market/guess/service/model/v2/GMEvents.java delete mode 100644 service/src/main/java/market/guess/service/model/v2/GMLMSR.java delete mode 100644 service/src/main/java/market/guess/service/model/v2/GMMarketMaker.java delete mode 100644 service/src/main/java/market/guess/service/model/v2/GMMethod.java delete mode 100644 service/src/main/java/market/guess/service/model/v2/GMOptions.java delete mode 100644 service/src/main/java/market/guess/service/model/v2/GMOrderBook.java delete mode 100644 service/src/main/java/market/guess/service/model/v2/GMUser.java delete mode 100644 service/src/main/java/market/guess/service/model/v2/GMUsers.java delete mode 100644 service/src/main/java/market/guess/service/model/v2/GuessMarket.java delete mode 100644 service/src/main/java/market/guess/service/model/v2/ObjectFactory.java create mode 100644 service/src/main/java/market/guess/service/risk/LocalRiskEngine.java create mode 100644 service/src/main/java/market/guess/service/risk/RiskEngine.java create mode 100644 service/src/main/java/market/guess/service/settlement/LocalSettlementContext.java create mode 100644 service/src/main/java/market/guess/service/settlement/SettlementContext.java (limited to 'service/src') diff --git a/service/src/main/java/market/guess/service/LocalGuessMarketContext.java b/service/src/main/java/market/guess/service/LocalGuessMarketContext.java index 3feef6a..29e3f5c 100644 --- a/service/src/main/java/market/guess/service/LocalGuessMarketContext.java +++ b/service/src/main/java/market/guess/service/LocalGuessMarketContext.java @@ -1,26 +1,44 @@ package market.guess.service; +import java.math.BigDecimal; +import java.time.Instant; import market.guess.api.GuessMarketContext; import market.guess.api.PurchaseReceiptDTO; import market.guess.api.Result; import market.guess.api.TradeRowDTO; import market.guess.model.event.EventDetailDTO; -import market.guess.service.infrastructure.MarketContext; -import market.guess.service.matching.OrderMatchingContext; +import market.guess.service.catalog.infrastructure.MarketContext; +import market.guess.service.domain.Order; +import market.guess.service.fulfillment.FulfillmentContext; +import market.guess.service.helpers.InstantOptions; +import market.guess.service.matching.MatchingEngine; +import market.guess.service.risk.RiskEngine; +import market.guess.service.settlement.SettlementContext; public final class LocalGuessMarketContext implements GuessMarketContext { - private final OrderMatchingContext orderMatching; private final MarketContext context; + private final RiskEngine risk; + private final MatchingEngine matching; + private final FulfillmentContext fulfillment; + private final SettlementContext settlement; - public LocalGuessMarketContext(MarketContext context, OrderMatchingContext orderMatching) { + public LocalGuessMarketContext( + MarketContext context, + RiskEngine risk, + MatchingEngine matching, + FulfillmentContext fulfillment, + SettlementContext settlement) { super(); this.context = context; - this.orderMatching = orderMatching; + this.risk = risk; + this.matching = matching; + this.fulfillment = fulfillment; + this.settlement = settlement; } @Override - public Result buyShares( - String userName, String eventKey, String optionKey, int quantity) { + public Result placeOrder( + String userName, String eventKey, String optionKey, BigDecimal price, long quantity) { var optional = context.getEvents().get(eventKey); var userOptional = context.getUsers().get(userName); @@ -30,17 +48,22 @@ public final class LocalGuessMarketContext implements GuessMarketContext { var event = optional.get(); var user = userOptional.get(); var option = event.getOption(optionKey); + var order = new Order(Instant.now(), event, option, price, quantity); - var trades = orderMatching.submitOrder(user, event, option, quantity); + var riskResult = risk.check(user, order); + if (!riskResult.isSuccess()) return Result.error(riskResult.getMessage()); + + var rawTrades = matching.match(order); + var trades = fulfillment.fulfill(user, order, rawTrades); return Result.ok( new PurchaseReceiptDTO( trades.stream() .map( t -> new TradeRowDTO( - t.at().toString(), - t.userName(), - t.optionName(), + InstantOptions.humanize(t.at()), + t.buyerUserName(), + t.marketName(), String.valueOf(t.quantity()), t.totalPaid().toPlainString())) .toList(), @@ -56,12 +79,14 @@ public final class LocalGuessMarketContext implements GuessMarketContext { var event = optional.get(); if (event.canSettle(userName)) { - - var payout = event.getPayout(); + settlement.settle(event, winningOptionKey); return Result.ok( new EventDetailDTO( - event.toEventSummary(), event.toMarketState(), event.getHistory(), "")); + event.toEventSummary(), + event.toMarketState(), + event.getHistory(), + event.getWinningOptionKey())); } return Result.error("Couldn't settle event."); diff --git a/service/src/main/java/market/guess/service/catalog/LocalCatalogContext.java b/service/src/main/java/market/guess/service/catalog/LocalCatalogContext.java index 6035ce7..7a32e62 100644 --- a/service/src/main/java/market/guess/service/catalog/LocalCatalogContext.java +++ b/service/src/main/java/market/guess/service/catalog/LocalCatalogContext.java @@ -3,37 +3,40 @@ package market.guess.service.catalog; import java.nio.file.Path; import java.util.List; import market.guess.api.CatalogContext; -import market.guess.api.LoadResultDTO; +import market.guess.api.LoadResult; import market.guess.api.Result; import market.guess.model.event.EventDetailDTO; import market.guess.model.event.EventSummaryDTO; +import market.guess.service.catalog.infrastructure.MarketContext; +import market.guess.service.catalog.infrastructure.provider.Loader; +import market.guess.service.catalog.infrastructure.repository.EventRepository; import market.guess.service.domain.Event; -import market.guess.service.infrastructure.MarketContext; -import market.guess.service.infrastructure.provider.Loader; public final class LocalCatalogContext implements CatalogContext { private final MarketContext context; private final Loader provider; + private final EventRepository events; - public LocalCatalogContext(Loader provider, MarketContext context) { + public LocalCatalogContext(Loader provider, MarketContext context, EventRepository events) { super(); this.provider = provider; this.context = context; + this.events = events; } @Override - public Result loadEvents(Path path) { + public Result loadEvents(Path path) { return provider.load(path); } @Override public Result> getAllEvents() { - return Result.ok(context.getEvents().getAll().stream().map(Event::toEventSummary).toList()); + return Result.ok(events.getAll().stream().map(Event::toEventSummary).toList()); } @Override public Result getEvent(String eventKey) { - var optional = context.getEvents().get(eventKey); + var optional = events.get(eventKey); if (optional.isEmpty()) return Result.error("Unable to find event."); var event = optional.get(); @@ -53,12 +56,12 @@ public final class LocalCatalogContext implements CatalogContext { } @Override - public Result restoreState(Path path) { + public Result restoreState(Path path) { try { context.load(); } catch (Exception e) { return Result.error("Failed to load.", e.getMessage()); } - return Result.ok(new LoadResultDTO(path.toString(), context.getEvents().getAll().size())); + return Result.ok(new LoadResult(path.toString(), context.getEvents().getAll().size())); } } diff --git a/service/src/main/java/market/guess/service/catalog/infrastructure/MarketContext.java b/service/src/main/java/market/guess/service/catalog/infrastructure/MarketContext.java new file mode 100644 index 0000000..24521ef --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/infrastructure/MarketContext.java @@ -0,0 +1,79 @@ +package market.guess.service.catalog.infrastructure; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonSyntaxException; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.time.Instant; +import java.util.List; +import market.guess.exception.GuessMarketException; +import market.guess.service.catalog.infrastructure.adapter.InstantTypeAdapter; +import market.guess.service.catalog.infrastructure.repository.EventRepository; +import market.guess.service.catalog.infrastructure.repository.UserRepository; +import market.guess.service.domain.Event; +import market.guess.service.domain.User; + +public final class MarketContext { + record Wrapper(List events, List users) {} + + private final EventRepository events; + private final UserRepository users; + + private static final Gson GSON = + new GsonBuilder() + .registerTypeAdapter(Instant.class, new InstantTypeAdapter()) + .setPrettyPrinting() + .create(); + + public MarketContext(EventRepository events, UserRepository users) { + this.events = events; + this.users = users; + } + + public EventRepository getEvents() { + return events; + } + + public UserRepository getUsers() { + return users; + } + + public void save() throws GuessMarketException { + var path = Paths.get("test-file.json"); + + try { + if (path.getParent() != null) Files.createDirectories(path.getParent()); + Files.writeString( + path, GSON.toJson(new Wrapper(events.getAll(), users.getAll())), StandardCharsets.UTF_8); + } catch (IOException e) { + throw new GuessMarketException("Failed to sove the file."); + } + } + + public void load() throws GuessMarketException { + try { + var wrapper = + GSON.fromJson( + Files.readString(Path.of("test-file.json"), StandardCharsets.UTF_8), Wrapper.class); + events.clear(); + users.clear(); + + for (var event : wrapper.events()) { + events.add(event); + } + + for (var user : wrapper.users()) { + users.add(user); + } + + } catch (JsonSyntaxException e) { + throw new GuessMarketException("The JSON file is malformed."); + } catch (IOException e) { + throw new GuessMarketException("Unable the file."); + } + } +} diff --git a/service/src/main/java/market/guess/service/catalog/infrastructure/adapter/InstantTypeAdapter.java b/service/src/main/java/market/guess/service/catalog/infrastructure/adapter/InstantTypeAdapter.java new file mode 100644 index 0000000..09af0b3 --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/infrastructure/adapter/InstantTypeAdapter.java @@ -0,0 +1,19 @@ +package market.guess.service.catalog.infrastructure.adapter; + +import com.google.gson.*; +import java.lang.reflect.Type; +import java.time.Instant; + +public final class InstantTypeAdapter + implements JsonSerializer, JsonDeserializer { + @Override + public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) { + return new JsonPrimitive(src.toString()); + } + + @Override + public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { + return Instant.parse(json.getAsString()); + } +} diff --git a/service/src/main/java/market/guess/service/catalog/infrastructure/mapper/Mapper.java b/service/src/main/java/market/guess/service/catalog/infrastructure/mapper/Mapper.java new file mode 100644 index 0000000..c6bd5b6 --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/infrastructure/mapper/Mapper.java @@ -0,0 +1,5 @@ +package market.guess.service.catalog.infrastructure.mapper; + +public interface Mapper { + TDomain toDomain(TModel source); +} diff --git a/service/src/main/java/market/guess/service/catalog/infrastructure/mapper/v1/EventMapperV1.java b/service/src/main/java/market/guess/service/catalog/infrastructure/mapper/v1/EventMapperV1.java new file mode 100644 index 0000000..78fd550 --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/infrastructure/mapper/v1/EventMapperV1.java @@ -0,0 +1,56 @@ +package market.guess.service.catalog.infrastructure.mapper.v1; + +import java.util.ArrayList; +import java.util.List; +import market.guess.api.CommissionTiming; +import market.guess.model.event.EventStatus; +import market.guess.service.catalog.infrastructure.mapper.Mapper; +import market.guess.service.catalog.model.v1.GMEvent; +import market.guess.service.domain.Event; +import market.guess.service.domain.Market; +import market.guess.service.mechanism.LmsrTradingMechanism; + +public final class EventMapperV1 implements Mapper { + + @Override + public Event toDomain(GMEvent source) { + var options = getOptions(source); + + return new Event( + getEventKey(source), + source.getId(), + joinName(source.getName()), + source.getDescription(), + source.getComision().getValue(), + getTiming(source.getComision().getType()), + new LmsrTradingMechanism(source.getGMMethod().getGMLMSR().getB(), options.size()), + EventStatus.ACTIVE, + options, + "Tester"); // ponytail: only user in this console app; swap for a real market-maker + // concept if multi-user support lands + } + + private static String getEventKey(GMEvent event) { + return String.valueOf(event.getId()); + } + + private static String joinName(List tokens) { + return tokens == null ? "" : String.join(" ", tokens); + } + + private static CommissionTiming getTiming(String type) throws IllegalArgumentException { + return switch (type) { + case "on-close" -> CommissionTiming.ON_CLOSE; + case "on-purchase" -> CommissionTiming.ON_PURCHASE; + default -> throw new IllegalArgumentException("Unknown comision type: " + type); + }; + } + + private static List getOptions(GMEvent x) { + var ret = new ArrayList(x.getGMOptions().getGMOption().size()); + for (var i = 0; i < x.getGMOptions().getGMOption().size(); i++) { + ret.add(new Market(getEventKey(x) + ":" + i, x.getGMOptions().getGMOption().get(i))); + } + return ret; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/infrastructure/mapper/v2/EventMapperV2.java b/service/src/main/java/market/guess/service/catalog/infrastructure/mapper/v2/EventMapperV2.java new file mode 100644 index 0000000..82455f1 --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/infrastructure/mapper/v2/EventMapperV2.java @@ -0,0 +1,69 @@ +package market.guess.service.catalog.infrastructure.mapper.v2; + +import java.util.ArrayList; +import java.util.List; +import market.guess.api.CommissionTiming; +import market.guess.model.event.EventStatus; +import market.guess.service.catalog.infrastructure.mapper.Mapper; +import market.guess.service.catalog.model.v2.GMEvent; +import market.guess.service.catalog.model.v2.GMLMSR; +import market.guess.service.catalog.model.v2.GMOrderBook; +import market.guess.service.domain.Event; +import market.guess.service.domain.Market; +import market.guess.service.mechanism.LmsrTradingMechanism; +import market.guess.service.mechanism.OrderBookTradingMechanism; +import market.guess.service.mechanism.TradingMechanism; + +public final class EventMapperV2 implements Mapper { + + @Override + public Event toDomain(GMEvent source) { + var options = getOptions(source); + + return new Event( + getEventKey(source), + source.getId(), + source.getName(), + source.getDescription(), + source.getCommission().getValue(), + getTiming(source.getCommission().getType()), + getMechanism(source, options.size()), + EventStatus.DRAFT, + options, + ""); + } + + private static String getEventKey(GMEvent event) { + return String.valueOf(event.getId()); + } + + private static CommissionTiming getTiming(String type) throws IllegalArgumentException { + return switch (type) { + case "on-close" -> CommissionTiming.ON_CLOSE; + case "on-purchase" -> CommissionTiming.ON_PURCHASE; + default -> throw new IllegalArgumentException("Unknown commission type: " + type); + }; + } + + private static TradingMechanism getMechanism(GMEvent source, int optionCount) { + if (source.getGMMethod().getGMLMSR() instanceof GMLMSR lmsr) { + return new LmsrTradingMechanism(lmsr.getB(), optionCount); + } + if (source.getGMMethod().getGMOrderBook() instanceof GMOrderBook orderBook) { + return new OrderBookTradingMechanism( + orderBook.getAllowMint().equalsIgnoreCase("true"), + orderBook.getInitial(), + orderBook.getD(), + optionCount); + } + throw new IllegalArgumentException(); + } + + private static List getOptions(GMEvent x) { + var ret = new ArrayList(x.getGMOptions().getGMOption().size()); + for (var i = 0; i < x.getGMOptions().getGMOption().size(); i++) { + ret.add(new Market(getEventKey(x) + ":" + i, x.getGMOptions().getGMOption().get(i))); + } + return ret; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/infrastructure/provider/Loader.java b/service/src/main/java/market/guess/service/catalog/infrastructure/provider/Loader.java new file mode 100644 index 0000000..62406bb --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/infrastructure/provider/Loader.java @@ -0,0 +1,12 @@ +package market.guess.service.catalog.infrastructure.provider; + +import java.nio.file.Path; +import market.guess.api.CatalogContext; +import market.guess.api.LoadResult; +import market.guess.api.Result; + +public interface Loader { + Result seed(CatalogContext context); + + Result load(Path path); +} diff --git a/service/src/main/java/market/guess/service/catalog/infrastructure/provider/v1/XMLLoaderV1.java b/service/src/main/java/market/guess/service/catalog/infrastructure/provider/v1/XMLLoaderV1.java new file mode 100644 index 0000000..67d0b67 --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/infrastructure/provider/v1/XMLLoaderV1.java @@ -0,0 +1,63 @@ +package market.guess.service.catalog.infrastructure.provider.v1; + +import jakarta.xml.bind.JAXBContext; +import jakarta.xml.bind.JAXBException; +import java.nio.file.Files; +import java.nio.file.Path; +import market.guess.api.CatalogContext; +import market.guess.api.LoadResult; +import market.guess.api.Result; +import market.guess.service.catalog.infrastructure.mapper.v1.EventMapperV1; +import market.guess.service.catalog.infrastructure.provider.Loader; +import market.guess.service.catalog.infrastructure.repository.EventRepository; +import market.guess.service.catalog.infrastructure.repository.UserRepository; +import market.guess.service.catalog.model.v1.GuessMarket; +import market.guess.service.domain.User; + +public final class XMLLoaderV1 implements Loader { + private final JAXBContext context; + + private final EventRepository eventRepository; + private final UserRepository userRepository; + private final EventMapperV1 mapper; + + public XMLLoaderV1( + EventRepository eventRepository, UserRepository userRepository, EventMapperV1 mapper) { + super(); + this.eventRepository = eventRepository; + this.userRepository = userRepository; + this.mapper = mapper; + try { + context = JAXBContext.newInstance(GuessMarket.class); + } catch (JAXBException e) { + throw new IllegalStateException(); + } + } + + @Override + public Result load(Path path) { + if (path.getFileName() == null + || !path.getFileName().toString().toLowerCase().endsWith(".xml")) { + return Result.error("NOT_XML", "The file must be an XML."); + } + + try (var stream = Files.newInputStream(path)) { + var doc = (GuessMarket) context.createUnmarshaller().unmarshal(stream); + for (var event : doc.getGMEvents().getGMEvent()) { + eventRepository.add(mapper.toDomain(event)); + } + + userRepository.add(new User("Tester", 9_999_999)); + + return Result.ok(new LoadResult(path.toString(), eventRepository.getAll().size())); + } catch (Exception e) { + return Result.error("UNREADABLE", "The file could not be read."); + } + } + + @Override + public Result seed(CatalogContext context) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'seed'"); + } +} diff --git a/service/src/main/java/market/guess/service/catalog/infrastructure/repository/EventRepository.java b/service/src/main/java/market/guess/service/catalog/infrastructure/repository/EventRepository.java new file mode 100644 index 0000000..be71a49 --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/infrastructure/repository/EventRepository.java @@ -0,0 +1,5 @@ +package market.guess.service.catalog.infrastructure.repository; + +import market.guess.service.domain.Event; + +public interface EventRepository extends Repository {} diff --git a/service/src/main/java/market/guess/service/catalog/infrastructure/repository/InMemoryEventRepository.java b/service/src/main/java/market/guess/service/catalog/infrastructure/repository/InMemoryEventRepository.java new file mode 100644 index 0000000..96c898b --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/infrastructure/repository/InMemoryEventRepository.java @@ -0,0 +1,32 @@ +package market.guess.service.catalog.infrastructure.repository; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import market.guess.service.domain.Event; + +public final class InMemoryEventRepository implements EventRepository { + private final List events = new ArrayList<>(); + + @Override + public Event add(Event element) { + events.add(element); + return element; + } + + @Override + public Optional get(String id) { + return events.stream().filter(event -> event.getEventKey().equalsIgnoreCase(id)).findFirst(); + } + + @Override + public List getAll() { + return Collections.unmodifiableList(events); + } + + @Override + public void clear() { + events.clear(); + } +} diff --git a/service/src/main/java/market/guess/service/catalog/infrastructure/repository/InMemoryUserRepository.java b/service/src/main/java/market/guess/service/catalog/infrastructure/repository/InMemoryUserRepository.java new file mode 100644 index 0000000..a9c0e8d --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/infrastructure/repository/InMemoryUserRepository.java @@ -0,0 +1,32 @@ +package market.guess.service.catalog.infrastructure.repository; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import market.guess.service.domain.User; + +public final class InMemoryUserRepository implements UserRepository { + private final List users = new ArrayList<>(); + + @Override + public User add(User element) { + users.add(element); + return element; + } + + @Override + public Optional get(String id) { + return users.stream().filter(u -> u.getName().equalsIgnoreCase(id)).findFirst(); + } + + @Override + public List getAll() { + return Collections.unmodifiableList(users); + } + + @Override + public void clear() { + users.clear(); + } +} diff --git a/service/src/main/java/market/guess/service/catalog/infrastructure/repository/Repository.java b/service/src/main/java/market/guess/service/catalog/infrastructure/repository/Repository.java new file mode 100644 index 0000000..b165b48 --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/infrastructure/repository/Repository.java @@ -0,0 +1,14 @@ +package market.guess.service.catalog.infrastructure.repository; + +import java.util.List; +import java.util.Optional; + +public interface Repository { + T add(T element); + + Optional get(String id); + + List getAll(); + + void clear(); +} diff --git a/service/src/main/java/market/guess/service/catalog/infrastructure/repository/UserRepository.java b/service/src/main/java/market/guess/service/catalog/infrastructure/repository/UserRepository.java new file mode 100644 index 0000000..ef9a543 --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/infrastructure/repository/UserRepository.java @@ -0,0 +1,5 @@ +package market.guess.service.catalog.infrastructure.repository; + +import market.guess.service.domain.User; + +public interface UserRepository extends Repository {} diff --git a/service/src/main/java/market/guess/service/catalog/model/v1/Comision.java b/service/src/main/java/market/guess/service/catalog/model/v1/Comision.java new file mode 100644 index 0000000..17c7a0b --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v1/Comision.java @@ -0,0 +1,77 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v1; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlValue; + +/** + * Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

{@code
+ * 
+ *   
+ *     
+ *       
+ *         
+ *           
+ *             
+ *             
+ *           
+ *         
+ *       
+ *     
+ *   
+ * 
+ * }
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType( + name = "", + propOrder = {"value"}) +@XmlRootElement(name = "comision") +public class Comision { + + @XmlValue protected int value; + + @XmlAttribute(name = "type", required = true) + protected String type; + + /** Gets the value of the value property. */ + public int getValue() { + return value; + } + + /** Sets the value of the value property. */ + public void setValue(int value) { + this.value = value; + } + + /** + * Gets the value of the type property. + * + * @return possible object is {@link String } + */ + public String getType() { + return type; + } + + /** + * Sets the value of the type property. + * + * @param value allowed object is {@link String } + */ + public void setType(String value) { + this.type = value; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/model/v1/GMEvent.java b/service/src/main/java/market/guess/service/catalog/model/v1/GMEvent.java new file mode 100644 index 0000000..0b829c5 --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v1/GMEvent.java @@ -0,0 +1,173 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v1; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; + +/** + * Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

{@code
+ * 
+ *   
+ *     
+ *       
+ *         
+ *         
+ *         
+ *         
+ *         
+ *       
+ *       
+ *         
+ *           
+ *         
+ *       
+ *     
+ *   
+ * 
+ * }
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType( + name = "", + propOrder = {"id", "description", "comision", "gmOptions", "gmMethod"}) +@XmlRootElement(name = "GM-event") +public class GMEvent { + + protected int id; + + @XmlElement(required = true) + protected String description; + + @XmlElement(required = true) + protected Comision comision; + + @XmlElement(name = "GM-options", required = true) + protected GMOptions gmOptions; + + @XmlElement(name = "GM-method", required = true) + protected GMMethod gmMethod; + + @XmlAttribute(name = "name", required = true) + protected List name; + + /** Gets the value of the id property. */ + public int getId() { + return id; + } + + /** Sets the value of the id property. */ + public void setId(int value) { + this.id = value; + } + + /** + * Gets the value of the description property. + * + * @return possible object is {@link String } + */ + public String getDescription() { + return description; + } + + /** + * Sets the value of the description property. + * + * @param value allowed object is {@link String } + */ + public void setDescription(String value) { + this.description = value; + } + + /** + * Gets the value of the comision property. + * + * @return possible object is {@link Comision } + */ + public Comision getComision() { + return comision; + } + + /** + * Sets the value of the comision property. + * + * @param value allowed object is {@link Comision } + */ + public void setComision(Comision value) { + this.comision = value; + } + + /** + * Gets the value of the gmOptions property. + * + * @return possible object is {@link GMOptions } + */ + public GMOptions getGMOptions() { + return gmOptions; + } + + /** + * Sets the value of the gmOptions property. + * + * @param value allowed object is {@link GMOptions } + */ + public void setGMOptions(GMOptions value) { + this.gmOptions = value; + } + + /** + * Gets the value of the gmMethod property. + * + * @return possible object is {@link GMMethod } + */ + public GMMethod getGMMethod() { + return gmMethod; + } + + /** + * Sets the value of the gmMethod property. + * + * @param value allowed object is {@link GMMethod } + */ + public void setGMMethod(GMMethod value) { + this.gmMethod = value; + } + + /** + * Gets the value of the name property. + * + *

This accessor method returns a reference to the live list, not a snapshot. Therefore any + * modification you make to the returned list will be present inside the JAXB object. This is why + * there is not a set method for the name property. + * + *

For example, to add a new item, do as follows: + * + *

+   * getName().add(newItem);
+   * 
+ * + *

Objects of the following type(s) are allowed in the list {@link String } + * + * @return The value of the name property. + */ + public List getName() { + if (name == null) { + name = new ArrayList<>(); + } + return this.name; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/model/v1/GMEvents.java b/service/src/main/java/market/guess/service/catalog/model/v1/GMEvents.java new file mode 100644 index 0000000..b078edd --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v1/GMEvents.java @@ -0,0 +1,67 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v1; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; + +/** + * Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

{@code
+ * 
+ *   
+ *     
+ *       
+ *         
+ *       
+ *     
+ *   
+ * 
+ * }
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType( + name = "", + propOrder = {"gmEvent"}) +@XmlRootElement(name = "GM-events") +public class GMEvents { + + @XmlElement(name = "GM-event", required = true) + protected List gmEvent; + + /** + * Gets the value of the gmEvent property. + * + *

This accessor method returns a reference to the live list, not a snapshot. Therefore any + * modification you make to the returned list will be present inside the JAXB object. This is why + * there is not a set method for the gmEvent property. + * + *

For example, to add a new item, do as follows: + * + *

+   * getGMEvent().add(newItem);
+   * 
+ * + *

Objects of the following type(s) are allowed in the list {@link GMEvent } + * + * @return The value of the gmEvent property. + */ + public List getGMEvent() { + if (gmEvent == null) { + gmEvent = new ArrayList<>(); + } + return this.gmEvent; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/model/v1/GMLMSR.java b/service/src/main/java/market/guess/service/catalog/model/v1/GMLMSR.java new file mode 100644 index 0000000..90648e2 --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v1/GMLMSR.java @@ -0,0 +1,49 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v1; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; + +/** + * Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

{@code
+ * 
+ *   
+ *     
+ *       
+ *         
+ *       
+ *     
+ *   
+ * 
+ * }
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType( + name = "", + propOrder = {"b"}) +@XmlRootElement(name = "GM-LMSR") +public class GMLMSR { + + protected int b; + + /** Gets the value of the b property. */ + public int getB() { + return b; + } + + /** Sets the value of the b property. */ + public void setB(int value) { + this.b = value; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/model/v1/GMMethod.java b/service/src/main/java/market/guess/service/catalog/model/v1/GMMethod.java new file mode 100644 index 0000000..8b73880 --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v1/GMMethod.java @@ -0,0 +1,59 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v1; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; + +/** + * Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

{@code
+ * 
+ *   
+ *     
+ *       
+ *         
+ *       
+ *     
+ *   
+ * 
+ * }
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType( + name = "", + propOrder = {"gmlmsr"}) +@XmlRootElement(name = "GM-method") +public class GMMethod { + + @XmlElement(name = "GM-LMSR", required = true) + protected GMLMSR gmlmsr; + + /** + * Gets the value of the gmlmsr property. + * + * @return possible object is {@link GMLMSR } + */ + public GMLMSR getGMLMSR() { + return gmlmsr; + } + + /** + * Sets the value of the gmlmsr property. + * + * @param value allowed object is {@link GMLMSR } + */ + public void setGMLMSR(GMLMSR value) { + this.gmlmsr = value; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/model/v1/GMOptions.java b/service/src/main/java/market/guess/service/catalog/model/v1/GMOptions.java new file mode 100644 index 0000000..9639d1c --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v1/GMOptions.java @@ -0,0 +1,67 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v1; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; + +/** + * Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

{@code
+ * 
+ *   
+ *     
+ *       
+ *         
+ *       
+ *     
+ *   
+ * 
+ * }
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType( + name = "", + propOrder = {"gmOption"}) +@XmlRootElement(name = "GM-options") +public class GMOptions { + + @XmlElement(name = "GM-option", required = true) + protected List gmOption; + + /** + * Gets the value of the gmOption property. + * + *

This accessor method returns a reference to the live list, not a snapshot. Therefore any + * modification you make to the returned list will be present inside the JAXB object. This is why + * there is not a set method for the gmOption property. + * + *

For example, to add a new item, do as follows: + * + *

+   * getGMOption().add(newItem);
+   * 
+ * + *

Objects of the following type(s) are allowed in the list {@link String } + * + * @return The value of the gmOption property. + */ + public List getGMOption() { + if (gmOption == null) { + gmOption = new ArrayList<>(); + } + return this.gmOption; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/model/v1/GuessMarket.java b/service/src/main/java/market/guess/service/catalog/model/v1/GuessMarket.java new file mode 100644 index 0000000..e584ac2 --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v1/GuessMarket.java @@ -0,0 +1,59 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v1; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; + +/** + * Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

{@code
+ * 
+ *   
+ *     
+ *       
+ *         
+ *       
+ *     
+ *   
+ * 
+ * }
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType( + name = "", + propOrder = {"gmEvents"}) +@XmlRootElement(name = "Guess-Market") +public class GuessMarket { + + @XmlElement(name = "GM-events", required = true) + protected GMEvents gmEvents; + + /** + * Gets the value of the gmEvents property. + * + * @return possible object is {@link GMEvents } + */ + public GMEvents getGMEvents() { + return gmEvents; + } + + /** + * Sets the value of the gmEvents property. + * + * @param value allowed object is {@link GMEvents } + */ + public void setGMEvents(GMEvents value) { + this.gmEvents = value; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/model/v1/ObjectFactory.java b/service/src/main/java/market/guess/service/catalog/model/v1/ObjectFactory.java new file mode 100644 index 0000000..cab68ed --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v1/ObjectFactory.java @@ -0,0 +1,143 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v1; + +import jakarta.xml.bind.JAXBElement; +import jakarta.xml.bind.annotation.XmlElementDecl; +import jakarta.xml.bind.annotation.XmlRegistry; +import javax.xml.namespace.QName; + +/** + * This object contains factory methods for each Java content interface and Java element interface + * generated in the market.guess.service.model.v1 package. + * + *

An ObjectFactory allows you to programmatically construct new instances of the Java + * representation for XML content. The Java representation of XML content can consist of schema + * derived interfaces and classes representing the binding of schema type definitions, element + * declarations and model groups. Factory methods for each of these are provided in this class. + */ +@XmlRegistry +public class ObjectFactory { + + private static final QName _Id_QNAME = new QName("", "id"); + private static final QName _Description_QNAME = new QName("", "description"); + private static final QName _B_QNAME = new QName("", "b"); + private static final QName _GMOption_QNAME = new QName("", "GM-option"); + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes + * for package: market.guess.service.model.v1 + */ + public ObjectFactory() {} + + /** + * Create an instance of {@link Comision } + * + * @return the new instance of {@link Comision } + */ + public Comision createComision() { + return new Comision(); + } + + /** + * Create an instance of {@link GuessMarket } + * + * @return the new instance of {@link GuessMarket } + */ + public GuessMarket createGuessMarket() { + return new GuessMarket(); + } + + /** + * Create an instance of {@link GMEvents } + * + * @return the new instance of {@link GMEvents } + */ + public GMEvents createGMEvents() { + return new GMEvents(); + } + + /** + * Create an instance of {@link GMEvent } + * + * @return the new instance of {@link GMEvent } + */ + public GMEvent createGMEvent() { + return new GMEvent(); + } + + /** + * Create an instance of {@link GMOptions } + * + * @return the new instance of {@link GMOptions } + */ + public GMOptions createGMOptions() { + return new GMOptions(); + } + + /** + * Create an instance of {@link GMMethod } + * + * @return the new instance of {@link GMMethod } + */ + public GMMethod createGMMethod() { + return new GMMethod(); + } + + /** + * Create an instance of {@link GMLMSR } + * + * @return the new instance of {@link GMLMSR } + */ + public GMLMSR createGMLMSR() { + return new GMLMSR(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >} + * + * @param value Java instance representing xml element's value. + * @return the new instance of {@link JAXBElement }{@code <}{@link Integer }{@code >} + */ + @XmlElementDecl(namespace = "", name = "id") + public JAXBElement createId(Integer value) { + return new JAXBElement<>(_Id_QNAME, Integer.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >} + * + * @param value Java instance representing xml element's value. + * @return the new instance of {@link JAXBElement }{@code <}{@link String }{@code >} + */ + @XmlElementDecl(namespace = "", name = "description") + public JAXBElement createDescription(String value) { + return new JAXBElement<>(_Description_QNAME, String.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >} + * + * @param value Java instance representing xml element's value. + * @return the new instance of {@link JAXBElement }{@code <}{@link Integer }{@code >} + */ + @XmlElementDecl(namespace = "", name = "b") + public JAXBElement createB(Integer value) { + return new JAXBElement<>(_B_QNAME, Integer.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >} + * + * @param value Java instance representing xml element's value. + * @return the new instance of {@link JAXBElement }{@code <}{@link String }{@code >} + */ + @XmlElementDecl(namespace = "", name = "GM-option") + public JAXBElement createGMOption(String value) { + return new JAXBElement<>(_GMOption_QNAME, String.class, null, value); + } +} diff --git a/service/src/main/java/market/guess/service/catalog/model/v2/Commission.java b/service/src/main/java/market/guess/service/catalog/model/v2/Commission.java new file mode 100644 index 0000000..b46807e --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v2/Commission.java @@ -0,0 +1,77 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v2; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlValue; + +/** + * Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

{@code
+ * 
+ *   
+ *     
+ *       
+ *         
+ *           
+ *             
+ *             
+ *           
+ *         
+ *       
+ *     
+ *   
+ * 
+ * }
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType( + name = "", + propOrder = {"value"}) +@XmlRootElement(name = "commission") +public class Commission { + + @XmlValue protected int value; + + @XmlAttribute(name = "type", required = true) + protected String type; + + /** Gets the value of the value property. */ + public int getValue() { + return value; + } + + /** Sets the value of the value property. */ + public void setValue(int value) { + this.value = value; + } + + /** + * Gets the value of the type property. + * + * @return possible object is {@link String } + */ + public String getType() { + return type; + } + + /** + * Sets the value of the type property. + * + * @param value allowed object is {@link String } + */ + public void setType(String value) { + this.type = value; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/model/v2/Event.java b/service/src/main/java/market/guess/service/catalog/model/v2/Event.java new file mode 100644 index 0000000..afd7a32 --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v2/Event.java @@ -0,0 +1,47 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v2; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; + +/** + * Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

{@code
+ * 
+ *   
+ *     
+ *       
+ *     
+ *   
+ * 
+ * }
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "") +@XmlRootElement(name = "event") +public class Event { + + @XmlAttribute(name = "id", required = true) + protected int id; + + /** Gets the value of the id property. */ + public int getId() { + return id; + } + + /** Sets the value of the id property. */ + public void setId(int value) { + this.id = value; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/model/v2/GMEvent.java b/service/src/main/java/market/guess/service/catalog/model/v2/GMEvent.java new file mode 100644 index 0000000..3ce6192 --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v2/GMEvent.java @@ -0,0 +1,161 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v2; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; + +/** + * Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

{@code
+ * 
+ *   
+ *     
+ *       
+ *         
+ *         
+ *         
+ *         
+ *         
+ *       
+ *       
+ *     
+ *   
+ * 
+ * }
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType( + name = "", + propOrder = {"id", "description", "commission", "gmOptions", "gmMethod"}) +@XmlRootElement(name = "GM-event") +public class GMEvent { + + protected int id; + + @XmlElement(required = true) + protected String description; + + @XmlElement(required = true) + protected Commission commission; + + @XmlElement(name = "GM-options", required = true) + protected GMOptions gmOptions; + + @XmlElement(name = "GM-method", required = true) + protected GMMethod gmMethod; + + @XmlAttribute(name = "name", required = true) + protected String name; + + /** Gets the value of the id property. */ + public int getId() { + return id; + } + + /** Sets the value of the id property. */ + public void setId(int value) { + this.id = value; + } + + /** + * Gets the value of the description property. + * + * @return possible object is {@link String } + */ + public String getDescription() { + return description; + } + + /** + * Sets the value of the description property. + * + * @param value allowed object is {@link String } + */ + public void setDescription(String value) { + this.description = value; + } + + /** + * Gets the value of the commission property. + * + * @return possible object is {@link Commission } + */ + public Commission getCommission() { + return commission; + } + + /** + * Sets the value of the commission property. + * + * @param value allowed object is {@link Commission } + */ + public void setCommission(Commission value) { + this.commission = value; + } + + /** + * Gets the value of the gmOptions property. + * + * @return possible object is {@link GMOptions } + */ + public GMOptions getGMOptions() { + return gmOptions; + } + + /** + * Sets the value of the gmOptions property. + * + * @param value allowed object is {@link GMOptions } + */ + public void setGMOptions(GMOptions value) { + this.gmOptions = value; + } + + /** + * Gets the value of the gmMethod property. + * + * @return possible object is {@link GMMethod } + */ + public GMMethod getGMMethod() { + return gmMethod; + } + + /** + * Sets the value of the gmMethod property. + * + * @param value allowed object is {@link GMMethod } + */ + public void setGMMethod(GMMethod value) { + this.gmMethod = value; + } + + /** + * Gets the value of the name property. + * + * @return possible object is {@link String } + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value allowed object is {@link String } + */ + public void setName(String value) { + this.name = value; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/model/v2/GMEvents.java b/service/src/main/java/market/guess/service/catalog/model/v2/GMEvents.java new file mode 100644 index 0000000..365161e --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v2/GMEvents.java @@ -0,0 +1,67 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v2; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; + +/** + * Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

{@code
+ * 
+ *   
+ *     
+ *       
+ *         
+ *       
+ *     
+ *   
+ * 
+ * }
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType( + name = "", + propOrder = {"gmEvent"}) +@XmlRootElement(name = "GM-events") +public class GMEvents { + + @XmlElement(name = "GM-event", required = true) + protected List gmEvent; + + /** + * Gets the value of the gmEvent property. + * + *

This accessor method returns a reference to the live list, not a snapshot. Therefore any + * modification you make to the returned list will be present inside the JAXB object. This is why + * there is not a set method for the gmEvent property. + * + *

For example, to add a new item, do as follows: + * + *

+   * getGMEvent().add(newItem);
+   * 
+ * + *

Objects of the following type(s) are allowed in the list {@link GMEvent } + * + * @return The value of the gmEvent property. + */ + public List getGMEvent() { + if (gmEvent == null) { + gmEvent = new ArrayList<>(); + } + return this.gmEvent; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/model/v2/GMLMSR.java b/service/src/main/java/market/guess/service/catalog/model/v2/GMLMSR.java new file mode 100644 index 0000000..aabd77a --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v2/GMLMSR.java @@ -0,0 +1,49 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v2; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; + +/** + * Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

{@code
+ * 
+ *   
+ *     
+ *       
+ *         
+ *       
+ *     
+ *   
+ * 
+ * }
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType( + name = "", + propOrder = {"b"}) +@XmlRootElement(name = "GM-LMSR") +public class GMLMSR { + + protected int b; + + /** Gets the value of the b property. */ + public int getB() { + return b; + } + + /** Sets the value of the b property. */ + public void setB(int value) { + this.b = value; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/model/v2/GMMarketMaker.java b/service/src/main/java/market/guess/service/catalog/model/v2/GMMarketMaker.java new file mode 100644 index 0000000..886f3f0 --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v2/GMMarketMaker.java @@ -0,0 +1,67 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v2; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; + +/** + * Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

{@code
+ * 
+ *   
+ *     
+ *       
+ *         
+ *       
+ *     
+ *   
+ * 
+ * }
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType( + name = "", + propOrder = {"event"}) +@XmlRootElement(name = "GM-market-maker") +public class GMMarketMaker { + + @XmlElement(required = true) + protected List event; + + /** + * Gets the value of the event property. + * + *

This accessor method returns a reference to the live list, not a snapshot. Therefore any + * modification you make to the returned list will be present inside the JAXB object. This is why + * there is not a set method for the event property. + * + *

For example, to add a new item, do as follows: + * + *

+   * getEvent().add(newItem);
+   * 
+ * + *

Objects of the following type(s) are allowed in the list {@link Event } + * + * @return The value of the event property. + */ + public List getEvent() { + if (event == null) { + event = new ArrayList<>(); + } + return this.event; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/model/v2/GMMethod.java b/service/src/main/java/market/guess/service/catalog/model/v2/GMMethod.java new file mode 100644 index 0000000..c9a4489 --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v2/GMMethod.java @@ -0,0 +1,81 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v2; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; + +/** + * Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

{@code
+ * 
+ *   
+ *     
+ *       
+ *         
+ *         
+ *       
+ *     
+ *   
+ * 
+ * }
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType( + name = "", + propOrder = {"gmlmsr", "gmOrderBook"}) +@XmlRootElement(name = "GM-method") +public class GMMethod { + + @XmlElement(name = "GM-LMSR") + protected GMLMSR gmlmsr; + + @XmlElement(name = "GM-order-book") + protected GMOrderBook gmOrderBook; + + /** + * Gets the value of the gmlmsr property. + * + * @return possible object is {@link GMLMSR } + */ + public GMLMSR getGMLMSR() { + return gmlmsr; + } + + /** + * Sets the value of the gmlmsr property. + * + * @param value allowed object is {@link GMLMSR } + */ + public void setGMLMSR(GMLMSR value) { + this.gmlmsr = value; + } + + /** + * Gets the value of the gmOrderBook property. + * + * @return possible object is {@link GMOrderBook } + */ + public GMOrderBook getGMOrderBook() { + return gmOrderBook; + } + + /** + * Sets the value of the gmOrderBook property. + * + * @param value allowed object is {@link GMOrderBook } + */ + public void setGMOrderBook(GMOrderBook value) { + this.gmOrderBook = value; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/model/v2/GMOptions.java b/service/src/main/java/market/guess/service/catalog/model/v2/GMOptions.java new file mode 100644 index 0000000..ca0bbb2 --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v2/GMOptions.java @@ -0,0 +1,67 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v2; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; + +/** + * Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

{@code
+ * 
+ *   
+ *     
+ *       
+ *         
+ *       
+ *     
+ *   
+ * 
+ * }
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType( + name = "", + propOrder = {"gmOption"}) +@XmlRootElement(name = "GM-options") +public class GMOptions { + + @XmlElement(name = "GM-option", required = true) + protected List gmOption; + + /** + * Gets the value of the gmOption property. + * + *

This accessor method returns a reference to the live list, not a snapshot. Therefore any + * modification you make to the returned list will be present inside the JAXB object. This is why + * there is not a set method for the gmOption property. + * + *

For example, to add a new item, do as follows: + * + *

+   * getGMOption().add(newItem);
+   * 
+ * + *

Objects of the following type(s) are allowed in the list {@link String } + * + * @return The value of the gmOption property. + */ + public List getGMOption() { + if (gmOption == null) { + gmOption = new ArrayList<>(); + } + return this.gmOption; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/model/v2/GMOrderBook.java b/service/src/main/java/market/guess/service/catalog/model/v2/GMOrderBook.java new file mode 100644 index 0000000..9d3836f --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v2/GMOrderBook.java @@ -0,0 +1,90 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v2; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; + +/** + * Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

{@code
+ * 
+ *   
+ *     
+ *       
+ *       
+ *       
+ *         
+ *           
+ *             
+ *             
+ *           
+ *         
+ *       
+ *     
+ *   
+ * 
+ * }
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "") +@XmlRootElement(name = "GM-order-book") +public class GMOrderBook { + + @XmlAttribute(name = "initial", required = true) + protected int initial; + + @XmlAttribute(name = "d", required = true) + protected int d; + + @XmlAttribute(name = "allow-mint", required = true) + protected String allowMint; + + /** Gets the value of the initial property. */ + public int getInitial() { + return initial; + } + + /** Sets the value of the initial property. */ + public void setInitial(int value) { + this.initial = value; + } + + /** Gets the value of the d property. */ + public int getD() { + return d; + } + + /** Sets the value of the d property. */ + public void setD(int value) { + this.d = value; + } + + /** + * Gets the value of the allowMint property. + * + * @return possible object is {@link String } + */ + public String getAllowMint() { + return allowMint; + } + + /** + * Sets the value of the allowMint property. + * + * @param value allowed object is {@link String } + */ + public void setAllowMint(String value) { + this.allowMint = value; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/model/v2/GMUser.java b/service/src/main/java/market/guess/service/catalog/model/v2/GMUser.java new file mode 100644 index 0000000..bc6e5d9 --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v2/GMUser.java @@ -0,0 +1,96 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v2; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; + +/** + * Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

{@code
+ * 
+ *   
+ *     
+ *       
+ *         
+ *         
+ *       
+ *       
+ *     
+ *   
+ * 
+ * }
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType( + name = "", + propOrder = {"initialCash", "gmMarketMaker"}) +@XmlRootElement(name = "GM-user") +public class GMUser { + + @XmlElement(name = "initial-cash") + protected int initialCash; + + @XmlElement(name = "GM-market-maker") + protected GMMarketMaker gmMarketMaker; + + @XmlAttribute(name = "name", required = true) + protected String name; + + /** Gets the value of the initialCash property. */ + public int getInitialCash() { + return initialCash; + } + + /** Sets the value of the initialCash property. */ + public void setInitialCash(int value) { + this.initialCash = value; + } + + /** + * Gets the value of the gmMarketMaker property. + * + * @return possible object is {@link GMMarketMaker } + */ + public GMMarketMaker getGMMarketMaker() { + return gmMarketMaker; + } + + /** + * Sets the value of the gmMarketMaker property. + * + * @param value allowed object is {@link GMMarketMaker } + */ + public void setGMMarketMaker(GMMarketMaker value) { + this.gmMarketMaker = value; + } + + /** + * Gets the value of the name property. + * + * @return possible object is {@link String } + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value allowed object is {@link String } + */ + public void setName(String value) { + this.name = value; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/model/v2/GMUsers.java b/service/src/main/java/market/guess/service/catalog/model/v2/GMUsers.java new file mode 100644 index 0000000..cc6c81d --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v2/GMUsers.java @@ -0,0 +1,67 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v2; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; + +/** + * Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

{@code
+ * 
+ *   
+ *     
+ *       
+ *         
+ *       
+ *     
+ *   
+ * 
+ * }
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType( + name = "", + propOrder = {"gmUser"}) +@XmlRootElement(name = "GM-users") +public class GMUsers { + + @XmlElement(name = "GM-user", required = true) + protected List gmUser; + + /** + * Gets the value of the gmUser property. + * + *

This accessor method returns a reference to the live list, not a snapshot. Therefore any + * modification you make to the returned list will be present inside the JAXB object. This is why + * there is not a set method for the gmUser property. + * + *

For example, to add a new item, do as follows: + * + *

+   * getGMUser().add(newItem);
+   * 
+ * + *

Objects of the following type(s) are allowed in the list {@link GMUser } + * + * @return The value of the gmUser property. + */ + public List getGMUser() { + if (gmUser == null) { + gmUser = new ArrayList<>(); + } + return this.gmUser; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/model/v2/GuessMarket.java b/service/src/main/java/market/guess/service/catalog/model/v2/GuessMarket.java new file mode 100644 index 0000000..e312651 --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v2/GuessMarket.java @@ -0,0 +1,81 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v2; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; + +/** + * Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

{@code
+ * 
+ *   
+ *     
+ *       
+ *         
+ *         
+ *       
+ *     
+ *   
+ * 
+ * }
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType( + name = "", + propOrder = {}) +@XmlRootElement(name = "Guess-Market") +public class GuessMarket { + + @XmlElement(name = "GM-events", required = true) + protected GMEvents gmEvents; + + @XmlElement(name = "GM-users", required = true) + protected GMUsers gmUsers; + + /** + * Gets the value of the gmEvents property. + * + * @return possible object is {@link GMEvents } + */ + public GMEvents getGMEvents() { + return gmEvents; + } + + /** + * Sets the value of the gmEvents property. + * + * @param value allowed object is {@link GMEvents } + */ + public void setGMEvents(GMEvents value) { + this.gmEvents = value; + } + + /** + * Gets the value of the gmUsers property. + * + * @return possible object is {@link GMUsers } + */ + public GMUsers getGMUsers() { + return gmUsers; + } + + /** + * Sets the value of the gmUsers property. + * + * @param value allowed object is {@link GMUsers } + */ + public void setGMUsers(GMUsers value) { + this.gmUsers = value; + } +} diff --git a/service/src/main/java/market/guess/service/catalog/model/v2/ObjectFactory.java b/service/src/main/java/market/guess/service/catalog/model/v2/ObjectFactory.java new file mode 100644 index 0000000..5a20f54 --- /dev/null +++ b/service/src/main/java/market/guess/service/catalog/model/v2/ObjectFactory.java @@ -0,0 +1,200 @@ +// +// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 +// See https://eclipse-ee4j.github.io/jaxb-ri +// Any modifications to this file will be lost upon recompilation of the source schema. +// + +package market.guess.service.catalog.model.v2; + +import jakarta.xml.bind.JAXBElement; +import jakarta.xml.bind.annotation.XmlElementDecl; +import jakarta.xml.bind.annotation.XmlRegistry; +import javax.xml.namespace.QName; + +/** + * This object contains factory methods for each Java content interface and Java element interface + * generated in the market.guess.service.model.v2 package. + * + *

An ObjectFactory allows you to programmatically construct new instances of the Java + * representation for XML content. The Java representation of XML content can consist of schema + * derived interfaces and classes representing the binding of schema type definitions, element + * declarations and model groups. Factory methods for each of these are provided in this class. + */ +@XmlRegistry +public class ObjectFactory { + + private static final QName _InitialCash_QNAME = new QName("", "initial-cash"); + private static final QName _Id_QNAME = new QName("", "id"); + private static final QName _Description_QNAME = new QName("", "description"); + private static final QName _B_QNAME = new QName("", "b"); + private static final QName _GMOption_QNAME = new QName("", "GM-option"); + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes + * for package: market.guess.service.model.v2 + */ + public ObjectFactory() {} + + /** + * Create an instance of {@link Event } + * + * @return the new instance of {@link Event } + */ + public Event createEvent() { + return new Event(); + } + + /** + * Create an instance of {@link Commission } + * + * @return the new instance of {@link Commission } + */ + public Commission createCommission() { + return new Commission(); + } + + /** + * Create an instance of {@link GuessMarket } + * + * @return the new instance of {@link GuessMarket } + */ + public GuessMarket createGuessMarket() { + return new GuessMarket(); + } + + /** + * Create an instance of {@link GMEvents } + * + * @return the new instance of {@link GMEvents } + */ + public GMEvents createGMEvents() { + return new GMEvents(); + } + + /** + * Create an instance of {@link GMEvent } + * + * @return the new instance of {@link GMEvent } + */ + public GMEvent createGMEvent() { + return new GMEvent(); + } + + /** + * Create an instance of {@link GMOptions } + * + * @return the new instance of {@link GMOptions } + */ + public GMOptions createGMOptions() { + return new GMOptions(); + } + + /** + * Create an instance of {@link GMMethod } + * + * @return the new instance of {@link GMMethod } + */ + public GMMethod createGMMethod() { + return new GMMethod(); + } + + /** + * Create an instance of {@link GMLMSR } + * + * @return the new instance of {@link GMLMSR } + */ + public GMLMSR createGMLMSR() { + return new GMLMSR(); + } + + /** + * Create an instance of {@link GMOrderBook } + * + * @return the new instance of {@link GMOrderBook } + */ + public GMOrderBook createGMOrderBook() { + return new GMOrderBook(); + } + + /** + * Create an instance of {@link GMUsers } + * + * @return the new instance of {@link GMUsers } + */ + public GMUsers createGMUsers() { + return new GMUsers(); + } + + /** + * Create an instance of {@link GMUser } + * + * @return the new instance of {@link GMUser } + */ + public GMUser createGMUser() { + return new GMUser(); + } + + /** + * Create an instance of {@link GMMarketMaker } + * + * @return the new instance of {@link GMMarketMaker } + */ + public GMMarketMaker createGMMarketMaker() { + return new GMMarketMaker(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >} + * + * @param value Java instance representing xml element's value. + * @return the new instance of {@link JAXBElement }{@code <}{@link Integer }{@code >} + */ + @XmlElementDecl(namespace = "", name = "initial-cash") + public JAXBElement createInitialCash(Integer value) { + return new JAXBElement<>(_InitialCash_QNAME, Integer.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >} + * + * @param value Java instance representing xml element's value. + * @return the new instance of {@link JAXBElement }{@code <}{@link Integer }{@code >} + */ + @XmlElementDecl(namespace = "", name = "id") + public JAXBElement createId(Integer value) { + return new JAXBElement<>(_Id_QNAME, Integer.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >} + * + * @param value Java instance representing xml element's value. + * @return the new instance of {@link JAXBElement }{@code <}{@link String }{@code >} + */ + @XmlElementDecl(namespace = "", name = "description") + public JAXBElement createDescription(String value) { + return new JAXBElement<>(_Description_QNAME, String.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >} + * + * @param value Java instance representing xml element's value. + * @return the new instance of {@link JAXBElement }{@code <}{@link Integer }{@code >} + */ + @XmlElementDecl(namespace = "", name = "b") + public JAXBElement createB(Integer value) { + return new JAXBElement<>(_B_QNAME, Integer.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >} + * + * @param value Java instance representing xml element's value. + * @return the new instance of {@link JAXBElement }{@code <}{@link String }{@code >} + */ + @XmlElementDecl(namespace = "", name = "GM-option") + public JAXBElement createGMOption(String value) { + return new JAXBElement<>(_GMOption_QNAME, String.class, null, value); + } +} diff --git a/service/src/main/java/market/guess/service/domain/BigDecimalOptions.java b/service/src/main/java/market/guess/service/domain/BigDecimalOptions.java deleted file mode 100644 index 992e44f..0000000 --- a/service/src/main/java/market/guess/service/domain/BigDecimalOptions.java +++ /dev/null @@ -1,22 +0,0 @@ -package market.guess.service.domain; - -import java.math.BigDecimal; -import java.math.RoundingMode; - -public record BigDecimalOptions(int scale, RoundingMode roundingMode) { - public static final BigDecimalOptions DEFAULT = new BigDecimalOptions(2, RoundingMode.HALF_EVEN); - public static final BigDecimal ZERO_MONEY = - BigDecimal.ZERO.setScale(DEFAULT.scale(), DEFAULT.roundingMode()); - - public static BigDecimal toMoney(BigDecimal value) { - return value.setScale(DEFAULT.scale(), DEFAULT.roundingMode()); - } - - public static BigDecimal toMoney(int value) { - return BigDecimal.valueOf(value).setScale(DEFAULT.scale(), DEFAULT.roundingMode()); - } - - public static BigDecimal toMoney(double value) { - return BigDecimal.valueOf(value).setScale(DEFAULT.scale(), DEFAULT.roundingMode()); - } -} diff --git a/service/src/main/java/market/guess/service/domain/Event.java b/service/src/main/java/market/guess/service/domain/Event.java index 943328a..6089aa3 100644 --- a/service/src/main/java/market/guess/service/domain/Event.java +++ b/service/src/main/java/market/guess/service/domain/Event.java @@ -5,10 +5,13 @@ import java.time.Instant; import java.util.ArrayList; import java.util.List; import market.guess.api.CommissionTiming; +import market.guess.api.MarketDTO; import market.guess.api.MarketStateDTO; import market.guess.api.TradeRowDTO; import market.guess.model.event.EventStatus; import market.guess.model.event.EventSummaryDTO; +import market.guess.service.helpers.BigDecimalOptions; +import market.guess.service.helpers.InstantOptions; import market.guess.service.ledger.Ledger; import market.guess.service.mechanism.TradingMechanism; @@ -54,6 +57,10 @@ public final class Event { this.state = status; } + public TradingMechanism getMechanism() { + return mechanism; + } + public String getEventKey() { return eventKey; } @@ -118,7 +125,7 @@ public final class Event { Instant time, String user, Market option, - int quantity, + long quantity, BigDecimal cost, BigDecimal commission) { var trade = @@ -131,7 +138,7 @@ public final class Event { public BigDecimal tradeVolumeOf(String option) { return trades.stream() - .filter(trade -> trade.optionKey().equalsIgnoreCase(option)) + .filter(trade -> trade.marketKey().equalsIgnoreCase(option)) .map(Trade::sharesCost) .reduce(BigDecimalOptions.ZERO_MONEY, BigDecimal::add); } @@ -148,9 +155,9 @@ public final class Event { for (var trade : trades.reversed()) { history.add( new TradeRowDTO( - trade.at().toString(), - trade.userName(), - trade.optionName(), + InstantOptions.humanize(trade.at()), + trade.buyerUserName(), + trade.marketName(), String.valueOf(trade.quantity()), trade.sharesCost().toPlainString())); } @@ -172,12 +179,18 @@ public final class Event { } public MarketStateDTO toMarketState() { + var prices = mechanism.prices(); + var marketDTOs = new ArrayList(); + for (var i = 0; i < markets.size(); i++) { + marketDTOs.add(markets.get(i).toMarket(prices[i])); + } + return new MarketStateDTO( eventKey, mechanism.getType(), - markets.stream().map(Market::toMarket).toList(), + marketDTOs, String.valueOf(ledger.getBalance()), - ""); + String.valueOf(getCommission())); } public Market getOption(String optionKey) { @@ -194,8 +207,7 @@ public final class Event { return false; } - public BigDecimal getPayout() { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'getPayout'"); + public void addSettlementCommission(BigDecimal amount) { + this.settlementCommission = settlementCommission.add(amount); } } diff --git a/service/src/main/java/market/guess/service/domain/Market.java b/service/src/main/java/market/guess/service/domain/Market.java index ce95bae..3ff7e2d 100644 --- a/service/src/main/java/market/guess/service/domain/Market.java +++ b/service/src/main/java/market/guess/service/domain/Market.java @@ -1,12 +1,13 @@ package market.guess.service.domain; +import java.math.BigDecimal; import market.guess.api.MarketDTO; public final class Market { private final String key; private final String name; - private int volume; + private long volume; public Market(String key, String name) { super(); @@ -22,11 +23,15 @@ public final class Market { return key; } - public int getVolume() { + public long getVolume() { return volume; } - public MarketDTO toMarket() { - return new MarketDTO(key, name, "", String.valueOf(volume)); + public void addVolume(long quantity) { + volume += quantity; + } + + public MarketDTO toMarket(BigDecimal price) { + return new MarketDTO(key, name, price.toPlainString(), String.valueOf(volume)); } } diff --git a/service/src/main/java/market/guess/service/domain/MarketAction.java b/service/src/main/java/market/guess/service/domain/MarketAction.java deleted file mode 100644 index d1a0ad5..0000000 --- a/service/src/main/java/market/guess/service/domain/MarketAction.java +++ /dev/null @@ -1,24 +0,0 @@ -package market.guess.service.domain; - -public record MarketAction( - String kind, String at, String userName, String eventKey, String optionKey, long quantity) { - - public static final String BUY = "BUY"; - public static final String SELL = "SELL"; - public static final String SETTLE = "SETTLE"; - - public static MarketAction buy( - String at, String userName, String eventKey, String optionKey, long quantity) { - return new MarketAction(BUY, at, userName, eventKey, optionKey, quantity); - } - - public static MarketAction sell( - String at, String userName, String eventKey, String optionKey, long quantity) { - return new MarketAction(SELL, at, userName, eventKey, optionKey, quantity); - } - - public static MarketAction settle( - String at, String userName, String eventKey, String winningOptionKey) { - return new MarketAction(SETTLE, at, userName, eventKey, winningOptionKey, 0); - } -} diff --git a/service/src/main/java/market/guess/service/domain/Order.java b/service/src/main/java/market/guess/service/domain/Order.java new file mode 100644 index 0000000..9d54020 --- /dev/null +++ b/service/src/main/java/market/guess/service/domain/Order.java @@ -0,0 +1,6 @@ +package market.guess.service.domain; + +import java.math.BigDecimal; +import java.time.Instant; + +public record Order(Instant at, Event event, Market market, BigDecimal price, long quantity) {} diff --git a/service/src/main/java/market/guess/service/domain/Settlement.java b/service/src/main/java/market/guess/service/domain/Settlement.java deleted file mode 100644 index cfc61f5..0000000 --- a/service/src/main/java/market/guess/service/domain/Settlement.java +++ /dev/null @@ -1,6 +0,0 @@ -package market.guess.service.domain; - -import java.math.BigDecimal; - -public record Settlement( - String winningOption, BigDecimal commission, BigDecimal paidOutToHolders) {} diff --git a/service/src/main/java/market/guess/service/domain/Trade.java b/service/src/main/java/market/guess/service/domain/Trade.java index 1211280..271582b 100644 --- a/service/src/main/java/market/guess/service/domain/Trade.java +++ b/service/src/main/java/market/guess/service/domain/Trade.java @@ -6,10 +6,10 @@ import java.time.Instant; public record Trade( int id, Instant at, - String userName, - String optionKey, - String optionName, - int quantity, + String buyerUserName, + String marketKey, + String marketName, + long quantity, BigDecimal sharesCost, BigDecimal commission) { diff --git a/service/src/main/java/market/guess/service/domain/User.java b/service/src/main/java/market/guess/service/domain/User.java index 3536c4e..a00b1a0 100644 --- a/service/src/main/java/market/guess/service/domain/User.java +++ b/service/src/main/java/market/guess/service/domain/User.java @@ -1,6 +1,7 @@ package market.guess.service.domain; import java.math.BigDecimal; +import market.guess.service.helpers.BigDecimalOptions; import market.guess.service.ledger.Ledger; public final class User { diff --git a/service/src/main/java/market/guess/service/fulfillment/FulfillmentContext.java b/service/src/main/java/market/guess/service/fulfillment/FulfillmentContext.java new file mode 100644 index 0000000..d5205e5 --- /dev/null +++ b/service/src/main/java/market/guess/service/fulfillment/FulfillmentContext.java @@ -0,0 +1,10 @@ +package market.guess.service.fulfillment; + +import java.util.List; +import market.guess.service.domain.Order; +import market.guess.service.domain.Trade; +import market.guess.service.domain.User; + +public interface FulfillmentContext { + List fulfill(User user, Order order, List rawTrades); +} diff --git a/service/src/main/java/market/guess/service/fulfillment/LocalFulfillmentContext.java b/service/src/main/java/market/guess/service/fulfillment/LocalFulfillmentContext.java new file mode 100644 index 0000000..64887dc --- /dev/null +++ b/service/src/main/java/market/guess/service/fulfillment/LocalFulfillmentContext.java @@ -0,0 +1,51 @@ +package market.guess.service.fulfillment; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import market.guess.api.CommissionTiming; +import market.guess.model.ledger.LedgerType; +import market.guess.service.domain.Order; +import market.guess.service.domain.Trade; +import market.guess.service.domain.User; +import market.guess.service.helpers.BigDecimalOptions; +import market.guess.service.ledger.LedgerContext; + +public final class LocalFulfillmentContext implements FulfillmentContext { + private final LedgerContext ledger; + + public LocalFulfillmentContext(LedgerContext ledger) { + this.ledger = ledger; + } + + @Override + public List fulfill(User user, Order order, List rawTrades) { + var event = order.event(); + var chargeNow = event.getCommissionTiming() == CommissionTiming.ON_PURCHASE; + var rate = BigDecimal.valueOf(event.getCommissionPercent()).divide(BigDecimal.valueOf(100)); + + var recorded = new ArrayList(); + for (var raw : rawTrades) { + var commission = + chargeNow + ? BigDecimalOptions.toMoney(raw.sharesCost().multiply(rate)) + : BigDecimalOptions.ZERO_MONEY; + var trade = + event.recordTrade( + order.at(), + user.getName(), + order.market(), + raw.quantity(), + raw.sharesCost(), + commission); + ledger.debit( + user.getName(), + LedgerType.PURCHASE, + trade.totalPaid(), + "Purchase: " + order.market().getName()); + order.market().addVolume(trade.quantity()); + recorded.add(trade); + } + return recorded; + } +} diff --git a/service/src/main/java/market/guess/service/helpers/BigDecimalOptions.java b/service/src/main/java/market/guess/service/helpers/BigDecimalOptions.java new file mode 100644 index 0000000..8fcf920 --- /dev/null +++ b/service/src/main/java/market/guess/service/helpers/BigDecimalOptions.java @@ -0,0 +1,22 @@ +package market.guess.service.helpers; + +import java.math.BigDecimal; +import java.math.RoundingMode; + +public record BigDecimalOptions(int scale, RoundingMode roundingMode) { + private static final BigDecimalOptions DEFAULT = new BigDecimalOptions(2, RoundingMode.HALF_EVEN); + public static final BigDecimal ZERO_MONEY = + BigDecimal.ZERO.setScale(DEFAULT.scale(), DEFAULT.roundingMode()); + + public static BigDecimal toMoney(BigDecimal value) { + return value.setScale(DEFAULT.scale(), DEFAULT.roundingMode()); + } + + public static BigDecimal toMoney(int value) { + return BigDecimal.valueOf(value).setScale(DEFAULT.scale(), DEFAULT.roundingMode()); + } + + public static BigDecimal toMoney(double value) { + return BigDecimal.valueOf(value).setScale(DEFAULT.scale(), DEFAULT.roundingMode()); + } +} diff --git a/service/src/main/java/market/guess/service/helpers/InstantOptions.java b/service/src/main/java/market/guess/service/helpers/InstantOptions.java new file mode 100644 index 0000000..3977dcb --- /dev/null +++ b/service/src/main/java/market/guess/service/helpers/InstantOptions.java @@ -0,0 +1,16 @@ +package market.guess.service.helpers; + +import java.time.Instant; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; + +public final class InstantOptions { + private static final DateTimeFormatter HUMAN = + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault()); + + private InstantOptions() {} + + public static String humanize(Instant instant) { + return HUMAN.format(instant); + } +} diff --git a/service/src/main/java/market/guess/service/infrastructure/MarketContext.java b/service/src/main/java/market/guess/service/infrastructure/MarketContext.java deleted file mode 100644 index 7113803..0000000 --- a/service/src/main/java/market/guess/service/infrastructure/MarketContext.java +++ /dev/null @@ -1,79 +0,0 @@ -package market.guess.service.infrastructure; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonSyntaxException; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.time.Instant; -import java.util.List; -import market.guess.exception.GuessMarketException; -import market.guess.service.domain.Event; -import market.guess.service.domain.User; -import market.guess.service.infrastructure.adapter.InstantTypeAdapter; -import market.guess.service.infrastructure.repository.EventRepository; -import market.guess.service.infrastructure.repository.UserRepository; - -public final class MarketContext { - record Wrapper(List events, List users) {} - - private final EventRepository events; - private final UserRepository users; - - private static final Gson GSON = - new GsonBuilder() - .registerTypeAdapter(Instant.class, new InstantTypeAdapter()) - .setPrettyPrinting() - .create(); - - public MarketContext(EventRepository events, UserRepository users) { - this.events = events; - this.users = users; - } - - public EventRepository getEvents() { - return events; - } - - public UserRepository getUsers() { - return users; - } - - public void save() throws GuessMarketException { - var path = Paths.get("test-file.json"); - - try { - if (path.getParent() != null) Files.createDirectories(path.getParent()); - Files.writeString( - path, GSON.toJson(new Wrapper(events.getAll(), users.getAll())), StandardCharsets.UTF_8); - } catch (IOException e) { - throw new GuessMarketException("Failed to sove the file."); - } - } - - public void load() throws GuessMarketException { - try { - var wrapper = - GSON.fromJson( - Files.readString(Path.of("test-file.json"), StandardCharsets.UTF_8), Wrapper.class); - events.clear(); - users.clear(); - - for (var event : wrapper.events()) { - events.add(event); - } - - for (var user : wrapper.users()) { - users.add(user); - } - - } catch (JsonSyntaxException e) { - throw new GuessMarketException("The JSON file is malformed."); - } catch (IOException e) { - throw new GuessMarketException("Unable the file."); - } - } -} diff --git a/service/src/main/java/market/guess/service/infrastructure/adapter/InstantTypeAdapter.java b/service/src/main/java/market/guess/service/infrastructure/adapter/InstantTypeAdapter.java deleted file mode 100644 index bc5ddb0..0000000 --- a/service/src/main/java/market/guess/service/infrastructure/adapter/InstantTypeAdapter.java +++ /dev/null @@ -1,19 +0,0 @@ -package market.guess.service.infrastructure.adapter; - -import com.google.gson.*; -import java.lang.reflect.Type; -import java.time.Instant; - -public final class InstantTypeAdapter - implements JsonSerializer, JsonDeserializer { - @Override - public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) { - return new JsonPrimitive(src.toString()); - } - - @Override - public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) - throws JsonParseException { - return Instant.parse(json.getAsString()); - } -} diff --git a/service/src/main/java/market/guess/service/infrastructure/mapper/Mapper.java b/service/src/main/java/market/guess/service/infrastructure/mapper/Mapper.java deleted file mode 100644 index e3c77bf..0000000 --- a/service/src/main/java/market/guess/service/infrastructure/mapper/Mapper.java +++ /dev/null @@ -1,5 +0,0 @@ -package market.guess.service.infrastructure.mapper; - -public interface Mapper { - TDomain toDomain(TModel source); -} diff --git a/service/src/main/java/market/guess/service/infrastructure/mapper/v1/EventMapperV1.java b/service/src/main/java/market/guess/service/infrastructure/mapper/v1/EventMapperV1.java deleted file mode 100644 index f049a0b..0000000 --- a/service/src/main/java/market/guess/service/infrastructure/mapper/v1/EventMapperV1.java +++ /dev/null @@ -1,55 +0,0 @@ -package market.guess.service.infrastructure.mapper.v1; - -import java.util.ArrayList; -import java.util.List; -import market.guess.api.CommissionTiming; -import market.guess.model.event.EventStatus; -import market.guess.service.domain.Event; -import market.guess.service.domain.Market; -import market.guess.service.infrastructure.mapper.Mapper; -import market.guess.service.mechanism.LmsrTradingMechanism; -import market.guess.service.model.v1.GMEvent; - -public final class EventMapperV1 implements Mapper { - - @Override - public Event toDomain(GMEvent source) { - var options = getOptions(source); - - return new Event( - getEventKey(source), - source.getId(), - joinName(source.getName()), - source.getDescription(), - source.getComision().getValue(), - getTiming(source.getComision().getType()), - new LmsrTradingMechanism(source.getGMMethod().getGMLMSR().getB(), options.size()), - EventStatus.ACTIVE, - options, - ""); - } - - private static String getEventKey(GMEvent event) { - return String.valueOf(event.getId()); - } - - private static String joinName(List tokens) { - return tokens == null ? "" : String.join(" ", tokens); - } - - private static CommissionTiming getTiming(String type) throws IllegalArgumentException { - return switch (type) { - case "on-close" -> CommissionTiming.ON_CLOSE; - case "on-purchase" -> CommissionTiming.ON_PURCHASE; - default -> throw new IllegalArgumentException("Unknown comision type: " + type); - }; - } - - private static List getOptions(GMEvent x) { - var ret = new ArrayList(x.getGMOptions().getGMOption().size()); - for (var i = 0; i < x.getGMOptions().getGMOption().size(); i++) { - ret.add(new Market(getEventKey(x) + ":" + i, x.getGMOptions().getGMOption().get(i))); - } - return ret; - } -} diff --git a/service/src/main/java/market/guess/service/infrastructure/mapper/v2/EventMapperV2.java b/service/src/main/java/market/guess/service/infrastructure/mapper/v2/EventMapperV2.java deleted file mode 100644 index 7037c02..0000000 --- a/service/src/main/java/market/guess/service/infrastructure/mapper/v2/EventMapperV2.java +++ /dev/null @@ -1,69 +0,0 @@ -package market.guess.service.infrastructure.mapper.v2; - -import java.util.ArrayList; -import java.util.List; -import market.guess.api.CommissionTiming; -import market.guess.model.event.EventStatus; -import market.guess.service.domain.Event; -import market.guess.service.domain.Market; -import market.guess.service.infrastructure.mapper.Mapper; -import market.guess.service.mechanism.LmsrTradingMechanism; -import market.guess.service.mechanism.OrderBookTradingMechanism; -import market.guess.service.mechanism.TradingMechanism; -import market.guess.service.model.v2.GMEvent; -import market.guess.service.model.v2.GMLMSR; -import market.guess.service.model.v2.GMOrderBook; - -public final class EventMapperV2 implements Mapper { - - @Override - public Event toDomain(GMEvent source) { - var options = getOptions(source); - - return new Event( - getEventKey(source), - source.getId(), - source.getName(), - source.getDescription(), - source.getCommission().getValue(), - getTiming(source.getCommission().getType()), - getMechanism(source, options.size()), - EventStatus.DRAFT, - options, - ""); - } - - private static String getEventKey(GMEvent event) { - return String.valueOf(event.getId()); - } - - private static CommissionTiming getTiming(String type) throws IllegalArgumentException { - return switch (type) { - case "on-close" -> CommissionTiming.ON_CLOSE; - case "on-purchase" -> CommissionTiming.ON_PURCHASE; - default -> throw new IllegalArgumentException("Unknown commission type: " + type); - }; - } - - private static TradingMechanism getMechanism(GMEvent source, int optionCount) { - if (source.getGMMethod().getGMLMSR() instanceof GMLMSR lmsr) { - return new LmsrTradingMechanism(lmsr.getB(), optionCount); - } - if (source.getGMMethod().getGMOrderBook() instanceof GMOrderBook orderBook) { - return new OrderBookTradingMechanism( - orderBook.getAllowMint().equalsIgnoreCase("true"), - orderBook.getInitial(), - orderBook.getD(), - optionCount); - } - throw new IllegalArgumentException(); - } - - private static List getOptions(GMEvent x) { - var ret = new ArrayList(x.getGMOptions().getGMOption().size()); - for (var i = 0; i < x.getGMOptions().getGMOption().size(); i++) { - ret.add(new Market(getEventKey(x) + ":" + i, x.getGMOptions().getGMOption().get(i))); - } - return ret; - } -} diff --git a/service/src/main/java/market/guess/service/infrastructure/provider/Loader.java b/service/src/main/java/market/guess/service/infrastructure/provider/Loader.java deleted file mode 100644 index fcca92f..0000000 --- a/service/src/main/java/market/guess/service/infrastructure/provider/Loader.java +++ /dev/null @@ -1,9 +0,0 @@ -package market.guess.service.infrastructure.provider; - -import java.nio.file.Path; -import market.guess.api.LoadResultDTO; -import market.guess.api.Result; - -public interface Loader { - Result load(Path path); -} diff --git a/service/src/main/java/market/guess/service/infrastructure/provider/v1/XMLLoaderV1.java b/service/src/main/java/market/guess/service/infrastructure/provider/v1/XMLLoaderV1.java deleted file mode 100644 index 412a5d2..0000000 --- a/service/src/main/java/market/guess/service/infrastructure/provider/v1/XMLLoaderV1.java +++ /dev/null @@ -1,59 +0,0 @@ -package market.guess.service.infrastructure.provider.v1; - -import jakarta.xml.bind.JAXBContext; -import jakarta.xml.bind.JAXBException; -import java.nio.file.Files; -import java.nio.file.Path; -import market.guess.api.LoadResultDTO; -import market.guess.api.Result; -import market.guess.service.domain.User; -import market.guess.service.infrastructure.mapper.v1.EventMapperV1; -import market.guess.service.infrastructure.provider.Loader; -import market.guess.service.infrastructure.repository.EventRepository; -import market.guess.service.infrastructure.repository.UserRepository; -import market.guess.service.model.v1.GuessMarket; - -public final class XMLLoaderV1 implements Loader { - private final JAXBContext context; - - private final EventRepository eventRepository; - private final UserRepository userRepository; - private final EventMapperV1 mapper; - - public XMLLoaderV1( - EventRepository eventRepository, UserRepository userRepository, EventMapperV1 mapper) { - super(); - this.eventRepository = eventRepository; - this.userRepository = userRepository; - this.mapper = mapper; - try { - context = JAXBContext.newInstance(GuessMarket.class); - } catch (JAXBException e) { - throw new IllegalStateException(); - } - } - - @Override - public Result load(Path path) { - - if (path.getFileName() == null - || !path.getFileName().toString().toLowerCase().endsWith(".xml")) { - return Result.error("NOT_XML", "The file must be an XML."); - } - - try (var stream = Files.newInputStream(path)) { - - var doc = (GuessMarket) context.createUnmarshaller().unmarshal(stream); - - for (var event : doc.getGMEvents().getGMEvent()) { - eventRepository.add(mapper.toDomain(event)); - } - - userRepository.add(new User("Tester", 9_999_999)); - - return Result.ok(new LoadResultDTO(path.toString(), eventRepository.getAll().size())); - } catch (Exception e) { - return Result.error("UNREADABLE", "The file could not be read."); - } - } -} diff --git a/service/src/main/java/market/guess/service/infrastructure/repository/EventRepository.java b/service/src/main/java/market/guess/service/infrastructure/repository/EventRepository.java deleted file mode 100644 index 186695b..0000000 --- a/service/src/main/java/market/guess/service/infrastructure/repository/EventRepository.java +++ /dev/null @@ -1,5 +0,0 @@ -package market.guess.service.infrastructure.repository; - -import market.guess.service.domain.Event; - -public interface EventRepository extends Repository {} diff --git a/service/src/main/java/market/guess/service/infrastructure/repository/InMemoryEventRepository.java b/service/src/main/java/market/guess/service/infrastructure/repository/InMemoryEventRepository.java deleted file mode 100644 index 8b8eeb2..0000000 --- a/service/src/main/java/market/guess/service/infrastructure/repository/InMemoryEventRepository.java +++ /dev/null @@ -1,32 +0,0 @@ -package market.guess.service.infrastructure.repository; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import market.guess.service.domain.Event; - -public final class InMemoryEventRepository implements EventRepository { - private final List events = new ArrayList<>(); - - @Override - public Event add(Event element) { - events.add(element); - return element; - } - - @Override - public Optional get(String id) { - return events.stream().filter(event -> event.getEventKey().equalsIgnoreCase(id)).findFirst(); - } - - @Override - public List getAll() { - return Collections.unmodifiableList(events); - } - - @Override - public void clear() { - events.clear(); - } -} diff --git a/service/src/main/java/market/guess/service/infrastructure/repository/InMemoryUserRepository.java b/service/src/main/java/market/guess/service/infrastructure/repository/InMemoryUserRepository.java deleted file mode 100644 index b611a77..0000000 --- a/service/src/main/java/market/guess/service/infrastructure/repository/InMemoryUserRepository.java +++ /dev/null @@ -1,32 +0,0 @@ -package market.guess.service.infrastructure.repository; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import market.guess.service.domain.User; - -public final class InMemoryUserRepository implements UserRepository { - private final List users = new ArrayList<>(); - - @Override - public User add(User element) { - users.add(element); - return element; - } - - @Override - public Optional get(String id) { - return users.stream().filter(u -> u.getName().equalsIgnoreCase(id)).findFirst(); - } - - @Override - public List getAll() { - return Collections.unmodifiableList(users); - } - - @Override - public void clear() { - users.clear(); - } -} diff --git a/service/src/main/java/market/guess/service/infrastructure/repository/Repository.java b/service/src/main/java/market/guess/service/infrastructure/repository/Repository.java deleted file mode 100644 index 41cb578..0000000 --- a/service/src/main/java/market/guess/service/infrastructure/repository/Repository.java +++ /dev/null @@ -1,14 +0,0 @@ -package market.guess.service.infrastructure.repository; - -import java.util.List; -import java.util.Optional; - -public interface Repository { - T add(T element); - - Optional get(String id); - - List getAll(); - - void clear(); -} diff --git a/service/src/main/java/market/guess/service/infrastructure/repository/UserRepository.java b/service/src/main/java/market/guess/service/infrastructure/repository/UserRepository.java deleted file mode 100644 index 4f0b0a6..0000000 --- a/service/src/main/java/market/guess/service/infrastructure/repository/UserRepository.java +++ /dev/null @@ -1,5 +0,0 @@ -package market.guess.service.infrastructure.repository; - -import market.guess.service.domain.User; - -public interface UserRepository extends Repository {} diff --git a/service/src/main/java/market/guess/service/ledger/Ledger.java b/service/src/main/java/market/guess/service/ledger/Ledger.java index 744fde7..72bf387 100644 --- a/service/src/main/java/market/guess/service/ledger/Ledger.java +++ b/service/src/main/java/market/guess/service/ledger/Ledger.java @@ -4,7 +4,7 @@ import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import market.guess.service.domain.BigDecimalOptions; +import market.guess.service.helpers.BigDecimalOptions; public final class Ledger { private final String owner; @@ -31,5 +31,6 @@ public final class Ledger { public void record(LedgerEntry entry) { entries.add(entry); + this.balance = entry.balanceAfter(); } } diff --git a/service/src/main/java/market/guess/service/ledger/LedgerContext.java b/service/src/main/java/market/guess/service/ledger/LedgerContext.java index 12ec614..bb1bf97 100644 --- a/service/src/main/java/market/guess/service/ledger/LedgerContext.java +++ b/service/src/main/java/market/guess/service/ledger/LedgerContext.java @@ -3,7 +3,7 @@ package market.guess.service.ledger; import java.math.BigDecimal; import java.time.Clock; import market.guess.model.ledger.LedgerType; -import market.guess.service.infrastructure.repository.UserRepository; +import market.guess.service.catalog.infrastructure.repository.UserRepository; public final class LedgerContext { private final Clock clock; @@ -11,10 +11,6 @@ public final class LedgerContext { private int runningId; - public LedgerContext(UserRepository users) { - this(users, Clock.systemUTC()); - } - public LedgerContext(UserRepository users, Clock clock) { super(); this.clock = clock; diff --git a/service/src/main/java/market/guess/service/matching/LocalMatchingEngine.java b/service/src/main/java/market/guess/service/matching/LocalMatchingEngine.java new file mode 100644 index 0000000..6a815c8 --- /dev/null +++ b/service/src/main/java/market/guess/service/matching/LocalMatchingEngine.java @@ -0,0 +1,20 @@ +package market.guess.service.matching; + +import java.util.List; +import market.guess.service.domain.Order; +import market.guess.service.domain.Trade; + +public final class LocalMatchingEngine implements MatchingEngine { + + @Override + public List match(Order order) { + var mechanism = order.event().getMechanism(); + return mechanism.buy(order.event(), order.market(), order.quantity()); + } + + @Override + public boolean cancelOrder() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'cancelOrder'"); + } +} diff --git a/service/src/main/java/market/guess/service/matching/MatchingEngine.java b/service/src/main/java/market/guess/service/matching/MatchingEngine.java new file mode 100644 index 0000000..a8fc0c4 --- /dev/null +++ b/service/src/main/java/market/guess/service/matching/MatchingEngine.java @@ -0,0 +1,11 @@ +package market.guess.service.matching; + +import java.util.List; +import market.guess.service.domain.Order; +import market.guess.service.domain.Trade; + +public interface MatchingEngine { + List match(Order order); + + boolean cancelOrder(); +} diff --git a/service/src/main/java/market/guess/service/matching/OrderMatchingContext.java b/service/src/main/java/market/guess/service/matching/OrderMatchingContext.java deleted file mode 100644 index 8882432..0000000 --- a/service/src/main/java/market/guess/service/matching/OrderMatchingContext.java +++ /dev/null @@ -1,13 +0,0 @@ -package market.guess.service.matching; - -import java.util.List; -import market.guess.service.domain.Event; -import market.guess.service.domain.Market; -import market.guess.service.domain.Trade; -import market.guess.service.domain.User; - -public interface OrderMatchingContext { - List submitOrder(User user, Event event, Market market, int quantity); - - boolean cancelOrder(); -} diff --git a/service/src/main/java/market/guess/service/mechanism/LmsrTradingMechanism.java b/service/src/main/java/market/guess/service/mechanism/LmsrTradingMechanism.java index cdba3f6..87c5661 100644 --- a/service/src/main/java/market/guess/service/mechanism/LmsrTradingMechanism.java +++ b/service/src/main/java/market/guess/service/mechanism/LmsrTradingMechanism.java @@ -1,17 +1,30 @@ package market.guess.service.mechanism; import java.math.BigDecimal; +import java.time.Clock; import java.util.Arrays; +import java.util.List; import market.guess.api.MechanismType; -import market.guess.service.domain.BigDecimalOptions; +import market.guess.service.domain.Event; +import market.guess.service.domain.Market; +import market.guess.service.domain.Trade; +import market.guess.service.helpers.BigDecimalOptions; public final class LmsrTradingMechanism implements TradingMechanism { private final int liquidity; private final int[] q; + private final Clock clock; + public LmsrTradingMechanism(int liquidity, int optionCount) { + this(liquidity, optionCount, Clock.systemUTC()); + } + + public LmsrTradingMechanism(int liquidity, int optionCount, Clock clock) { + super(); this.liquidity = liquidity; this.q = new int[optionCount]; + this.clock = clock; } @Override @@ -20,12 +33,8 @@ public final class LmsrTradingMechanism implements TradingMechanism { } @Override - public BigDecimal openingCost() { - return BigDecimalOptions.toMoney(cost(new int[q.length])); - } - - @Override - public TradeExecution buy(int optionIndex, int quantity) { + public List buy(Event event, Market market, long quantity) { + var optionIndex = event.getMarkets().indexOf(market); var before = cost(q); var after = q.clone(); @@ -34,7 +43,16 @@ public final class LmsrTradingMechanism implements TradingMechanism { q[optionIndex] += quantity; - return new TradeExecution(quantity, BigDecimalOptions.toMoney(delta)); + return List.of( + new Trade( + 0, + clock.instant(), + null, + market.getKey(), + market.getName(), + quantity, + BigDecimalOptions.toMoney(delta), + null)); } @Override diff --git a/service/src/main/java/market/guess/service/mechanism/OrderBookTradingMechanism.java b/service/src/main/java/market/guess/service/mechanism/OrderBookTradingMechanism.java index 43f4843..4e0dd0a 100644 --- a/service/src/main/java/market/guess/service/mechanism/OrderBookTradingMechanism.java +++ b/service/src/main/java/market/guess/service/mechanism/OrderBookTradingMechanism.java @@ -5,8 +5,10 @@ import java.math.RoundingMode; import java.util.ArrayList; import java.util.List; import market.guess.api.MechanismType; -import market.guess.service.domain.BigDecimalOptions; +import market.guess.service.domain.Event; +import market.guess.service.domain.Market; import market.guess.service.domain.Trade; +import market.guess.service.helpers.BigDecimalOptions; public final class OrderBookTradingMechanism implements TradingMechanism { public enum Side { @@ -54,13 +56,9 @@ public final class OrderBookTradingMechanism implements TradingMechanism { } @Override - public BigDecimal openingCost() { - return BigDecimalOptions.toMoney(initial); - } - - @Override - public Trade buy(int optionIndex, int quantity) { - return match(optionIndex, Side.BUY, quantity, null, false); + public List buy(Event event, Market market, long quantity) { + var optionIndex = event.getMarkets().indexOf(market); + return List.of(match(optionIndex, Side.BUY, (int) quantity, null, false)); } /** Priced limit order — not on the shared interface, no engine call site yet. */ diff --git a/service/src/main/java/market/guess/service/mechanism/TradingMechanism.java b/service/src/main/java/market/guess/service/mechanism/TradingMechanism.java index 204a170..16a5c6f 100644 --- a/service/src/main/java/market/guess/service/mechanism/TradingMechanism.java +++ b/service/src/main/java/market/guess/service/mechanism/TradingMechanism.java @@ -1,16 +1,17 @@ package market.guess.service.mechanism; import java.math.BigDecimal; +import java.util.List; import market.guess.api.MechanismType; +import market.guess.service.domain.Event; +import market.guess.service.domain.Market; import market.guess.service.domain.Trade; public sealed interface TradingMechanism permits LmsrTradingMechanism, OrderBookTradingMechanism { MechanismType getType(); - BigDecimal openingCost(); - - Trade buy(int optionIndex, int quantity); + List buy(Event event, Market market, long quantity); BigDecimal[] prices(); } diff --git a/service/src/main/java/market/guess/service/model/v1/Comision.java b/service/src/main/java/market/guess/service/model/v1/Comision.java deleted file mode 100644 index c8a374c..0000000 --- a/service/src/main/java/market/guess/service/model/v1/Comision.java +++ /dev/null @@ -1,94 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v1; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; -import jakarta.xml.bind.annotation.XmlValue; - - -/** - *

Java class for anonymous complex type

. - * - *

The following schema fragment specifies the expected content contained within this class.

- * - *
{@code
- * 
- *   
- *     
- *       
- *         
- *           
- *             
- *             
- *           
- *         
- *       
- *     
- *   
- * 
- * }
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "value" -}) -@XmlRootElement(name = "comision") -public class Comision { - - @XmlValue - protected int value; - @XmlAttribute(name = "type", required = true) - protected String type; - - /** - * Gets the value of the value property. - * - */ - public int getValue() { - return value; - } - - /** - * Sets the value of the value property. - * - */ - public void setValue(int value) { - this.value = value; - } - - /** - * Gets the value of the type property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getType() { - return type; - } - - /** - * Sets the value of the type property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setType(String value) { - this.type = value; - } - -} diff --git a/service/src/main/java/market/guess/service/model/v1/GMEvent.java b/service/src/main/java/market/guess/service/model/v1/GMEvent.java deleted file mode 100644 index efe5d30..0000000 --- a/service/src/main/java/market/guess/service/model/v1/GMEvent.java +++ /dev/null @@ -1,215 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v1; - -import java.util.ArrayList; -import java.util.List; -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type

. - * - *

The following schema fragment specifies the expected content contained within this class.

- * - *
{@code
- * 
- *   
- *     
- *       
- *         
- *         
- *         
- *         
- *         
- *       
- *       
- *         
- *           
- *         
- *       
- *     
- *   
- * 
- * }
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "id", - "description", - "comision", - "gmOptions", - "gmMethod" -}) -@XmlRootElement(name = "GM-event") -public class GMEvent { - - protected int id; - @XmlElement(required = true) - protected String description; - @XmlElement(required = true) - protected Comision comision; - @XmlElement(name = "GM-options", required = true) - protected GMOptions gmOptions; - @XmlElement(name = "GM-method", required = true) - protected GMMethod gmMethod; - @XmlAttribute(name = "name", required = true) - protected List name; - - /** - * Gets the value of the id property. - * - */ - public int getId() { - return id; - } - - /** - * Sets the value of the id property. - * - */ - public void setId(int value) { - this.id = value; - } - - /** - * Gets the value of the description property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDescription() { - return description; - } - - /** - * Sets the value of the description property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDescription(String value) { - this.description = value; - } - - /** - * Gets the value of the comision property. - * - * @return - * possible object is - * {@link Comision } - * - */ - public Comision getComision() { - return comision; - } - - /** - * Sets the value of the comision property. - * - * @param value - * allowed object is - * {@link Comision } - * - */ - public void setComision(Comision value) { - this.comision = value; - } - - /** - * Gets the value of the gmOptions property. - * - * @return - * possible object is - * {@link GMOptions } - * - */ - public GMOptions getGMOptions() { - return gmOptions; - } - - /** - * Sets the value of the gmOptions property. - * - * @param value - * allowed object is - * {@link GMOptions } - * - */ - public void setGMOptions(GMOptions value) { - this.gmOptions = value; - } - - /** - * Gets the value of the gmMethod property. - * - * @return - * possible object is - * {@link GMMethod } - * - */ - public GMMethod getGMMethod() { - return gmMethod; - } - - /** - * Sets the value of the gmMethod property. - * - * @param value - * allowed object is - * {@link GMMethod } - * - */ - public void setGMMethod(GMMethod value) { - this.gmMethod = value; - } - - /** - * Gets the value of the name property. - * - *

This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the name property.

- * - *

- * For example, to add a new item, do as follows: - *

- *
-     * getName().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link String } - *

- * - * - * @return - * The value of the name property. - */ - public List getName() { - if (name == null) { - name = new ArrayList<>(); - } - return this.name; - } - -} diff --git a/service/src/main/java/market/guess/service/model/v1/GMEvents.java b/service/src/main/java/market/guess/service/model/v1/GMEvents.java deleted file mode 100644 index ca4efea..0000000 --- a/service/src/main/java/market/guess/service/model/v1/GMEvents.java +++ /dev/null @@ -1,80 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v1; - -import java.util.ArrayList; -import java.util.List; -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type

. - * - *

The following schema fragment specifies the expected content contained within this class.

- * - *
{@code
- * 
- *   
- *     
- *       
- *         
- *       
- *     
- *   
- * 
- * }
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "gmEvent" -}) -@XmlRootElement(name = "GM-events") -public class GMEvents { - - @XmlElement(name = "GM-event", required = true) - protected List gmEvent; - - /** - * Gets the value of the gmEvent property. - * - *

This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the gmEvent property.

- * - *

- * For example, to add a new item, do as follows: - *

- *
-     * getGMEvent().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link GMEvent } - *

- * - * - * @return - * The value of the gmEvent property. - */ - public List getGMEvent() { - if (gmEvent == null) { - gmEvent = new ArrayList<>(); - } - return this.gmEvent; - } - -} diff --git a/service/src/main/java/market/guess/service/model/v1/GMLMSR.java b/service/src/main/java/market/guess/service/model/v1/GMLMSR.java deleted file mode 100644 index a8e90a5..0000000 --- a/service/src/main/java/market/guess/service/model/v1/GMLMSR.java +++ /dev/null @@ -1,60 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v1; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type

. - * - *

The following schema fragment specifies the expected content contained within this class.

- * - *
{@code
- * 
- *   
- *     
- *       
- *         
- *       
- *     
- *   
- * 
- * }
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "b" -}) -@XmlRootElement(name = "GM-LMSR") -public class GMLMSR { - - protected int b; - - /** - * Gets the value of the b property. - * - */ - public int getB() { - return b; - } - - /** - * Sets the value of the b property. - * - */ - public void setB(int value) { - this.b = value; - } - -} diff --git a/service/src/main/java/market/guess/service/model/v1/GMMethod.java b/service/src/main/java/market/guess/service/model/v1/GMMethod.java deleted file mode 100644 index 867d932..0000000 --- a/service/src/main/java/market/guess/service/model/v1/GMMethod.java +++ /dev/null @@ -1,70 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v1; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type

. - * - *

The following schema fragment specifies the expected content contained within this class.

- * - *
{@code
- * 
- *   
- *     
- *       
- *         
- *       
- *     
- *   
- * 
- * }
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "gmlmsr" -}) -@XmlRootElement(name = "GM-method") -public class GMMethod { - - @XmlElement(name = "GM-LMSR", required = true) - protected GMLMSR gmlmsr; - - /** - * Gets the value of the gmlmsr property. - * - * @return - * possible object is - * {@link GMLMSR } - * - */ - public GMLMSR getGMLMSR() { - return gmlmsr; - } - - /** - * Sets the value of the gmlmsr property. - * - * @param value - * allowed object is - * {@link GMLMSR } - * - */ - public void setGMLMSR(GMLMSR value) { - this.gmlmsr = value; - } - -} diff --git a/service/src/main/java/market/guess/service/model/v1/GMOptions.java b/service/src/main/java/market/guess/service/model/v1/GMOptions.java deleted file mode 100644 index d344f74..0000000 --- a/service/src/main/java/market/guess/service/model/v1/GMOptions.java +++ /dev/null @@ -1,80 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v1; - -import java.util.ArrayList; -import java.util.List; -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type

. - * - *

The following schema fragment specifies the expected content contained within this class.

- * - *
{@code
- * 
- *   
- *     
- *       
- *         
- *       
- *     
- *   
- * 
- * }
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "gmOption" -}) -@XmlRootElement(name = "GM-options") -public class GMOptions { - - @XmlElement(name = "GM-option", required = true) - protected List gmOption; - - /** - * Gets the value of the gmOption property. - * - *

This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the gmOption property.

- * - *

- * For example, to add a new item, do as follows: - *

- *
-     * getGMOption().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link String } - *

- * - * - * @return - * The value of the gmOption property. - */ - public List getGMOption() { - if (gmOption == null) { - gmOption = new ArrayList<>(); - } - return this.gmOption; - } - -} diff --git a/service/src/main/java/market/guess/service/model/v1/GuessMarket.java b/service/src/main/java/market/guess/service/model/v1/GuessMarket.java deleted file mode 100644 index 43f134d..0000000 --- a/service/src/main/java/market/guess/service/model/v1/GuessMarket.java +++ /dev/null @@ -1,70 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v1; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type

. - * - *

The following schema fragment specifies the expected content contained within this class.

- * - *
{@code
- * 
- *   
- *     
- *       
- *         
- *       
- *     
- *   
- * 
- * }
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "gmEvents" -}) -@XmlRootElement(name = "Guess-Market") -public class GuessMarket { - - @XmlElement(name = "GM-events", required = true) - protected GMEvents gmEvents; - - /** - * Gets the value of the gmEvents property. - * - * @return - * possible object is - * {@link GMEvents } - * - */ - public GMEvents getGMEvents() { - return gmEvents; - } - - /** - * Sets the value of the gmEvents property. - * - * @param value - * allowed object is - * {@link GMEvents } - * - */ - public void setGMEvents(GMEvents value) { - this.gmEvents = value; - } - -} diff --git a/service/src/main/java/market/guess/service/model/v1/ObjectFactory.java b/service/src/main/java/market/guess/service/model/v1/ObjectFactory.java deleted file mode 100644 index cd43428..0000000 --- a/service/src/main/java/market/guess/service/model/v1/ObjectFactory.java +++ /dev/null @@ -1,167 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v1; - -import javax.xml.namespace.QName; -import jakarta.xml.bind.JAXBElement; -import jakarta.xml.bind.annotation.XmlElementDecl; -import jakarta.xml.bind.annotation.XmlRegistry; - - -/** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the market.guess.service.model.v1 package. - *

An ObjectFactory allows you to programmatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are - * provided in this class. - * - */ -@XmlRegistry -public class ObjectFactory { - - private static final QName _Id_QNAME = new QName("", "id"); - private static final QName _Description_QNAME = new QName("", "description"); - private static final QName _B_QNAME = new QName("", "b"); - private static final QName _GMOption_QNAME = new QName("", "GM-option"); - - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: market.guess.service.model.v1 - * - */ - public ObjectFactory() { - } - - /** - * Create an instance of {@link Comision } - * - * @return - * the new instance of {@link Comision } - */ - public Comision createComision() { - return new Comision(); - } - - /** - * Create an instance of {@link GuessMarket } - * - * @return - * the new instance of {@link GuessMarket } - */ - public GuessMarket createGuessMarket() { - return new GuessMarket(); - } - - /** - * Create an instance of {@link GMEvents } - * - * @return - * the new instance of {@link GMEvents } - */ - public GMEvents createGMEvents() { - return new GMEvents(); - } - - /** - * Create an instance of {@link GMEvent } - * - * @return - * the new instance of {@link GMEvent } - */ - public GMEvent createGMEvent() { - return new GMEvent(); - } - - /** - * Create an instance of {@link GMOptions } - * - * @return - * the new instance of {@link GMOptions } - */ - public GMOptions createGMOptions() { - return new GMOptions(); - } - - /** - * Create an instance of {@link GMMethod } - * - * @return - * the new instance of {@link GMMethod } - */ - public GMMethod createGMMethod() { - return new GMMethod(); - } - - /** - * Create an instance of {@link GMLMSR } - * - * @return - * the new instance of {@link GMLMSR } - */ - public GMLMSR createGMLMSR() { - return new GMLMSR(); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >} - * - * @param value - * Java instance representing xml element's value. - * @return - * the new instance of {@link JAXBElement }{@code <}{@link Integer }{@code >} - */ - @XmlElementDecl(namespace = "", name = "id") - public JAXBElement createId(Integer value) { - return new JAXBElement<>(_Id_QNAME, Integer.class, null, value); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >} - * - * @param value - * Java instance representing xml element's value. - * @return - * the new instance of {@link JAXBElement }{@code <}{@link String }{@code >} - */ - @XmlElementDecl(namespace = "", name = "description") - public JAXBElement createDescription(String value) { - return new JAXBElement<>(_Description_QNAME, String.class, null, value); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >} - * - * @param value - * Java instance representing xml element's value. - * @return - * the new instance of {@link JAXBElement }{@code <}{@link Integer }{@code >} - */ - @XmlElementDecl(namespace = "", name = "b") - public JAXBElement createB(Integer value) { - return new JAXBElement<>(_B_QNAME, Integer.class, null, value); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >} - * - * @param value - * Java instance representing xml element's value. - * @return - * the new instance of {@link JAXBElement }{@code <}{@link String }{@code >} - */ - @XmlElementDecl(namespace = "", name = "GM-option") - public JAXBElement createGMOption(String value) { - return new JAXBElement<>(_GMOption_QNAME, String.class, null, value); - } - -} diff --git a/service/src/main/java/market/guess/service/model/v2/Commission.java b/service/src/main/java/market/guess/service/model/v2/Commission.java deleted file mode 100644 index 5448ff0..0000000 --- a/service/src/main/java/market/guess/service/model/v2/Commission.java +++ /dev/null @@ -1,94 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v2; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; -import jakarta.xml.bind.annotation.XmlValue; - - -/** - *

Java class for anonymous complex type

. - * - *

The following schema fragment specifies the expected content contained within this class.

- * - *
{@code
- * 
- *   
- *     
- *       
- *         
- *           
- *             
- *             
- *           
- *         
- *       
- *     
- *   
- * 
- * }
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "value" -}) -@XmlRootElement(name = "commission") -public class Commission { - - @XmlValue - protected int value; - @XmlAttribute(name = "type", required = true) - protected String type; - - /** - * Gets the value of the value property. - * - */ - public int getValue() { - return value; - } - - /** - * Sets the value of the value property. - * - */ - public void setValue(int value) { - this.value = value; - } - - /** - * Gets the value of the type property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getType() { - return type; - } - - /** - * Sets the value of the type property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setType(String value) { - this.type = value; - } - -} diff --git a/service/src/main/java/market/guess/service/model/v2/Event.java b/service/src/main/java/market/guess/service/model/v2/Event.java deleted file mode 100644 index 53ca4ca..0000000 --- a/service/src/main/java/market/guess/service/model/v2/Event.java +++ /dev/null @@ -1,58 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v2; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type

. - * - *

The following schema fragment specifies the expected content contained within this class.

- * - *
{@code
- * 
- *   
- *     
- *       
- *     
- *   
- * 
- * }
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "") -@XmlRootElement(name = "event") -public class Event { - - @XmlAttribute(name = "id", required = true) - protected int id; - - /** - * Gets the value of the id property. - * - */ - public int getId() { - return id; - } - - /** - * Sets the value of the id property. - * - */ - public void setId(int value) { - this.id = value; - } - -} diff --git a/service/src/main/java/market/guess/service/model/v2/GMEvent.java b/service/src/main/java/market/guess/service/model/v2/GMEvent.java deleted file mode 100644 index c011c32..0000000 --- a/service/src/main/java/market/guess/service/model/v2/GMEvent.java +++ /dev/null @@ -1,201 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v2; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type

. - * - *

The following schema fragment specifies the expected content contained within this class.

- * - *
{@code
- * 
- *   
- *     
- *       
- *         
- *         
- *         
- *         
- *         
- *       
- *       
- *     
- *   
- * 
- * }
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "id", - "description", - "commission", - "gmOptions", - "gmMethod" -}) -@XmlRootElement(name = "GM-event") -public class GMEvent { - - protected int id; - @XmlElement(required = true) - protected String description; - @XmlElement(required = true) - protected Commission commission; - @XmlElement(name = "GM-options", required = true) - protected GMOptions gmOptions; - @XmlElement(name = "GM-method", required = true) - protected GMMethod gmMethod; - @XmlAttribute(name = "name", required = true) - protected String name; - - /** - * Gets the value of the id property. - * - */ - public int getId() { - return id; - } - - /** - * Sets the value of the id property. - * - */ - public void setId(int value) { - this.id = value; - } - - /** - * Gets the value of the description property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDescription() { - return description; - } - - /** - * Sets the value of the description property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDescription(String value) { - this.description = value; - } - - /** - * Gets the value of the commission property. - * - * @return - * possible object is - * {@link Commission } - * - */ - public Commission getCommission() { - return commission; - } - - /** - * Sets the value of the commission property. - * - * @param value - * allowed object is - * {@link Commission } - * - */ - public void setCommission(Commission value) { - this.commission = value; - } - - /** - * Gets the value of the gmOptions property. - * - * @return - * possible object is - * {@link GMOptions } - * - */ - public GMOptions getGMOptions() { - return gmOptions; - } - - /** - * Sets the value of the gmOptions property. - * - * @param value - * allowed object is - * {@link GMOptions } - * - */ - public void setGMOptions(GMOptions value) { - this.gmOptions = value; - } - - /** - * Gets the value of the gmMethod property. - * - * @return - * possible object is - * {@link GMMethod } - * - */ - public GMMethod getGMMethod() { - return gmMethod; - } - - /** - * Sets the value of the gmMethod property. - * - * @param value - * allowed object is - * {@link GMMethod } - * - */ - public void setGMMethod(GMMethod value) { - this.gmMethod = value; - } - - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } - -} diff --git a/service/src/main/java/market/guess/service/model/v2/GMEvents.java b/service/src/main/java/market/guess/service/model/v2/GMEvents.java deleted file mode 100644 index 61a5473..0000000 --- a/service/src/main/java/market/guess/service/model/v2/GMEvents.java +++ /dev/null @@ -1,80 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v2; - -import java.util.ArrayList; -import java.util.List; -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type

. - * - *

The following schema fragment specifies the expected content contained within this class.

- * - *
{@code
- * 
- *   
- *     
- *       
- *         
- *       
- *     
- *   
- * 
- * }
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "gmEvent" -}) -@XmlRootElement(name = "GM-events") -public class GMEvents { - - @XmlElement(name = "GM-event", required = true) - protected List gmEvent; - - /** - * Gets the value of the gmEvent property. - * - *

This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the gmEvent property.

- * - *

- * For example, to add a new item, do as follows: - *

- *
-     * getGMEvent().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link GMEvent } - *

- * - * - * @return - * The value of the gmEvent property. - */ - public List getGMEvent() { - if (gmEvent == null) { - gmEvent = new ArrayList<>(); - } - return this.gmEvent; - } - -} diff --git a/service/src/main/java/market/guess/service/model/v2/GMLMSR.java b/service/src/main/java/market/guess/service/model/v2/GMLMSR.java deleted file mode 100644 index b299a19..0000000 --- a/service/src/main/java/market/guess/service/model/v2/GMLMSR.java +++ /dev/null @@ -1,60 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v2; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type

. - * - *

The following schema fragment specifies the expected content contained within this class.

- * - *
{@code
- * 
- *   
- *     
- *       
- *         
- *       
- *     
- *   
- * 
- * }
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "b" -}) -@XmlRootElement(name = "GM-LMSR") -public class GMLMSR { - - protected int b; - - /** - * Gets the value of the b property. - * - */ - public int getB() { - return b; - } - - /** - * Sets the value of the b property. - * - */ - public void setB(int value) { - this.b = value; - } - -} diff --git a/service/src/main/java/market/guess/service/model/v2/GMMarketMaker.java b/service/src/main/java/market/guess/service/model/v2/GMMarketMaker.java deleted file mode 100644 index 2eb0e6e..0000000 --- a/service/src/main/java/market/guess/service/model/v2/GMMarketMaker.java +++ /dev/null @@ -1,80 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v2; - -import java.util.ArrayList; -import java.util.List; -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type

. - * - *

The following schema fragment specifies the expected content contained within this class.

- * - *
{@code
- * 
- *   
- *     
- *       
- *         
- *       
- *     
- *   
- * 
- * }
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "event" -}) -@XmlRootElement(name = "GM-market-maker") -public class GMMarketMaker { - - @XmlElement(required = true) - protected List event; - - /** - * Gets the value of the event property. - * - *

This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the event property.

- * - *

- * For example, to add a new item, do as follows: - *

- *
-     * getEvent().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Event } - *

- * - * - * @return - * The value of the event property. - */ - public List getEvent() { - if (event == null) { - event = new ArrayList<>(); - } - return this.event; - } - -} diff --git a/service/src/main/java/market/guess/service/model/v2/GMMethod.java b/service/src/main/java/market/guess/service/model/v2/GMMethod.java deleted file mode 100644 index 06338c0..0000000 --- a/service/src/main/java/market/guess/service/model/v2/GMMethod.java +++ /dev/null @@ -1,98 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v2; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type

. - * - *

The following schema fragment specifies the expected content contained within this class.

- * - *
{@code
- * 
- *   
- *     
- *       
- *         
- *         
- *       
- *     
- *   
- * 
- * }
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "gmlmsr", - "gmOrderBook" -}) -@XmlRootElement(name = "GM-method") -public class GMMethod { - - @XmlElement(name = "GM-LMSR") - protected GMLMSR gmlmsr; - @XmlElement(name = "GM-order-book") - protected GMOrderBook gmOrderBook; - - /** - * Gets the value of the gmlmsr property. - * - * @return - * possible object is - * {@link GMLMSR } - * - */ - public GMLMSR getGMLMSR() { - return gmlmsr; - } - - /** - * Sets the value of the gmlmsr property. - * - * @param value - * allowed object is - * {@link GMLMSR } - * - */ - public void setGMLMSR(GMLMSR value) { - this.gmlmsr = value; - } - - /** - * Gets the value of the gmOrderBook property. - * - * @return - * possible object is - * {@link GMOrderBook } - * - */ - public GMOrderBook getGMOrderBook() { - return gmOrderBook; - } - - /** - * Sets the value of the gmOrderBook property. - * - * @param value - * allowed object is - * {@link GMOrderBook } - * - */ - public void setGMOrderBook(GMOrderBook value) { - this.gmOrderBook = value; - } - -} diff --git a/service/src/main/java/market/guess/service/model/v2/GMOptions.java b/service/src/main/java/market/guess/service/model/v2/GMOptions.java deleted file mode 100644 index a819656..0000000 --- a/service/src/main/java/market/guess/service/model/v2/GMOptions.java +++ /dev/null @@ -1,80 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v2; - -import java.util.ArrayList; -import java.util.List; -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type

. - * - *

The following schema fragment specifies the expected content contained within this class.

- * - *
{@code
- * 
- *   
- *     
- *       
- *         
- *       
- *     
- *   
- * 
- * }
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "gmOption" -}) -@XmlRootElement(name = "GM-options") -public class GMOptions { - - @XmlElement(name = "GM-option", required = true) - protected List gmOption; - - /** - * Gets the value of the gmOption property. - * - *

This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the gmOption property.

- * - *

- * For example, to add a new item, do as follows: - *

- *
-     * getGMOption().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link String } - *

- * - * - * @return - * The value of the gmOption property. - */ - public List getGMOption() { - if (gmOption == null) { - gmOption = new ArrayList<>(); - } - return this.gmOption; - } - -} diff --git a/service/src/main/java/market/guess/service/model/v2/GMOrderBook.java b/service/src/main/java/market/guess/service/model/v2/GMOrderBook.java deleted file mode 100644 index f38c707..0000000 --- a/service/src/main/java/market/guess/service/model/v2/GMOrderBook.java +++ /dev/null @@ -1,111 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v2; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type

. - * - *

The following schema fragment specifies the expected content contained within this class.

- * - *
{@code
- * 
- *   
- *     
- *       
- *       
- *       
- *         
- *           
- *             
- *             
- *           
- *         
- *       
- *     
- *   
- * 
- * }
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "") -@XmlRootElement(name = "GM-order-book") -public class GMOrderBook { - - @XmlAttribute(name = "initial", required = true) - protected int initial; - @XmlAttribute(name = "d", required = true) - protected int d; - @XmlAttribute(name = "allow-mint", required = true) - protected String allowMint; - - /** - * Gets the value of the initial property. - * - */ - public int getInitial() { - return initial; - } - - /** - * Sets the value of the initial property. - * - */ - public void setInitial(int value) { - this.initial = value; - } - - /** - * Gets the value of the d property. - * - */ - public int getD() { - return d; - } - - /** - * Sets the value of the d property. - * - */ - public void setD(int value) { - this.d = value; - } - - /** - * Gets the value of the allowMint property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getAllowMint() { - return allowMint; - } - - /** - * Sets the value of the allowMint property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setAllowMint(String value) { - this.allowMint = value; - } - -} diff --git a/service/src/main/java/market/guess/service/model/v2/GMUser.java b/service/src/main/java/market/guess/service/model/v2/GMUser.java deleted file mode 100644 index 85b41f4..0000000 --- a/service/src/main/java/market/guess/service/model/v2/GMUser.java +++ /dev/null @@ -1,118 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v2; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type

. - * - *

The following schema fragment specifies the expected content contained within this class.

- * - *
{@code
- * 
- *   
- *     
- *       
- *         
- *         
- *       
- *       
- *     
- *   
- * 
- * }
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "initialCash", - "gmMarketMaker" -}) -@XmlRootElement(name = "GM-user") -public class GMUser { - - @XmlElement(name = "initial-cash") - protected int initialCash; - @XmlElement(name = "GM-market-maker") - protected GMMarketMaker gmMarketMaker; - @XmlAttribute(name = "name", required = true) - protected String name; - - /** - * Gets the value of the initialCash property. - * - */ - public int getInitialCash() { - return initialCash; - } - - /** - * Sets the value of the initialCash property. - * - */ - public void setInitialCash(int value) { - this.initialCash = value; - } - - /** - * Gets the value of the gmMarketMaker property. - * - * @return - * possible object is - * {@link GMMarketMaker } - * - */ - public GMMarketMaker getGMMarketMaker() { - return gmMarketMaker; - } - - /** - * Sets the value of the gmMarketMaker property. - * - * @param value - * allowed object is - * {@link GMMarketMaker } - * - */ - public void setGMMarketMaker(GMMarketMaker value) { - this.gmMarketMaker = value; - } - - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } - -} diff --git a/service/src/main/java/market/guess/service/model/v2/GMUsers.java b/service/src/main/java/market/guess/service/model/v2/GMUsers.java deleted file mode 100644 index cfebbc4..0000000 --- a/service/src/main/java/market/guess/service/model/v2/GMUsers.java +++ /dev/null @@ -1,80 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v2; - -import java.util.ArrayList; -import java.util.List; -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type

. - * - *

The following schema fragment specifies the expected content contained within this class.

- * - *
{@code
- * 
- *   
- *     
- *       
- *         
- *       
- *     
- *   
- * 
- * }
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "gmUser" -}) -@XmlRootElement(name = "GM-users") -public class GMUsers { - - @XmlElement(name = "GM-user", required = true) - protected List gmUser; - - /** - * Gets the value of the gmUser property. - * - *

This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the gmUser property.

- * - *

- * For example, to add a new item, do as follows: - *

- *
-     * getGMUser().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link GMUser } - *

- * - * - * @return - * The value of the gmUser property. - */ - public List getGMUser() { - if (gmUser == null) { - gmUser = new ArrayList<>(); - } - return this.gmUser; - } - -} diff --git a/service/src/main/java/market/guess/service/model/v2/GuessMarket.java b/service/src/main/java/market/guess/service/model/v2/GuessMarket.java deleted file mode 100644 index 1ce28c8..0000000 --- a/service/src/main/java/market/guess/service/model/v2/GuessMarket.java +++ /dev/null @@ -1,97 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v2; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type

. - * - *

The following schema fragment specifies the expected content contained within this class.

- * - *
{@code
- * 
- *   
- *     
- *       
- *         
- *         
- *       
- *     
- *   
- * 
- * }
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - -}) -@XmlRootElement(name = "Guess-Market") -public class GuessMarket { - - @XmlElement(name = "GM-events", required = true) - protected GMEvents gmEvents; - @XmlElement(name = "GM-users", required = true) - protected GMUsers gmUsers; - - /** - * Gets the value of the gmEvents property. - * - * @return - * possible object is - * {@link GMEvents } - * - */ - public GMEvents getGMEvents() { - return gmEvents; - } - - /** - * Sets the value of the gmEvents property. - * - * @param value - * allowed object is - * {@link GMEvents } - * - */ - public void setGMEvents(GMEvents value) { - this.gmEvents = value; - } - - /** - * Gets the value of the gmUsers property. - * - * @return - * possible object is - * {@link GMUsers } - * - */ - public GMUsers getGMUsers() { - return gmUsers; - } - - /** - * Sets the value of the gmUsers property. - * - * @param value - * allowed object is - * {@link GMUsers } - * - */ - public void setGMUsers(GMUsers value) { - this.gmUsers = value; - } - -} diff --git a/service/src/main/java/market/guess/service/model/v2/ObjectFactory.java b/service/src/main/java/market/guess/service/model/v2/ObjectFactory.java deleted file mode 100644 index 7f0fff9..0000000 --- a/service/src/main/java/market/guess/service/model/v2/ObjectFactory.java +++ /dev/null @@ -1,231 +0,0 @@ -// -// This file was generated by the Eclipse Implementation of JAXB, v4.0.5 -// See https://eclipse-ee4j.github.io/jaxb-ri -// Any modifications to this file will be lost upon recompilation of the source schema. -// - - -package market.guess.service.model.v2; - -import javax.xml.namespace.QName; -import jakarta.xml.bind.JAXBElement; -import jakarta.xml.bind.annotation.XmlElementDecl; -import jakarta.xml.bind.annotation.XmlRegistry; - - -/** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the market.guess.service.model.v2 package. - *

An ObjectFactory allows you to programmatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are - * provided in this class. - * - */ -@XmlRegistry -public class ObjectFactory { - - private static final QName _InitialCash_QNAME = new QName("", "initial-cash"); - private static final QName _Id_QNAME = new QName("", "id"); - private static final QName _Description_QNAME = new QName("", "description"); - private static final QName _B_QNAME = new QName("", "b"); - private static final QName _GMOption_QNAME = new QName("", "GM-option"); - - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: market.guess.service.model.v2 - * - */ - public ObjectFactory() { - } - - /** - * Create an instance of {@link Event } - * - * @return - * the new instance of {@link Event } - */ - public Event createEvent() { - return new Event(); - } - - /** - * Create an instance of {@link Commission } - * - * @return - * the new instance of {@link Commission } - */ - public Commission createCommission() { - return new Commission(); - } - - /** - * Create an instance of {@link GuessMarket } - * - * @return - * the new instance of {@link GuessMarket } - */ - public GuessMarket createGuessMarket() { - return new GuessMarket(); - } - - /** - * Create an instance of {@link GMEvents } - * - * @return - * the new instance of {@link GMEvents } - */ - public GMEvents createGMEvents() { - return new GMEvents(); - } - - /** - * Create an instance of {@link GMEvent } - * - * @return - * the new instance of {@link GMEvent } - */ - public GMEvent createGMEvent() { - return new GMEvent(); - } - - /** - * Create an instance of {@link GMOptions } - * - * @return - * the new instance of {@link GMOptions } - */ - public GMOptions createGMOptions() { - return new GMOptions(); - } - - /** - * Create an instance of {@link GMMethod } - * - * @return - * the new instance of {@link GMMethod } - */ - public GMMethod createGMMethod() { - return new GMMethod(); - } - - /** - * Create an instance of {@link GMLMSR } - * - * @return - * the new instance of {@link GMLMSR } - */ - public GMLMSR createGMLMSR() { - return new GMLMSR(); - } - - /** - * Create an instance of {@link GMOrderBook } - * - * @return - * the new instance of {@link GMOrderBook } - */ - public GMOrderBook createGMOrderBook() { - return new GMOrderBook(); - } - - /** - * Create an instance of {@link GMUsers } - * - * @return - * the new instance of {@link GMUsers } - */ - public GMUsers createGMUsers() { - return new GMUsers(); - } - - /** - * Create an instance of {@link GMUser } - * - * @return - * the new instance of {@link GMUser } - */ - public GMUser createGMUser() { - return new GMUser(); - } - - /** - * Create an instance of {@link GMMarketMaker } - * - * @return - * the new instance of {@link GMMarketMaker } - */ - public GMMarketMaker createGMMarketMaker() { - return new GMMarketMaker(); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >} - * - * @param value - * Java instance representing xml element's value. - * @return - * the new instance of {@link JAXBElement }{@code <}{@link Integer }{@code >} - */ - @XmlElementDecl(namespace = "", name = "initial-cash") - public JAXBElement createInitialCash(Integer value) { - return new JAXBElement<>(_InitialCash_QNAME, Integer.class, null, value); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >} - * - * @param value - * Java instance representing xml element's value. - * @return - * the new instance of {@link JAXBElement }{@code <}{@link Integer }{@code >} - */ - @XmlElementDecl(namespace = "", name = "id") - public JAXBElement createId(Integer value) { - return new JAXBElement<>(_Id_QNAME, Integer.class, null, value); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >} - * - * @param value - * Java instance representing xml element's value. - * @return - * the new instance of {@link JAXBElement }{@code <}{@link String }{@code >} - */ - @XmlElementDecl(namespace = "", name = "description") - public JAXBElement createDescription(String value) { - return new JAXBElement<>(_Description_QNAME, String.class, null, value); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >} - * - * @param value - * Java instance representing xml element's value. - * @return - * the new instance of {@link JAXBElement }{@code <}{@link Integer }{@code >} - */ - @XmlElementDecl(namespace = "", name = "b") - public JAXBElement createB(Integer value) { - return new JAXBElement<>(_B_QNAME, Integer.class, null, value); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >} - * - * @param value - * Java instance representing xml element's value. - * @return - * the new instance of {@link JAXBElement }{@code <}{@link String }{@code >} - */ - @XmlElementDecl(namespace = "", name = "GM-option") - public JAXBElement createGMOption(String value) { - return new JAXBElement<>(_GMOption_QNAME, String.class, null, value); - } - -} diff --git a/service/src/main/java/market/guess/service/risk/LocalRiskEngine.java b/service/src/main/java/market/guess/service/risk/LocalRiskEngine.java new file mode 100644 index 0000000..d3e46e2 --- /dev/null +++ b/service/src/main/java/market/guess/service/risk/LocalRiskEngine.java @@ -0,0 +1,18 @@ +package market.guess.service.risk; + +import java.math.BigDecimal; +import market.guess.api.Result; +import market.guess.service.domain.Order; +import market.guess.service.domain.User; + +public final class LocalRiskEngine implements RiskEngine { + + @Override + public Result check(User user, Order order) { + var cost = order.price().multiply(BigDecimal.valueOf(order.quantity())); + if (user.getLedger().getBalance().compareTo(cost) < 0) { + return Result.error("Insufficient balance."); + } + return Result.ok(); + } +} diff --git a/service/src/main/java/market/guess/service/risk/RiskEngine.java b/service/src/main/java/market/guess/service/risk/RiskEngine.java new file mode 100644 index 0000000..3b71650 --- /dev/null +++ b/service/src/main/java/market/guess/service/risk/RiskEngine.java @@ -0,0 +1,9 @@ +package market.guess.service.risk; + +import market.guess.api.Result; +import market.guess.service.domain.Order; +import market.guess.service.domain.User; + +public interface RiskEngine { + Result check(User user, Order order); +} diff --git a/service/src/main/java/market/guess/service/settlement/LocalSettlementContext.java b/service/src/main/java/market/guess/service/settlement/LocalSettlementContext.java new file mode 100644 index 0000000..118e349 --- /dev/null +++ b/service/src/main/java/market/guess/service/settlement/LocalSettlementContext.java @@ -0,0 +1,50 @@ +package market.guess.service.settlement; + +import java.math.BigDecimal; +import java.util.HashMap; +import market.guess.api.CommissionTiming; +import market.guess.model.event.EventStatus; +import market.guess.model.ledger.LedgerType; +import market.guess.service.domain.Event; +import market.guess.service.helpers.BigDecimalOptions; +import market.guess.service.ledger.LedgerContext; + +public final class LocalSettlementContext implements SettlementContext { + private final LedgerContext ledger; + + public LocalSettlementContext(LedgerContext ledger) { + this.ledger = ledger; + } + + @Override + public BigDecimal settle(Event event, String winningOptionKey) { + event.setWinningOptionKey(winningOptionKey); + + var chargeCommission = event.getCommissionTiming() == CommissionTiming.ON_CLOSE; + var rate = BigDecimal.valueOf(event.getCommissionPercent()).divide(BigDecimal.valueOf(100)); + var winningOption = event.getOption(winningOptionKey); + + var sharesByUser = new HashMap(); + for (var trade : event.getTrades()) { + if (!trade.marketKey().equalsIgnoreCase(winningOptionKey)) continue; + sharesByUser.merge(trade.buyerUserName(), trade.quantity(), Long::sum); + } + + var totalPayout = BigDecimalOptions.ZERO_MONEY; + for (var entry : sharesByUser.entrySet()) { + var gross = BigDecimalOptions.toMoney(BigDecimal.valueOf(entry.getValue())); + var commission = + chargeCommission + ? BigDecimalOptions.toMoney(gross.multiply(rate)) + : BigDecimalOptions.ZERO_MONEY; + var net = gross.subtract(commission); + + ledger.credit(entry.getKey(), LedgerType.PAYOUT, net, "Payout: " + winningOption.getName()); + event.addSettlementCommission(commission); + totalPayout = totalPayout.add(net); + } + + event.setState(EventStatus.SETTLED); + return totalPayout; + } +} diff --git a/service/src/main/java/market/guess/service/settlement/SettlementContext.java b/service/src/main/java/market/guess/service/settlement/SettlementContext.java new file mode 100644 index 0000000..07b9cd0 --- /dev/null +++ b/service/src/main/java/market/guess/service/settlement/SettlementContext.java @@ -0,0 +1,8 @@ +package market.guess.service.settlement; + +import java.math.BigDecimal; +import market.guess.service.domain.Event; + +public interface SettlementContext { + BigDecimal settle(Event event, String winningOptionKey); +} -- cgit v1.2.3