diff options
| author | Somhairle H. Marisol <[email protected]> | 2026-09-22 08:58:52 +0800 |
|---|---|---|
| committer | Somhairle H. Marisol <[email protected]> | 2026-09-22 08:58:52 +0800 |
| commit | 72f466b9b3ea6ece726e6b182cfc36bbd3f6fa15 (patch) | |
| tree | 8d1bf9285314eb37ce47525e4d0c052fcdf08ca8 /tests/FundLab.Api.Tests | |
| parent | d4b0c26b396bfcf1be029d8db3a1c0fc033a6765 (diff) | |
| download | fund-lab-72f466b9b3ea6ece726e6b182cfc36bbd3f6fa15.tar.gz | |
Add stock probe market/adjust/suspension fields and StockRules (3d-30 B1-B2)
Diffstat (limited to 'tests/FundLab.Api.Tests')
| -rw-r--r-- | tests/FundLab.Api.Tests/FundValuationTests.fs | 2 | ||||
| -rw-r--r-- | tests/FundLab.Api.Tests/StockQuoteProbeTests.fs | 18 | ||||
| -rw-r--r-- | tests/FundLab.Api.Tests/StockSellTests.fs | 2 | ||||
| -rw-r--r-- | tests/FundLab.Api.Tests/StockTradeTests.fs | 3 |
4 files changed, 23 insertions, 2 deletions
diff --git a/tests/FundLab.Api.Tests/FundValuationTests.fs b/tests/FundLab.Api.Tests/FundValuationTests.fs index 197686d..409bfba 100644 --- a/tests/FundLab.Api.Tests/FundValuationTests.fs +++ b/tests/FundLab.Api.Tests/FundValuationTests.fs @@ -7,7 +7,7 @@ open FundLab.Api module FundValuationSupport = let stockQuote (code: string) (price: decimal) : StockQuote = - { Code = code; Name = Some "贵州茅台"; Price = Some price; Currency = "CNY" } + { Code = code; Name = Some "贵州茅台"; Price = Some price; Currency = "CNY"; Market = Some "sh"; Adjust = Some "none"; Suspended = Some false } let bondQuote (code: string) (price: decimal) : BondQuote = { diff --git a/tests/FundLab.Api.Tests/StockQuoteProbeTests.fs b/tests/FundLab.Api.Tests/StockQuoteProbeTests.fs index 2cad557..b869f17 100644 --- a/tests/FundLab.Api.Tests/StockQuoteProbeTests.fs +++ b/tests/FundLab.Api.Tests/StockQuoteProbeTests.fs @@ -58,6 +58,21 @@ type StockQuoteProbeTests(fixture: PostgresFixture) = | Error failure -> failwithf "expected a stock quote, got %A" failure [<Fact>] + member _.``probe parses market, adjust and suspension flags``() = + let json = + "{\"schema_version\":\"fund-lab.akshare.v1\",\"operation\":\"stock-quote\",\"source\":\"akshare\",\"source_revision\":\"akshare-test/eastmoney\",\"collected_at\":\"2026-09-21T08:00:00Z\",\"instrument\":{\"code\":\"000001\"},\"quote\":{\"name\":\"平安银行\",\"price\":\"11.2300\",\"currency\":\"CNY\",\"market\":\"sz\",\"adjust\":\"none\",\"suspended\":true}}" + + let probe = + AkshareStockQuoteProbe(StockQuoteProbeSupport.collectorReturning (fun () -> Ok json)) :> IStockQuoteProbe + + match probe.GetQuote("000001", CancellationToken.None) with + | Ok quote -> + Assert.Equal<string option>(Some "sz", quote.Market) + Assert.Equal<string option>(Some "none", quote.Adjust) + Assert.Equal<bool option>(Some true, quote.Suspended) + | Error failure -> failwithf "expected a stock quote, got %A" failure + + [<Fact>] member _.``probe keeps a missing name missing instead of fabricating data``() = let json = StockQuoteProbeSupport.payload "600519" None (Some "1252.57") @@ -139,6 +154,9 @@ type StockQuoteProbeTests(fixture: PostgresFixture) = Name = Some "贵州茅台" Price = Some 1252.57m Currency = "CNY" + Market = Some "sh" + Adjust = Some "none" + Suspended = Some false }) let status, body = diff --git a/tests/FundLab.Api.Tests/StockSellTests.fs b/tests/FundLab.Api.Tests/StockSellTests.fs index cbdef8b..972293a 100644 --- a/tests/FundLab.Api.Tests/StockSellTests.fs +++ b/tests/FundLab.Api.Tests/StockSellTests.fs @@ -6,7 +6,7 @@ open FundLab.Api module StockSellSupport = let quote (code: string) (price: decimal) : StockQuote = - { Code = code; Name = Some "招商银行"; Price = Some price; Currency = "CNY" } + { Code = code; Name = Some "招商银行"; Price = Some price; Currency = "CNY"; Market = Some "sh"; Adjust = Some "none"; Suspended = Some false } let stubQuoteProbe (quotes: Map<string, decimal>) = { new IStockQuoteProbe with diff --git a/tests/FundLab.Api.Tests/StockTradeTests.fs b/tests/FundLab.Api.Tests/StockTradeTests.fs index a2269a1..f8a8492 100644 --- a/tests/FundLab.Api.Tests/StockTradeTests.fs +++ b/tests/FundLab.Api.Tests/StockTradeTests.fs @@ -20,6 +20,9 @@ module StockTradeSupport = Name = Some "贵州茅台" Price = Some 1252.57m Currency = "CNY" + Market = Some "sh" + Adjust = Some "none" + Suspended = Some false } let appWithQuote (probe: IStockQuoteProbe) = |
