Initial commit: Add project files
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
researchSellPolicyRequestSchema,
|
||||
researchSellPolicyResponseSchema
|
||||
} from '../schema'
|
||||
|
||||
const baseRequest = {
|
||||
positionLotId: '00000000-0000-0000-0000-000000000001',
|
||||
cycleId: '00000000-0000-0000-0000-000000000002',
|
||||
evidenceId: 'evidence-1',
|
||||
datasetId: 'dataset-1',
|
||||
modelVersion: 'model-1',
|
||||
configVersion: 'config-1',
|
||||
codeSha: 'sha-1',
|
||||
asOf: '2026-08-01T07:00:00Z',
|
||||
publishedAtCutoff: '2026-08-01T06:00:00Z',
|
||||
currentSecurityPortfolioWeight: 0.6,
|
||||
currentLotPortfolioWeight: 0.2,
|
||||
strategicCoreFloorWeight: 0.3,
|
||||
hardImpairmentApproved: false,
|
||||
capitalFloorBreached: false,
|
||||
survivalSellRatioOfLot: 0,
|
||||
gapBelowFloorAtr: 0,
|
||||
consecutiveCloseBreaches: 0,
|
||||
cooldownSatisfied: true,
|
||||
concentrationSellRatioOfLot: 0,
|
||||
opportunityEdgeLowerBound: 0,
|
||||
opportunitySellRatioOfLot: 0
|
||||
}
|
||||
|
||||
describe('research sell policy contracts', () => {
|
||||
it('accepts a valid point-in-time request', () => {
|
||||
expect(researchSellPolicyRequestSchema.safeParse(baseRequest).success).toBe(true)
|
||||
})
|
||||
|
||||
it('rejects a lot weight above security weight', () => {
|
||||
const result = researchSellPolicyRequestSchema.safeParse({
|
||||
...baseRequest,
|
||||
currentLotPortfolioWeight: 0.7
|
||||
})
|
||||
expect(result.success).toBe(false)
|
||||
})
|
||||
|
||||
it('rejects a future published-at cutoff', () => {
|
||||
const result = researchSellPolicyRequestSchema.safeParse({
|
||||
...baseRequest,
|
||||
publishedAtCutoff: '2026-08-01T08:00:00Z'
|
||||
})
|
||||
expect(result.success).toBe(false)
|
||||
})
|
||||
|
||||
it('rejects an unknown production status', () => {
|
||||
const result = researchSellPolicyResponseSchema.safeParse({
|
||||
action: 'Hold',
|
||||
sellRatioOfLot: 0,
|
||||
targetSecurityPortfolioWeightAfter: 0.6,
|
||||
policyId: 'ALG-HOLD-001',
|
||||
reasonCode: 'NO_SELL_CONDITION',
|
||||
reentryEligible: false,
|
||||
policyTrace: [],
|
||||
evidenceStatus: 'PRODUCTION'
|
||||
})
|
||||
expect(result.success).toBe(false)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user