From 3cc0b4dcfeed042e5a69628c6b7f45580ad1e2f9 Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Tue, 22 Sep 2026 01:12:52 +0800 Subject: Add real AKShare bond quote probe slice (3d-14) --- src/FundLab.Api/App.fs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/FundLab.Api/App.fs') diff --git a/src/FundLab.Api/App.fs b/src/FundLab.Api/App.fs index e359af9..b083c37 100644 --- a/src/FundLab.Api/App.fs +++ b/src/FundLab.Api/App.fs @@ -356,6 +356,15 @@ type MarketProbes = { NavDates: INavDateProbe NavSeries: INavSeriesProbe + BondQuotes: IBondQuoteProbe + } + +type BondQuoteApiResponse = + { + code: string + name: string option + price: string option + maturityDate: string option } module App = @@ -1703,10 +1712,27 @@ module App = ctx | Error failure -> marketDataError failure next ctx + let private getBondQuote (probe: IBondQuoteProbe) : HttpHandler = + fun next ctx -> + let code = ctx.Request.Query["code"].ToString() + + match probe.GetQuote(code, ctx.RequestAborted) with + | Ok quote -> + json + ({ code = quote.Code + name = quote.Name + price = quote.Price |> Option.map decimalText + maturityDate = quote.MaturityDate |> Option.map dateText } + : BondQuoteApiResponse) + next + ctx + | Error failure -> marketDataError failure next ctx + let private marketProbeRoutes (probes: MarketProbes) = [ GET >=> route "/market/nav-dates" >=> getMarketNavDates probes.NavDates GET >=> route "/market/nav-series" >=> getMarketNavSeries probes.NavSeries + GET >=> route "/market/bond-quote" >=> getBondQuote probes.BondQuotes ] let private createApplicationInternal -- cgit v1.2.3