This commit is contained in:
parent
b7424f63a7
commit
564bb58e2c
3 changed files with 13 additions and 9 deletions
|
|
@ -191,7 +191,7 @@ public class TaskListener extends QueueConsumer implements InitializingBean {
|
|||
Registry amfRegistry = null;
|
||||
boolean isRubPmt = pmtRegistry.getSecuritySymbol().equals(CurrencyCode.RUB.getKey());
|
||||
if (!isRubPmt) {
|
||||
amfRegistry = imdgQueryService.findAmtRegistry(pmtRegistry, CurrencyCode.RUB.getKey());
|
||||
amfRegistry = imdgQueryService.findAmfRegistry(pmtRegistry, CurrencyCode.RUB.getKey());
|
||||
}
|
||||
|
||||
String currency = isRubPmt ? CurrencyCode.CNY.getKey() : pmtRegistry.getSecuritySymbol();
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ public class ImdgQueryService {
|
|||
);
|
||||
}
|
||||
|
||||
public Registry findAmtRegistry(Registry registry, String securitySymbol) {
|
||||
public Registry findAmfRegistry(Registry registry, String securitySymbol) {
|
||||
ImdgPredicateBuilder pb = registryImdg.predicateBuilder();
|
||||
return registryImdg.getSingleObjectByPredicate(
|
||||
pb.and(
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public class OrderCalculationService {
|
|||
throw new IllegalStateException(String.format("Not fond rate by security symbol: %s", CurrencyCode.CNY.getKey()));
|
||||
}
|
||||
BigDecimal rateValue = rates.getValue();
|
||||
BigDecimal sum3 = mathCeil(sum1, lotSize);
|
||||
BigDecimal sum3 = sum1.divide(BigDecimal.valueOf(lotSize), 0, RoundingMode.DOWN);
|
||||
BigDecimal sum4 = sum3.multiply(rateValue, MC).negate();
|
||||
BigDecimal sum5 = sum3.negate();
|
||||
|
||||
|
|
@ -116,12 +116,12 @@ public class OrderCalculationService {
|
|||
}
|
||||
BigDecimal rateValue = rates.getValue();
|
||||
|
||||
BigDecimal sum1 = planPosition.divide(rateValue, MC).abs();
|
||||
BigDecimal sum1 = planPosition.divide(rateValue, MC).abs(); //sum1 - рубли в юани
|
||||
|
||||
Registry am_f = imdgQueryService.findAmtRegistry(registry, "CNY");
|
||||
Registry am_f = imdgQueryService.findAmfRegistry(registry, "CNY");
|
||||
Collection<Registry> om_ts = imdgQueryService.findOTRegistry(registry, RegistryTradingParams.OM_T, "CNY");
|
||||
Collection<Registry> tm_ts = imdgQueryService.findOTRegistry(registry, RegistryTradingParams.TM_T, "CNY");
|
||||
log.trace("calculation for {}[{}]: AM*T[{}], OM*T[{}], TM*T[{}]",
|
||||
log.trace("calculation for {}[{}]: AM*F[{}], OM*T[{}], TM*T[{}]",
|
||||
registry.getRegistryCode(),
|
||||
registry.getId(),
|
||||
am_f != null ? am_f.getId() : null,
|
||||
|
|
@ -132,8 +132,12 @@ public class OrderCalculationService {
|
|||
.add(safeSumBD(tm_ts, Registry::getBalance));
|
||||
|
||||
BigDecimal sum2 = planPositionCny.setScale(lotSize, RoundingMode.HALF_DOWN);
|
||||
BigDecimal y = sum1.min(sum2);
|
||||
BigDecimal sum3 = mathCeil(y, lotSize).negate();
|
||||
BigDecimal lotSizBC = BigDecimal.valueOf(lotSize);
|
||||
BigDecimal lotSizeCny = sum1.divide(lotSizBC, 0, RoundingMode.DOWN);
|
||||
BigDecimal lotSizeCnyByAmf = sum2.divide(lotSizBC, 0, RoundingMode.DOWN);
|
||||
log.trace("quantityLot by pmt: {}/{}={}", sum1, lotSizeCny, lotSizeCny);
|
||||
log.trace("quantityLot by amf: {}/{}={}", sum2, lotSizeCny, lotSizeCnyByAmf);
|
||||
BigDecimal sum3 = lotSizeCny.min(lotSizeCnyByAmf).negate();
|
||||
BigDecimal sum4 = sum3.multiply(rateValue, MC).negate();
|
||||
BigDecimal sum5 = sum3.negate();
|
||||
|
||||
|
|
@ -170,7 +174,7 @@ public class OrderCalculationService {
|
|||
return "RUB".equals(registry.getSecuritySymbol());
|
||||
}
|
||||
|
||||
private BigDecimal mathCeil(BigDecimal val, Integer multiplicity) {
|
||||
public static BigDecimal mathCeil(BigDecimal val, Integer multiplicity) {
|
||||
return BigDecimal.valueOf(Math.ceil(val.doubleValue() / multiplicity));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue