Compare commits

..

6 Commits

Author SHA1 Message Date
Fretux 6b152854bd Update Discord trade listings 2026-11-21 00:42:57 +01:00
Fretux d29892eac5 Update Discord trade listings 2026-11-21 00:09:14 +01:00
Fretux 218c022779 Update Discord trade listings 2026-11-20 00:53:35 +01:00
Fretux af8b173abd Update Discord trade listings 2026-11-20 00:40:07 +01:00
Fretux f37559ad6a Update Discord trade listings 2026-11-19 23:51:10 +01:00
Fretux 51459d6ae5 Update Discord trade listings 2026-11-19 23:46:59 +01:00
27 changed files with 6411 additions and 2349 deletions
+94 -23
View File
@@ -5,11 +5,36 @@ Run `py -B provisional_valuelist.py` to regenerate:
- `provisional_valuelist.csv`: ranked relative estimates and confidence levels.
- `exchange_quotes.csv`: exact single-unit asking quotes with source text.
- `bundle_quotes.csv`: explicit multi-unit asking quotes with source text.
- `confidence_report.csv`: unrounded fits and leave-one-quote-out sensitivity by variant.
- `quote_impact.csv`: every variant's value after each connected quote is removed.
- `quote_conflicts.csv`: direct quotes for the same pair with incompatible ratios.
- `evidence_comparison.csv`: the weighted fit beside an explicit-only refit,
including changes and variants disconnected when inferred pairs are removed.
The current snapshot contains 1,256 listings. The parser found 15 simple quotes
and 15 bundle quotes. Twenty-four quotes connect 28 variants to Aizen Evo; only
seven variants receive a numeric entry. Other connected
variants remain in the CSV as unranked with `insufficient` confidence.
The detailed `trades.csv` keeps a pretrade unit in `offer`, marks an explicit
`PRE`/`Pretrade` listing in `pretrade`, and puts any already received
`BEST OFFER`/`HIGH OFFER` in `received_bid`. Received bids are not owned
inventory or completed trades. A request for the "best offer" remains in LF.
Record confirmed exchanges in `completed_trades.csv` before regenerating. Each
row needs a unique `trade_id`, ISO `trade_date`, exact `given` and `received`
unit sides, and an `evidence` reference such as a message link or screenshot ID.
`notes` may be blank. For example, a confirmed exchange of two Homura Evo and
one Buddha Evo for one Aizen Evo would use `2 Homura Evo + Buddha Evo` in
`given` and `Aizen Evo` in `received`. This is a format example, not a recorded
trade. Keep each side to named variants with optional integer quantities;
ambiguous wording and overlapping variants are rejected. To use another input
file, pass `--completed-trades path/to/file.csv`. The checked-in file has only
a header until real completed trades are recorded.
The current snapshot contains 1,759 listings. The parser found 24 simple quotes
and 22 bundle quotes, and no completed trades have been entered. Forty-one
asking quotes connect 44 variants to Aizen Evo. Eight
eligible estimates are marked `unstable` and unranked. Aizen Evo and Shiny
Homura Evo have numeric entries. The direct-pair conflict report is empty after
stat-specific offers were removed from the base-variant quotes. An explicit
ask for six Aizen Evo in exchange for one Homura Evo remains in the evidence;
it makes Homura Evo unstable.
## How the estimates work
@@ -18,32 +43,78 @@ whose two sides contain only named variants and quantities. It rejects broad
wish lists, alternatives, unspecified adds, stats and quality descriptions,
and inventory rows that do not clearly describe a bundle. Each offered unit
must appear in the listing's `offer` field. Repeated identical quotes from one
author count once.
author count once. A proposal is excluded from the base-variant fit when its
offered inventory identifies the unit only with specific stats. The current
audit excluded eight such proposals; they remain in `trades.csv` for later
stat-aware modeling.
The model fixes **Aizen Evo = 1,000 points**. It fits unit values so the sum of
points on each side of a proposed exchange is approximately equal. Direct
unit quotes have three times the weight of bundle quotes. A small pull toward
the 1,000-point reference keeps the sparse equations solvable. Values are
rounded to the nearest 50 points. This is an **asking-price model**, not a
record of completed exchanges; the regularization affects thin estimates.
points on each side of an exchange is approximately equal. Completed trades
have weight 9. Explicit direct asks have weight 3 and explicit bundle asks
weight 1. Inferred offer/LF pairs get one-third of the matching explicit
weight: 1 for direct pairs and 1/3 for bundles. This snapshot contains 29
explicit proposals and 17 inferred pairs. The ValueList and confidence report
show their source counts separately. The two ask
files contain only proposed exchanges; completed records stay in their own
input file. A small pull toward the 1,000-point reference keeps sparse equations
solvable. Values are rounded to the nearest 50 points. The regularization
affects thin estimates, and a manually recorded completion is only as reliable
as its evidence reference.
`low` means at least four distinct source rows mention the unit in accepted
quotes. `very_low` means two or three. The Aizen reference and Shiny Dark Mage
are also displayed when evidence is thinner; their counts are visible. No
entry earns high confidence from this dataset. `insufficient` entries have
no numeric value or rank.
The ValueList and confidence report show separate `asking_quote_count` and
`completed_trade_count` columns, plus `explicit_ask_count` and
`inferred_ask_count`. `quote_count` is the combined number of
distinct source listings and trade IDs. A variant with a completed trade and
at least one other independent source can become eligible for ranking; the
leave-one-out stability gate still applies. `source_rows` uses normal row
numbers for asks and `trade:<id>` for completions. The `basis` column shows
which source types mention the variant.
Shiny Aizen Evo is placed immediately above normal Aizen Evo from the ordering
provided by the user. Its confidence is `constraint_only`, and its numeric
value is deliberately blank: the file does not establish a multiplier. A
For each connected ask or completed trade, the model is fitted again without it.
`confidence_report.csv` shows the full unrounded fit, the minimum and maximum
leave-one-out values, the largest percentage change, and the quote causing it.
`quote_impact.csv` provides every removal, its evidence type, source text,
resulting value, and signed percentage change. A positive change means the fitted value rises
when that quote is removed.
If removing one quote disconnects a variant from Aizen, its source row appears
in `disconnects_when_removed`. A previously eligible variant is `unstable` and
has no numeric value or rank if any removal disconnects it or changes its fit
by more than 25%. This is a practical screening threshold, not a statistical
confidence interval. The Aizen reference remains fixed by definition.
`evidence_comparison.csv` refits the model using only explicit proposals and
completed trades. Its `all_fit` and `explicit_only_fit` are unrounded diagnostic
fits, even for unstable variants. The `*_ranked_value` columns remain blank
whenever the corresponding fit is unstable or insufficient. A disconnected
variant has no explicit-only fit or value. Shiny Dark Mage Evo is unstable and
unranked in both the weighted and explicit-only fits.
`quote_conflicts.csv` compares exact direct quotes for the same pair of variants.
It lists both source texts when their implied value ratios differ by more than
25%. Bundle quotes participate in the sensitivity check, but the direct-pair
conflict report does not compare different bundle compositions.
Among stable eligible variants, `low` means at least four distinct sources
mention the unit; `very_low` means two or three. Shiny Dark Mage is displayed
with two sources as a provisional exception. `insufficient` entries have too
few independent quotes for a numeric value or rank. No entry earns high
confidence from this dataset.
In the current snapshot, Shiny Aizen Evo is placed immediately above normal
Aizen Evo from the ordering provided by the user. Its confidence is
`constraint_only`, and its numeric value is deliberately blank: the file does
not establish a multiplier. If enough completed trades later support a stable
numeric fit above Aizen Evo, it can receive a fitted value without creating a
second row. A
listing asks 900 rerolls for Shiny Aizen, and another asks for unspecified
"bulks" of normal Aizen; neither supplies a quantitative comparison.
The rank of Shiny Aizen represents only **greater than Aizen Evo**. Its true
position relative to other units may be higher. For stronger values, collect
completed trades or repeated exact quotes with quantities, evolution state,
shiny state, stat quality, and date. Fit the model again as those arrive.
position relative to other units may be higher. For stronger values, record
more completed trades with provenance and exact quantities, evolution state,
shiny state, stat quality, and date, then fit the model again.
`interest_index.csv`, generated by `py -B calculate_interest_index.py`, is a
separate demand-versus-supply report. The current report covers 34 variants
from 1,177 distinct authors. It must not be read as a value ranking.
separate demand-versus-supply report. The current report covers 35 variants
from 1,550 distinct authors. In explicit `my X for Y` proposals, X counts as
offered and Y as requested. It must not be read as a value ranking.
+21 -14
View File
@@ -1,16 +1,23 @@
source_row,quote_type,offered,requested,source_text
47,explicit_for,"{""Shiny Piccolo Evo"": 1, ""Shiny Chuuni Evo"": 1, ""Shiny Elf Mage Evo"": 1}","{""Aizen Evo"": 1}",My Shiny Piccolo Evo + Shiny Chuuni Evo + Shiny Elf Mage Evo for Aizen Evo
177,explicit_for,"{""Shiny Boros Evo"": 1, ""Shiny Gilgamesh Evo"": 1, ""Shiny Mamy Evo"": 2}","{""Shiny Homura Evo"": 1}","Shiny Homura Evo FOR Shiny Boros Evo, Shiny Gilgamesh Evo, 2x Shiny Mamy Evo"
177,explicit_for,"{""Shiny Boros Evo"": 1, ""Shiny Gilgamesh Evo"": 1}","{""Shiny Emilia Evo"": 1}",Shiny Emilia Evo FOR Shiny Boros Evo AND Shiny Gilgamesh Evo
370,explicit_for,"{""Aizen Evo"": 1, ""Homura Evo"": 1}","{""Thorfinn Evo"": 1}",My Aizen Evo and Homura Evo for Thorfinn Evo
401,explicit_for,"{""Alucard Evo"": 1, ""Shiny Ice Queen Evo"": 1}","{""Aizen Evo"": 1}",MY Alucard Evo AND Shiny ICE QUEEN Evo FOR Aizen Evo
541,listing_pair,"{""Shiny Buddha Evo"": 1}","{""Homura Evo"": 1, ""Chuuni Evo"": 1}",Shiny Buddha Evo -> Homura Evo + Chuuni Evo
641,listing_pair,"{""Poseidon Evo"": 2, ""Nami Evo"": 1}","{""Dark Mage Evo"": 1}",2 Poseidon Evo AND Nami Evo -> Dark Mage Evo
717,explicit_for,"{""Roger Evo"": 1, ""Homura Evo"": 1}","{""Aizen Evo"": 1}",MY ROGER Evo AND Homura Evo FOR Aizen Evo
747,explicit_for,"{""Shiny Chuuni Evo"": 1, ""Gilgamesh Evo"": 1}","{""Homura Evo"": 1}",My Shiny Chuuni Evo and Gilgamesh Evo for Homura Evo
781,explicit_for,"{""Shiny Mamy Evo"": 1, ""Shiny Dark Mage Evo"": 1}","{""Aizen Evo"": 1}",My Shiny Mamy Evo and Shiny Dark Mage Evo for Aizen Evo
805,listing_pair,"{""Homura Evo"": 2, ""Buddha Evo"": 1}","{""Aizen Evo"": 1}",2 Homura Evo+Buddha Evo -> Aizen Evo
1107,listing_pair,"{""Chuuni Evo"": 1, ""Cream Evo"": 1}","{""Dark Mage Evo"": 1}",Chuuni Evo AND Cream Evo -> Dark Mage Evo
1145,explicit_for,"{""Aizen Evo"": 1, ""Shiny Power Evo"": 1}","{""Shiny Homura Evo"": 1}",my Aizen Evo and Shiny power Evo for Shiny Homura Evo
1202,explicit_for,"{""Shiny Yoshina Evo"": 1, ""Chuuni Evo"": 1, ""Buddha Evo"": 1, ""Kisuke Evo"": 1}","{""Homura Evo"": 1}",Homura Evo for my Shiny Yoshina Evo+Chuuni Evo+Buddha Evo+kisuke Evo
1239,listing_pair,"{""Shiny Deer Tan Evo"": 1, ""Deer Tan Evo"": 1}","{""Shiny Idol Evo"": 1}",Shiny Deer Tan Evo and Deer Tan Evo -> Shiny idol Evo
52,explicit_for,"{""Android 21 Evo"": 1, ""Alucard Evo"": 1}","{""Shiny Homura Evo"": 1}",MY Android 21 Evo + Alucard Evo FOR Shiny Homura Evo
174,explicit_for,"{""Shiny Boros Evo"": 1, ""Shiny Gilgamesh Evo"": 1, ""Shiny Mamy Evo"": 2}","{""Shiny Homura Evo"": 1}","Shiny Homura Evo FOR Shiny Boros Evo, Shiny Gilgamesh Evo, 2x Shiny Mamy Evo"
174,explicit_for,"{""Shiny Boros Evo"": 1, ""Shiny Gilgamesh Evo"": 1}","{""Shiny Emilia Evo"": 1}",Shiny Emilia Evo FOR Shiny Boros Evo AND Shiny Gilgamesh Evo
253,explicit_for,"{""Shiny Dark Mage Evo"": 1, ""Buddha Evo"": 1}","{""Homura Evo"": 1}",my Shiny Dark Mage Evo + Buddha Evo for Homura Evo
366,explicit_for,"{""Aizen Evo"": 1, ""Homura Evo"": 1}","{""Thorfinn Evo"": 1}",My Aizen Evo and Homura Evo for Thorfinn Evo
463,explicit_for,"{""Shiny Somber Evo"": 1, ""Shiny Sakamoto Evo"": 1, ""Jelly Evo"": 1, ""Cid Unevo"": 2, ""Nagumo Unevo"": 2}","{""Shiny Chuuni Evo"": 1}",Shiny Somber Evo + Shiny Sakamoto Evo + Jelly Evo + 2 x Cid Unevo + 2 x Nagumo Unevo for Shiny Chuuni Evo
536,listing_pair,"{""Shiny Buddha Evo"": 1}","{""Homura Evo"": 1, ""Chuuni Evo"": 1}",Shiny Buddha Evo -> Homura Evo + Chuuni Evo
636,listing_pair,"{""Poseidon Evo"": 2, ""Nami Evo"": 1}","{""Dark Mage Evo"": 1}",2 Poseidon Evo AND Nami Evo -> Dark Mage Evo
776,explicit_for,"{""Shiny Mamy Evo"": 1, ""Shiny Dark Mage Evo"": 1}","{""Aizen Evo"": 1}",My Shiny Mamy Evo and Shiny Dark Mage Evo for Aizen Evo
800,listing_pair,"{""Homura Evo"": 2, ""Buddha Evo"": 1}","{""Aizen Evo"": 1}",2 Homura Evo+Buddha Evo -> Aizen Evo
1101,listing_pair,"{""Chuuni Evo"": 1, ""Cream Evo"": 1}","{""Dark Mage Evo"": 1}",Chuuni Evo AND Cream Evo -> Dark Mage Evo
1138,explicit_for,"{""Aizen Evo"": 1, ""Shiny Power Evo"": 1}","{""Shiny Homura Evo"": 1}",my Aizen Evo and Shiny power Evo for Shiny Homura Evo
1195,explicit_for,"{""Shiny Yoshina Evo"": 1, ""Chuuni Evo"": 1, ""Buddha Evo"": 1, ""Kisuke Evo"": 1}","{""Homura Evo"": 1}",Homura Evo for my Shiny Yoshina Evo+Chuuni Evo+Buddha Evo+kisuke Evo
1195,explicit_for,"{""Shiny Yoshina Evo"": 1, ""Chuuni Evo"": 1}","{""Shiny Dark Mage Evo"": 1}",Shiny Dark Mage Evo for my Shiny Yoshina Evo and Chuuni Evo
1232,listing_pair,"{""Shiny Deer Tan Evo"": 1, ""Deer Tan Evo"": 1}","{""Shiny Idol Evo"": 1}",Shiny Deer Tan Evo and Deer Tan Evo -> Shiny idol Evo
1256,listing_pair,"{""Cid Evo"": 1, ""Poseidon Evo"": 1}","{""Dark Mage Evo"": 1}",Cid Evo and Poseidon Evo -> Dark Mage Evo
1265,explicit_for,"{""Cid Evo"": 1, ""Skull Knight Evo"": 1, ""Dark Mage Evo"": 3}","{""Homura Evo"": 1}","Cid Evo,Skull Knight Evo, 3 Dark Mage Evo FOR Homura Evo"
1306,listing_pair,"{""Jiraiya Evo"": 1, ""Poseidon Evo"": 1}","{""Dark Mage Evo"": 1}",my Jiraiya Evo and Poseidon Evo -> Dark Mage Evo
1334,explicit_for,"{""Shiny Issei Evo"": 1, ""Shiny Nagumo Evo"": 1, ""Ice Lily Evo"": 1}","{""Shiny Buddha Evo"": 1}","Shiny Buddha Evo For Shiny Issei Evo, Shiny Nagumo Evo And Ice Lily Evo"
1543,listing_pair,"{""Cid Evo"": 1, ""Skull Knight Unevo"": 1}","{""Dark Mage Evo"": 1}",Cid Evo and Skull Knight Unevo -> Dark Mage Evo
1702,explicit_for,"{""Shiny Poseidon Evo"": 1, ""Shiny Saki Evo"": 1, ""Shiny Tiger Evo"": 1}","{""Homura Evo"": 1}",My Shiny Poseidon Evo + Shiny Saki Evo + Shiny Tiger Evo for Homura Evo
1 source_row quote_type offered requested source_text
2 47 explicit_for {"Shiny Piccolo Evo": 1, "Shiny Chuuni Evo": 1, "Shiny Elf Mage Evo": 1} {"Aizen Evo": 1} My Shiny Piccolo Evo + Shiny Chuuni Evo + Shiny Elf Mage Evo for Aizen Evo
3 177 52 explicit_for {"Shiny Boros Evo": 1, "Shiny Gilgamesh Evo": 1, "Shiny Mamy Evo": 2} {"Android 21 Evo": 1, "Alucard Evo": 1} {"Shiny Homura Evo": 1} Shiny Homura Evo FOR Shiny Boros Evo, Shiny Gilgamesh Evo, 2x Shiny Mamy Evo MY Android 21 Evo + Alucard Evo FOR Shiny Homura Evo
4 177 174 explicit_for {"Shiny Boros Evo": 1, "Shiny Gilgamesh Evo": 1} {"Shiny Boros Evo": 1, "Shiny Gilgamesh Evo": 1, "Shiny Mamy Evo": 2} {"Shiny Emilia Evo": 1} {"Shiny Homura Evo": 1} Shiny Emilia Evo FOR Shiny Boros Evo AND Shiny Gilgamesh Evo Shiny Homura Evo FOR Shiny Boros Evo, Shiny Gilgamesh Evo, 2x Shiny Mamy Evo
5 370 174 explicit_for {"Aizen Evo": 1, "Homura Evo": 1} {"Shiny Boros Evo": 1, "Shiny Gilgamesh Evo": 1} {"Thorfinn Evo": 1} {"Shiny Emilia Evo": 1} My Aizen Evo and Homura Evo for Thorfinn Evo Shiny Emilia Evo FOR Shiny Boros Evo AND Shiny Gilgamesh Evo
6 401 253 explicit_for {"Alucard Evo": 1, "Shiny Ice Queen Evo": 1} {"Shiny Dark Mage Evo": 1, "Buddha Evo": 1} {"Aizen Evo": 1} {"Homura Evo": 1} MY Alucard Evo AND Shiny ICE QUEEN Evo FOR Aizen Evo my Shiny Dark Mage Evo + Buddha Evo for Homura Evo
7 541 366 listing_pair explicit_for {"Shiny Buddha Evo": 1} {"Aizen Evo": 1, "Homura Evo": 1} {"Homura Evo": 1, "Chuuni Evo": 1} {"Thorfinn Evo": 1} Shiny Buddha Evo -> Homura Evo + Chuuni Evo My Aizen Evo and Homura Evo for Thorfinn Evo
8 641 463 listing_pair explicit_for {"Poseidon Evo": 2, "Nami Evo": 1} {"Shiny Somber Evo": 1, "Shiny Sakamoto Evo": 1, "Jelly Evo": 1, "Cid Unevo": 2, "Nagumo Unevo": 2} {"Dark Mage Evo": 1} {"Shiny Chuuni Evo": 1} 2 Poseidon Evo AND Nami Evo -> Dark Mage Evo Shiny Somber Evo + Shiny Sakamoto Evo + Jelly Evo + 2 x Cid Unevo + 2 x Nagumo Unevo for Shiny Chuuni Evo
9 717 536 explicit_for listing_pair {"Roger Evo": 1, "Homura Evo": 1} {"Shiny Buddha Evo": 1} {"Aizen Evo": 1} {"Homura Evo": 1, "Chuuni Evo": 1} MY ROGER Evo AND Homura Evo FOR Aizen Evo Shiny Buddha Evo -> Homura Evo + Chuuni Evo
10 747 636 explicit_for listing_pair {"Shiny Chuuni Evo": 1, "Gilgamesh Evo": 1} {"Poseidon Evo": 2, "Nami Evo": 1} {"Homura Evo": 1} {"Dark Mage Evo": 1} My Shiny Chuuni Evo and Gilgamesh Evo for Homura Evo 2 Poseidon Evo AND Nami Evo -> Dark Mage Evo
11 781 776 explicit_for {"Shiny Mamy Evo": 1, "Shiny Dark Mage Evo": 1} {"Aizen Evo": 1} My Shiny Mamy Evo and Shiny Dark Mage Evo for Aizen Evo
12 805 800 listing_pair {"Homura Evo": 2, "Buddha Evo": 1} {"Aizen Evo": 1} 2 Homura Evo+Buddha Evo -> Aizen Evo
13 1107 1101 listing_pair {"Chuuni Evo": 1, "Cream Evo": 1} {"Dark Mage Evo": 1} Chuuni Evo AND Cream Evo -> Dark Mage Evo
14 1145 1138 explicit_for {"Aizen Evo": 1, "Shiny Power Evo": 1} {"Shiny Homura Evo": 1} my Aizen Evo and Shiny power Evo for Shiny Homura Evo
15 1202 1195 explicit_for {"Shiny Yoshina Evo": 1, "Chuuni Evo": 1, "Buddha Evo": 1, "Kisuke Evo": 1} {"Homura Evo": 1} Homura Evo for my Shiny Yoshina Evo+Chuuni Evo+Buddha Evo+kisuke Evo
16 1239 1195 listing_pair explicit_for {"Shiny Deer Tan Evo": 1, "Deer Tan Evo": 1} {"Shiny Yoshina Evo": 1, "Chuuni Evo": 1} {"Shiny Idol Evo": 1} {"Shiny Dark Mage Evo": 1} Shiny Deer Tan Evo and Deer Tan Evo -> Shiny idol Evo Shiny Dark Mage Evo for my Shiny Yoshina Evo and Chuuni Evo
17 1232 listing_pair {"Shiny Deer Tan Evo": 1, "Deer Tan Evo": 1} {"Shiny Idol Evo": 1} Shiny Deer Tan Evo and Deer Tan Evo -> Shiny idol Evo
18 1256 listing_pair {"Cid Evo": 1, "Poseidon Evo": 1} {"Dark Mage Evo": 1} Cid Evo and Poseidon Evo -> Dark Mage Evo
19 1265 explicit_for {"Cid Evo": 1, "Skull Knight Evo": 1, "Dark Mage Evo": 3} {"Homura Evo": 1} Cid Evo,Skull Knight Evo, 3 Dark Mage Evo FOR Homura Evo
20 1306 listing_pair {"Jiraiya Evo": 1, "Poseidon Evo": 1} {"Dark Mage Evo": 1} my Jiraiya Evo and Poseidon Evo -> Dark Mage Evo
21 1334 explicit_for {"Shiny Issei Evo": 1, "Shiny Nagumo Evo": 1, "Ice Lily Evo": 1} {"Shiny Buddha Evo": 1} Shiny Buddha Evo For Shiny Issei Evo, Shiny Nagumo Evo And Ice Lily Evo
22 1543 listing_pair {"Cid Evo": 1, "Skull Knight Unevo": 1} {"Dark Mage Evo": 1} Cid Evo and Skull Knight Unevo -> Dark Mage Evo
23 1702 explicit_for {"Shiny Poseidon Evo": 1, "Shiny Saki Evo": 1, "Shiny Tiger Evo": 1} {"Homura Evo": 1} My Shiny Poseidon Evo + Shiny Saki Evo + Shiny Tiger Evo for Homura Evo
+4 -1
View File
@@ -6,7 +6,7 @@ from collections import Counter
import re
from calculate_interest_index import variants
from extract_exchange_quotes import FOR, parse_side
from extract_exchange_quotes import FOR, only_stat_specific_inventory, parse_side
SEPARATOR = re.compile(r"\s*(?:\+|,|\band\b)\s*", re.IGNORECASE)
@@ -69,6 +69,9 @@ def extract_bundle_quotes(rows: list[dict[str, str]]) -> list[dict]:
continue
if not set(offered) <= inventory or set(offered) & set(requested):
continue
if any(only_stat_specific_inventory(row.get("offer") or "", unit)
for unit in offered):
continue
key = (author, tuple(sorted(offered.items())), tuple(sorted(requested.items())))
if key in seen:
continue
+12
View File
@@ -34,12 +34,24 @@ UNIT_PATTERN = re.compile(
re.IGNORECASE,
)
MY_PREFIX = re.compile(r"\bmy\s+$", re.IGNORECASE)
OWNED_BEFORE_FOR = re.compile(r"\bmy\b[^|]*?\bfor\b", re.IGNORECASE)
OWNED_AFTER_FOR = re.compile(r"\bfor\s+my\b[^|]*", re.IGNORECASE)
def variants(text: str, *, request: bool = False) -> set[str]:
"""Find explicit unit variants, counting each at most once per side."""
found: set[str] = set()
owned_spans: list[tuple[int, int]] = []
if request:
for match in OWNED_BEFORE_FOR.finditer(text):
# The units between 'my' and 'for' are the trader's offer.
owned_spans.append((match.start(), match.end() - len("for")))
for match in OWNED_AFTER_FOR.finditer(text):
if not any(start <= match.start() < end for start, end in owned_spans):
owned_spans.append((match.start(), match.end()))
for match in UNIT_PATTERN.finditer(text):
if request and any(start <= match.start() < end for start, end in owned_spans):
continue
if request and MY_PREFIX.search(text[max(0, match.start() - 12):match.start()]):
continue
name = CANONICAL_NAMES[canonical_key(match.group("unit"))]
+1
View File
@@ -0,0 +1 @@
trade_id,trade_date,given,received,evidence,notes
1 trade_id trade_date given received evidence notes
+51
View File
@@ -0,0 +1,51 @@
"""Load manually confirmed exchanges, separate from Discord asking listings."""
from __future__ import annotations
import csv
from datetime import date
from pathlib import Path
import re
from bundle_quotes import parse_bundle
FIELDS = ("trade_id", "trade_date", "given", "received", "evidence", "notes")
TRADE_ID = re.compile(r"[A-Za-z0-9_-]+\Z")
def load_completed_trades(path: Path) -> list[dict]:
"""Reject malformed records rather than silently treating them as prices."""
with path.open(encoding="utf-8-sig", newline="") as stream:
reader = csv.DictReader(stream)
if reader.fieldnames is None or not set(FIELDS).issubset(reader.fieldnames):
raise ValueError(f"{path} needs columns: {', '.join(FIELDS)}")
result = []
seen_ids = set()
for row_number, row in enumerate(reader, start=2):
if None in row or any(value is None for value in row.values()):
raise ValueError(f"{path} row {row_number}: malformed CSV row")
trade_id = row["trade_id"].strip()
trade_date = row["trade_date"].strip()
evidence = row["evidence"].strip()
if not TRADE_ID.fullmatch(trade_id) or trade_id in seen_ids:
raise ValueError(f"{path} row {row_number}: trade_id must be unique and use letters, digits, _ or -")
seen_ids.add(trade_id)
try:
if date.fromisoformat(trade_date).isoformat() != trade_date:
raise ValueError
except ValueError:
raise ValueError(f"{path} row {row_number}: trade_date must be YYYY-MM-DD") from None
if not evidence:
raise ValueError(f"{path} row {row_number}: evidence is required")
given = parse_bundle(row["given"])
received = parse_bundle(row["received"])
if (given is None or received is None or given[1] is not None or received[1] is not None
or set(given[0]) & set(received[0])):
raise ValueError(f"{path} row {row_number}: use distinct exact variants and quantities on both sides")
result.append({"trade_id": trade_id, "trade_date": trade_date,
"offered": dict(given[0]), "requested": dict(received[0]),
"source_row": f"trade:{trade_id}",
"source_text": f"{row['given'].strip()} -> {row['received'].strip()}",
"evidence": evidence, "notes": row["notes"].strip()})
return result
+45
View File
@@ -0,0 +1,45 @@
unit_variant,quote_count,asking_quote_count,explicit_ask_count,inferred_ask_count,completed_trade_count,full_fit_value,leave_one_out_min,leave_one_out_max,max_change_pct,most_influential_source_row,most_influential_evidence_type,most_influential_quote,disconnects_when_removed,status,conflicting_source_rows
Aizen Evo,8,8,6,2,0,1000.0,1000.0,1000.0,0.0,,,,,reference,
Alucard Evo,2,2,2,0,0,2488.9,840.0,2908.9,66.3,187,asking_direct_explicit,2 Homura Evo FOR Alucard Evo,,insufficient,
Alucard Unevo,1,1,1,0,0,1037.9,985.1,1077.5,5.1,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,65 | 536 | 1334,insufficient,
Android 21 Evo,1,1,1,0,0,1.0,1.0,840.0,83896.7,187,asking_direct_explicit,2 Homura Evo FOR Alucard Evo,52,insufficient,
Buddha Evo,5,5,3,2,0,258.1,172.2,441.4,71.1,800,asking_bundle_inferred,2 Homura Evo+Buddha Evo -> Aizen Evo,,unstable,
Chuuni Evo,6,6,2,4,0,254.2,154.5,328.3,39.2,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,,unstable,
Cid Evo,5,5,3,2,0,252.6,148.3,331.1,41.3,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,,unstable,
Cid Unevo,1,1,1,0,0,65.8,17.7,70.3,73.1,228,asking_direct_explicit,Shiny Chuuni Evo for Aizen Evo,463,insufficient,
Cream Evo,1,1,0,1,0,451.5,442.7,457.2,2.0,800,asking_bundle_inferred,2 Homura Evo+Buddha Evo -> Aizen Evo,1101,insufficient,
Dark Mage Evo,16,16,5,11,0,261.5,150.6,345.9,42.4,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,,unstable,
Elf Mage Evo,1,1,0,1,0,1000.0,1000.0,1000.0,0.0,52,asking_direct_explicit,MY Shiny Gilgamesh Evo FOR THORFINN Evo,1641,insufficient,
Gilgamesh Unevo,1,1,1,0,0,286.6,204.0,462.9,61.5,800,asking_bundle_inferred,2 Homura Evo+Buddha Evo -> Aizen Evo,115,insufficient,
Homura Evo,12,12,8,4,0,1360.1,694.9,1858.5,48.9,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,,unstable,
Ice Lily Evo,1,1,1,0,0,596.5,462.0,697.2,22.6,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,536 | 1334,insufficient,
Jelly Evo,1,1,1,0,0,532.9,508.9,535.1,4.5,228,asking_direct_explicit,Shiny Chuuni Evo for Aizen Evo,463,insufficient,
Jiraiya Evo,1,1,0,1,0,526.3,494.7,593.0,12.7,1378,asking_direct_explicit,MY 2 Poseidon Evo FOR Dark Mage Evo,1306,insufficient,
Kisuke Evo,1,1,1,0,0,520.5,372.4,614.9,28.5,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,1195,insufficient,
Nagumo Evo,1,1,0,1,0,340.6,241.6,416.0,29.1,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,1540,insufficient,
Nagumo Unevo,1,1,1,0,0,65.8,17.7,70.3,73.1,228,asking_direct_explicit,Shiny Chuuni Evo for Aizen Evo,463,insufficient,
Nami Evo,1,1,0,1,0,599.9,591.8,698.6,16.5,1378,asking_direct_explicit,MY 2 Poseidon Evo FOR Dark Mage Evo,636,insufficient,
Poseidon Evo,4,4,1,3,0,118.8,1.0,159.8,99.2,1378,asking_direct_explicit,MY 2 Poseidon Evo FOR Dark Mage Evo,,unstable,
Shiny Boros Evo,1,1,1,0,0,183.8,24.8,726.8,295.5,52,asking_direct_explicit,MY Shiny Gilgamesh Evo FOR THORFINN Evo,,insufficient,
Shiny Buddha Evo,2,2,1,1,0,1520.0,1157.6,1791.2,23.8,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,536,insufficient,
Shiny Chuuni Evo,4,4,4,0,0,965.2,654.4,994.1,32.2,228,asking_direct_explicit,Shiny Chuuni Evo for Aizen Evo,,unstable,
Shiny Dark Mage Evo,4,4,3,1,0,986.0,646.4,1304.6,34.4,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,,unstable,
Shiny Elf Mage Evo,1,1,1,0,0,207.6,198.6,332.9,60.4,228,asking_direct_explicit,Shiny Chuuni Evo for Aizen Evo,47,insufficient,
Shiny Emilia Evo,1,1,1,0,0,1688.3,1357.1,1784.6,19.6,52,asking_direct_explicit,MY Shiny Gilgamesh Evo FOR THORFINN Evo,174,insufficient,
Shiny Gilgamesh Evo,2,2,2,0,0,1690.4,726.8,1971.6,57.0,52,asking_direct_explicit,MY Shiny Gilgamesh Evo FOR THORFINN Evo,,insufficient,
Shiny Homura Evo,3,3,3,0,0,2116.6,1602.2,2225.4,24.3,52,asking_bundle_explicit,MY Android 21 Evo + Alucard Evo FOR Shiny Homura Evo,,ranked,
Shiny Issei Evo,1,1,1,0,0,596.5,462.0,697.2,22.6,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,536 | 1334,insufficient,
Shiny Killstreak Evo,1,1,0,1,0,340.6,241.6,416.0,29.1,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,490,insufficient,
Shiny Mamy Evo,2,2,2,0,0,169.2,1.0,347.2,105.2,776,asking_bundle_explicit,My Shiny Mamy Evo and Shiny Dark Mage Evo for Aizen Evo,,insufficient,
Shiny Nagumo Evo,2,2,2,0,0,520.7,491.9,577.3,10.9,65,asking_direct_explicit,2 Shiny Nagumo Evo for Alucard Unevo,536 | 1334,insufficient,
Shiny Piccolo Evo,1,1,1,0,0,207.6,198.6,332.9,60.4,228,asking_direct_explicit,Shiny Chuuni Evo for Aizen Evo,47,insufficient,
Shiny Poseidon Evo,2,2,2,0,0,942.0,525.8,988.0,44.2,1357,asking_direct_explicit,MY Shiny Poseidon Evo FOR Shiny Chuuni Evo,,insufficient,
Shiny Power Evo,1,1,1,0,0,1091.8,686.7,1177.4,37.1,52,asking_bundle_explicit,MY Android 21 Evo + Alucard Evo FOR Shiny Homura Evo,1138,insufficient,
Shiny Sakamoto Evo,1,1,1,0,0,532.9,508.9,535.1,4.5,228,asking_direct_explicit,Shiny Chuuni Evo for Aizen Evo,463,insufficient,
Shiny Saki Evo,1,1,1,0,0,362.1,101.5,557.4,72.0,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,1702,insufficient,
Shiny Somber Evo,1,1,1,0,0,532.9,508.9,535.1,4.5,228,asking_direct_explicit,Shiny Chuuni Evo for Aizen Evo,463,insufficient,
Shiny Tiger Evo,1,1,1,0,0,362.1,101.5,557.4,72.0,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,1702,insufficient,
Shiny Yoshina Evo,1,1,1,0,0,686.8,466.5,899.5,32.1,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,,insufficient,
Skull Knight Evo,1,1,1,0,0,674.5,564.9,754.6,16.3,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,1265,insufficient,
Skull Knight Unevo,1,1,0,1,0,452.4,448.6,459.1,1.5,1624,asking_direct_explicit,MY Cid Evo FOR Dark Mage Evo,1543,insufficient,
Thorfinn Evo,2,2,2,0,0,1750.6,846.2,2116.1,51.7,366,asking_bundle_explicit,My Aizen Evo and Homura Evo for Thorfinn Evo,,insufficient,
1 unit_variant quote_count asking_quote_count explicit_ask_count inferred_ask_count completed_trade_count full_fit_value leave_one_out_min leave_one_out_max max_change_pct most_influential_source_row most_influential_evidence_type most_influential_quote disconnects_when_removed status conflicting_source_rows
2 Aizen Evo 8 8 6 2 0 1000.0 1000.0 1000.0 0.0 reference
3 Alucard Evo 2 2 2 0 0 2488.9 840.0 2908.9 66.3 187 asking_direct_explicit 2 Homura Evo FOR Alucard Evo insufficient
4 Alucard Unevo 1 1 1 0 0 1037.9 985.1 1077.5 5.1 1687 asking_direct_explicit MY Homura Evo FOR 6 Aizen Evo 65 | 536 | 1334 insufficient
5 Android 21 Evo 1 1 1 0 0 1.0 1.0 840.0 83896.7 187 asking_direct_explicit 2 Homura Evo FOR Alucard Evo 52 insufficient
6 Buddha Evo 5 5 3 2 0 258.1 172.2 441.4 71.1 800 asking_bundle_inferred 2 Homura Evo+Buddha Evo -> Aizen Evo unstable
7 Chuuni Evo 6 6 2 4 0 254.2 154.5 328.3 39.2 1687 asking_direct_explicit MY Homura Evo FOR 6 Aizen Evo unstable
8 Cid Evo 5 5 3 2 0 252.6 148.3 331.1 41.3 1687 asking_direct_explicit MY Homura Evo FOR 6 Aizen Evo unstable
9 Cid Unevo 1 1 1 0 0 65.8 17.7 70.3 73.1 228 asking_direct_explicit Shiny Chuuni Evo for Aizen Evo 463 insufficient
10 Cream Evo 1 1 0 1 0 451.5 442.7 457.2 2.0 800 asking_bundle_inferred 2 Homura Evo+Buddha Evo -> Aizen Evo 1101 insufficient
11 Dark Mage Evo 16 16 5 11 0 261.5 150.6 345.9 42.4 1687 asking_direct_explicit MY Homura Evo FOR 6 Aizen Evo unstable
12 Elf Mage Evo 1 1 0 1 0 1000.0 1000.0 1000.0 0.0 52 asking_direct_explicit MY Shiny Gilgamesh Evo FOR THORFINN Evo 1641 insufficient
13 Gilgamesh Unevo 1 1 1 0 0 286.6 204.0 462.9 61.5 800 asking_bundle_inferred 2 Homura Evo+Buddha Evo -> Aizen Evo 115 insufficient
14 Homura Evo 12 12 8 4 0 1360.1 694.9 1858.5 48.9 1687 asking_direct_explicit MY Homura Evo FOR 6 Aizen Evo unstable
15 Ice Lily Evo 1 1 1 0 0 596.5 462.0 697.2 22.6 1687 asking_direct_explicit MY Homura Evo FOR 6 Aizen Evo 536 | 1334 insufficient
16 Jelly Evo 1 1 1 0 0 532.9 508.9 535.1 4.5 228 asking_direct_explicit Shiny Chuuni Evo for Aizen Evo 463 insufficient
17 Jiraiya Evo 1 1 0 1 0 526.3 494.7 593.0 12.7 1378 asking_direct_explicit MY 2 Poseidon Evo FOR Dark Mage Evo 1306 insufficient
18 Kisuke Evo 1 1 1 0 0 520.5 372.4 614.9 28.5 1687 asking_direct_explicit MY Homura Evo FOR 6 Aizen Evo 1195 insufficient
19 Nagumo Evo 1 1 0 1 0 340.6 241.6 416.0 29.1 1687 asking_direct_explicit MY Homura Evo FOR 6 Aizen Evo 1540 insufficient
20 Nagumo Unevo 1 1 1 0 0 65.8 17.7 70.3 73.1 228 asking_direct_explicit Shiny Chuuni Evo for Aizen Evo 463 insufficient
21 Nami Evo 1 1 0 1 0 599.9 591.8 698.6 16.5 1378 asking_direct_explicit MY 2 Poseidon Evo FOR Dark Mage Evo 636 insufficient
22 Poseidon Evo 4 4 1 3 0 118.8 1.0 159.8 99.2 1378 asking_direct_explicit MY 2 Poseidon Evo FOR Dark Mage Evo unstable
23 Shiny Boros Evo 1 1 1 0 0 183.8 24.8 726.8 295.5 52 asking_direct_explicit MY Shiny Gilgamesh Evo FOR THORFINN Evo insufficient
24 Shiny Buddha Evo 2 2 1 1 0 1520.0 1157.6 1791.2 23.8 1687 asking_direct_explicit MY Homura Evo FOR 6 Aizen Evo 536 insufficient
25 Shiny Chuuni Evo 4 4 4 0 0 965.2 654.4 994.1 32.2 228 asking_direct_explicit Shiny Chuuni Evo for Aizen Evo unstable
26 Shiny Dark Mage Evo 4 4 3 1 0 986.0 646.4 1304.6 34.4 1687 asking_direct_explicit MY Homura Evo FOR 6 Aizen Evo unstable
27 Shiny Elf Mage Evo 1 1 1 0 0 207.6 198.6 332.9 60.4 228 asking_direct_explicit Shiny Chuuni Evo for Aizen Evo 47 insufficient
28 Shiny Emilia Evo 1 1 1 0 0 1688.3 1357.1 1784.6 19.6 52 asking_direct_explicit MY Shiny Gilgamesh Evo FOR THORFINN Evo 174 insufficient
29 Shiny Gilgamesh Evo 2 2 2 0 0 1690.4 726.8 1971.6 57.0 52 asking_direct_explicit MY Shiny Gilgamesh Evo FOR THORFINN Evo insufficient
30 Shiny Homura Evo 3 3 3 0 0 2116.6 1602.2 2225.4 24.3 52 asking_bundle_explicit MY Android 21 Evo + Alucard Evo FOR Shiny Homura Evo ranked
31 Shiny Issei Evo 1 1 1 0 0 596.5 462.0 697.2 22.6 1687 asking_direct_explicit MY Homura Evo FOR 6 Aizen Evo 536 | 1334 insufficient
32 Shiny Killstreak Evo 1 1 0 1 0 340.6 241.6 416.0 29.1 1687 asking_direct_explicit MY Homura Evo FOR 6 Aizen Evo 490 insufficient
33 Shiny Mamy Evo 2 2 2 0 0 169.2 1.0 347.2 105.2 776 asking_bundle_explicit My Shiny Mamy Evo and Shiny Dark Mage Evo for Aizen Evo insufficient
34 Shiny Nagumo Evo 2 2 2 0 0 520.7 491.9 577.3 10.9 65 asking_direct_explicit 2 Shiny Nagumo Evo for Alucard Unevo 536 | 1334 insufficient
35 Shiny Piccolo Evo 1 1 1 0 0 207.6 198.6 332.9 60.4 228 asking_direct_explicit Shiny Chuuni Evo for Aizen Evo 47 insufficient
36 Shiny Poseidon Evo 2 2 2 0 0 942.0 525.8 988.0 44.2 1357 asking_direct_explicit MY Shiny Poseidon Evo FOR Shiny Chuuni Evo insufficient
37 Shiny Power Evo 1 1 1 0 0 1091.8 686.7 1177.4 37.1 52 asking_bundle_explicit MY Android 21 Evo + Alucard Evo FOR Shiny Homura Evo 1138 insufficient
38 Shiny Sakamoto Evo 1 1 1 0 0 532.9 508.9 535.1 4.5 228 asking_direct_explicit Shiny Chuuni Evo for Aizen Evo 463 insufficient
39 Shiny Saki Evo 1 1 1 0 0 362.1 101.5 557.4 72.0 1687 asking_direct_explicit MY Homura Evo FOR 6 Aizen Evo 1702 insufficient
40 Shiny Somber Evo 1 1 1 0 0 532.9 508.9 535.1 4.5 228 asking_direct_explicit Shiny Chuuni Evo for Aizen Evo 463 insufficient
41 Shiny Tiger Evo 1 1 1 0 0 362.1 101.5 557.4 72.0 1687 asking_direct_explicit MY Homura Evo FOR 6 Aizen Evo 1702 insufficient
42 Shiny Yoshina Evo 1 1 1 0 0 686.8 466.5 899.5 32.1 1687 asking_direct_explicit MY Homura Evo FOR 6 Aizen Evo insufficient
43 Skull Knight Evo 1 1 1 0 0 674.5 564.9 754.6 16.3 1687 asking_direct_explicit MY Homura Evo FOR 6 Aizen Evo 1265 insufficient
44 Skull Knight Unevo 1 1 0 1 0 452.4 448.6 459.1 1.5 1624 asking_direct_explicit MY Cid Evo FOR Dark Mage Evo 1543 insufficient
45 Thorfinn Evo 2 2 2 0 0 1750.6 846.2 2116.1 51.7 366 asking_bundle_explicit My Aizen Evo and Homura Evo for Thorfinn Evo insufficient
+685 -904
View File
File diff suppressed because it is too large Load Diff
+845 -26
View File
File diff suppressed because it is too large Load Diff
+46
View File
@@ -0,0 +1,46 @@
unit_variant,all_fit,all_ranked_value,all_confidence,all_explicit_asks,all_inferred_asks,explicit_only_fit,explicit_only_ranked_value,explicit_only_confidence,change_pct_without_inferred,explicit_only_connection
Aizen Evo,1000.0,1000,low,6,2,1000.0,1000,low,0.0,connected
Alucard Evo,2488.9,,insufficient,2,0,3033.2,,insufficient,21.9,connected
Alucard Unevo,1037.9,,insufficient,1,0,,,disconnected,,disconnected
Android 21 Evo,1.0,,insufficient,1,0,1.0,,insufficient,0.0,connected
Buddha Evo,258.1,,unstable,3,2,804.8,,unstable,211.8,connected
Chuuni Evo,254.2,,unstable,2,4,348.1,,insufficient,36.9,connected
Cid Evo,252.6,,unstable,3,2,350.7,,unstable,38.8,connected
Cid Unevo,65.8,,insufficient,1,0,66.5,,insufficient,1.1,connected
Cream Evo,451.5,,insufficient,0,1,,,disconnected,,disconnected
Dark Mage Evo,261.5,,unstable,5,11,340.8,,unstable,30.3,connected
Elf Mage Evo,1000.0,,insufficient,0,1,,,disconnected,,disconnected
Gilgamesh Unevo,286.6,,insufficient,1,0,812.3,,insufficient,183.4,connected
Homura Evo,1360.1,,unstable,8,4,1669.1,,unstable,22.7,connected
Ice Lily Evo,596.5,,insufficient,1,0,,,disconnected,,disconnected
Jelly Evo,532.9,,insufficient,1,0,533.2,,insufficient,0.1,connected
Jiraiya Evo,526.3,,insufficient,0,1,,,disconnected,,disconnected
Kisuke Evo,520.5,,insufficient,1,0,455.6,,insufficient,-12.5,connected
Nagumo Evo,340.6,,insufficient,0,1,,,disconnected,,disconnected
Nagumo Unevo,65.8,,insufficient,1,0,66.5,,insufficient,1.1,connected
Nami Evo,599.9,,insufficient,0,1,,,disconnected,,disconnected
Poseidon Evo,118.8,,unstable,1,3,188.6,,insufficient,58.8,connected
Shiny Aizen Evo,,,constraint_only,0,0,,,constraint_only,,constraint_only
Shiny Boros Evo,183.8,,insufficient,1,0,67.0,,insufficient,-63.5,connected
Shiny Buddha Evo,1520.0,,insufficient,1,1,,,disconnected,,disconnected
Shiny Chuuni Evo,965.2,,unstable,4,0,969.4,,unstable,0.4,connected
Shiny Dark Mage Evo,986.0,,unstable,3,1,820.6,,unstable,-16.8,connected
Shiny Elf Mage Evo,207.6,,insufficient,1,0,205.9,,insufficient,-0.8,connected
Shiny Emilia Evo,1688.3,,insufficient,1,0,1730.7,,insufficient,2.5,connected
Shiny Gilgamesh Evo,1690.4,,insufficient,2,0,1861.1,,insufficient,10.1,connected
Shiny Homura Evo,2116.6,2100,very_low,3,0,2312.0,,unstable,9.2,connected
Shiny Issei Evo,596.5,,insufficient,1,0,,,disconnected,,disconnected
Shiny Killstreak Evo,340.6,,insufficient,0,1,,,disconnected,,disconnected
Shiny Mamy Evo,169.2,,insufficient,2,0,267.8,,insufficient,58.3,connected
Shiny Nagumo Evo,520.7,,insufficient,2,0,,,disconnected,,disconnected
Shiny Piccolo Evo,207.6,,insufficient,1,0,205.9,,insufficient,-0.8,connected
Shiny Poseidon Evo,942.0,,insufficient,2,0,950.7,,insufficient,0.9,connected
Shiny Power Evo,1091.8,,insufficient,1,0,1245.6,,insufficient,14.1,connected
Shiny Sakamoto Evo,532.9,,insufficient,1,0,533.2,,insufficient,0.1,connected
Shiny Saki Evo,362.1,,insufficient,1,0,483.2,,insufficient,33.4,connected
Shiny Somber Evo,532.9,,insufficient,1,0,533.2,,insufficient,0.1,connected
Shiny Tiger Evo,362.1,,insufficient,1,0,483.2,,insufficient,33.4,connected
Shiny Yoshina Evo,686.8,,insufficient,1,0,468.9,,insufficient,-31.7,connected
Skull Knight Evo,674.5,,insufficient,1,0,661.6,,insufficient,-1.9,connected
Skull Knight Unevo,452.4,,insufficient,0,1,,,disconnected,,disconnected
Thorfinn Evo,1750.6,,insufficient,2,0,1932.8,,insufficient,10.4,connected
1 unit_variant all_fit all_ranked_value all_confidence all_explicit_asks all_inferred_asks explicit_only_fit explicit_only_ranked_value explicit_only_confidence change_pct_without_inferred explicit_only_connection
2 Aizen Evo 1000.0 1000 low 6 2 1000.0 1000 low 0.0 connected
3 Alucard Evo 2488.9 insufficient 2 0 3033.2 insufficient 21.9 connected
4 Alucard Unevo 1037.9 insufficient 1 0 disconnected disconnected
5 Android 21 Evo 1.0 insufficient 1 0 1.0 insufficient 0.0 connected
6 Buddha Evo 258.1 unstable 3 2 804.8 unstable 211.8 connected
7 Chuuni Evo 254.2 unstable 2 4 348.1 insufficient 36.9 connected
8 Cid Evo 252.6 unstable 3 2 350.7 unstable 38.8 connected
9 Cid Unevo 65.8 insufficient 1 0 66.5 insufficient 1.1 connected
10 Cream Evo 451.5 insufficient 0 1 disconnected disconnected
11 Dark Mage Evo 261.5 unstable 5 11 340.8 unstable 30.3 connected
12 Elf Mage Evo 1000.0 insufficient 0 1 disconnected disconnected
13 Gilgamesh Unevo 286.6 insufficient 1 0 812.3 insufficient 183.4 connected
14 Homura Evo 1360.1 unstable 8 4 1669.1 unstable 22.7 connected
15 Ice Lily Evo 596.5 insufficient 1 0 disconnected disconnected
16 Jelly Evo 532.9 insufficient 1 0 533.2 insufficient 0.1 connected
17 Jiraiya Evo 526.3 insufficient 0 1 disconnected disconnected
18 Kisuke Evo 520.5 insufficient 1 0 455.6 insufficient -12.5 connected
19 Nagumo Evo 340.6 insufficient 0 1 disconnected disconnected
20 Nagumo Unevo 65.8 insufficient 1 0 66.5 insufficient 1.1 connected
21 Nami Evo 599.9 insufficient 0 1 disconnected disconnected
22 Poseidon Evo 118.8 unstable 1 3 188.6 insufficient 58.8 connected
23 Shiny Aizen Evo constraint_only 0 0 constraint_only constraint_only
24 Shiny Boros Evo 183.8 insufficient 1 0 67.0 insufficient -63.5 connected
25 Shiny Buddha Evo 1520.0 insufficient 1 1 disconnected disconnected
26 Shiny Chuuni Evo 965.2 unstable 4 0 969.4 unstable 0.4 connected
27 Shiny Dark Mage Evo 986.0 unstable 3 1 820.6 unstable -16.8 connected
28 Shiny Elf Mage Evo 207.6 insufficient 1 0 205.9 insufficient -0.8 connected
29 Shiny Emilia Evo 1688.3 insufficient 1 0 1730.7 insufficient 2.5 connected
30 Shiny Gilgamesh Evo 1690.4 insufficient 2 0 1861.1 insufficient 10.1 connected
31 Shiny Homura Evo 2116.6 2100 very_low 3 0 2312.0 unstable 9.2 connected
32 Shiny Issei Evo 596.5 insufficient 1 0 disconnected disconnected
33 Shiny Killstreak Evo 340.6 insufficient 0 1 disconnected disconnected
34 Shiny Mamy Evo 169.2 insufficient 2 0 267.8 insufficient 58.3 connected
35 Shiny Nagumo Evo 520.7 insufficient 2 0 disconnected disconnected
36 Shiny Piccolo Evo 207.6 insufficient 1 0 205.9 insufficient -0.8 connected
37 Shiny Poseidon Evo 942.0 insufficient 2 0 950.7 insufficient 0.9 connected
38 Shiny Power Evo 1091.8 insufficient 1 0 1245.6 insufficient 14.1 connected
39 Shiny Sakamoto Evo 532.9 insufficient 1 0 533.2 insufficient 0.1 connected
40 Shiny Saki Evo 362.1 insufficient 1 0 483.2 insufficient 33.4 connected
41 Shiny Somber Evo 532.9 insufficient 1 0 533.2 insufficient 0.1 connected
42 Shiny Tiger Evo 362.1 insufficient 1 0 483.2 insufficient 33.4 connected
43 Shiny Yoshina Evo 686.8 insufficient 1 0 468.9 insufficient -31.7 connected
44 Skull Knight Evo 674.5 insufficient 1 0 661.6 insufficient -1.9 connected
45 Skull Knight Unevo 452.4 insufficient 0 1 disconnected disconnected
46 Thorfinn Evo 1750.6 insufficient 2 0 1932.8 insufficient 10.4 connected
+22 -13
View File
@@ -1,16 +1,25 @@
source_row,quote_type,offered_unit,offered_qty,requested_unit,requested_qty,requested_units_per_offered_unit,source_text
6,explicit_for,Alucard Evo,1,Aizen Evo,1,1.0,MY Alucard Evo FOR Aizen Evo
52,explicit_for,Shiny Gilgamesh Evo,1,Thorfinn Evo,1,1.0,MY Shiny Gilgamesh Evo FOR THORFINN Evo
65,explicit_for,Shiny Nagumo Evo,2,Alucard Unevo,1,0.5,2 Shiny Nagumo Evo for Alucard Unevo
115,explicit_for,Buddha Evo,1,Gilgamesh Unevo,1,1.0,Gilgamesh Unevo for my Buddha Evo
190,explicit_for,Homura Evo,2,Alucard Evo,1,0.5,2 Homura Evo FOR Alucard Evo
381,explicit_for,Shiny Siren Unevo,1,Shiny Elf Mage Unevo,1,1.0,My Shiny Siren Unevo for Shiny Elf Mage Unevo
383,listing_pair,Shiny Dark Mage Evo,1,Dark Mage Evo,5,5.0,Shiny Dark Mage Evo -> 5 Dark Mage Evo
495,listing_pair,Shiny Killstreak Evo,1,Dark Mage Evo,1,1.0,Shiny Killstreak Evo -> Dark Mage Evo
593,explicit_for,Shiny Cream Evo,1,Shiny Deer Tan Evo,1,1.0,Shiny Cream Evo for Shiny Deer Tan Evo
720,explicit_for,Shiny Siren Unevo,1,Shiny Elf Mage Unevo,1,1.0,My Shiny Siren Unevo for Shiny Elf Mage Unevo
755,listing_pair,Chuuni Evo,1,Dark Mage Evo,1,1.0,Chuuni Evo -> Dark Mage Evo
761,listing_pair,Shizo Evo,1,Rohan Evo,1,1.0,SHIZO Evo -> ROHAN Evo
953,explicit_for,Homura Evo,1,Alucard Evo,1,1.0,my Homura Evo for Alucard Evo
1084,listing_pair,Dark Mage Evo,6,Homura Evo,1,0.1667,6 Dark Mage Evo -> Homura Evo
1118,explicit_for,Dark Mage Evo,5,Homura Evo,1,0.2,MY 5 Dark Mage Evo FOR Homura Evo
1248,listing_pair,Dark Mage Evo,6,Homura Evo,1,0.1667,6 Dark Mage Evo -> Homura Evo
187,explicit_for,Homura Evo,2,Alucard Evo,1,0.5,2 Homura Evo FOR Alucard Evo
228,explicit_for,Shiny Chuuni Evo,1,Aizen Evo,1,1.0,Shiny Chuuni Evo for Aizen Evo
377,explicit_for,Shiny Siren Unevo,1,Shiny Elf Mage Unevo,1,1.0,My Shiny Siren Unevo for Shiny Elf Mage Unevo
379,listing_pair,Shiny Dark Mage Evo,1,Dark Mage Evo,5,5.0,Shiny Dark Mage Evo -> 5 Dark Mage Evo
468,listing_pair,Buddha Evo,1,Chuuni Evo,1,1.0,Buddha Evo -> Chuuni Evo
490,listing_pair,Shiny Killstreak Evo,1,Dark Mage Evo,1,1.0,Shiny Killstreak Evo -> Dark Mage Evo
588,explicit_for,Shiny Cream Evo,1,Shiny Deer Tan Evo,1,1.0,Shiny Cream Evo for Shiny Deer Tan Evo
715,explicit_for,Shiny Siren Unevo,1,Shiny Elf Mage Unevo,1,1.0,My Shiny Siren Unevo for Shiny Elf Mage Unevo
750,listing_pair,Chuuni Evo,1,Dark Mage Evo,1,1.0,Chuuni Evo -> Dark Mage Evo
756,listing_pair,Shizo Evo,1,Rohan Evo,1,1.0,SHIZO Evo -> ROHAN Evo
1078,listing_pair,Dark Mage Evo,6,Homura Evo,1,0.1667,6 Dark Mage Evo -> Homura Evo
1112,explicit_for,Dark Mage Evo,5,Homura Evo,1,0.2,MY 5 Dark Mage Evo FOR Homura Evo
1241,listing_pair,Dark Mage Evo,6,Homura Evo,1,0.1667,6 Dark Mage Evo -> Homura Evo
1357,explicit_for,Shiny Poseidon Evo,1,Shiny Chuuni Evo,1,1.0,MY Shiny Poseidon Evo FOR Shiny Chuuni Evo
1378,explicit_for,Poseidon Evo,2,Dark Mage Evo,1,0.5,MY 2 Poseidon Evo FOR Dark Mage Evo
1540,listing_pair,Nagumo Evo,1,Dark Mage Evo,1,1.0,Nagumo Evo -> Dark Mage Evo
1624,explicit_for,Cid Evo,1,Dark Mage Evo,1,1.0,MY Cid Evo FOR Dark Mage Evo
1641,listing_pair,Aizen Evo,1,Elf Mage Evo,1,1.0,Aizen Evo -> Elf Mage Evo
1675,explicit_for,Chuuni Evo,1,Dark Mage Evo,1,1.0,Chuuni Evo for Dark Mage Evo
1675,explicit_for,Chuuni Evo,1,Cid Evo,1,1.0,Cid Evo for Chuuni Evo
1687,explicit_for,Homura Evo,1,Aizen Evo,6,6.0,MY Homura Evo FOR 6 Aizen Evo
1 source_row quote_type offered_unit offered_qty requested_unit requested_qty requested_units_per_offered_unit source_text
2 6 52 explicit_for Alucard Evo Shiny Gilgamesh Evo 1 Aizen Evo Thorfinn Evo 1 1.0 MY Alucard Evo FOR Aizen Evo MY Shiny Gilgamesh Evo FOR THORFINN Evo
3 65 explicit_for Shiny Nagumo Evo 2 Alucard Unevo 1 0.5 2 Shiny Nagumo Evo for Alucard Unevo
4 115 explicit_for Buddha Evo 1 Gilgamesh Unevo 1 1.0 Gilgamesh Unevo for my Buddha Evo
5 190 187 explicit_for Homura Evo 2 Alucard Evo 1 0.5 2 Homura Evo FOR Alucard Evo
6 381 228 explicit_for Shiny Siren Unevo Shiny Chuuni Evo 1 Shiny Elf Mage Unevo Aizen Evo 1 1.0 My Shiny Siren Unevo for Shiny Elf Mage Unevo Shiny Chuuni Evo for Aizen Evo
7 383 377 listing_pair explicit_for Shiny Dark Mage Evo Shiny Siren Unevo 1 Dark Mage Evo Shiny Elf Mage Unevo 5 1 5.0 1.0 Shiny Dark Mage Evo -> 5 Dark Mage Evo My Shiny Siren Unevo for Shiny Elf Mage Unevo
8 495 379 listing_pair Shiny Killstreak Evo Shiny Dark Mage Evo 1 Dark Mage Evo 1 5 1.0 5.0 Shiny Killstreak Evo -> Dark Mage Evo Shiny Dark Mage Evo -> 5 Dark Mage Evo
9 593 468 explicit_for listing_pair Shiny Cream Evo Buddha Evo 1 Shiny Deer Tan Evo Chuuni Evo 1 1.0 Shiny Cream Evo for Shiny Deer Tan Evo Buddha Evo -> Chuuni Evo
10 720 490 explicit_for listing_pair Shiny Siren Unevo Shiny Killstreak Evo 1 Shiny Elf Mage Unevo Dark Mage Evo 1 1.0 My Shiny Siren Unevo for Shiny Elf Mage Unevo Shiny Killstreak Evo -> Dark Mage Evo
11 755 588 listing_pair explicit_for Chuuni Evo Shiny Cream Evo 1 Dark Mage Evo Shiny Deer Tan Evo 1 1.0 Chuuni Evo -> Dark Mage Evo Shiny Cream Evo for Shiny Deer Tan Evo
12 761 715 listing_pair explicit_for Shizo Evo Shiny Siren Unevo 1 Rohan Evo Shiny Elf Mage Unevo 1 1.0 SHIZO Evo -> ROHAN Evo My Shiny Siren Unevo for Shiny Elf Mage Unevo
13 953 750 explicit_for listing_pair Homura Evo Chuuni Evo 1 Alucard Evo Dark Mage Evo 1 1.0 my Homura Evo for Alucard Evo Chuuni Evo -> Dark Mage Evo
14 1084 756 listing_pair Dark Mage Evo Shizo Evo 6 1 Homura Evo Rohan Evo 1 0.1667 1.0 6 Dark Mage Evo -> Homura Evo SHIZO Evo -> ROHAN Evo
15 1118 1078 explicit_for listing_pair Dark Mage Evo 5 6 Homura Evo 1 0.2 0.1667 MY 5 Dark Mage Evo FOR Homura Evo 6 Dark Mage Evo -> Homura Evo
16 1248 1112 listing_pair explicit_for Dark Mage Evo 6 5 Homura Evo 1 0.1667 0.2 6 Dark Mage Evo -> Homura Evo MY 5 Dark Mage Evo FOR Homura Evo
17 1241 listing_pair Dark Mage Evo 6 Homura Evo 1 0.1667 6 Dark Mage Evo -> Homura Evo
18 1357 explicit_for Shiny Poseidon Evo 1 Shiny Chuuni Evo 1 1.0 MY Shiny Poseidon Evo FOR Shiny Chuuni Evo
19 1378 explicit_for Poseidon Evo 2 Dark Mage Evo 1 0.5 MY 2 Poseidon Evo FOR Dark Mage Evo
20 1540 listing_pair Nagumo Evo 1 Dark Mage Evo 1 1.0 Nagumo Evo -> Dark Mage Evo
21 1624 explicit_for Cid Evo 1 Dark Mage Evo 1 1.0 MY Cid Evo FOR Dark Mage Evo
22 1641 listing_pair Aizen Evo 1 Elf Mage Evo 1 1.0 Aizen Evo -> Elf Mage Evo
23 1675 explicit_for Chuuni Evo 1 Dark Mage Evo 1 1.0 Chuuni Evo for Dark Mage Evo
24 1675 explicit_for Chuuni Evo 1 Cid Evo 1 1.0 Cid Evo for Chuuni Evo
25 1687 explicit_for Homura Evo 1 Aizen Evo 6 6.0 MY Homura Evo FOR 6 Aizen Evo
+14
View File
@@ -21,6 +21,18 @@ FOR = re.compile(r"\bfor\b", re.IGNORECASE)
FIELDS = ("source_row", "quote_type", "offered_unit", "offered_qty",
"requested_unit", "requested_qty", "requested_units_per_offered_unit",
"source_text")
STAT_QUALITY = re.compile(
r"\b(?:SSS|SS|FULL\s+S|PERF(?:ECT)?\s+SPA)\b|"
r"\b[A-S][+-]?\s*/\s*(?:SSS|SS|[A-S][+-]?)\b|"
r"\b\d+\s+[A-S][+-]?\s*,\s*[A-S][+-]?\s*,\s*[A-S][+-]?\b|"
r"\b\d+(?:[.,]\d+)?\s*%", re.I,
)
def only_stat_specific_inventory(offer: str, unit: str) -> bool:
"""An unqualified quote cannot price a unit only listed with stat quality."""
mentions = [part for part in offer.split("|") if unit in variants(part)]
return bool(mentions) and all(STAT_QUALITY.search(part) for part in mentions)
def parse_side(text: str) -> tuple[str, int, str | None] | None:
@@ -77,6 +89,8 @@ def extract_quotes(rows: list[dict[str, str]]) -> list[dict[str, str | int | flo
continue
if offered[0] not in offered_inventory:
continue
if only_stat_specific_inventory(row.get("offer") or "", offered[0]):
continue
key = (author, offered[0], offered[1], requested[0], requested[1])
if key in seen:
continue
+35 -34
View File
@@ -1,35 +1,36 @@
unit_variant,interest_index,requested_by,offered_by,total_mentions
Thorfinn Evo,1600,34,7,41
Aizen Evo,354,142,174,316
Homura Evo,247,148,261,409
Shiny Aizen Evo,234,10,21,31
Mamy Evo,233,11,23,34
Shiny Skull Knight Evo,216,9,21,30
Shiny Homura Evo,210,14,32,46
Alucard Evo,186,47,113,160
Shiny Idol Evo,185,6,18,24
Shiny Power Evo,182,5,16,21
Shiny Vengeful Swordsman Evo,180,7,21,28
Shiny Cid Evo,171,12,35,47
Shiny Dark Mage Evo,142,19,64,83
Roger Evo,124,15,60,75
Shiny Mamy Evo,116,11,49,60
Shiny Chuuni Evo,105,20,92,112
Chuuni Evo,103,40,178,218
Shiny Buddha Evo,97,6,37,43
Dark Mage Unevo,95,6,38,44
Somber Evo,93,6,39,45
Dark Mage Evo,89,66,333,399
Shiny Poseidon Evo,80,5,40,45
Shiny Inhuman Evo,75,5,43,48
Shiny Gilgamesh Evo,67,6,55,61
Gilgamesh Evo,63,25,189,214
Sakamoto Evo,57,5,58,63
Poseidon Evo,55,10,100,110
Buddha Evo,54,22,198,220
Shiny Elf Mage Evo,51,7,81,88
Shiny Nagumo Evo,49,5,68,73
Shiny Somber Evo,46,5,72,77
Cid Evo,44,18,205,223
Vengeful Swordsman Evo,39,9,131,140
Nagumo Evo,28,12,228,240
Thorfinn Evo,2243,50,6,56
Aizen Evo,307,195,243,438
Dio Evo,279,8,12,20
Shiny Aizen Evo,218,13,25,38
Homura Evo,213,200,360,560
Shiny Skull Knight Evo,185,15,34,49
Shiny Homura Evo,163,15,39,54
Mamy Evo,163,12,32,44
Alucard Evo,162,62,150,212
Shiny Yoshina Evo,133,11,37,48
Shiny Vengeful Swordsman Evo,131,9,32,41
Shiny Dark Mage Evo,128,27,86,113
Shiny Mamy Evo,118,20,71,91
Shiny Boros Evo,111,6,28,34
Shiny Idol Evo,111,6,28,34
Shiny Cid Evo,106,12,51,63
Shiny Chuuni Evo,103,31,123,154
Roger Evo,100,18,77,95
Shiny Buddha Evo,82,9,53,62
Dark Mage Evo,67,79,464,543
Chuuni Evo,67,43,260,303
Shiny Inhuman Evo,61,7,59,66
Shiny Gilgamesh Evo,55,9,80,89
Shiny Poseidon Evo,54,6,60,66
Gilgamesh Evo,52,33,259,292
Dark Mage Unevo,50,5,58,63
Somber Evo,50,5,58,63
Skull Knight Evo,44,7,83,90
Buddha Evo,37,25,285,310
Vengeful Swordsman Evo,36,14,176,190
Shiny Nagumo Evo,34,6,98,104
Cid Evo,30,20,288,308
Shiny Elf Mage Evo,26,6,128,134
Poseidon Evo,24,7,156,163
Nagumo Evo,18,12,312,324
1 unit_variant interest_index requested_by offered_by total_mentions
2 Thorfinn Evo 1600 2243 34 50 7 6 41 56
3 Aizen Evo 354 307 142 195 174 243 316 438
4 Homura Evo Dio Evo 247 279 148 8 261 12 409 20
5 Shiny Aizen Evo 234 218 10 13 21 25 31 38
6 Mamy Evo Homura Evo 233 213 11 200 23 360 34 560
7 Shiny Skull Knight Evo 216 185 9 15 21 34 30 49
8 Shiny Homura Evo 210 163 14 15 32 39 46 54
9 Alucard Evo Mamy Evo 186 163 47 12 113 32 160 44
10 Shiny Idol Evo Alucard Evo 185 162 6 62 18 150 24 212
11 Shiny Power Evo Shiny Yoshina Evo 182 133 5 11 16 37 21 48
12 Shiny Vengeful Swordsman Evo 180 131 7 9 21 32 28 41
13 Shiny Cid Evo Shiny Dark Mage Evo 171 128 12 27 35 86 47 113
14 Shiny Dark Mage Evo Shiny Mamy Evo 142 118 19 20 64 71 83 91
15 Roger Evo Shiny Boros Evo 124 111 15 6 60 28 75 34
16 Shiny Mamy Evo Shiny Idol Evo 116 111 11 6 49 28 60 34
17 Shiny Chuuni Evo Shiny Cid Evo 105 106 20 12 92 51 112 63
18 Chuuni Evo Shiny Chuuni Evo 103 40 31 178 123 218 154
19 Shiny Buddha Evo Roger Evo 97 100 6 18 37 77 43 95
20 Dark Mage Unevo Shiny Buddha Evo 95 82 6 9 38 53 44 62
21 Somber Evo Dark Mage Evo 93 67 6 79 39 464 45 543
22 Dark Mage Evo Chuuni Evo 89 67 66 43 333 260 399 303
23 Shiny Poseidon Evo Shiny Inhuman Evo 80 61 5 7 40 59 45 66
24 Shiny Inhuman Evo Shiny Gilgamesh Evo 75 55 5 9 43 80 48 89
25 Shiny Gilgamesh Evo Shiny Poseidon Evo 67 54 6 55 60 61 66
26 Gilgamesh Evo 63 52 25 33 189 259 214 292
27 Sakamoto Evo Dark Mage Unevo 57 50 5 58 63
28 Poseidon Evo Somber Evo 55 50 10 5 100 58 110 63
29 Buddha Evo Skull Knight Evo 54 44 22 7 198 83 220 90
30 Shiny Elf Mage Evo Buddha Evo 51 37 7 25 81 285 88 310
31 Shiny Nagumo Evo Vengeful Swordsman Evo 49 36 5 14 68 176 73 190
32 Shiny Somber Evo Shiny Nagumo Evo 46 34 5 6 72 98 77 104
33 Cid Evo 44 30 18 20 205 288 223 308
34 Vengeful Swordsman Evo Shiny Elf Mage Evo 39 26 9 6 131 128 140 134
35 Nagumo Evo Poseidon Evo 28 24 12 7 228 156 240 163
36 Nagumo Evo 18 12 312 324
+46 -30
View File
@@ -1,30 +1,46 @@
rank,unit_variant,relative_value,confidence,quote_count,source_rows,basis,note
1,Shiny Aizen Evo,,constraint_only,0,,user_supplied_ordering,Worth more than Aizen Evo; multiplier unknown
2,Aizen Evo,1000,low,8,6 | 47 | 370 | 401 | 717 | 781 | 805 | 1145,fitted_asking_quotes,Aizen Evo = 1000 reference
3,Alucard Evo,850,low,4,6 | 190 | 401 | 953,fitted_asking_quotes,
4,Shiny Dark Mage Evo,700,very_low,2,383 | 781,fitted_asking_quotes,
5,Homura Evo,550,low,11,190 | 370 | 541 | 717 | 747 | 805 | 953 | 1084 | 1118 | 1202 | 1248,fitted_asking_quotes,
6,Buddha Evo,250,very_low,3,115 | 805 | 1202,fitted_asking_quotes,
7,Dark Mage Evo,100,low,8,383 | 495 | 641 | 755 | 1084 | 1107 | 1118 | 1248,fitted_asking_quotes,
8,Chuuni Evo,100,low,4,541 | 755 | 1107 | 1202,fitted_asking_quotes,
,Cream Evo,,insufficient,1,1107,fitted_asking_quotes,Too few independent quotes for a numeric estimate
,Gilgamesh Evo,,insufficient,1,747,fitted_asking_quotes,Too few independent quotes for a numeric estimate
,Gilgamesh Unevo,,insufficient,1,115,fitted_asking_quotes,Too few independent quotes for a numeric estimate
,Kisuke Evo,,insufficient,1,1202,fitted_asking_quotes,Too few independent quotes for a numeric estimate
,Nami Evo,,insufficient,1,641,fitted_asking_quotes,Too few independent quotes for a numeric estimate
,Poseidon Evo,,insufficient,1,641,fitted_asking_quotes,Too few independent quotes for a numeric estimate
,Roger Evo,,insufficient,1,717,fitted_asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Boros Evo,,insufficient,1,177,fitted_asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Buddha Evo,,insufficient,1,541,fitted_asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Chuuni Evo,,insufficient,2,47 | 747,fitted_asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Elf Mage Evo,,insufficient,1,47,fitted_asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Emilia Evo,,insufficient,1,177,fitted_asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Gilgamesh Evo,,insufficient,1,177,fitted_asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Homura Evo,,insufficient,2,177 | 1145,fitted_asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Ice Queen Evo,,insufficient,1,401,fitted_asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Killstreak Evo,,insufficient,1,495,fitted_asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Mamy Evo,,insufficient,2,177 | 781,fitted_asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Piccolo Evo,,insufficient,1,47,fitted_asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Power Evo,,insufficient,1,1145,fitted_asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Yoshina Evo,,insufficient,1,1202,fitted_asking_quotes,Too few independent quotes for a numeric estimate
,Thorfinn Evo,,insufficient,1,370,fitted_asking_quotes,Too few independent quotes for a numeric estimate
rank,unit_variant,relative_value,confidence,quote_count,asking_quote_count,explicit_ask_count,inferred_ask_count,completed_trade_count,source_rows,basis,note
1,Shiny Homura Evo,2100,very_low,3,3,3,0,0,52 | 174 | 1138,asking_quotes,
2,Shiny Aizen Evo,,constraint_only,0,0,0,0,0,,user_supplied_ordering,Worth more than Aizen Evo; multiplier unknown
3,Aizen Evo,1000,low,8,8,6,2,0,47 | 228 | 366 | 776 | 800 | 1138 | 1641 | 1687,asking_quotes,Aizen Evo = 1000 reference
,Alucard Evo,,insufficient,2,2,2,0,0,52 | 187,asking_quotes,Too few independent quotes for a numeric estimate
,Alucard Unevo,,insufficient,1,1,1,0,0,65,asking_quotes,Too few independent quotes for a numeric estimate
,Android 21 Evo,,insufficient,1,1,1,0,0,52,asking_quotes,Too few independent quotes for a numeric estimate
,Buddha Evo,,unstable,5,5,3,2,0,115 | 253 | 468 | 800 | 1195,asking_quotes,Estimate changes or disconnects when one quote is removed
,Chuuni Evo,,unstable,6,6,2,4,0,468 | 536 | 750 | 1101 | 1195 | 1675,asking_quotes,Estimate changes or disconnects when one quote is removed
,Cid Evo,,unstable,5,5,3,2,0,1256 | 1265 | 1543 | 1624 | 1675,asking_quotes,Estimate changes or disconnects when one quote is removed
,Cid Unevo,,insufficient,1,1,1,0,0,463,asking_quotes,Too few independent quotes for a numeric estimate
,Cream Evo,,insufficient,1,1,0,1,0,1101,asking_quotes,Too few independent quotes for a numeric estimate
,Dark Mage Evo,,unstable,16,16,5,11,0,379 | 490 | 636 | 750 | 1078 | 1101 | 1112 | 1241 | 1256 | 1265 | 1306 | 1378 | 1540 | 1543 | 1624 | 1675,asking_quotes,Estimate changes or disconnects when one quote is removed
,Elf Mage Evo,,insufficient,1,1,0,1,0,1641,asking_quotes,Too few independent quotes for a numeric estimate
,Gilgamesh Unevo,,insufficient,1,1,1,0,0,115,asking_quotes,Too few independent quotes for a numeric estimate
,Homura Evo,,unstable,12,12,8,4,0,187 | 253 | 366 | 536 | 800 | 1078 | 1112 | 1195 | 1241 | 1265 | 1687 | 1702,asking_quotes,Estimate changes or disconnects when one quote is removed
,Ice Lily Evo,,insufficient,1,1,1,0,0,1334,asking_quotes,Too few independent quotes for a numeric estimate
,Jelly Evo,,insufficient,1,1,1,0,0,463,asking_quotes,Too few independent quotes for a numeric estimate
,Jiraiya Evo,,insufficient,1,1,0,1,0,1306,asking_quotes,Too few independent quotes for a numeric estimate
,Kisuke Evo,,insufficient,1,1,1,0,0,1195,asking_quotes,Too few independent quotes for a numeric estimate
,Nagumo Evo,,insufficient,1,1,0,1,0,1540,asking_quotes,Too few independent quotes for a numeric estimate
,Nagumo Unevo,,insufficient,1,1,1,0,0,463,asking_quotes,Too few independent quotes for a numeric estimate
,Nami Evo,,insufficient,1,1,0,1,0,636,asking_quotes,Too few independent quotes for a numeric estimate
,Poseidon Evo,,unstable,4,4,1,3,0,636 | 1256 | 1306 | 1378,asking_quotes,Estimate changes or disconnects when one quote is removed
,Shiny Boros Evo,,insufficient,1,1,1,0,0,174,asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Buddha Evo,,insufficient,2,2,1,1,0,536 | 1334,asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Chuuni Evo,,unstable,4,4,4,0,0,47 | 228 | 463 | 1357,asking_quotes,Estimate changes or disconnects when one quote is removed
,Shiny Dark Mage Evo,,unstable,4,4,3,1,0,253 | 379 | 776 | 1195,asking_quotes,Estimate changes or disconnects when one quote is removed
,Shiny Elf Mage Evo,,insufficient,1,1,1,0,0,47,asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Emilia Evo,,insufficient,1,1,1,0,0,174,asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Gilgamesh Evo,,insufficient,2,2,2,0,0,52 | 174,asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Issei Evo,,insufficient,1,1,1,0,0,1334,asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Killstreak Evo,,insufficient,1,1,0,1,0,490,asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Mamy Evo,,insufficient,2,2,2,0,0,174 | 776,asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Nagumo Evo,,insufficient,2,2,2,0,0,65 | 1334,asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Piccolo Evo,,insufficient,1,1,1,0,0,47,asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Poseidon Evo,,insufficient,2,2,2,0,0,1357 | 1702,asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Power Evo,,insufficient,1,1,1,0,0,1138,asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Sakamoto Evo,,insufficient,1,1,1,0,0,463,asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Saki Evo,,insufficient,1,1,1,0,0,1702,asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Somber Evo,,insufficient,1,1,1,0,0,463,asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Tiger Evo,,insufficient,1,1,1,0,0,1702,asking_quotes,Too few independent quotes for a numeric estimate
,Shiny Yoshina Evo,,insufficient,1,1,1,0,0,1195,asking_quotes,Too few independent quotes for a numeric estimate
,Skull Knight Evo,,insufficient,1,1,1,0,0,1265,asking_quotes,Too few independent quotes for a numeric estimate
,Skull Knight Unevo,,insufficient,1,1,0,1,0,1543,asking_quotes,Too few independent quotes for a numeric estimate
,Thorfinn Evo,,insufficient,2,2,2,0,0,52 | 366,asking_quotes,Too few independent quotes for a numeric estimate
1 rank unit_variant relative_value confidence quote_count asking_quote_count explicit_ask_count inferred_ask_count completed_trade_count source_rows basis note
2 1 Shiny Aizen Evo Shiny Homura Evo 2100 constraint_only very_low 0 3 3 3 0 0 52 | 174 | 1138 user_supplied_ordering asking_quotes Worth more than Aizen Evo; multiplier unknown
3 2 Aizen Evo Shiny Aizen Evo 1000 low constraint_only 8 0 0 0 0 0 6 | 47 | 370 | 401 | 717 | 781 | 805 | 1145 fitted_asking_quotes user_supplied_ordering Aizen Evo = 1000 reference Worth more than Aizen Evo; multiplier unknown
4 3 Alucard Evo Aizen Evo 850 1000 low 4 8 8 6 2 0 6 | 190 | 401 | 953 47 | 228 | 366 | 776 | 800 | 1138 | 1641 | 1687 fitted_asking_quotes asking_quotes Aizen Evo = 1000 reference
5 4 Shiny Dark Mage Evo Alucard Evo 700 very_low insufficient 2 2 2 0 0 383 | 781 52 | 187 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate
6 5 Homura Evo Alucard Unevo 550 low insufficient 11 1 1 1 0 0 190 | 370 | 541 | 717 | 747 | 805 | 953 | 1084 | 1118 | 1202 | 1248 65 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate
7 6 Buddha Evo Android 21 Evo 250 very_low insufficient 3 1 1 1 0 0 115 | 805 | 1202 52 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate
8 7 Dark Mage Evo Buddha Evo 100 low unstable 8 5 5 3 2 0 383 | 495 | 641 | 755 | 1084 | 1107 | 1118 | 1248 115 | 253 | 468 | 800 | 1195 fitted_asking_quotes asking_quotes Estimate changes or disconnects when one quote is removed
9 8 Chuuni Evo 100 low unstable 4 6 6 2 4 0 541 | 755 | 1107 | 1202 468 | 536 | 750 | 1101 | 1195 | 1675 fitted_asking_quotes asking_quotes Estimate changes or disconnects when one quote is removed
10 Cream Evo Cid Evo insufficient unstable 1 5 5 3 2 0 1107 1256 | 1265 | 1543 | 1624 | 1675 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate Estimate changes or disconnects when one quote is removed
11 Gilgamesh Evo Cid Unevo insufficient 1 1 1 0 0 747 463 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate
12 Gilgamesh Unevo Cream Evo insufficient 1 1 0 1 0 115 1101 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate
13 Kisuke Evo Dark Mage Evo insufficient unstable 1 16 16 5 11 0 1202 379 | 490 | 636 | 750 | 1078 | 1101 | 1112 | 1241 | 1256 | 1265 | 1306 | 1378 | 1540 | 1543 | 1624 | 1675 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate Estimate changes or disconnects when one quote is removed
14 Nami Evo Elf Mage Evo insufficient 1 1 0 1 0 641 1641 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate
15 Poseidon Evo Gilgamesh Unevo insufficient 1 1 1 0 0 641 115 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate
16 Roger Evo Homura Evo insufficient unstable 1 12 12 8 4 0 717 187 | 253 | 366 | 536 | 800 | 1078 | 1112 | 1195 | 1241 | 1265 | 1687 | 1702 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate Estimate changes or disconnects when one quote is removed
17 Shiny Boros Evo Ice Lily Evo insufficient 1 1 1 0 0 177 1334 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate
18 Shiny Buddha Evo Jelly Evo insufficient 1 1 1 0 0 541 463 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate
19 Shiny Chuuni Evo Jiraiya Evo insufficient 2 1 1 0 1 0 47 | 747 1306 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate
20 Shiny Elf Mage Evo Kisuke Evo insufficient 1 1 1 0 0 47 1195 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate
21 Shiny Emilia Evo Nagumo Evo insufficient 1 1 0 1 0 177 1540 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate
22 Shiny Gilgamesh Evo Nagumo Unevo insufficient 1 1 1 0 0 177 463 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate
23 Shiny Homura Evo Nami Evo insufficient 2 1 1 0 1 0 177 | 1145 636 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate
24 Shiny Ice Queen Evo Poseidon Evo insufficient unstable 1 4 4 1 3 0 401 636 | 1256 | 1306 | 1378 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate Estimate changes or disconnects when one quote is removed
25 Shiny Killstreak Evo Shiny Boros Evo insufficient 1 1 1 0 0 495 174 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate
26 Shiny Mamy Evo Shiny Buddha Evo insufficient 2 2 1 1 0 177 | 781 536 | 1334 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate
27 Shiny Piccolo Evo Shiny Chuuni Evo insufficient unstable 1 4 4 4 0 0 47 47 | 228 | 463 | 1357 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate Estimate changes or disconnects when one quote is removed
28 Shiny Power Evo Shiny Dark Mage Evo insufficient unstable 1 4 4 3 1 0 1145 253 | 379 | 776 | 1195 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate Estimate changes or disconnects when one quote is removed
29 Shiny Yoshina Evo Shiny Elf Mage Evo insufficient 1 1 1 0 0 1202 47 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate
30 Thorfinn Evo Shiny Emilia Evo insufficient 1 1 1 0 0 370 174 fitted_asking_quotes asking_quotes Too few independent quotes for a numeric estimate
31 Shiny Gilgamesh Evo insufficient 2 2 2 0 0 52 | 174 asking_quotes Too few independent quotes for a numeric estimate
32 Shiny Issei Evo insufficient 1 1 1 0 0 1334 asking_quotes Too few independent quotes for a numeric estimate
33 Shiny Killstreak Evo insufficient 1 1 0 1 0 490 asking_quotes Too few independent quotes for a numeric estimate
34 Shiny Mamy Evo insufficient 2 2 2 0 0 174 | 776 asking_quotes Too few independent quotes for a numeric estimate
35 Shiny Nagumo Evo insufficient 2 2 2 0 0 65 | 1334 asking_quotes Too few independent quotes for a numeric estimate
36 Shiny Piccolo Evo insufficient 1 1 1 0 0 47 asking_quotes Too few independent quotes for a numeric estimate
37 Shiny Poseidon Evo insufficient 2 2 2 0 0 1357 | 1702 asking_quotes Too few independent quotes for a numeric estimate
38 Shiny Power Evo insufficient 1 1 1 0 0 1138 asking_quotes Too few independent quotes for a numeric estimate
39 Shiny Sakamoto Evo insufficient 1 1 1 0 0 463 asking_quotes Too few independent quotes for a numeric estimate
40 Shiny Saki Evo insufficient 1 1 1 0 0 1702 asking_quotes Too few independent quotes for a numeric estimate
41 Shiny Somber Evo insufficient 1 1 1 0 0 463 asking_quotes Too few independent quotes for a numeric estimate
42 Shiny Tiger Evo insufficient 1 1 1 0 0 1702 asking_quotes Too few independent quotes for a numeric estimate
43 Shiny Yoshina Evo insufficient 1 1 1 0 0 1195 asking_quotes Too few independent quotes for a numeric estimate
44 Skull Knight Evo insufficient 1 1 1 0 0 1265 asking_quotes Too few independent quotes for a numeric estimate
45 Skull Knight Unevo insufficient 1 1 0 1 0 1543 asking_quotes Too few independent quotes for a numeric estimate
46 Thorfinn Evo insufficient 2 2 2 0 0 52 | 366 asking_quotes Too few independent quotes for a numeric estimate
+242 -30
View File
@@ -1,8 +1,8 @@
#!/usr/bin/env python3
"""Fit a provisional relative ValueList to explicit unit and bundle asks.
"""Fit a provisional relative ValueList to completed trades and asking quotes.
The scale fixes Aizen Evo at 1000. These are asking-based estimates, not
completed-trade prices. Shiny Aizen has an ordering constraint only.
The scale fixes Aizen Evo at 1000. Completed trades are recorded separately
from proposed exchanges. Shiny Aizen has an ordering constraint only.
"""
from __future__ import annotations
@@ -10,10 +10,12 @@ from __future__ import annotations
import argparse
from collections import Counter, defaultdict
import csv
from itertools import combinations
import json
from pathlib import Path
from bundle_quotes import extract_bundle_quotes
from completed_trades import load_completed_trades
from extract_exchange_quotes import FIELDS as DIRECT_FIELDS, extract_quotes
@@ -21,6 +23,34 @@ ANCHOR = "Aizen Evo"
SHINY_AIZEN = "Shiny Aizen Evo"
ANCHOR_VALUE = 1000.0
RIDGE = 0.03
COMPLETED_WEIGHT = 9.0
INFERRED_WEIGHT_FACTOR = 1.0 / 3.0
MAX_STABLE_CHANGE_PCT = 25.0
CONFLICT_RATIO = 1.25
CONFIDENCE_FIELDS = ("unit_variant", "quote_count", "asking_quote_count",
"explicit_ask_count", "inferred_ask_count",
"completed_trade_count", "full_fit_value",
"leave_one_out_min", "leave_one_out_max", "max_change_pct",
"most_influential_source_row", "most_influential_evidence_type",
"most_influential_quote",
"disconnects_when_removed", "status", "conflicting_source_rows")
CONFLICT_FIELDS = ("unit_a", "unit_b", "source_row_a", "source_row_b",
"value_ratio_a", "value_ratio_b", "ratio_difference_pct",
"source_text_a", "source_text_b")
IMPACT_FIELDS = ("unit_variant", "removed_source_row", "removed_evidence_type", "removed_quote",
"leave_one_out_value", "change_pct", "disconnected")
COMPARISON_FIELDS = ("unit_variant", "all_fit", "all_ranked_value", "all_confidence",
"all_explicit_asks", "all_inferred_asks", "explicit_only_fit",
"explicit_only_ranked_value", "explicit_only_confidence",
"change_pct_without_inferred", "explicit_only_connection")
def source_order(source: int | str) -> tuple[int, int | str]:
return (1, source) if isinstance(source, str) else (0, source)
def source_list(sources: set[int | str]) -> str:
return " | ".join(map(str, sorted(sources, key=source_order)))
def solve_linear(matrix: list[list[float]], vector: list[float]) -> list[float]:
@@ -44,17 +74,10 @@ def solve_linear(matrix: list[list[float]], vector: list[float]) -> list[float]:
return [augmented[i][size] for i in range(size)]
def fit_values(direct: list[dict], bundles: list[dict]) -> tuple[list[dict], dict]:
quotes = []
for item in direct:
quotes.append(({item["offered_unit"]: int(item["offered_qty"])},
{item["requested_unit"]: int(item["requested_qty"])},
int(item["source_row"]), 3.0))
for item in bundles:
quotes.append((item["offered"], item["requested"], item["source_row"], 1.0))
def fit_quotes(quotes: list[tuple]) -> tuple[dict[str, float], list[tuple], dict[str, set[int | str]]]:
"""Fit only the component connected to the fixed Aizen reference."""
graph: dict[str, set[str]] = defaultdict(set)
for offered, requested, _, _ in quotes:
for offered, requested, _, _, _, _ in quotes:
units = set(offered) | set(requested)
for unit in units:
graph[unit].update(units - {unit})
@@ -74,9 +97,8 @@ def fit_values(direct: list[dict], bundles: list[dict]) -> tuple[list[dict], dic
for i in range(size):
matrix[i][i] = RIDGE
counts: Counter[str] = Counter()
sources: dict[str, set[int]] = defaultdict(set)
for offered, requested, source_row, weight in connected:
sources: dict[str, set[int | str]] = defaultdict(set)
for offered, requested, source_row, weight, _, _ in connected:
coefficients: Counter[str] = Counter(offered)
coefficients.subtract(requested)
total_quantity = sum(offered.values()) + sum(requested.values())
@@ -84,7 +106,6 @@ def fit_values(direct: list[dict], bundles: list[dict]) -> tuple[list[dict], dic
for unit, count in coefficients.items() if count})
target = -coefficients.get(ANCHOR, 0.0) * ANCHOR_VALUE
for unit in set(offered) | set(requested):
counts[unit] += 1
sources[unit].add(source_row)
for unit, coefficient in coefficients.items():
if unit == ANCHOR:
@@ -98,29 +119,144 @@ def fit_values(direct: list[dict], bundles: list[dict]) -> tuple[list[dict], dic
solved = solve_linear(matrix, vector)
values = {ANCHOR: ANCHOR_VALUE}
values.update({unit: max(1.0, solved[index[unit]]) for unit in units})
return values, connected, sources
def conflicting_quotes(direct: list[dict]) -> list[dict]:
"""Find direct quotes for the same pair whose implied ratios differ by >25%."""
pairs: dict[tuple[str, str], list[tuple[dict, float]]] = defaultdict(list)
for quote in direct:
first, second = sorted((quote["offered_unit"], quote["requested_unit"]))
offered_qty, requested_qty = int(quote["offered_qty"]), int(quote["requested_qty"])
ratio = (requested_qty / offered_qty if quote["offered_unit"] == first
else offered_qty / requested_qty)
pairs[first, second].append((quote, ratio))
result = []
for (first, second), items in sorted(pairs.items()):
for (left, left_ratio), (right, right_ratio) in combinations(items, 2):
difference = 100 * (max(left_ratio, right_ratio) / min(left_ratio, right_ratio) - 1)
if max(left_ratio, right_ratio) / min(left_ratio, right_ratio) <= CONFLICT_RATIO:
continue
result.append({"unit_a": first, "unit_b": second,
"source_row_a": left["source_row"], "source_row_b": right["source_row"],
"value_ratio_a": round(left_ratio, 4), "value_ratio_b": round(right_ratio, 4),
"ratio_difference_pct": round(difference, 1),
"source_text_a": left["source_text"], "source_text_b": right["source_text"]})
return result
def fit_values(direct: list[dict], bundles: list[dict], completed: list[dict] | None = None,
*, include_report: bool = False) -> tuple:
quotes = []
for item in direct:
inferred = item.get("quote_type") == "listing_pair"
quotes.append(({item["offered_unit"]: int(item["offered_qty"])},
{item["requested_unit"]: int(item["requested_qty"])},
int(item["source_row"]), 3.0 * (INFERRED_WEIGHT_FACTOR if inferred else 1.0),
item.get("source_text", ""),
"asking_direct_inferred" if inferred else "asking_direct_explicit"))
for item in bundles:
inferred = item.get("quote_type") == "listing_pair"
quotes.append((item["offered"], item["requested"], int(item["source_row"]),
INFERRED_WEIGHT_FACTOR if inferred else 1.0,
item.get("source_text", ""),
"asking_bundle_inferred" if inferred else "asking_bundle_explicit"))
for item in completed or []:
quotes.append((item["offered"], item["requested"], item["source_row"],
COMPLETED_WEIGHT, item.get("source_text", ""), "completed_trade"))
values, connected, sources = fit_quotes(quotes)
conflicts = conflicting_quotes(direct)
conflicting_rows: dict[str, set[int]] = defaultdict(set)
for conflict in conflicts:
for unit in (conflict["unit_a"], conflict["unit_b"]):
conflicting_rows[unit].update((conflict["source_row_a"], conflict["source_row_b"]))
omissions = [(quote, fit_quotes(connected[:i] + connected[i + 1:])[0])
for i, quote in enumerate(connected)]
report = []
impacts = []
result = []
for unit, value in values.items():
count = len(sources[unit])
ranked = count >= 3 or unit in (ANCHOR, "Shiny Dark Mage Evo")
confidence = ("low" if count >= 4 else "very_low") if ranked else "insufficient"
completed_count = len({q[2] for q in connected if q[5] == "completed_trade"
and unit in set(q[0]) | set(q[1])})
asking_count = count - completed_count
explicit_sources = {q[2] for q in connected if q[5].endswith("_explicit")
and unit in set(q[0]) | set(q[1])}
inferred_sources = {q[2] for q in connected if q[5].endswith("_inferred")
and unit in set(q[0]) | set(q[1])} - explicit_sources
omitted_values = [(quote, fitted.get(unit)) for quote, fitted in omissions]
for quote, fitted in omitted_values:
impacts.append({
"unit_variant": unit, "removed_source_row": quote[2],
"removed_evidence_type": quote[5],
"removed_quote": quote[4],
"leave_one_out_value": round(fitted, 1) if fitted is not None else "",
"change_pct": round(100 * (fitted - value) / value, 1) if fitted is not None else "",
"disconnected": "yes" if fitted is None else "no",
})
retained = [(quote, fitted) for quote, fitted in omitted_values if fitted is not None]
disconnected = [quote for quote, fitted in omitted_values if fitted is None]
largest = (max(retained, key=lambda pair: abs(pair[1] - value), default=None)
if unit != ANCHOR else None)
max_change = (100 * abs(largest[1] - value) / value if largest else 0.0)
eligible = count >= 3 or (completed_count >= 1 and count >= 2) or unit in (
ANCHOR, "Shiny Dark Mage Evo")
ordering_conflict = unit == SHINY_AIZEN and value <= ANCHOR_VALUE
unstable = eligible and unit != ANCHOR and (
bool(disconnected) or max_change > MAX_STABLE_CHANGE_PCT or ordering_conflict)
ranked = eligible and not unstable
confidence = ("constraint_only" if unit == SHINY_AIZEN and not ranked else
"unstable" if unstable else
("low" if count >= 4 else "very_low") if ranked else "insufficient")
status = "reference" if unit == ANCHOR else "unstable" if unstable else (
"ranked" if ranked else "insufficient")
report.append({
"unit_variant": unit, "quote_count": count,
"asking_quote_count": asking_count, "completed_trade_count": completed_count,
"explicit_ask_count": len(explicit_sources),
"inferred_ask_count": len(inferred_sources),
"full_fit_value": round(value, 1),
"leave_one_out_min": round(min(fitted for _, fitted in retained), 1) if retained else "",
"leave_one_out_max": round(max(fitted for _, fitted in retained), 1) if retained else "",
"max_change_pct": round(max_change, 1),
"most_influential_source_row": largest[0][2] if largest else "",
"most_influential_evidence_type": largest[0][5] if largest else "",
"most_influential_quote": largest[0][4] if largest else "",
"disconnects_when_removed": source_list({q[2] for q in disconnected}),
"status": status,
"conflicting_source_rows": " | ".join(map(str, sorted(conflicting_rows[unit]))),
})
result.append({
"unit_variant": unit,
"relative_value": round(value / 50) * 50 if ranked else "",
"confidence": confidence,
"quote_count": count,
"source_rows": " | ".join(map(str, sorted(sources[unit]))),
"basis": "fitted_asking_quotes",
"note": ("Aizen Evo = 1000 reference" if unit == ANCHOR else
"asking_quote_count": asking_count,
"explicit_ask_count": len(explicit_sources),
"inferred_ask_count": len(inferred_sources),
"completed_trade_count": completed_count,
"source_rows": source_list(sources[unit]),
"basis": ("completed_and_asking" if completed_count and asking_count else
"completed_trades" if completed_count else "asking_quotes"),
"note": ("Worth more than Aizen Evo; numeric estimate unavailable or conflicts with ordering"
if unit == SHINY_AIZEN and not ranked else
"Aizen Evo = 1000 reference" if unit == ANCHOR else
"Estimate changes or disconnects when one quote is removed" if unstable else
"Too few independent quotes for a numeric estimate" if not ranked else ""),
"_sort_value": value if ranked else None,
"_sort_value": value if ranked else ANCHOR_VALUE + 0.01 if unit == SHINY_AIZEN else None,
})
# This variant has no quantitative quote. Its position is a lower-bound
# placement based on the user's known ordering, never a fabricated price.
if SHINY_AIZEN not in values:
result.append({
"unit_variant": SHINY_AIZEN,
"relative_value": "",
"confidence": "constraint_only",
"quote_count": 0,
"asking_quote_count": 0,
"explicit_ask_count": 0,
"inferred_ask_count": 0,
"completed_trade_count": 0,
"source_rows": "",
"basis": "user_supplied_ordering",
"note": "Worth more than Aizen Evo; multiplier unknown",
@@ -134,20 +270,68 @@ def fit_values(direct: list[dict], bundles: list[dict]) -> tuple[list[dict], dic
rank += 1
row["rank"] = rank if row["_sort_value"] is not None else ""
del row["_sort_value"]
report.sort(key=lambda row: row["unit_variant"])
summary = {"simple_quotes": len(direct), "bundle_quotes": len(bundles),
"connected_quotes": len(connected), "connected_units": len(component)}
"completed_trades": len(completed or []),
"connected_quotes": len(connected), "connected_units": len(values),
"unstable_units": sum(row["status"] == "unstable" for row in report),
"conflicting_quote_pairs": len(conflicts)}
if include_report:
return result, summary, report, conflicts, impacts
return result, summary
def compare_evidence_modes(all_values: list[dict], all_report: list[dict],
explicit_values: list[dict], explicit_report: list[dict]) -> list[dict]:
"""Show the diagnostic fit and published value with inferred asks removed."""
all_rows = {row["unit_variant"]: row for row in all_values}
explicit_rows = {row["unit_variant"]: row for row in explicit_values}
all_fits = {row["unit_variant"]: row for row in all_report}
explicit_fits = {row["unit_variant"]: row for row in explicit_report}
result = []
for unit in sorted(all_rows.keys() | explicit_rows.keys()):
full = all_rows.get(unit, {})
reduced = explicit_rows.get(unit, {})
full_fit = all_fits.get(unit, {}).get("full_fit_value", "")
reduced_fit = explicit_fits.get(unit, {}).get("full_fit_value", "")
change = (round(100 * (reduced_fit - full_fit) / full_fit, 1)
if isinstance(full_fit, (int, float)) and full_fit
and isinstance(reduced_fit, (int, float)) else "")
result.append({
"unit_variant": unit,
"all_fit": full_fit,
"all_ranked_value": full.get("relative_value", ""),
"all_confidence": full.get("confidence", ""),
"all_explicit_asks": full.get("explicit_ask_count", 0),
"all_inferred_asks": full.get("inferred_ask_count", 0),
"explicit_only_fit": reduced_fit,
"explicit_only_ranked_value": reduced.get("relative_value", ""),
"explicit_only_confidence": reduced.get(
"confidence", "disconnected" if unit in all_fits else ""),
"change_pct_without_inferred": change,
"explicit_only_connection": ("connected" if unit in explicit_fits else
"disconnected" if unit in all_fits else "constraint_only"),
})
return result
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--input", type=Path, default=Path("trades.csv"))
parser.add_argument("--completed-trades", type=Path, default=Path("completed_trades.csv"))
parser.add_argument("--output", type=Path, default=Path("provisional_valuelist.csv"))
parser.add_argument("--bundle-output", type=Path, default=Path("bundle_quotes.csv"))
parser.add_argument("--direct-output", type=Path, default=Path("exchange_quotes.csv"))
parser.add_argument("--confidence-output", type=Path, default=Path("confidence_report.csv"))
parser.add_argument("--conflicts-output", type=Path, default=Path("quote_conflicts.csv"))
parser.add_argument("--impact-output", type=Path, default=Path("quote_impact.csv"))
parser.add_argument("--comparison-output", type=Path, default=Path("evidence_comparison.csv"))
args = parser.parse_args()
destinations = [args.output.resolve(), args.bundle_output.resolve(), args.direct_output.resolve()]
if len(set(destinations)) != 3 or args.input.resolve() in destinations:
destinations = [args.output.resolve(), args.bundle_output.resolve(), args.direct_output.resolve(),
args.confidence_output.resolve(), args.conflicts_output.resolve(),
args.impact_output.resolve(), args.comparison_output.resolve()]
inputs = {args.input.resolve(), args.completed_trades.resolve()}
if len(inputs) != 2 or len(set(destinations)) != len(destinations) or inputs.intersection(destinations):
parser.error("input and output paths must all differ")
try:
with args.input.open(encoding="utf-8-sig", newline="") as stream:
@@ -158,7 +342,14 @@ def main() -> None:
rows = list(reader)
direct = extract_quotes(rows)
bundles = extract_bundle_quotes(rows)
values, summary = fit_values(direct, bundles)
completed = load_completed_trades(args.completed_trades)
values, summary, report, conflicts, impacts = fit_values(
direct, bundles, completed, include_report=True)
explicit_values, _, explicit_report, _, _ = fit_values(
[quote for quote in direct if quote["quote_type"] == "explicit_for"],
[quote for quote in bundles if quote["quote_type"] == "explicit_for"],
completed, include_report=True)
comparison = compare_evidence_modes(values, report, explicit_values, explicit_report)
for destination in destinations:
destination.parent.mkdir(parents=True, exist_ok=True)
with args.direct_output.open("w", encoding="utf-8-sig", newline="") as stream:
@@ -175,15 +366,36 @@ def main() -> None:
"requested": json.dumps(quote["requested"], ensure_ascii=False)})
with args.output.open("w", encoding="utf-8-sig", newline="") as stream:
writer = csv.DictWriter(stream, fieldnames=("rank", "unit_variant", "relative_value",
"confidence", "quote_count", "source_rows",
"confidence", "quote_count", "asking_quote_count",
"explicit_ask_count", "inferred_ask_count",
"completed_trade_count", "source_rows",
"basis", "note"))
writer.writeheader()
writer.writerows(values)
with args.confidence_output.open("w", encoding="utf-8-sig", newline="") as stream:
writer = csv.DictWriter(stream, fieldnames=CONFIDENCE_FIELDS)
writer.writeheader()
writer.writerows(report)
with args.conflicts_output.open("w", encoding="utf-8-sig", newline="") as stream:
writer = csv.DictWriter(stream, fieldnames=CONFLICT_FIELDS)
writer.writeheader()
writer.writerows(conflicts)
with args.impact_output.open("w", encoding="utf-8-sig", newline="") as stream:
writer = csv.DictWriter(stream, fieldnames=IMPACT_FIELDS)
writer.writeheader()
writer.writerows(impacts)
with args.comparison_output.open("w", encoding="utf-8-sig", newline="") as stream:
writer = csv.DictWriter(stream, fieldnames=COMPARISON_FIELDS)
writer.writeheader()
writer.writerows(comparison)
except (OSError, ValueError) as error:
parser.error(str(error))
print(f"Saved {len(values)} provisional entries from {len(rows)} listings; "
f"{summary['simple_quotes']} simple and {summary['bundle_quotes']} bundle quotes; "
f"{summary['connected_quotes']} quotes in the Aizen component.")
f"{summary['simple_quotes']} simple and {summary['bundle_quotes']} bundle asks; "
f"{summary['completed_trades']} completed trades; "
f"{summary['connected_quotes']} exchanges in the Aizen component; "
f"{summary['unstable_units']} unstable variants and "
f"{summary['conflicting_quote_pairs']} conflicting quote pairs.")
if __name__ == "__main__":
+1
View File
@@ -0,0 +1 @@
unit_a,unit_b,source_row_a,source_row_b,value_ratio_a,value_ratio_b,ratio_difference_pct,source_text_a,source_text_b
1 unit_a unit_b source_row_a source_row_b value_ratio_a value_ratio_b ratio_difference_pct source_text_a source_text_b
+1805
View File
File diff suppressed because it is too large Load Diff
+5 -4
View File
@@ -1,4 +1,5 @@
reported_handles,warning_text,reporter_hash,reports_seen
Alejandrooooo | XxPaulGamerxX12,Scammer @Alejandrooooo (@XxPaulGamerxX12) forge photo,dc8e87ecefbf9b0c3a6172bc,2
zxcebaaakaa,'@zxcebaaakaa is a scammer dont trade him.,58cfc864cecc252a28dca73a,2
higherfischeran | franklin_orbit_83651,User report: IRL trading and possible scamming; profile screenshot supplied. Not independently verified.,756e53c0d3685517b913749a,1
"reported_handles","warning_text","reporter_hash","reports_seen"
"Alejandrooooo | XxPaulGamerxX12","Scammer @Alejandrooooo (@XxPaulGamerxX12) forge photo","dc8e87ecefbf9b0c3a6172bc","2"
"zxcebaaakaa","'@zxcebaaakaa is a scammer dont trade him.","58cfc864cecc252a28dca73a","2"
"higherfischeran | franklin_orbit_83651","User report: IRL trading and possible scamming; profile screenshot supplied. Not independently verified.","756e53c0d3685517b913749a","1"
"itsme_you1#0000 | darkwwee#0000 | p3reira._16913 | Never_ItsNever123 | teahmyeah | csmcsmcsm11","Scammer List: @itsme_you1#0000/ @darkwwee#0000/ @p3reira._16913/ @Never_ItsNever123/ @teahmyeah/@csmcsmcsm11","053369d6bf84388577b1a565","2"
1 reported_handles warning_text reporter_hash reports_seen
2 Alejandrooooo | XxPaulGamerxX12 Scammer @Alejandrooooo (@XxPaulGamerxX12) forge photo dc8e87ecefbf9b0c3a6172bc 2
3 zxcebaaakaa '@zxcebaaakaa is a scammer dont trade him. 58cfc864cecc252a28dca73a 2
4 higherfischeran | franklin_orbit_83651 User report: IRL trading and possible scamming; profile screenshot supplied. Not independently verified. 756e53c0d3685517b913749a 1
5 itsme_you1#0000 | darkwwee#0000 | p3reira._16913 | Never_ItsNever123 | teahmyeah | csmcsmcsm11 Scammer List: @itsme_you1#0000/ @darkwwee#0000/ @p3reira._16913/ @Never_ItsNever123/ @teahmyeah/@csmcsmcsm11 053369d6bf84388577b1a565 2
+8
View File
@@ -17,6 +17,14 @@ class ValueListTests(unittest.TestCase):
variants("my Aizen Evo for Homura Evo", request=True),
{"Homura Evo"},
)
self.assertEqual(
variants("my Alucard Evo + Shiny Dark Mage Evo for Aizen Evo", request=True),
{"Aizen Evo"},
)
self.assertEqual(
variants("Homura Evo for my Shiny Poseidon Evo + Dark Mage Evo", request=True),
{"Homura Evo"},
)
def test_counts_authors_once_and_excludes_nlf(self):
stream = StringIO(newline="")
+72
View File
@@ -0,0 +1,72 @@
import csv
from io import StringIO
from pathlib import Path
import unittest
from unittest.mock import patch
from completed_trades import FIELDS, load_completed_trades
from provisional_valuelist import fit_values
class CompletedTradeTests(unittest.TestCase):
def trades_csv(self, records):
stream = StringIO(newline="")
writer = csv.DictWriter(stream, fieldnames=FIELDS)
writer.writeheader()
writer.writerows(records)
stream.seek(0)
return stream
def test_recorded_bundle_is_parsed_and_invalid_record_rejected(self):
path = Path("completed.csv")
record = {"trade_id": "t1", "trade_date": "2026-11-19",
"given": "2 Homura Evo + Buddha Evo", "received": "Aizen Evo",
"evidence": "screenshot-1", "notes": "confirmed by both sides"}
with patch.object(Path, "open", return_value=self.trades_csv([record])):
trade = load_completed_trades(path)[0]
self.assertEqual(trade["offered"], {"Homura Evo": 2, "Buddha Evo": 1})
self.assertEqual(trade["source_row"], "trade:t1")
invalid = {**record, "trade_id": "t2", "given": "Homura Evo or Buddha Evo"}
with patch.object(Path, "open", return_value=self.trades_csv([record, invalid])):
with self.assertRaisesRegex(ValueError, "row 3"):
load_completed_trades(path)
def test_completed_trades_have_stronger_weight_and_separate_counts(self):
asks = [{"offered_unit": "Homura Evo", "offered_qty": 1,
"requested_unit": "Aizen Evo", "requested_qty": 1,
"source_row": row, "source_text": "Homura Evo for Aizen Evo"}
for row in (2, 3, 4)]
completed = [{"offered": {"Homura Evo": 2}, "requested": {"Aizen Evo": 1},
"source_row": f"trade:t{number}", "source_text": "2 Homura Evo -> Aizen Evo"}
for number in (1, 2)]
_, _, ask_report, _, _ = fit_values(asks, [], include_report=True)
rows, _, mixed_report, _, impacts = fit_values(asks, [], completed, include_report=True)
ask_value = next(row["full_fit_value"] for row in ask_report
if row["unit_variant"] == "Homura Evo")
mixed_value = next(row["full_fit_value"] for row in mixed_report
if row["unit_variant"] == "Homura Evo")
self.assertLess(abs(mixed_value - 500), abs(ask_value - 500))
homura = next(row for row in rows if row["unit_variant"] == "Homura Evo")
self.assertEqual((homura["asking_quote_count"], homura["completed_trade_count"]), (3, 2))
self.assertEqual(homura["basis"], "completed_and_asking")
self.assertTrue(any(item["removed_evidence_type"] == "completed_trade" for item in impacts))
def test_two_completed_trades_can_rank_without_asking_quotes(self):
completed = [{"offered": {"Aizen Evo": 2},
"requested": {"Shiny Aizen Evo": 1},
"source_row": f"trade:t{number}",
"source_text": "2 Aizen Evo -> Shiny Aizen Evo"}
for number in (1, 2)]
rows, summary = fit_values([], [], completed)
shiny_rows = [row for row in rows if row["unit_variant"] == "Shiny Aizen Evo"]
self.assertEqual(len(shiny_rows), 1)
self.assertEqual(shiny_rows[0]["completed_trade_count"], 2)
self.assertEqual(shiny_rows[0]["asking_quote_count"], 0)
self.assertEqual(shiny_rows[0]["basis"], "completed_trades")
self.assertNotEqual(shiny_rows[0]["relative_value"], "")
self.assertEqual(summary["completed_trades"], 2)
self.assertEqual((summary["simple_quotes"], summary["bundle_quotes"]), (0, 0))
if __name__ == "__main__":
unittest.main()
+461
View File
@@ -0,0 +1,461 @@
import csv
from io import StringIO
from pathlib import Path
import sqlite3
import unittest
from unittest.mock import patch
from discord_trade_parser import (Message, clean_export_text, clean_offer_items, clean_request_fields,
export_csv, export_scam_warnings, extract_scam_warnings, iter_messages,
normalize_request_segments, separate_received_bid,
parse_listing, parse_listings,
repair_glued_reposts,
repair_misfiled_lf_inventory,
repair_misfiled_inventory,
repair_misfiled_mlf_inventory,
repair_standalone_lf_inventory,
repair_inline_side_cues,
recover_explicit_my_offers,
recover_partial_proposal_offers,
repair_confirmed_long_lf_inventory,
repair_confirmed_proposal_sides,
repair_alucard_lf_inventory)
class OpenStringIO(StringIO):
def close(self):
# Let the test inspect the CSV after export_csv closes its context.
pass
class TradeItemCleanupTests(unittest.TestCase):
def test_multiplication_sign_quantities(self):
self.assertEqual(clean_export_text("2\u00d7 Homura Evo | \u00d71 Shizo Evo | Chuuni Evo \u00d72"),
"2x Homura Evo | 1x Shizo Evo | 2x Chuuni Evo")
def test_received_bid_is_not_owned_inventory(self):
self.assertEqual(
separate_received_bid("Shiny Megumin Evo | best offer: Shiny Aizen Evo"),
("Shiny Megumin Evo", "Shiny Aizen Evo"),
)
self.assertEqual(
separate_received_bid("Shiny Mist Ninja Evo | HIGH OFFER Shiny Homura Evo, 2 Aizen Evo"),
("Shiny Mist Ninja Evo", "Shiny Homura Evo, 2 Aizen Evo"),
)
def test_warning_csv_quotes_apostrophe_prefixed_text(self):
with sqlite3.connect(":memory:") as conn:
conn.execute("CREATE TABLE scam_warnings (id INTEGER PRIMARY KEY, "
"reported_handles TEXT, warning_text TEXT, "
"reporter_hash TEXT, reports_seen INTEGER)")
conn.executemany("INSERT INTO scam_warnings "
"(reported_handles,warning_text,reporter_hash,reports_seen) "
"VALUES (?,?,?,?)", [
("a", "@a is a scammer", "one", 1),
("b | c", "Scammer List: @b/@c", "two", 1),
])
stream = OpenStringIO()
with patch.object(Path, "open", return_value=stream):
self.assertEqual(export_scam_warnings(conn, Path("warnings.csv")), 2)
lines = stream.getvalue().splitlines()
self.assertTrue(all(line.startswith('"') and line.endswith('"') for line in lines))
rows = list(csv.DictReader(StringIO(stream.getvalue())))
self.assertEqual(len(rows), 2)
self.assertEqual(rows[0]["warning_text"], "'@a is a scammer")
self.assertEqual(rows[1]["reported_handles"], "b | c")
def test_multiline_scammer_list_is_extracted_from_trade(self):
message = Message("display:trader", "Trading: Aizen Evo\nLF: Homura Evo\n"
"Scammer List:\n\n"
" @itsme_you1#0000/ @darkwwee#0000/ @p3reira._16913/ "
"@Never_ItsNever123/ @teahmyeah/@csmcsmcsm11\n\n"
"I answer every dm")
trade, warnings = extract_scam_warnings(message)
self.assertEqual(len(warnings), 1)
self.assertEqual(warnings[0].reported_handles,
"itsme_you1#0000 | darkwwee#0000 | p3reira._16913 | "
"Never_ItsNever123 | teahmyeah | csmcsmcsm11")
self.assertNotIn("Scammer List", trade.body)
self.assertNotIn("@itsme_you1", trade.body)
self.assertEqual(parse_listings(trade)[0].offer, "Aizen Evo")
def test_dyno_notices_are_skipped_without_dropping_user_trades(self):
paste = ("[\n14:06\n]\nDyno\n:\nYour message was too long.\n"
"[\n14:07\n]\nAlice\n:\nTrading Aizen Evo\nLF Homura Evo\n"
"[14:08]\nDyno (@Dyno) [BOT],\n:\nTrading Aizen Evo\n"
"[14:09]\nBob\n:\nTrading Dyno pet and Homura Evo\n")
messages = list(iter_messages(paste.splitlines()))
self.assertEqual([msg.author for msg in messages],
["display:alice", "display:bob"])
self.assertEqual([listing.offer for msg in messages
for listing in parse_listings(msg)],
["Aizen Evo", "Dyno pet and Homura Evo"])
self.assertEqual(parse_listings(Message("display:dyno#3861", "Trading Aizen Evo")), [])
def test_autocorrects_clear_unit_typos_with_variant_cues(self):
self.assertEqual(clean_export_text("Homurra Evo | Dark Mgae Unevo | Shiny Homurra"),
"Homura Evo | Dark Mage Unevo | Shiny Homura Evo")
self.assertEqual(clean_export_text("2 Homurra | Offers"),
"2 Homura Evo | Offers")
def test_autocorrect_keeps_ambiguous_and_unrelated_words(self):
self.assertEqual(clean_export_text("Aken Evo | Shiny Hunter"),
"Aken Evo | Shiny Hunter")
def test_confirmed_name_aliases_preserve_distinct_variant_status(self):
self.assertEqual(clean_export_text("Shiny Raukai Evo | Angle Unevo | Yoshino Evo"),
"Shiny Rukia Evo | Angel Unevo | Yoshina Evo")
self.assertEqual(clean_export_text("Magic Girl Evo | Infinity Mage Evo | Saka Evo"),
"Madoka Evo | Merlin Evo | Sakamoto Evo")
self.assertEqual(clean_export_text("Infinity Mage / Merlin Evo"),
"Merlin Evo")
self.assertEqual(clean_export_text("Valentine Bundle (100RR)"),
"Valentine Bundle (100RR)")
self.assertEqual(clean_export_text("Shiny Skull Knight Evo / Skeleton Knight"),
"Shiny Skull Knight Evo")
self.assertEqual(clean_export_text("Shiny Gowther / Doll Evo"),
"Shiny Doll Evo")
self.assertEqual(clean_export_text("Deer Tan Evo / noko tan (Shiny)"),
"Shiny Deer Tan Evo")
def test_explicit_inventory_splits_preserve_totals_and_shiny_status(self):
self.assertEqual(clean_export_text("7x Shiny Siren (2 Evo)"),
"2x Shiny Siren Evo | 5x Shiny Siren Unevo")
self.assertEqual(clean_export_text("14X Chuuni (11 Unevo 3 Evo) (HAVE 1 Evo ITEM)"),
"11x Chuuni Unevo | 3x Chuuni Evo (HAVE 1 Evo ITEM)")
self.assertEqual(clean_export_text("4x Poseidon Evo (1x Shiny)"),
"1x Shiny Poseidon Evo | 3x Poseidon Evo")
self.assertEqual(clean_export_text("2 Chuuni Evo 1 Unevo"),
"2x Chuuni Evo | 1x Chuuni Unevo")
self.assertEqual(clean_export_text("Toad Sensei Evo Shiny s/s-/sss"),
"Shiny Toad Sensei Evo s/s-/sss")
self.assertEqual(clean_export_text("3x Unevo Shiny Cream"),
"3x Shiny Cream Unevo")
self.assertEqual(clean_export_text("Deer Tan Evo Shiny AND NON"),
"Shiny Deer Tan Evo | Deer Tan Evo")
self.assertEqual(clean_export_text("Cid Evo Shiny Unevo"),
"Shiny Cid Evo")
self.assertEqual(clean_export_text("Dark Mage Evo Shiny for my Chuuni Evo"),
"Shiny Dark Mage Evo for my Chuuni Evo")
self.assertEqual(clean_export_text("Unevo Shiny Vanilla Ice (Cream Evo)"),
"Shiny Cream Unevo")
def test_keeps_stats_broad_options_and_owned_best_offer(self):
offer = ("SSS DMG 23.1% | All Gamepasses | ALL SKINS | "
"BEST OFFER:Aizen Evo FULL SSS | HIGH OFFER Shiny Homura Evo")
self.assertEqual(clean_offer_items(offer), offer)
def test_removes_chat_and_ui_fragments_without_damaging_stats(self):
offer = ("[ ] | Shiny Elf Mage Evo {SS | A- | S+} | "
"Dark Mage Evo S-/S-/S- | no response = nty | 1 • 19:36 | "
"Shiny Homura Evo S+ | S | SSS | COME WITH OFFER | "
"Please Use My And Yours | Total Value:885 | -1x Gilgamesh Evo")
self.assertEqual(
clean_offer_items(offer),
"Shiny Elf Mage Evo {SS / A- / S+} | Dark Mage Evo S-/S-/S- | "
"Shiny Homura Evo S+ / S / SSS | 1x Gilgamesh Evo",
)
def test_parse_listing_rejects_channel_only_message(self):
self.assertIsNone(parse_listing(Message("a", "Trading: channel for Server Boosters")))
listing = parse_listing(Message("b", "Trading: Aizen Evo | no response = nty\nLF: Homura Evo"))
self.assertEqual(listing.offer, "Aizen Evo")
def test_request_cleanup_moves_explicit_labels_and_keeps_trade_requests(self):
looking, lf, mlf, nlf = clean_request_fields(
"PRE | OFFERS | SSS DMG 23% | (MLF: ALL FOR Dio Evo) | (NLF bundles 1-3) | "
"No reply = nty | NO WANT GP/ clown offers",
"Shiny Hunter", "Skins")
self.assertEqual(lf, "PRE | OFFERS | SSS DMG 23%")
self.assertEqual(mlf, "Shiny Hunter | ALL FOR Dio Evo")
self.assertEqual(nlf, "Skins | bundles 1-3 | GP/ clown offers")
self.assertEqual(looking, "PRE | OFFERS | SSS DMG 23% | MLF: Shiny Hunter | ALL FOR Dio Evo")
def test_request_cleanup_recovers_missing_mlf_and_removes_ui(self):
looking, lf, mlf, nlf = clean_request_fields(
"OFFERS | #【】 | My 4 units for one SSS SPA#",
"Offers | Nail relic", "Ignore = NTY | Battlepass",
"MLF: SSS Stats | Offers | Nail relic")
self.assertEqual(lf, "OFFERS | My 4 units for one SSS SPA")
self.assertEqual(mlf, "Offers | Nail relic")
self.assertEqual(nlf, "Battlepass")
self.assertIn("MLF: Offers | Nail relic", looking)
_, lf, mlf, _ = clean_request_fields("", "Offers | Nail relic", "",
"MLF: SSS Stats | Offers | Nail relic")
self.assertEqual((lf, mlf), ("", "SSS Stats | Offers | Nail relic"))
self.assertEqual(clean_request_fields("", "", "Rerolls | Ignoring Clowns/Lowballs")[3],
"Rerolls | Lowballs")
_, lf, _, nlf = clean_request_fields(
"Offers", "", "very low value offers; low demand; Only SSS stats (for Homura Evo)")
self.assertEqual(lf, "Offers | Only SSS stats (for Homura Evo)")
self.assertEqual(nlf, "very low value offers; low demand")
self.assertEqual(clean_request_fields(
"GOOD OFFERSTrading | Aizen Evo | Homura Evo | GOOD OFFERS", "", "")[1],
"GOOD OFFERS")
self.assertEqual(clean_request_fields("Keyword:", "", "")[1], "")
self.assertEqual(normalize_request_segments("SHINIES:Cid,Dark Mage"),
"Shiny Cid Evo,Shiny Dark Mage Evo")
def test_glued_trade_label_does_not_put_inventory_in_mlf(self):
message = Message("a", "Trade\nShiny Inhuman Evo\nLF offers "
"MLF all for Alucard Evo i can add more unitstrade\n"
"Shiny Inhuman Evo\nLF offers")
listing = parse_listing(message)
self.assertEqual(listing.offer, "Shiny Inhuman Evo")
self.assertEqual(listing.mlf, "all for Alucard Evo i can add more units")
_, _, mlf, _ = clean_request_fields(
"offers", "all for Alucard Evo i can add more unitstrade | Shiny Inhuman Evo | "
"all for Alucard Evo i can add more units", "")
self.assertEqual(mlf, "all for Alucard Evo i can add more units")
def test_friend_inventory_is_a_separate_offer(self):
message = Message("a", "Trading: Aizen Evo\nMLF: Shiny Chuuni Evo\n"
"My Friend is\nShiny Buddha Evo")
listings = parse_listings(message)
self.assertEqual(len(listings), 2)
self.assertEqual(listings[0].mlf, "Shiny Chuuni Evo")
self.assertEqual(listings[1].offer, "Shiny Buddha Evo")
self.assertEqual(listings[1].looking_for, "")
def test_confirmed_misfiled_nlf_inventory_becomes_offer(self):
offer, lf, nlf = repair_misfiled_inventory(
"Shiny Homura Evo", "OVERPAYS",
"Shiny Gilgamesh Evo | x1 FULL SSS Aizen Evo 23%/10.7%/12.1% | "
"x1 FULL SSS Homura Evo (LF 6 SSS DMG / Aizen) | "
"BUNDLES/RR/ASSASIN UPD UNITS/GAMEPASS | WILL READ ALL DMS ( NO RESPONSE = AFK)")
self.assertIn("Shiny Gilgamesh Evo", offer)
self.assertIn("x1 FULL SSS Homura Evo", offer)
self.assertIn("6 SSS DMG / Aizen", lf)
self.assertEqual(nlf, "")
def test_confirmed_misfiled_mlf_inventory_becomes_offer(self):
offer, lf, mlf = repair_misfiled_mlf_inventory(
"Shiny Homura Evo", "OVERPAYS",
"OVERPAY | NORMAL UNITS | x1 Aizen Evo (FULL S) | "
"x6 Homura Evo ALL GOOD STATS (LF Aizen Evo/ FULL SSS Homura/ FOR MY 2 Homura)")
self.assertIn("x1 Aizen Evo (FULL S)", offer)
self.assertIn("x6 Homura Evo ALL GOOD STATS", offer)
self.assertIn("Aizen Evo/ FULL SSS Homura/ FOR MY 2 Homura", lf)
self.assertEqual(mlf, "OVERPAY")
def test_glued_reposts_keep_requests_and_recover_offers(self):
offer, lf, mlf = repair_glued_reposts(
"Nagumo Evo | Homura Evo", "Battlepass | Homura Evo, Battlepass and addTrade | "
"Nagumo Evo | Chuuni Evo too | Homura Evo, Battlepass and add", "")
self.assertEqual(lf, "Battlepass | Homura Evo, Battlepass and add")
self.assertIn("Chuuni Evo", offer)
self.assertEqual(mlf, "")
offer, lf, mlf = repair_glued_reposts(
"Cid Evo", "", "UPGRADEtrading | Buddha Evo with SSS spa 11.7 | "
"Cid Evo | UPGRADE | Buddha Evo with SSS spa 11.7")
self.assertIn("Buddha Evo with SSS spa 11.7", offer)
self.assertEqual((lf, mlf), ("", "UPGRADE"))
def test_confirmed_lf_inventory_moves_to_offer(self):
cases = [
("2X SSS DMG FOR MY Shiny Poseidon Evo | Evo MYTIC's | "
"6x Dark Mage Evo | SKINS | 2x ERWIN DELINQUENT | "
"Shiny POSEI/Chuuni Evo AND ADDS FOR MY ROGER Evo",
"6x Dark Mage Evo", "2X SSS DMG FOR MY Shiny Poseidon Evo | "
"Shiny POSEI/Chuuni Evo AND ADDS FOR MY ROGER Evo"),
("S stat Fodder Units | 4 Deer Tan Evo | 2 Dark Mage Unevo | "
"S stat Fodder Units | 2 Merlin Evo | "
"Vip and Shiny hunter(Must be both in 1 trade) for Emilia Evo",
"4 Deer Tan Evo", "Vip and Shiny hunter(Must be both in 1 trade) for Emilia Evo"),
("both Homura Evo for Aizen Evo | Shiny UNITS | Shiny esdeath Evo | "
"NON-Shiny UNITS | Violentine Evo | "
"s tier upgrade for my Shiny units",
"Shiny esdeath Evo", "both Homura Evo for Aizen Evo | "
"s tier upgrade for my Shiny units"),
]
for lf, moved, expected_lf in cases:
with self.subTest(moved=moved):
offer, result_lf = repair_misfiled_lf_inventory("Aizen Evo", lf)
self.assertIn(moved, offer)
self.assertEqual(result_lf, expected_lf)
def test_inline_side_cues_keep_owned_items_and_move_requests(self):
offer, lf, nlf = repair_inline_side_cues(
"Shiny Mist Ninja Evo LOOKIN FOR FAIR TRADE NO SCAM | "
"Homura Evo sss rng ( for 4 sss dmg/spa) | "
"Battlepass (WILL NOT TRADE FOR Dark Mage Evo + ADDS)", "", "")
self.assertIn("Shiny Mist Ninja Evo", offer)
self.assertIn("Homura Evo sss rng", offer)
self.assertIn("Battlepass", offer)
self.assertEqual(lf, "FAIR TRADE | 4 sss dmg/spa")
self.assertEqual(nlf, "Dark Mage Evo + ADDS")
offer, lf, _ = repair_inline_side_cues(
"Dark Mage Evo | olf Homura Evo/overpays/Chuuni Evo item(please chooms ) | "
"UPGRADES/", "OFFERS", "")
self.assertEqual(offer, "Dark Mage Evo")
self.assertEqual(lf, "OFFERS | Homura Evo/overpays/Chuuni Evo item | UPGRADES")
offer, lf, _ = repair_inline_side_cues(
"6x Dark Mage Evo (ALL GOOD STATS) [2x FOR ANY SSS] | "
"100+ Fodder Units (9 for 10rr)", "", "")
self.assertEqual(offer, "6x Dark Mage Evo (ALL GOOD STATS) | 100+ Fodder Units")
self.assertEqual(lf, "ANY SSS for 2 Dark Mage Evo | 10 RR for 9 Fodder Units")
def test_owned_standalone_lf_list_moves_to_offer(self):
offer, lf = repair_standalone_lf_inventory(
"Homura Evo SS/SSS/SSS",
"Alucard Evo | Shiny Chuuni Evo | 4x SSS spa | Buddha Evo | "
"Aizen Evo/UPGRADES",
"my 4x SSS spa + Shiny Somber Evo for Alucard Evo | "
"My Alucard Evo + Shiny Dark Mage Evo for Aizen Evo")
self.assertIn("Alucard Evo", offer)
self.assertIn("4x SSS spa", offer)
self.assertIn("Shiny Dark Mage Evo", offer)
self.assertEqual(lf, "Aizen Evo/UPGRADES")
def test_my_proposal_recovers_missing_owned_variants(self):
offer = recover_explicit_my_offers(
"Shiny Boros Evo | Dark Mage Unevo",
"My Boros Evo for Thorfinn Evo | my Dark Mage Evo for SSS DMG",
"")
self.assertIn("Boros Evo", offer)
self.assertIn("Dark Mage Evo", offer)
self.assertEqual(offer.count("Shiny Boros Evo"), 1)
self.assertNotIn("Thorfinn Evo", offer)
def test_partial_proposal_recovers_confirmed_offered_units(self):
offer = recover_partial_proposal_offers(
"Shiny Toad Sensei Evo",
"Shiny Toad Sensei Evo and Nagumo Evo for Shiny Cid Evo", "")
self.assertIn("Nagumo Evo", offer)
offer = recover_partial_proposal_offers(
"Shiny Nagumo Evo", "",
"Chuuni Evo/Evo ITEM FOR Chuuni Evo AND Buddha Unevo OR OFFER")
self.assertIn("Chuuni Evo | Evo ITEM", offer)
def test_confirmed_proposal_directions(self):
offer, lf, _ = repair_confirmed_proposal_sides(
"Battlepass",
"Shiny Gohan Evo / Gohan Evo / Shiny Android 21 Evo for bundles or RR",
"")
self.assertIn("Shiny Android 21 Evo", offer)
self.assertEqual(lf, "bundles or RR")
offer, _, _ = repair_confirmed_proposal_sides(
"SSS DMG", "", "Shiny Chuuni Evo for Aizen Evo")
self.assertIn("Shiny Chuuni Evo", offer)
self.assertNotIn("Aizen Evo", offer)
def test_confirmed_long_lf_inventory_moves_to_offer(self):
offer, lf = repair_confirmed_long_lf_inventory(
"Homura Evo",
"Sss for Each | 3Dark Mage Evo | Sss for Each | Chuuni Evo | "
"Sss | Boros Evo | Cid Evo | Sss Stats | "
"my Homura Evo for Aizen Evo")
self.assertIn("3Dark Mage Evo", offer)
self.assertIn("Cid Evo", offer)
self.assertEqual(lf, "SSS for each | SSS Stats | my Homura Evo for Aizen Evo")
def test_alucard_list_preserves_wanted_adds(self):
original = ("%29+ high sss dmg or Aizen Evo | HIGH SSS %14+/28+ | "
"SSS DMG 21.6 | Shiny Chuuni Evo or some Dark Mage Evo for sss dmg or spa | "
"SSS SPA 11.5 | SSS SPA Chuuni Evo | Shiny Killstreak Evo | "
"Dark Mage Evo/Buddha Evo adds for my Shiny units | Elf Mage Evo | "
"Inhuman Evo S+ spa | Dark Mage Unevo | offers Aizen Evo,Alucard Evo,high sss stats")
offer, lf = repair_alucard_lf_inventory("Alucard Evo", original)
self.assertIn("SSS SPA 11.5", offer)
self.assertIn("Shiny Killstreak Evo", offer)
self.assertIn("Elf Mage Evo", offer)
self.assertIn("Dark Mage Evo/Buddha Evo adds", lf)
self.assertNotIn("SSS SPA 11.5", lf)
raw = original.replace("Aizen Evo", "aizen", 1).replace(
"Shiny Chuuni Evo or some Dark Mage Evo", "shiny chunni or some dark mage")
raw += " | Dm offers"
raw_offer, raw_lf = repair_alucard_lf_inventory("Alucard Evo", raw)
self.assertIn("SSS SPA 11.5", raw_offer)
self.assertNotIn("Dm offers", raw_lf)
def test_export_separates_pretrade_and_received_bid(self):
conn = sqlite3.connect(":memory:")
conn.execute("""CREATE TABLE trades (
id INTEGER PRIMARY KEY, offer TEXT, looking_for TEXT, lf TEXT,
mlf TEXT, nlf TEXT, author_hash TEXT, seen_count INTEGER,
update_count INTEGER, canon_offer TEXT)""")
conn.execute(
"INSERT INTO trades VALUES (?,?,?,?,?,?,?,?,?,?)",
(1, "PRE | Shiny Megumin | best offer: Shiny Aizen",
"", "", "", "", "a", 1, 0, "pretrade megumin"),
)
stream = OpenStringIO(newline="")
with patch.object(Path, "open", return_value=stream):
self.assertEqual(export_csv(conn, Path("trades.csv"), detailed=True), 1)
stream.seek(0)
row = next(csv.DictReader(stream))
self.assertEqual(row["offer"], "Shiny Megumin")
self.assertEqual(row["pretrade"], "yes")
self.assertEqual(row["received_bid"], "Shiny Aizen Evo")
def test_export_filters_old_database_rows(self):
conn = sqlite3.connect(":memory:")
conn.execute("""CREATE TABLE trades (
id INTEGER PRIMARY KEY, offer TEXT, looking_for TEXT, lf TEXT,
mlf TEXT, nlf TEXT, author_hash TEXT, seen_count INTEGER,
update_count INTEGER)""")
conn.executemany(
"INSERT INTO trades VALUES (?,?,?,?,?,?,?,?,?)",
[(1, "channel for Server Boosters", "", "", "", "", "a", 1, 0),
(2, "Aizen Evo | no response = nty", "Homura Evo", "Homura Evo", "", "", "b", 1, 0),
(3, "ILLUSIONST (TRANSCENDED) FOR BUNDLE 2", "", "", "", "", "c", 1, 0),
(4, "Homura Evo", "SSS Stats | Evo mythics", "SSS Stats | Evo mythics",
"", "", "d", 1, 0)],
)
stream = OpenStringIO(newline="")
with patch.object(Path, "open", return_value=stream):
count = export_csv(conn, Path("trades.csv"), detailed=True)
stream.seek(0)
rows = list(csv.DictReader(stream))
self.assertEqual(count, 3)
self.assertEqual(rows[0]["offer"], "Aizen Evo")
self.assertEqual(rows[0]["lf"], "Homura Evo")
self.assertEqual(rows[1]["offer"], "Aizen Evo")
self.assertEqual(rows[1]["lf"], "BUNDLE 2")
self.assertEqual(rows[2]["lf"], "SSS Stats | Evo mythics")
def test_export_recovers_one_friend_row_from_repeated_legacy_listings(self):
conn = sqlite3.connect(":memory:")
conn.execute("""CREATE TABLE trades (
id INTEGER PRIMARY KEY, offer TEXT, looking_for TEXT, lf TEXT,
mlf TEXT, nlf TEXT, author_hash TEXT, seen_count INTEGER,
update_count INTEGER, canon_offer TEXT)""")
for row_id in (1, 2):
conn.execute(
"INSERT INTO trades VALUES (?,?,?,?,?,?,?,?,?,?)",
(row_id, "Aizen Evo", "MLF: Shiny Chuuni Evo | My Friend is | Shiny Buddha Evo",
"", "Shiny Chuuni Evo | My Friend is | Shiny Buddha Evo", "",
"parent", 1, 0, "aizen evo"),
)
stream = OpenStringIO(newline="")
with patch.object(Path, "open", return_value=stream):
count = export_csv(conn, Path("trades.csv"), detailed=True)
stream.seek(0)
rows = list(csv.DictReader(stream))
self.assertEqual(count, 3)
self.assertEqual(sum(row["offer"] == "Shiny Buddha Evo" for row in rows), 1)
self.assertTrue(all("My Friend is" not in row["mlf"] for row in rows))
def test_export_keeps_stat_condition_inside_recovered_offer(self):
conn = sqlite3.connect(":memory:")
conn.execute("""CREATE TABLE trades (
id INTEGER PRIMARY KEY, offer TEXT, looking_for TEXT, lf TEXT,
mlf TEXT, nlf TEXT, author_hash TEXT, seen_count INTEGER,
update_count INTEGER)""")
request = ("2X SSS DMG FOR MY Shiny Poseidon Evo | Evo MYTIC's | "
"6x Dark Mage Evo (ALL GOOD STATS) [2x FOR ANY SSS] | "
"Shiny POSEI/Chuuni Evo AND ADDS FOR MY ROGER Evo")
conn.execute("INSERT INTO trades VALUES (?,?,?,?,?,?,?,?,?)",
(1, "Shiny Poseidon Evo", request, request, "", "", "a", 1, 0))
stream = OpenStringIO(newline="")
with patch.object(Path, "open", return_value=stream):
export_csv(conn, Path("trades.csv"), detailed=True)
stream.seek(0)
row = next(csv.DictReader(stream))
self.assertIn("[2x FOR ANY SSS]", row["offer"])
self.assertNotIn("ANY SSS]", row["lf"])
if __name__ == "__main__":
unittest.main()
+16
View File
@@ -1,9 +1,25 @@
import unittest
from bundle_quotes import extract_bundle_quotes
from extract_exchange_quotes import extract_quotes, parse_side
class ExchangeQuoteTests(unittest.TestCase):
def test_stat_specific_inventory_is_not_a_base_variant_quote(self):
rows = [
{"author_hash": "a", "offer": "Homura Evo (SSS RNG)",
"lf": "my Homura Evo for Alucard Evo", "mlf": ""},
{"author_hash": "b", "offer": "Homura Evo (SSS RNG) | Homura Evo",
"lf": "my Homura Evo for Alucard Evo", "mlf": ""},
{"author_hash": "c", "offer": "Shiny Poseidon Evo | 14x Dark Mage Evo (A+/SSS/SS) | 2x Chuuni Evo",
"lf": "My Shiny Poseidon Evo, 1 Dark Mage Evo, 2x Chuuni Evo for Homura Evo",
"mlf": ""},
{"author_hash": "d", "offer": "2x Homura Evo 1 s,s,A, Alucard Evo",
"lf": "", "mlf": "my 2x Homura Evo for Aizen Evo"},
]
self.assertEqual([q["source_row"] for q in extract_quotes(rows)], [3])
self.assertEqual(extract_bundle_quotes(rows), [])
def test_only_exact_variant_and_quantity(self):
self.assertEqual(parse_side("my 2 Shiny Aizen Evo"),
("Shiny Aizen Evo", 2, "my"))
+108 -1
View File
@@ -1,10 +1,65 @@
import unittest
from bundle_quotes import extract_bundle_quotes, parse_bundle
from provisional_valuelist import fit_values
from provisional_valuelist import compare_evidence_modes, conflicting_quotes, fit_values
class ProvisionalValueListTests(unittest.TestCase):
def test_inferred_pairs_have_lower_weight_and_separate_comparison(self):
direct = [
{"offered_unit": "Homura Evo", "offered_qty": quantity,
"requested_unit": "Aizen Evo", "requested_qty": 1,
"source_row": row, "quote_type": kind, "source_text": "proposal"}
for row, quantity, kind in ((1, 2, "explicit_for"), (2, 2, "explicit_for"),
(3, 2, "explicit_for"), (4, 1, "listing_pair"))
]
all_values, _, all_report, _, impacts = fit_values(direct, [], include_report=True)
explicit_values, _, explicit_report, _, _ = fit_values(
direct[:3], [], include_report=True)
comparison = compare_evidence_modes(
all_values, all_report, explicit_values, explicit_report)
row = next(item for item in comparison if item["unit_variant"] == "Homura Evo")
self.assertEqual((row["all_explicit_asks"], row["all_inferred_asks"]), (3, 1))
self.assertGreater(row["all_fit"], row["explicit_only_fit"])
self.assertLess(row["all_fit"], 600) # The one-for-one inferred ask cannot dominate.
self.assertEqual((row["all_ranked_value"], row["explicit_only_ranked_value"]),
(550, 500))
self.assertTrue(any(item["removed_evidence_type"] == "asking_direct_inferred"
for item in impacts))
def test_comparison_keeps_unstable_variants_unranked(self):
direct = [
{"offered_unit": "Homura Evo", "offered_qty": quantity,
"requested_unit": "Aizen Evo", "requested_qty": 1,
"source_row": row, "quote_type": "explicit_for", "source_text": "proposal"}
for row, quantity in ((2, 1), (3, 1), (4, 10))
]
values, _, report, _, _ = fit_values(direct, [], include_report=True)
row = next(item for item in compare_evidence_modes(values, report, values, report)
if item["unit_variant"] == "Homura Evo")
self.assertEqual(row["all_confidence"], "unstable")
self.assertEqual((row["all_ranked_value"], row["explicit_only_ranked_value"]),
("", ""))
def test_comparison_marks_variant_disconnected_without_inferred_pair(self):
direct = [
{"offered_unit": "Homura Evo", "offered_qty": 1,
"requested_unit": "Aizen Evo", "requested_qty": 1,
"source_row": 2, "quote_type": "explicit_for", "source_text": "proposal"},
{"offered_unit": "Chuuni Evo", "offered_qty": 1,
"requested_unit": "Homura Evo", "requested_qty": 1,
"source_row": 3, "quote_type": "listing_pair", "source_text": "listing"},
]
values, _, report, _, _ = fit_values(direct, [], include_report=True)
explicit_values, _, explicit_report, _, _ = fit_values(
direct[:1], [], include_report=True)
row = next(item for item in compare_evidence_modes(
values, report, explicit_values, explicit_report)
if item["unit_variant"] == "Chuuni Evo")
self.assertEqual(row["explicit_only_connection"], "disconnected")
self.assertEqual(row["explicit_only_confidence"], "disconnected")
self.assertEqual(row["explicit_only_fit"], "")
def test_explicit_quantified_bundle_and_ambiguous_alternative(self):
self.assertEqual(parse_bundle("my 2 Homura Evo + Buddha Evo")[0],
{"Homura Evo": 2, "Buddha Evo": 1})
@@ -27,6 +82,58 @@ class ProvisionalValueListTests(unittest.TestCase):
self.assertEqual(shiny["relative_value"], "")
self.assertEqual(shiny["confidence"], "constraint_only")
def test_conflicting_direct_quotes_show_both_sources(self):
direct = [
{"offered_unit": "Homura Evo", "offered_qty": 2,
"requested_unit": "Alucard Evo", "requested_qty": 1,
"source_row": 10, "source_text": "2 Homura Evo for Alucard Evo"},
{"offered_unit": "Homura Evo", "offered_qty": 1,
"requested_unit": "Alucard Evo", "requested_qty": 1,
"source_row": 20, "source_text": "Homura Evo for Alucard Evo"},
]
conflicts = conflicting_quotes(direct)
self.assertEqual(len(conflicts), 1)
self.assertEqual((conflicts[0]["source_row_a"], conflicts[0]["source_row_b"]), (10, 20))
self.assertEqual(conflicts[0]["ratio_difference_pct"], 100.0)
def test_influential_quote_removes_numeric_rank(self):
direct = [
{"offered_unit": "Homura Evo", "offered_qty": qty,
"requested_unit": "Aizen Evo", "requested_qty": 1,
"source_row": row, "source_text": f"{qty} Homura Evo for Aizen Evo"}
for row, qty in ((2, 1), (3, 1), (4, 10))
]
rows, _, report, _, impacts = fit_values(direct, [], include_report=True)
homura = next(row for row in rows if row["unit_variant"] == "Homura Evo")
evidence = next(row for row in report if row["unit_variant"] == "Homura Evo")
self.assertEqual(homura["confidence"], "unstable")
self.assertEqual((homura["rank"], homura["relative_value"]), ("", ""))
self.assertGreater(evidence["max_change_pct"], 25)
self.assertEqual(evidence["most_influential_source_row"], 4)
removed_outlier = next(item for item in impacts if item["unit_variant"] == "Homura Evo"
and item["removed_source_row"] == 4)
self.assertGreater(removed_outlier["change_pct"], 25)
def test_bridge_quote_disconnects_variant(self):
direct = [
{"offered_unit": "Homura Evo", "offered_qty": 1,
"requested_unit": "Aizen Evo", "requested_qty": 1,
"source_row": 2, "source_text": "Homura for Aizen"},
*({"offered_unit": "Chuuni Evo", "offered_qty": 1,
"requested_unit": "Homura Evo", "requested_qty": 1,
"source_row": row, "source_text": "Chuuni for Homura"}
for row in (3, 4, 5)),
]
rows, _, report, _, impacts = fit_values(direct, [], include_report=True)
chuuni = next(row for row in rows if row["unit_variant"] == "Chuuni Evo")
evidence = next(row for row in report if row["unit_variant"] == "Chuuni Evo")
self.assertEqual(chuuni["confidence"], "unstable")
self.assertEqual(chuuni["rank"], "")
self.assertEqual(evidence["disconnects_when_removed"], "2")
bridge = next(item for item in impacts if item["unit_variant"] == "Chuuni Evo"
and item["removed_source_row"] == 2)
self.assertEqual((bridge["leave_one_out_value"], bridge["disconnected"]), ("", "yes"))
if __name__ == "__main__":
unittest.main()
+1760 -1257
View File
File diff suppressed because it is too large Load Diff
Binary file not shown.
Binary file not shown.
View File