ValidateExchangeInstruments

This commit is contained in:
akulikov 2023-05-27 18:52:21 +03:00
parent 48f619fdc7
commit a0b8291e1d
5 changed files with 158 additions and 78 deletions

View file

@ -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<ExchangeInstrument> exchangeInstrumentsList;
private List<DirAuctionBiddingType> dirAuctionBiddingTypeList;
private List<DirCurrencyCode> dirCurrencyCodeList;
private List<DirTradingModeMkr> dirTradingModeMkrList;
public MMListingsRequestParam(MMListingsRequest request) {
this.request = request;
@ -31,28 +25,4 @@ public class MMListingsRequestParam {
public void setExchangeInstrumentsList(List<ExchangeInstrument> exchangeInstrumentsList) {
this.exchangeInstrumentsList = exchangeInstrumentsList;
}
public List<DirAuctionBiddingType> getDirAuctionBiddingTypeList() {
return dirAuctionBiddingTypeList;
}
public void setDirAuctionBiddingTypeList(List<DirAuctionBiddingType> dirAuctionBiddingTypeList) {
this.dirAuctionBiddingTypeList = dirAuctionBiddingTypeList;
}
public List<DirCurrencyCode> getDirCurrencyCodeList() {
return dirCurrencyCodeList;
}
public void setDirCurrencyCodeList(List<DirCurrencyCode> dirCurrencyCodeList) {
this.dirCurrencyCodeList = dirCurrencyCodeList;
}
public List<DirTradingModeMkr> getDirTradingModeMkrList() {
return dirTradingModeMkrList;
}
public void setDirTradingModeMkrList(List<DirTradingModeMkr> dirTradingModeMkrList) {
this.dirTradingModeMkrList = dirTradingModeMkrList;
}
}

View file

@ -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<MMListingsRequestParam> {
private final Logger log = LoggerFactory.getLogger(getClass());
@ -92,6 +93,13 @@ public class PrepareExchangeInstruments extends Stage<MMListingsRequestParam> {
}
}
List<ExchangeInstrument> filteredExchangeInstrument = exchangeInstrumentList.stream()
.filter(exchangeInstrument -> !exchangeInstrument.isInvalidData())
.collect(Collectors.toList());
// todo check list is empty
param.setExchangeInstrumentsList(filteredExchangeInstrument);
return null;
}
}

View file

@ -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<MMListingsRequestParam> {
private final Logger log = LoggerFactory.getLogger(getClass());
@Override
public ProcessResult process(MMListingsRequestParam param) {
List<ExchangeInstrument> 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<ExchangeInstrument> filteredExchangeInstrument = exchangeInstrumentList.stream()
.filter(exchangeInstrument -> !exchangeInstrument.isInvalidData())
.collect(Collectors.toList());
// todo check list is empty
param.setExchangeInstrumentsList(filteredExchangeInstrument);
return null;
}
}

View file

@ -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;
}
}

View file

@ -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;
}