This commit is contained in:
parent
06b38cc61f
commit
ee0f95fcde
2 changed files with 18 additions and 24 deletions
|
|
@ -38,7 +38,6 @@ import ru.spcex.platform.utils.time.TimeUtil;
|
|||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
|
|
@ -69,7 +68,6 @@ public class ExecutionFondComponent {
|
|||
private final KafkaSender kafkaSender;
|
||||
private final NotificationSender notifications;
|
||||
private final boolean valuation;
|
||||
private static MathContext prec2 = new MathContext(2, RoundingMode.HALF_UP);
|
||||
|
||||
|
||||
@Autowired
|
||||
|
|
@ -238,37 +236,28 @@ public class ExecutionFondComponent {
|
|||
FixedIncomeSecurity fixedIncome = (FixedIncomeSecurity) security;
|
||||
BigDecimal nominalValue;
|
||||
Listing listing = listingImdg.getFirstObjectBySQL("securityId = %d and market = '%s'".formatted(fixedIncome.getId(), sTrades.getClassCode()));
|
||||
BigDecimal lotSize = listing != null ? safeBD(listing.getLotSize()) : BigDecimal.ZERO;
|
||||
BigDecimal ncd = safeBD(sTrades.getAccruedint());// eFond.interestAmount
|
||||
if (BondType.I.equalsByKey(fixedIncome.getBondType())) {
|
||||
ImdgPredicateBuilder pb = fixedIncomeCashFlowImdg.predicateBuilder();
|
||||
ImdgPredicate prdct = pb.and(
|
||||
pb.equals("securityId", fixedIncome.getId()),
|
||||
sTrades.getSettleDate() != null ?
|
||||
pb.equals("valueDate", sTrades.getSettleDate()) : pb.alwaysFalse()
|
||||
//fixme в тз settlementDate
|
||||
);
|
||||
FixedIncomeCashFlow cashFlow = fixedIncomeCashFlowImdg.getFirstObjectByPredicate(prdct);
|
||||
if (cashFlow != null) {
|
||||
nominalValue = safeBD(cashFlow.getNominalValue());
|
||||
} else {
|
||||
nominalValue = BigDecimal.ZERO;
|
||||
}
|
||||
BigDecimal lotSize = listing != null ? safeBD(listing.getLotSize()) : BigDecimal.ONE;
|
||||
ImdgPredicateBuilder pb = fixedIncomeCashFlowImdg.predicateBuilder();
|
||||
ImdgPredicate prdct = pb.and(
|
||||
pb.equals("securityId", fixedIncome.getId()),
|
||||
sTrades.getSettleDate() != null ?
|
||||
pb.equals("valueDate", sTrades.getSettleDate()) : pb.alwaysFalse()
|
||||
);
|
||||
FixedIncomeCashFlow cashFlow = fixedIncomeCashFlowImdg.getFirstObjectByPredicate(prdct);
|
||||
if (cashFlow != null) {
|
||||
nominalValue = safeBD(cashFlow.getNominalValue());
|
||||
} else {
|
||||
nominalValue = safeBD(fixedIncome.getNominalValue());
|
||||
}
|
||||
{
|
||||
lotSize.multiply(lots);
|
||||
settlementAmount = lotSize.multiply(lots)
|
||||
.multiply(nominalValue)
|
||||
.multiply(price)
|
||||
.divide(new BigDecimal(100), prec2) //first rounding
|
||||
.add(ncd.setScale(2, RoundingMode.HALF_UP)); //second rounding
|
||||
.divide(new BigDecimal(100), RoundingMode.HALF_UP)
|
||||
.setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
eFond.setSettlementAmount(settlementAmount);
|
||||
//ОКРУГЛЕНИЕ( NV* quantity * price/100) + ОКРУГЛЕНИЕ (executionFond.interestAmount) для каждой сделки
|
||||
} else if (InstrumentType.EQTY.equalsByKey(security.getInstrumentType())) {
|
||||
settlementAmount = lots.multiply(price, prec2);
|
||||
settlementAmount = lots.multiply(price).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
eFond.setSettlementAmount(settlementAmount);
|
||||
if (settlementAmount.compareTo(safeBD(sTrades.getValue())) != 0) {
|
||||
|
|
|
|||
|
|
@ -100,6 +100,11 @@ public class ImdgPredicateBuilderSqlMock implements ImdgPredicateBuilder {
|
|||
return sql("true");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImdgPredicate alwaysFalse() {
|
||||
return sql("false");
|
||||
}
|
||||
|
||||
static class SimpleSQLPredicate implements ImdgPredicate {
|
||||
protected String sql;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue