Rewrite trader service for V4 P0

This commit is contained in:
Codex
2026-06-26 21:53:22 +08:00
parent 2fe4077164
commit 5d210053d0
184 changed files with 2780 additions and 6945 deletions
@@ -0,0 +1,38 @@
package com.quantai.trader.runtime;
import com.quantai.trader.domain.TraderException;
import com.quantai.trader.enums.TraderExecutionMode;
import com.quantai.trader.enums.TraderRunMode;
import org.junit.jupiter.api.Test;
import static com.quantai.trader.TestFixtures.properties;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
class P0RuntimeGuardTest {
@Test
void allowsReplaySimAndShadowWhenTradingIsDisabled() {
assertThatCode(() -> new P0RuntimeGuard(properties(TraderRunMode.REPLAY_SIM, TraderExecutionMode.REPLAY_SIM, false, false)).validateStartup())
.doesNotThrowAnyException();
assertThatCode(() -> new P0RuntimeGuard(properties(TraderRunMode.SHADOW, TraderExecutionMode.SHADOW, false, false)).validateStartup())
.doesNotThrowAnyException();
}
@Test
void rejectsPaperOrRealModesInsteadOfConvertingThem() {
assertThatThrownBy(() -> new P0RuntimeGuard(properties(TraderRunMode.PAPER, TraderExecutionMode.SHADOW, false, false)).validateStartup())
.isInstanceOf(TraderException.class)
.hasMessageContaining("REPLAY_SIM or SHADOW");
assertThatThrownBy(() -> new P0RuntimeGuard(properties(TraderRunMode.SHADOW, TraderExecutionMode.REAL, false, false)).validateStartup())
.isInstanceOf(TraderException.class)
.hasMessageContaining("execution.mode");
}
@Test
void rejectsAnyTradingEnabledP0Runtime() {
assertThatThrownBy(() -> new P0RuntimeGuard(properties(TraderRunMode.REPLAY_SIM, TraderExecutionMode.REPLAY_SIM, true, false)).validateStartup())
.isInstanceOf(TraderException.class)
.hasMessageContaining("trading-enabled=false");
}
}