summaryrefslogtreecommitdiff
path: root/src/FundLab.Api/App.fs
diff options
context:
space:
mode:
authorSomhairle H. Marisol <[email protected]>2026-09-22 01:12:52 +0800
committerSomhairle H. Marisol <[email protected]>2026-09-22 01:12:52 +0800
commit3cc0b4dcfeed042e5a69628c6b7f45580ad1e2f9 (patch)
treeb86805c2680327412d6f5d554d4506ebfe62fc2f /src/FundLab.Api/App.fs
parent70e1ad4fc8ba248f835d415faade8a91ac3dc1f8 (diff)
downloadfund-lab-3cc0b4dcfeed042e5a69628c6b7f45580ad1e2f9.tar.gz
Add real AKShare bond quote probe slice (3d-14)
Diffstat (limited to 'src/FundLab.Api/App.fs')
-rw-r--r--src/FundLab.Api/App.fs26
1 files changed, 26 insertions, 0 deletions
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