diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml
index 05d8fdb..30a2651 100644
--- a/.github/workflows/R-CMD-check.yaml
+++ b/.github/workflows/R-CMD-check.yaml
@@ -59,6 +59,9 @@ jobs:
Rscript test_replay.R
Rscript test_replay_log.R
Rscript test_compare_books.R
+ Rscript test_change_report.R
+ Rscript change-report.R example-log.csv 2026-10-01T14:00:06.049Z 2026-10-01T14:00:06.050Z > "$RUNNER_TEMP/change-report.html"
+ grep -Fq "1 of 3 selections changed" "$RUNNER_TEMP/change-report.html"
Rscript compare-books.R example-log.csv 2026-10-01T14:00:06.049Z 6000 fictional-final game "Harbor Owls" north south
Rscript replay-log.R example-log.csv 2026-10-01T14:00:06.050Z
diff --git a/.github/workflows/reference.yml b/.github/workflows/reference.yml
index e6f6cd1..5a99f00 100644
--- a/.github/workflows/reference.yml
+++ b/.github/workflows/reference.yml
@@ -36,6 +36,9 @@ jobs:
- name: Render and check the decision-clock report
working-directory: tutorials/point-in-time
run: Rscript build-clock-report.R ../../docs/clock-report
+ - name: Build the two-deadline report and its offline project
+ working-directory: tutorials/point-in-time
+ run: Rscript build-change-report.R ../../docs/decision-changes
- name: Build and install the documented source package
id: source-package
run: |
diff --git a/pkgdown/index.md b/pkgdown/index.md
index 0bfac54..faf480e 100644
--- a/pkgdown/index.md
+++ b/pkgdown/index.md
@@ -10,6 +10,8 @@ In a twelve-second fictional log, a withdrawal and two delayed prices change wha
At 14:00:04 an analyst had seen a price of 1.90. A 2.10 update stamped 14:00:03 reached the analyst at 14:00:06. Use the six-message fictional log to find when each price became available. You can run the tutorial in base R or in your browser.
+[Compare two deadlines in your own log](decision-changes/). The worked report shows how one millisecond changed one of three fictional quotes. The download includes everything needed to run the comparison in base R.
+
[Open the replay tutorial](https://github.com/JacobiusMakes/parlayapiR/tree/main/tutorials/point-in-time). The tutorial appears in [R Weekly, issue 49 of 2026](https://rweekly.org/2026-W49.html).
## How often did an NFL team make an extra point?
diff --git a/tutorials/point-in-time/CHANGE-REPORT.md b/tutorials/point-in-time/CHANGE-REPORT.md
new file mode 100644
index 0000000..dd89188
--- /dev/null
+++ b/tutorials/point-in-time/CHANGE-REPORT.md
@@ -0,0 +1,15 @@
+# Compare two moneyline decisions with base R
+
+Extract the ZIP to a directory. From that directory, write a report to a new file:
+
+```sh
+Rscript change-report.R example-log.csv 2026-10-01T14:00:06.049Z 2026-10-01T14:00:06.050Z > comparison.html
+```
+
+Open `comparison.html` in your browser. North’s Harbor Owls quote changes from 1.90 to 2.10. North’s Valley Foxes quote and South’s Harbor Owls quote keep their earlier prices. Set the second cutoff to `2026-10-01T14:00:09Z` to see North’s withdrawal. All observations in the supplied CSV are fictional.
+
+For your own report, replace the CSV filename and both UTC cutoffs. Use the nine columns in `example-log.csv`. The five identity fields are event_id, book, market (h2h), period and selection. Supply updated_utc and received_utc as UTC timestamps ending in Z with up to three fractional digits. Receipt must be at or after the source update. For state quoted, decimal_price must exceed 1. For withdrawn, leave decimal_price empty. The two cutoffs must be in increasing order. No R packages, network requests or API key are required. Use a new output filename each time you want to keep a previous report.
+
+The report includes event IDs, books, markets, periods, selections, source timestamps, states and prices from your file. Anyone you give the HTML to can read those values. Only selections observed by the second cutoff are shown. A later message with an older source update cannot roll a price back. Conflicting observations with the same latest update have an unknown price. The comparison describes the two endpoints; a selection may change and revert in between.
+
+To check the supplied example and the other cases, run `Rscript test_change_report.R` from the extracted directory.
diff --git a/tutorials/point-in-time/README.md b/tutorials/point-in-time/README.md
index bfb61e6..567afaa 100644
--- a/tutorials/point-in-time/README.md
+++ b/tutorials/point-in-time/README.md
@@ -41,6 +41,8 @@ In this fictional final, North’s last known Owls price is **1.90**. Move the c
[See the file format and output states](log-guide.md). For your own log, use the nine columns in [example-log.csv](example-log.csv). Keep event ID, bookmaker, market, period and selection separate. Use `h2h`, decimal prices, and UTC source and receipt timestamps ending in `Z` with up to three fractional digits. Leave the price blank on a withdrawal. The output includes only selections observed by the cutoff. A withdrawn or conflicting selection has an empty price. Receipt times must come from your collector. A file containing only final prices cannot establish arrival history.
+[See which selections changed between two deadlines](https://jacobiusmakes.github.io/parlayapiR/decision-changes/). In the worked report, one millisecond changes North’s Owls price from 1.90 to 2.10 while two other quotes stay put. Download the project there to generate an HTML comparison from your own CSV with base R.
+
## Compare two books at the same deadline
[Run the two-book replay](compare-books.md) on the same fictional final. At 14:00:06.049 South leads with 1.95. One millisecond later North leads with 2.10. Tighten the source-age limit or move past the withdrawal to see when a comparison becomes unavailable.
diff --git a/tutorials/point-in-time/build-change-report.R b/tutorials/point-in-time/build-change-report.R
new file mode 100644
index 0000000..c7d440a
--- /dev/null
+++ b/tutorials/point-in-time/build-change-report.R
@@ -0,0 +1,23 @@
+# Build the public worked example and downloadable project from the same source.
+source("replay.R")
+source("replay-log.R")
+source("change-report.R")
+source("register-report.R")
+args <- commandArgs(trailingOnly = TRUE)
+stopifnot(length(args) == 1L)
+dir.create(args[1L], recursive = TRUE, showWarnings = FALSE)
+dest <- normalizePath(args[1L], mustWork = TRUE)
+before <- "2026-10-01T14:00:06.049Z"
+after <- "2026-10-01T14:00:06.050Z"
+rows <- decision_changes("example-log.csv", before, after)
+stopifnot(nrow(rows) == 3L, sum(rows$change == "Price changed") == 1L)
+html <- render_changes(rows, before, after, "change-report.html", example = TRUE)
+writeLines(enc2utf8(html), file.path(dest, "index.html"), useBytes = TRUE)
+files <- c("CHANGE-REPORT.md", "change-report.R", "change-report.html", "example-log.csv",
+ "replay.R", "replay-log.R", "test_change_report.R")
+archive <- file.path(dest, "project.zip")
+if (file.exists(archive)) unlink(archive)
+stopifnot(utils::zip(archive, files, flags = "-qX") == 0L)
+stopifnot(setequal(utils::unzip(archive, list = TRUE)$Name, files))
+register_report(file.path(dirname(dest), "sitemap.xml"),
+ "https://jacobiusmakes.github.io/parlayapiR/decision-changes/")
diff --git a/tutorials/point-in-time/build-clock-report.R b/tutorials/point-in-time/build-clock-report.R
index 18b8d18..0070374 100644
--- a/tutorials/point-in-time/build-clock-report.R
+++ b/tutorials/point-in-time/build-clock-report.R
@@ -3,6 +3,7 @@ build_report <- function(destination) {
dir.create(destination, showWarnings = FALSE, recursive = TRUE)
destination <- normalizePath(destination, mustWork = TRUE)
source("replay.R", local = TRUE)
+ source("register-report.R", local = TRUE)
t0 <- example_start()
intervals <- clock_intervals(example_log(), "home", t0, t0 + 12)
utc <- function(x) format(x, "%Y-%m-%dT%H:%M:%SZ", tz = "UTC")
@@ -58,17 +59,7 @@ build_report <- function(destination) {
params = list(start_second = 8, end_second = 9))
check_render(file.path(extracted, "index.html"), "1 second of the 1-second window", 1L)
- sitemap <- file.path(dirname(destination), "sitemap.xml")
- xml <- xml2::read_xml(sitemap)
- locate <- function(x) xml2::xml_text(xml2::xml_find_all(x, "//*[local-name()='loc']"))
- before <- locate(xml)
- if (!url %in% before) {
- node <- xml2::xml_add_child(xml2::xml_root(xml), "url")
- xml2::xml_add_child(node, "loc", url)
- xml2::write_xml(xml, sitemap)
- }
- after <- locate(xml2::read_xml(sitemap))
- stopifnot(identical(after[after != url], before[before != url]), sum(after == url) == 1L)
+ register_report(file.path(dirname(destination), "sitemap.xml"), url)
}
args <- commandArgs(trailingOnly = TRUE)
diff --git a/tutorials/point-in-time/change-report.R b/tutorials/point-in-time/change-report.R
new file mode 100644
index 0000000..ec6e354
--- /dev/null
+++ b/tutorials/point-in-time/change-report.R
@@ -0,0 +1,103 @@
+# Source replay.R and replay-log.R before using the functions interactively.
+decision_changes <- function(path, before_utc, after_utc) {
+ before <- parse_utc(before_utc)
+ after <- parse_utc(after_utc)
+ if (length(before) != 1L || length(after) != 1L || before >= after)
+ stop("Choose two increasing UTC decision times.")
+
+ rows <- read_log(path)
+ first <- replay_rows(rows, before)
+ last <- replay_rows(rows, after)
+ fields <- c("event_id", "book", "market", "period", "selection")
+ # A length prefix keeps a separator inside a team or bookmaker name unambiguous.
+ identity_key <- function(frame) {
+ if (!nrow(frame)) return(character())
+ parts <- lapply(frame[fields], function(v) {
+ v <- enc2utf8(v)
+ paste0(nchar(v, type = "bytes"), ":", v)
+ })
+ do.call(paste0, unname(parts))
+ }
+ prior <- match(identity_key(last), identity_key(first))
+ result <- last[fields]
+ result$before_state <- first$state[prior]
+ result$before_state[is.na(prior)] <- "unseen"
+ result$before_price <- first$decimal_price[prior]
+ result$before_updated <- first$updated_utc[prior]
+ result$after_state <- last$state
+ result$after_price <- last$decimal_price
+ result$after_updated <- last$updated_utc
+ change <- rep("Unchanged", nrow(last))
+ repriced <- result$before_state == "quoted" & result$after_state == "quoted" &
+ result$before_price != result$after_price
+ change[repriced] <- "Price changed"
+ change[result$before_state != result$after_state] <- "State changed"
+ change[is.na(prior)] <- "First observed"
+ result$change <- change
+ result[order(change == "Unchanged", method = "radix"), , drop = FALSE]
+}
+
+escape_text <- function(x) {
+ x <- gsub("&", "&", x, fixed = TRUE)
+ x <- gsub("<", "<", x, fixed = TRUE)
+ gsub(">", ">", x, fixed = TRUE)
+}
+
+render_changes <- function(rows, before_utc, after_utc, template, example = FALSE) {
+ quote_label <- function(state, price) {
+ switch(state, quoted = if (price == round(price, 2)) sprintf("%.2f", price) else as.character(price), withdrawn = "Withdrawn",
+ conflict = "Conflicting observations", unseen = "Unseen")
+ }
+ observation <- function(label, value, updated) {
+ clock <- if (is.na(updated)) "" else paste0("Source update ")
+ paste0("
", label, "
", escape_text(value), "
", clock, "
")
+ }
+ card <- function(i) {
+ row <- rows[i, , drop = FALSE]
+ left <- quote_label(row$before_state, row$before_price)
+ right <- quote_label(row$after_state, row$after_price)
+ if (row$change == "Price changed" && identical(left, right)) {
+ left <- sprintf("%.17g", row$before_price)
+ right <- sprintf("%.17g", row$after_price)
+ }
+ paste0('
A difference means the selection first appeared, its quote state changed or its decimal price changed. An unchanged row can have a newer source timestamp. The report compares two snapshots of the file. Changes between those instants can cancel out.