From a0b8291e1db1b2e716b35991ffa0a78141d968d6 Mon Sep 17 00:00:00 2001 From: akulikov Date: Sat, 27 May 2023 18:52:21 +0300 Subject: [PATCH] ValidateExchangeInstruments --- .../listings_mm/MMListingsRequestParam.java | 30 ------- .../PrepareExchangeInstruments.java | 8 ++ .../ValidateExchangeInstruments.java | 65 ++++++++++++++ .../request/objects/ExchangeInstrument.java | 85 +++++++++++++++++++ .../request/objects/TradingMode.java | 48 ----------- 5 files changed, 158 insertions(+), 78 deletions(-) create mode 100644 clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/logic/listings_mm/ValidateExchangeInstruments.java diff --git a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/logic/listings_mm/MMListingsRequestParam.java b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/logic/listings_mm/MMListingsRequestParam.java index 62d90774a..c20f18628 100644 --- a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/logic/listings_mm/MMListingsRequestParam.java +++ b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/logic/listings_mm/MMListingsRequestParam.java @@ -1,9 +1,6 @@ package ru.spcex.clearing.gatewayapi.logic.listings_mm; import ru.spcex.clearing.gatewayapi.request.MMListingsRequest; -import ru.spcex.clearing.gatewayapi.request.objects.DirAuctionBiddingType; -import ru.spcex.clearing.gatewayapi.request.objects.DirCurrencyCode; -import ru.spcex.clearing.gatewayapi.request.objects.DirTradingModeMkr; import ru.spcex.clearing.gatewayapi.request.objects.ExchangeInstrument; import java.util.List; @@ -11,9 +8,6 @@ import java.util.List; public class MMListingsRequestParam { private final MMListingsRequest request; private List exchangeInstrumentsList; - private List dirAuctionBiddingTypeList; - private List dirCurrencyCodeList; - private List dirTradingModeMkrList; public MMListingsRequestParam(MMListingsRequest request) { this.request = request; @@ -31,28 +25,4 @@ public class MMListingsRequestParam { public void setExchangeInstrumentsList(List exchangeInstrumentsList) { this.exchangeInstrumentsList = exchangeInstrumentsList; } - - public List getDirAuctionBiddingTypeList() { - return dirAuctionBiddingTypeList; - } - - public void setDirAuctionBiddingTypeList(List dirAuctionBiddingTypeList) { - this.dirAuctionBiddingTypeList = dirAuctionBiddingTypeList; - } - - public List getDirCurrencyCodeList() { - return dirCurrencyCodeList; - } - - public void setDirCurrencyCodeList(List dirCurrencyCodeList) { - this.dirCurrencyCodeList = dirCurrencyCodeList; - } - - public List getDirTradingModeMkrList() { - return dirTradingModeMkrList; - } - - public void setDirTradingModeMkrList(List dirTradingModeMkrList) { - this.dirTradingModeMkrList = dirTradingModeMkrList; - } } diff --git a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/logic/listings_mm/PrepareExchangeInstruments.java b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/logic/listings_mm/PrepareExchangeInstruments.java index d43ca1246..034a42b86 100644 --- a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/logic/listings_mm/PrepareExchangeInstruments.java +++ b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/logic/listings_mm/PrepareExchangeInstruments.java @@ -13,6 +13,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; +import java.util.stream.Collectors; public class PrepareExchangeInstruments extends Stage { private final Logger log = LoggerFactory.getLogger(getClass()); @@ -92,6 +93,13 @@ public class PrepareExchangeInstruments extends Stage { } } + List filteredExchangeInstrument = exchangeInstrumentList.stream() + .filter(exchangeInstrument -> !exchangeInstrument.isInvalidData()) + .collect(Collectors.toList()); + + // todo check list is empty + + param.setExchangeInstrumentsList(filteredExchangeInstrument); return null; } } diff --git a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/logic/listings_mm/ValidateExchangeInstruments.java b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/logic/listings_mm/ValidateExchangeInstruments.java new file mode 100644 index 000000000..9c0e166a5 --- /dev/null +++ b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/logic/listings_mm/ValidateExchangeInstruments.java @@ -0,0 +1,65 @@ +package ru.spcex.clearing.gatewayapi.logic.listings_mm; + +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import ru.spcex.clearing.gatewayapi.logic.ProcessResult; +import ru.spcex.clearing.gatewayapi.logic.Stage; +import ru.spcex.clearing.gatewayapi.request.objects.ExchangeInstrument; +import ru.spcex.platform.enumeration.WorkflowStatus; +import ru.spcex.platform.utils.enumeration.IEnumKey; + +import java.util.List; +import java.util.stream.Collectors; + +public class ValidateExchangeInstruments extends Stage { + private final Logger log = LoggerFactory.getLogger(getClass()); + + @Override + public ProcessResult process(MMListingsRequestParam param) { + List exchangeInstrumentList = param.getExchangeInstrumentsList(); + for (ExchangeInstrument exchangeInstrument : exchangeInstrumentList) { + if (StringUtils.isEmpty(exchangeInstrument.getCode())) { + log.warn("Invalid exchange_instrument (id = {}), code is empty or null, skipped", exchangeInstrument.getId()); + exchangeInstrument.setInvalidData(true); + } + + if (StringUtils.isEmpty(exchangeInstrument.getName())) { + log.warn("Empty or null name for exchange_instrument (id = {})", exchangeInstrument.getId()); + exchangeInstrument.setInvalidData(true); + } + + if (exchangeInstrument.getInitiatorId() == null) { + log.warn("initiator_id empty for exchange_instrument (id = {})", exchangeInstrument.getId()); + exchangeInstrument.setInvalidData(true); + } + + if (StringUtils.isEmpty(exchangeInstrument.getSettlementCurrencyLetterCode())) { + log.warn("settlement_currency_letter_code empty or null for exchange_instrument (id = {})", exchangeInstrument.getId()); + exchangeInstrument.setInvalidData(true); + } + + if (exchangeInstrument.getLot() == null) { + log.warn("lot null for exchange_instrument (id = {})", exchangeInstrument.getId()); + exchangeInstrument.setInvalidData(true); + } + + String workflowStatusStr = exchangeInstrument.getWorkflowStatus(); + WorkflowStatus workflowStatus = IEnumKey.getEnumByKey(WorkflowStatus.class, workflowStatusStr); + if (workflowStatus == null) { + log.warn("Invalid workflow_status {} for exchange_instrument (id = {})", workflowStatusStr, exchangeInstrument.getId()); + exchangeInstrument.setInvalidData(true); + } + + } + + List filteredExchangeInstrument = exchangeInstrumentList.stream() + .filter(exchangeInstrument -> !exchangeInstrument.isInvalidData()) + .collect(Collectors.toList()); + + // todo check list is empty + + param.setExchangeInstrumentsList(filteredExchangeInstrument); + return null; + } +} diff --git a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/request/objects/ExchangeInstrument.java b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/request/objects/ExchangeInstrument.java index 86854b5e8..cf25ec36d 100644 --- a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/request/objects/ExchangeInstrument.java +++ b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/request/objects/ExchangeInstrument.java @@ -38,6 +38,20 @@ public class ExchangeInstrument extends WithMapId { ) private UUID initiatorId; + @JsonProperty("bank_deposit_agreement_type") + @ApiModelProperty( + value = """ + Вид договора банковского депозита + + Передавать: + «S», если «S (Срочный)» + «V», если «V (До востребования)» + «K», если «K (Комбинированный)» + """, + example = "S" + ) + private String bankDepositAgreementType; + @JsonProperty("auction_bidding_type_id") @ApiModelProperty( value = "Тип аукциона\\торгов. Ссылка на dir_auction_bidding_type (id)", @@ -87,6 +101,37 @@ public class ExchangeInstrument extends WithMapId { ) private String settlementCurrencyLetterCode; + @JsonProperty("settle_code") + @ApiModelProperty( + value = "Код (условия) расчетов", + example = "example" + ) + private String settleCode; + + @JsonProperty("min_step") + @ApiModelProperty( + value = "Минимальный шаг цены, значение listing.dir_price_min_step_precision.min_step", + example = "6" + ) + private Long minStep; + + @JsonProperty("precision") + @ApiModelProperty( + value = """ + Точность цены, значение из listing.dir_price_min_step_precision.precision, + соответствующее значению из listing.dir_price_min_step_precision.min_step + """, + example = "1" + ) + private Long precision; + + @JsonProperty("lot") + @ApiModelProperty( + value = "Лот", + example = "10" + ) + private Long lot; + @JsonProperty("order_execution_type_by_price") @ApiModelProperty( value = """ @@ -308,4 +353,44 @@ public class ExchangeInstrument extends WithMapId { public void setDirAuctionBiddingType(DirAuctionBiddingType dirAuctionBiddingType) { this.dirAuctionBiddingType = dirAuctionBiddingType; } + + public String getBankDepositAgreementType() { + return bankDepositAgreementType; + } + + public void setBankDepositAgreementType(String bankDepositAgreementType) { + this.bankDepositAgreementType = bankDepositAgreementType; + } + + public String getSettleCode() { + return settleCode; + } + + public void setSettleCode(String settleCode) { + this.settleCode = settleCode; + } + + public Long getMinStep() { + return minStep; + } + + public void setMinStep(Long minStep) { + this.minStep = minStep; + } + + public Long getPrecision() { + return precision; + } + + public void setPrecision(Long precision) { + this.precision = precision; + } + + public Long getLot() { + return lot; + } + + public void setLot(Long lot) { + this.lot = lot; + } } \ No newline at end of file diff --git a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/request/objects/TradingMode.java b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/request/objects/TradingMode.java index b4c9325b1..493b929ed 100644 --- a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/request/objects/TradingMode.java +++ b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/request/objects/TradingMode.java @@ -21,30 +21,6 @@ public class TradingMode extends WithMapId { ) private UUID tradingModeId; - @JsonProperty("min_step") - @ApiModelProperty( - value = "Минимальный шаг цены, значение listing.dir_price_min_step_precision.min_step", - example = "6" - ) - private Long minStep; - - @JsonProperty("precision") - @ApiModelProperty( - value = """ - Значение listing.dir_price_min_step_precision.precision, соответствующее - значению listing.dir_price_min_step_precision.min_step в поле «Минимальный шаг цены» - """, - example = "1" - ) - private Long precision; - - @JsonProperty("lot_size") - @ApiModelProperty( - value = "Размер лота", - example = "10" - ) - private Long lotSize; - @JsonProperty("trading_currency_letter_code") @ApiModelProperty( value = "Валюта торгов. Ссылка на dir_currency_code (letter_code)", @@ -83,30 +59,6 @@ public class TradingMode extends WithMapId { this.tradingModeId = tradingModeId; } - public Long getMinStep() { - return minStep; - } - - public void setMinStep(Long minStep) { - this.minStep = minStep; - } - - public Long getPrecision() { - return precision; - } - - public void setPrecision(Long precision) { - this.precision = precision; - } - - public Long getLotSize() { - return lotSize; - } - - public void setLotSize(Long lotSize) { - this.lotSize = lotSize; - } - public UUID getTradingCurrencyLetterCode() { return tradingCurrencyLetterCode; }