From 43a060117d20e135edf709f564b412392b52b372 Mon Sep 17 00:00:00 2001 From: Kenny <48362370+masterred92@users.noreply.github.com> Date: Mon, 30 Nov 2026 19:48:26 -0800 Subject: [PATCH 1/5] feat: add competitive analysis with conservative estimates --- NeutralFlip.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/NeutralFlip.lua b/NeutralFlip.lua index 46310dc..7c9300c 100644 --- a/NeutralFlip.lua +++ b/NeutralFlip.lua @@ -231,6 +231,25 @@ local function route(itemID, buy, sell, cut, from, to, now, bags) } end +-- Cash recovery scenario: unsold stock is assigned zero cash proceeds, not zero asset value. +-- Deposit is refundable on units sold; one failed posting per unsold unit. +function NF.CashScenario(o, sold) + if not o or not o.deposit or not o.qty or o.qty <= 0 or type(sold) ~= "number" or sold < 0 or sold > o.qty or sold ~= math.floor(sold) then return nil end + local capital = o.buy * o.qty + local lost = math.ceil(o.deposit * (o.qty - sold) / o.qty) + return sold * o.net - capital - lost +end + +function NF.RecoveryUnits(o) + if not o or not o.qty or o.qty <= 0 or not o.deposit then return nil end + local lo, hi = 0, o.qty + while lo < hi do + local mid = math.floor((lo + hi) / 2) + if NF.CashScenario(o, mid) >= 0 then hi = mid else lo = mid + 1 end + end + if NF.CashScenario(o, lo) >= 0 then return lo end +end + -- Both routes for one item (0, 1 or 2 entries). function NF.ItemRoutes(itemID, now, bags) local fac = playerFaction() @@ -272,6 +291,8 @@ function NF.FormatLine(i, o) local notes = { ("%s %s %s, %s %s %s"):format(NF.KindLabel(o.from), L["price"], ago(o.buyAge), NF.KindLabel(o.to), L["price"], ago(o.sellAge)) .. " " .. L["old"] } if not o.qtyKnown then notes[#notes + 1] = "quantity at lowest buy price unknown" end if o.deposit then notes[#notes + 1] = "deposit at risk " .. C.Money(o.deposit) else notes[#notes + 1] = "deposit unknown" end + local recovery = NF.RecoveryUnits(o) + if recovery then notes[#notes + 1] = ("cash recovery: sell %d/%d (one posting)"):format(recovery, o.qty) end if o.carried > 0 then notes[#notes + 1] = "you carry " .. o.carried end if o.thin then notes[#notes + 1] = "THIN MARKET: check by hand" end return s .. " [" .. table.concat(notes, ", ") .. "]" From 7ae7f499b972a89e47ec1563e8de83bb95a0b03b Mon Sep 17 00:00:00 2001 From: Kenny <48362370+masterred92@users.noreply.github.com> Date: Mon, 30 Nov 2026 19:48:50 -0800 Subject: [PATCH 2/5] test: regression coverage for new analysis --- tests/test_neutralflip.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_neutralflip.lua b/tests/test_neutralflip.lua index 1b01e9a..d9ed231 100644 --- a/tests/test_neutralflip.lua +++ b/tests/test_neutralflip.lua @@ -52,6 +52,11 @@ check(o and o.deposit == math.floor(db.rates.neutral * 5 * 30), "deposit at risk -- Peacebloom: neutral 150 (qty unknown) vs home 200: list home at 199*0.95=189, profit 39 < minProfit 50 -> none for _, x in ipairs(list) do check(x.itemID ~= 2447, "small Peacebloom gap filtered") end check(not o.thin, "19x ratio not thin") +check(NF.CashScenario(o, 0) == -o.buy * o.qty - o.deposit, "zero sales cash exposure") +check(NF.CashScenario(o, o.qty) == o.total, "all sales recover deposit") +local recover = NF.RecoveryUnits(o) +check(recover and NF.CashScenario(o, recover) >= 0 and NF.CashScenario(o, recover - 1) < 0, "minimum cash recovery units") +check(NF.RecoveryUnits({qty = 3}) == nil, "unknown deposit stays unknown") local text = NF.ListText() check(text:find("BUY at Alliance AH") and text:find("LIST at neutral AH"), "list text: " .. text) From 862d0784b1c4c5978b88d3813fb437defc106969 Mon Sep 17 00:00:00 2001 From: Kenny <48362370+masterred92@users.noreply.github.com> Date: Mon, 30 Nov 2026 20:05:18 -0800 Subject: [PATCH 3/5] release: prepare 0.4.0 --- NeutralFlip.toc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NeutralFlip.toc b/NeutralFlip.toc index d5bd47c..66d5244 100644 --- a/NeutralFlip.toc +++ b/NeutralFlip.toc @@ -2,7 +2,7 @@ ## Title: NeutralFlip ## Notes: Compares your faction AH with the neutral (Booty Bay / Gadgetzan / Everlook) AH and lists buys worth carrying across, after the 5%/15% cuts. You press every button. ## Author: Kenny -## Version: 0.3.4 +## Version: 0.4.0 ## SavedVariables: KennyNeutralFlipDB ## OptionalDeps: PriceLog, MatTooltip, LibDataBroker-1.1, TomTom ## X-License: MIT From 798964bb7f322f05d600f473f1d41bf8f5996088 Mon Sep 17 00:00:00 2001 From: Kenny <48362370+masterred92@users.noreply.github.com> Date: Mon, 30 Nov 2026 20:06:25 -0800 Subject: [PATCH 4/5] docs: describe 0.4.0 features and limitations --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dde36c5..483d4a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.4.0 +- Adds conditional cash recovery: minimum units that must sell at the observed listing price to recover acquisition outlay and one failed posting's estimated deposit on unsold units. Unsold stock is assigned no cash proceeds, not zero asset value. +- Unknown deposits remain unknown; listing quantity is not demand. + ## 0.3.4 - Rejects malformed, undated, future-dated and stale comparison records. - Estimated profit is conditional on selling the listed quantity; unknown deposits and buy quantities are labelled. From 1dcffd75c2cf0bbd9c06cbbd3907e0c850cb2ab4 Mon Sep 17 00:00:00 2001 From: Kenny <48362370+masterred92@users.noreply.github.com> Date: Mon, 30 Nov 2026 20:09:32 -0800 Subject: [PATCH 5/5] docs: align README with 0.4.0 --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 98a7107..23f29c2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@
