refactor(orchestrator): share pure strategy bookkeeping (CL19)
This commit is contained in:
parent
984dc1a9cc
commit
6055aeeee9
17 changed files with 297 additions and 157 deletions
|
|
@ -2,6 +2,7 @@ import { describe, expect, test } from 'bun:test';
|
|||
import { stageFinancialTransaction } from '@stock-bot/engine';
|
||||
import { parseFinancialDecimal } from '@stock-bot/types';
|
||||
import {
|
||||
compareEventKeys,
|
||||
parseFinancialTransactionResult,
|
||||
type CanonicalMatchingCommand,
|
||||
} from '../../apps/stock/orchestrator/src/contracts/canonical-execution';
|
||||
|
|
@ -145,7 +146,11 @@ describe('trusted canonical paper feed policy', () => {
|
|||
});
|
||||
},
|
||||
value => {
|
||||
value.matching.series.push({ ...value.matching.series[0]!, seriesId: 'other' });
|
||||
value.matching.series.push({
|
||||
...value.matching.series[0]!,
|
||||
seriesId: 'other',
|
||||
mode: 'Quote',
|
||||
});
|
||||
},
|
||||
];
|
||||
for (const change of changes) {
|
||||
|
|
@ -465,3 +470,36 @@ describe('paper frame deterministic native command planning', () => {
|
|||
).toThrow(PaperRuntimeError);
|
||||
});
|
||||
});
|
||||
|
||||
test('paper planning and admission use Rust-compatible phase, UTF-8 and sequence ordering', () => {
|
||||
const instruments = ['𐀀', '\ue000', 'A'];
|
||||
const f = fixture(paperFeedConfiguration(instruments));
|
||||
const frame = paperFeedFrame(1000, instruments);
|
||||
const plan = f.plan(frame);
|
||||
expect(plan.map(input => input.command.key)).toEqual(
|
||||
plan.map(input => input.command.key).sort(compareEventKeys)
|
||||
);
|
||||
expect(
|
||||
plan
|
||||
.filter(input => input.command.body.kind === 'openSession')
|
||||
.map(input => input.command.key.instrumentId)
|
||||
).toEqual(['A', '\ue000', '𐀀']);
|
||||
expect(
|
||||
plan
|
||||
.filter(input => input.command.body.kind === 'execute')
|
||||
.map(input => input.command.key.instrumentId)
|
||||
).toEqual(['A', '\ue000', '𐀀']);
|
||||
for (const input of plan) {
|
||||
f.apply(input.command);
|
||||
}
|
||||
const keys: CanonicalMatchingCommand['key'][] = [
|
||||
{ at: 10, phase: 'SessionClose', instrumentId: 'A', sourceSequence: 0 },
|
||||
{ at: 10, phase: 'Execution', instrumentId: 'A', sourceSequence: 0 },
|
||||
{ at: 10, phase: 'Decision', instrumentId: 'A', sourceSequence: 0 },
|
||||
{ at: 10, phase: 'Observation', instrumentId: '𐀀', sourceSequence: 2 },
|
||||
{ at: 10, phase: 'Observation', instrumentId: '𐀀', sourceSequence: 1 },
|
||||
{ at: 10, phase: 'Observation', instrumentId: '\ue000', sourceSequence: 9 },
|
||||
{ at: 9, phase: 'SessionClose', instrumentId: '𐀀', sourceSequence: 9 },
|
||||
];
|
||||
expect([...keys].sort(compareEventKeys)).toEqual([...keys].reverse());
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue