Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
21 changes: 21 additions & 0 deletions NeutralFlip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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, ", ") .. "]"
Expand Down
2 changes: 1 addition & 1 deletion NeutralFlip.toc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<p align="center"><img src="media/logo.png" alt="NeutralFlip logo" width="200"></p>

# NeutralFlip (WoW: Forever) v0.3.4
# NeutralFlip (WoW: Forever) v0.4.0

The list includes conditional cash recovery when the deposit is known: how many units need to sell to recover acquisition outlay and one failed posting on unsold units. This is not a probability of sale.

[![MasterRed](https://img.shields.io/badge/MasterRed-Play%20smarter%20%7C%20Know%20more-DB353A?labelColor=141416)](https://github.com/masterred92) ![Independent developer](https://img.shields.io/badge/Independent-Developer-E7E7EA?labelColor=141416)

Expand Down
5 changes: 5 additions & 0 deletions tests/test_neutralflip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading