32 lines
1.2 KiB
Java
32 lines
1.2 KiB
Java
|
|
package com.quantai.trader.execution;
|
||
|
|
|
||
|
|
import com.quantai.trader.domain.ExecutionDecision;
|
||
|
|
import com.quantai.trader.domain.TraderEntryPlan;
|
||
|
|
import com.quantai.trader.domain.TraderMarketSnapshot;
|
||
|
|
import org.springframework.stereotype.Component;
|
||
|
|
|
||
|
|
import java.math.BigDecimal;
|
||
|
|
import java.util.Map;
|
||
|
|
|
||
|
|
@Component
|
||
|
|
public class ExecutionQualityGate {
|
||
|
|
|
||
|
|
public ExecutionDecision evaluate(TraderMarketSnapshot snapshot, TraderEntryPlan entryPlan) {
|
||
|
|
BigDecimal score = entryPlan.executionQualityScore() == null
|
||
|
|
? new BigDecimal("0.50")
|
||
|
|
: entryPlan.executionQualityScore();
|
||
|
|
if (!entryPlan.completeForEntry()) {
|
||
|
|
return new ExecutionDecision(false, score, "ENTRY_PLAN_INCOMPLETE", "TRADER_ENTRY_PLAN_INCOMPLETE", Map.of());
|
||
|
|
}
|
||
|
|
if (score.compareTo(new BigDecimal("0.20")) < 0) {
|
||
|
|
return new ExecutionDecision(false, score, "EXECUTION_QUALITY_TOO_LOW", "TRADER_RISK_BLOCKED", Map.of(
|
||
|
|
"executionQualityScore", score
|
||
|
|
));
|
||
|
|
}
|
||
|
|
return new ExecutionDecision(true, score, "EXECUTION_PROXY_PASS", null, Map.of(
|
||
|
|
"executionQualityScore", score,
|
||
|
|
"proxyOnly", true
|
||
|
|
));
|
||
|
|
}
|
||
|
|
}
|