From aa4dba4f70749b459c3922ce68610c4d78e644e6 Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Tue, 22 Sep 2026 01:35:29 +0800 Subject: Fix bond quote probe to use live convertible-bond spot data (3d-15) --- tests/FundLab.Api.Tests/BondQuoteProbeTests.fs | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests/FundLab.Api.Tests/BondQuoteProbeTests.fs') diff --git a/tests/FundLab.Api.Tests/BondQuoteProbeTests.fs b/tests/FundLab.Api.Tests/BondQuoteProbeTests.fs index a94bf58..442ed7c 100644 --- a/tests/FundLab.Api.Tests/BondQuoteProbeTests.fs +++ b/tests/FundLab.Api.Tests/BondQuoteProbeTests.fs @@ -69,6 +69,33 @@ type BondQuoteProbeTests(fixture: PostgresFixture) = Assert.Equal(None, quote.MaturityDate) | Error failure -> failwithf "expected a bond quote, got %A" failure + [] + member _.``probe parses a spot-shaped payload where maturity is unknown``() = + let json = BondQuoteProbeSupport.payload "110075" (Some "南航转债") (Some "106.368") None + + let probe = + AkshareBondQuoteProbe(BondQuoteProbeSupport.collectorReturning (fun () -> Ok json)) :> IBondQuoteProbe + + match probe.GetQuote("110075", CancellationToken.None) with + | Ok quote -> + Assert.Equal("110075", quote.Code) + Assert.Equal(Some "南航转债", quote.Name) + Assert.Equal(Some 106.368m, quote.Price) + Assert.Equal(None, quote.MaturityDate) + | Error failure -> failwithf "expected a bond quote, got %A" failure + + [] + member _.``probe surfaces a no valid quote collector failure``() = + let probe = + AkshareBondQuoteProbe( + BondQuoteProbeSupport.collectorReturning (fun () -> Error "AKShare collector failed: no valid quote for 999999") + ) + :> IBondQuoteProbe + + match probe.GetQuote("999999", CancellationToken.None) with + | Error(MarketDataCollectorUnavailable message) -> Assert.Contains("no valid quote for 999999", message) + | other -> failwithf "expected MarketDataCollectorUnavailable, got %A" other + [] member _.``probe rejects a malformed bond code without touching the collector``() = let probe = -- cgit v1.2.3