execution uploading logs

This commit is contained in:
ialbert 2024-08-07 16:38:39 +03:00
parent 4bf2c45c69
commit a835a59e8d
4 changed files with 21 additions and 4 deletions

View file

@ -106,6 +106,7 @@ public class ExecutionCurrencyComponent implements IExecutionUploadComponent {
public void processNewTS(Long fromId) {
boolean cleanLoad = fromId == null;
if (cleanLoad) {
log.info("clearing cash...");
cash.clear();
initExecCash();
}
@ -136,6 +137,7 @@ public class ExecutionCurrencyComponent implements IExecutionUploadComponent {
//убираем уже добавленные в ExecutionCurrency
if (!cleanLoad) {
log.info("filtering strades based on ExecutionCurrency cash...");
sTrades.removeIf(sTrd -> {
Side sTrdSide = IEnumKey.getEnumByKey(Side.class, sTrd.getOperation());
if (sTrdSide == null || !(sTrdSide.equals(Side.BUY) || sTrdSide.equals(Side.SELL))) {
@ -170,21 +172,23 @@ public class ExecutionCurrencyComponent implements IExecutionUploadComponent {
if (!cleanLoad || (storedId = cash.get(execKey)) == null) {
newEC.setId(idGen.nextId());
cash.put(execKey, ExecUploadCashInfo.cash(newEC));
log.debug("New executionCurrency.id={} was created.", newEC.getId());
} else {
newEC.setId(storedId.id());
newEC.setUpdated(newEC.getCreated());
newEC.setCreated(storedId.createDt());
log.debug("executionCurrency.id={} was updated.", newEC.getId());
}
execsToInsert.put(newEC.getId(), newEC);
//executionCurrencyImdg.insert(newEC);
sendNotification(newEC);
log.debug("New executionCurrency.id={} was created.", newEC.getId());
} catch (ClearingException ce) {
auditMessage(ce);
} catch (Exception e) {
log.error("When create new ExecutionCurrency by STrade[{}] error: {}", sTrd.getId(), ExceptionUtils.getStackTrace(e));
}
}
log.info("batch putAll {} ExecutionCurrency", execsToInsert.size());
executionCurrencyImdg.putAll(execsToInsert, 200);
Long newMaxTradeNum = sTrades.stream().mapToLong(STrades::getTradeNum).max().orElse(0); // orElseGet(() -> tradeNum)

View file

@ -105,6 +105,7 @@ public class ExecutionDepositComponent implements IExecutionUploadComponent {
public void processNewTS(Long fromId) {
boolean cleanLoad = fromId == null;
if (cleanLoad) {
log.info("clearing cash...");
cash.clear();
initExecCash();
}
@ -134,6 +135,7 @@ public class ExecutionDepositComponent implements IExecutionUploadComponent {
//убираем уже добавленные в ExecutionDeposit
if (!cleanLoad) {
log.info("filtering strades based on ExecutionDeposit cash...");
sTrades.removeIf(sTrd -> {
Side sTrdSide = IEnumKey.getEnumByKey(Side.class, sTrd.getOperation());
if (sTrdSide == null || !(sTrdSide.equals(Side.BUY) || sTrdSide.equals(Side.SELL))) {
@ -168,21 +170,23 @@ public class ExecutionDepositComponent implements IExecutionUploadComponent {
if (!cleanLoad || (storedId = cash.get(execKey)) == null) {
newED.setId(idGen.nextId());
cash.put(execKey, ExecUploadCashInfo.cash(newED));
log.debug("New executionDeposit.id={} was created.", newED.getId());
} else {
newED.setId(storedId.id());
newED.setUpdated(newED.getCreated());
newED.setCreated(storedId.createDt());
log.debug("executionDeposit.id={} was updated.", newED.getId());
}
execsToInsert.put(newED.getId(), newED);
//executionDepositImdg.insert(newED);
sendNotification(newED);
log.debug("New executionDeposit.id={} was created.", newED.getId());
} catch (ClearingException ce) {
auditMessage(ce);
} catch (Exception e) {
log.error("When create new ExecutionDeposit by STrade[{}] error: {}", sTrd.getId(), ExceptionUtils.getStackTrace(e));
}
}
log.info("batch putAll {} ExecutionDeposit", execsToInsert.size());
executionDepositImdg.putAll(execsToInsert, 200);
Long newMaxTradeNum = sTrades.stream().mapToLong(STrades::getTradeNum).max().orElseGet(() -> tradeNum);

View file

@ -124,6 +124,7 @@ public class ExecutionFondComponent implements IExecutionUploadComponent {
public void processNewTS(Long fromId) {
boolean cleanLoad = fromId == null;
if (cleanLoad) {
log.info("clearing cash...");
cash.clear();
initExecCash();
}
@ -153,6 +154,7 @@ public class ExecutionFondComponent implements IExecutionUploadComponent {
//убираем уже добавленные в ExecutionDeposit
if (!cleanLoad) {
log.info("filtering strades based on ExecutionFond cash...");
sTrades.removeIf(sTrd -> {
Side sTrdSide = IEnumKey.getEnumByKey(Side.class, sTrd.getOperation());
if (sTrdSide == null || !(sTrdSide.equals(Side.BUY) || sTrdSide.equals(Side.SELL))) {
@ -187,21 +189,23 @@ public class ExecutionFondComponent implements IExecutionUploadComponent {
if (!cleanLoad || (storedId = cash.get(execKey)) == null) {
newED.setId(idGen.nextId());
cash.put(execKey, ExecUploadCashInfo.cash(newED));
log.debug("New executionFond.id={} was created.", newED.getId());
} else {
newED.setId(storedId.id());
newED.setUpdated(newED.getCreated());
newED.setCreated(storedId.createDt());
log.debug("executionFond.id={} was updated.", newED.getId());
}
execsToInsert.put(newED.getId(), newED);
//executionFondImdg.insert(newED);
sendNotification(newED);
log.debug("New executionDeposit.id={} was created.", newED.getId());
} catch (ClearingException ce) {
auditMessage(ce);
} catch (Exception e) {
log.error("When create new ExecutionDeposit by STrade[{}] error: {}", sTrd.getId(), ExceptionUtils.getStackTrace(e));
log.error("When create new ExecutionFond by STrade[{}] error: {}", sTrd.getId(), ExceptionUtils.getStackTrace(e));
}
}
log.info("batch putAll {} ExecutionFond", execsToInsert.size());
executionFondImdg.putAll(execsToInsert, 200);
Long newMaxTradeNum = sTrades.stream().mapToLong(STrades::getTradeNum).max().orElseGet(() -> tradeNum);

View file

@ -3,18 +3,23 @@ package ru.spcex.clearing.service.execution;
import java.time.LocalDate;
import java.util.Collection;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.clearing.classes.statics.data.execution.ExecutionCommon;
import ru.spcex.platform.imdg.api.Imdg;
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
public class ExecutionUploadCashUtil {
private static final Logger log = LoggerFactory.getLogger(ExecutionUploadCashUtil.class);
public static <T extends ExecutionCommon>
void loadExecutions(Imdg<T> executionImdg, Map<ExecUploadKey, ExecUploadCashInfo> cash) {
log.info("loading cash for {}...", executionImdg.getMapName());
LocalDate today = LocalDate.now();
ImdgPredicateBuilder pb = executionImdg.predicateBuilder();
Collection<T> execs = executionImdg.getCollectionObjectsByPredicate(
pb.equals("tradingDate", today)
);
log.info("loading cash for {} done. executions found: {}", executionImdg.getMapName(), execs.size());
execs.forEach(e -> cash.put(ExecUploadKey.cash(e), ExecUploadCashInfo.cash(e)));
}
}