execution uploading logs
This commit is contained in:
parent
4bf2c45c69
commit
a835a59e8d
4 changed files with 21 additions and 4 deletions
|
|
@ -106,6 +106,7 @@ public class ExecutionCurrencyComponent implements IExecutionUploadComponent {
|
||||||
public void processNewTS(Long fromId) {
|
public void processNewTS(Long fromId) {
|
||||||
boolean cleanLoad = fromId == null;
|
boolean cleanLoad = fromId == null;
|
||||||
if (cleanLoad) {
|
if (cleanLoad) {
|
||||||
|
log.info("clearing cash...");
|
||||||
cash.clear();
|
cash.clear();
|
||||||
initExecCash();
|
initExecCash();
|
||||||
}
|
}
|
||||||
|
|
@ -136,6 +137,7 @@ public class ExecutionCurrencyComponent implements IExecutionUploadComponent {
|
||||||
|
|
||||||
//убираем уже добавленные в ExecutionCurrency
|
//убираем уже добавленные в ExecutionCurrency
|
||||||
if (!cleanLoad) {
|
if (!cleanLoad) {
|
||||||
|
log.info("filtering strades based on ExecutionCurrency cash...");
|
||||||
sTrades.removeIf(sTrd -> {
|
sTrades.removeIf(sTrd -> {
|
||||||
Side sTrdSide = IEnumKey.getEnumByKey(Side.class, sTrd.getOperation());
|
Side sTrdSide = IEnumKey.getEnumByKey(Side.class, sTrd.getOperation());
|
||||||
if (sTrdSide == null || !(sTrdSide.equals(Side.BUY) || sTrdSide.equals(Side.SELL))) {
|
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) {
|
if (!cleanLoad || (storedId = cash.get(execKey)) == null) {
|
||||||
newEC.setId(idGen.nextId());
|
newEC.setId(idGen.nextId());
|
||||||
cash.put(execKey, ExecUploadCashInfo.cash(newEC));
|
cash.put(execKey, ExecUploadCashInfo.cash(newEC));
|
||||||
|
log.debug("New executionCurrency.id={} was created.", newEC.getId());
|
||||||
} else {
|
} else {
|
||||||
newEC.setId(storedId.id());
|
newEC.setId(storedId.id());
|
||||||
newEC.setUpdated(newEC.getCreated());
|
newEC.setUpdated(newEC.getCreated());
|
||||||
newEC.setCreated(storedId.createDt());
|
newEC.setCreated(storedId.createDt());
|
||||||
|
log.debug("executionCurrency.id={} was updated.", newEC.getId());
|
||||||
}
|
}
|
||||||
execsToInsert.put(newEC.getId(), newEC);
|
execsToInsert.put(newEC.getId(), newEC);
|
||||||
//executionCurrencyImdg.insert(newEC);
|
//executionCurrencyImdg.insert(newEC);
|
||||||
sendNotification(newEC);
|
sendNotification(newEC);
|
||||||
log.debug("New executionCurrency.id={} was created.", newEC.getId());
|
|
||||||
} catch (ClearingException ce) {
|
} catch (ClearingException ce) {
|
||||||
auditMessage(ce);
|
auditMessage(ce);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("When create new ExecutionCurrency by STrade[{}] error: {}", sTrd.getId(), ExceptionUtils.getStackTrace(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);
|
executionCurrencyImdg.putAll(execsToInsert, 200);
|
||||||
|
|
||||||
Long newMaxTradeNum = sTrades.stream().mapToLong(STrades::getTradeNum).max().orElse(0); // orElseGet(() -> tradeNum)
|
Long newMaxTradeNum = sTrades.stream().mapToLong(STrades::getTradeNum).max().orElse(0); // orElseGet(() -> tradeNum)
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,7 @@ public class ExecutionDepositComponent implements IExecutionUploadComponent {
|
||||||
public void processNewTS(Long fromId) {
|
public void processNewTS(Long fromId) {
|
||||||
boolean cleanLoad = fromId == null;
|
boolean cleanLoad = fromId == null;
|
||||||
if (cleanLoad) {
|
if (cleanLoad) {
|
||||||
|
log.info("clearing cash...");
|
||||||
cash.clear();
|
cash.clear();
|
||||||
initExecCash();
|
initExecCash();
|
||||||
}
|
}
|
||||||
|
|
@ -134,6 +135,7 @@ public class ExecutionDepositComponent implements IExecutionUploadComponent {
|
||||||
|
|
||||||
//убираем уже добавленные в ExecutionDeposit
|
//убираем уже добавленные в ExecutionDeposit
|
||||||
if (!cleanLoad) {
|
if (!cleanLoad) {
|
||||||
|
log.info("filtering strades based on ExecutionDeposit cash...");
|
||||||
sTrades.removeIf(sTrd -> {
|
sTrades.removeIf(sTrd -> {
|
||||||
Side sTrdSide = IEnumKey.getEnumByKey(Side.class, sTrd.getOperation());
|
Side sTrdSide = IEnumKey.getEnumByKey(Side.class, sTrd.getOperation());
|
||||||
if (sTrdSide == null || !(sTrdSide.equals(Side.BUY) || sTrdSide.equals(Side.SELL))) {
|
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) {
|
if (!cleanLoad || (storedId = cash.get(execKey)) == null) {
|
||||||
newED.setId(idGen.nextId());
|
newED.setId(idGen.nextId());
|
||||||
cash.put(execKey, ExecUploadCashInfo.cash(newED));
|
cash.put(execKey, ExecUploadCashInfo.cash(newED));
|
||||||
|
log.debug("New executionDeposit.id={} was created.", newED.getId());
|
||||||
} else {
|
} else {
|
||||||
newED.setId(storedId.id());
|
newED.setId(storedId.id());
|
||||||
newED.setUpdated(newED.getCreated());
|
newED.setUpdated(newED.getCreated());
|
||||||
newED.setCreated(storedId.createDt());
|
newED.setCreated(storedId.createDt());
|
||||||
|
log.debug("executionDeposit.id={} was updated.", newED.getId());
|
||||||
}
|
}
|
||||||
execsToInsert.put(newED.getId(), newED);
|
execsToInsert.put(newED.getId(), newED);
|
||||||
//executionDepositImdg.insert(newED);
|
//executionDepositImdg.insert(newED);
|
||||||
sendNotification(newED);
|
sendNotification(newED);
|
||||||
log.debug("New executionDeposit.id={} was created.", newED.getId());
|
|
||||||
} catch (ClearingException ce) {
|
} catch (ClearingException ce) {
|
||||||
auditMessage(ce);
|
auditMessage(ce);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("When create new ExecutionDeposit by STrade[{}] error: {}", sTrd.getId(), ExceptionUtils.getStackTrace(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);
|
executionDepositImdg.putAll(execsToInsert, 200);
|
||||||
|
|
||||||
Long newMaxTradeNum = sTrades.stream().mapToLong(STrades::getTradeNum).max().orElseGet(() -> tradeNum);
|
Long newMaxTradeNum = sTrades.stream().mapToLong(STrades::getTradeNum).max().orElseGet(() -> tradeNum);
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,7 @@ public class ExecutionFondComponent implements IExecutionUploadComponent {
|
||||||
public void processNewTS(Long fromId) {
|
public void processNewTS(Long fromId) {
|
||||||
boolean cleanLoad = fromId == null;
|
boolean cleanLoad = fromId == null;
|
||||||
if (cleanLoad) {
|
if (cleanLoad) {
|
||||||
|
log.info("clearing cash...");
|
||||||
cash.clear();
|
cash.clear();
|
||||||
initExecCash();
|
initExecCash();
|
||||||
}
|
}
|
||||||
|
|
@ -153,6 +154,7 @@ public class ExecutionFondComponent implements IExecutionUploadComponent {
|
||||||
|
|
||||||
//убираем уже добавленные в ExecutionDeposit
|
//убираем уже добавленные в ExecutionDeposit
|
||||||
if (!cleanLoad) {
|
if (!cleanLoad) {
|
||||||
|
log.info("filtering strades based on ExecutionFond cash...");
|
||||||
sTrades.removeIf(sTrd -> {
|
sTrades.removeIf(sTrd -> {
|
||||||
Side sTrdSide = IEnumKey.getEnumByKey(Side.class, sTrd.getOperation());
|
Side sTrdSide = IEnumKey.getEnumByKey(Side.class, sTrd.getOperation());
|
||||||
if (sTrdSide == null || !(sTrdSide.equals(Side.BUY) || sTrdSide.equals(Side.SELL))) {
|
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) {
|
if (!cleanLoad || (storedId = cash.get(execKey)) == null) {
|
||||||
newED.setId(idGen.nextId());
|
newED.setId(idGen.nextId());
|
||||||
cash.put(execKey, ExecUploadCashInfo.cash(newED));
|
cash.put(execKey, ExecUploadCashInfo.cash(newED));
|
||||||
|
log.debug("New executionFond.id={} was created.", newED.getId());
|
||||||
} else {
|
} else {
|
||||||
newED.setId(storedId.id());
|
newED.setId(storedId.id());
|
||||||
newED.setUpdated(newED.getCreated());
|
newED.setUpdated(newED.getCreated());
|
||||||
newED.setCreated(storedId.createDt());
|
newED.setCreated(storedId.createDt());
|
||||||
|
log.debug("executionFond.id={} was updated.", newED.getId());
|
||||||
}
|
}
|
||||||
execsToInsert.put(newED.getId(), newED);
|
execsToInsert.put(newED.getId(), newED);
|
||||||
//executionFondImdg.insert(newED);
|
//executionFondImdg.insert(newED);
|
||||||
sendNotification(newED);
|
sendNotification(newED);
|
||||||
log.debug("New executionDeposit.id={} was created.", newED.getId());
|
|
||||||
} catch (ClearingException ce) {
|
} catch (ClearingException ce) {
|
||||||
auditMessage(ce);
|
auditMessage(ce);
|
||||||
} catch (Exception e) {
|
} 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);
|
executionFondImdg.putAll(execsToInsert, 200);
|
||||||
|
|
||||||
Long newMaxTradeNum = sTrades.stream().mapToLong(STrades::getTradeNum).max().orElseGet(() -> tradeNum);
|
Long newMaxTradeNum = sTrades.stream().mapToLong(STrades::getTradeNum).max().orElseGet(() -> tradeNum);
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,23 @@ package ru.spcex.clearing.service.execution;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import ru.clearing.classes.statics.data.execution.ExecutionCommon;
|
import ru.clearing.classes.statics.data.execution.ExecutionCommon;
|
||||||
import ru.spcex.platform.imdg.api.Imdg;
|
import ru.spcex.platform.imdg.api.Imdg;
|
||||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||||
|
|
||||||
public class ExecutionUploadCashUtil {
|
public class ExecutionUploadCashUtil {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(ExecutionUploadCashUtil.class);
|
||||||
public static <T extends ExecutionCommon>
|
public static <T extends ExecutionCommon>
|
||||||
void loadExecutions(Imdg<T> executionImdg, Map<ExecUploadKey, ExecUploadCashInfo> cash) {
|
void loadExecutions(Imdg<T> executionImdg, Map<ExecUploadKey, ExecUploadCashInfo> cash) {
|
||||||
|
log.info("loading cash for {}...", executionImdg.getMapName());
|
||||||
LocalDate today = LocalDate.now();
|
LocalDate today = LocalDate.now();
|
||||||
ImdgPredicateBuilder pb = executionImdg.predicateBuilder();
|
ImdgPredicateBuilder pb = executionImdg.predicateBuilder();
|
||||||
Collection<T> execs = executionImdg.getCollectionObjectsByPredicate(
|
Collection<T> execs = executionImdg.getCollectionObjectsByPredicate(
|
||||||
pb.equals("tradingDate", today)
|
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)));
|
execs.forEach(e -> cash.put(ExecUploadKey.cash(e), ExecUploadCashInfo.cash(e)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue