What does FX Spreads, DCC Traps and Residency Days conclude, in numbers, about “Counting Days: 183, Rolling Windows and a Weighted Formula”?
Answer: Chapter 5 compares counting rules: under the substantial presence test, someone who visits the US every year has a steady limit of 121 days; the same itinerary counts 120 days by calendar year and 240 in some twelve months.
Scope of the numbers: Its exchange rates, fees and itineraries are illustrative models; all calculations are generated by its programs; the book is not tax, immigration, legal or investment advice. Marked boxes separate published evidence, runnable Python calculations (16 programs), classical sources and the author's hypotheses.
Data table
The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 120, 121
| days t-2 | t-1 | t | weighted | meets test |
| 121 | 121 | 121 | 181.50 | False |
| 122 | 122 | 122 | 183.00 | True |
| 90 | 90 | 150 | 195.00 | True |
| 150 | 150 | 120 | 195.00 | True |
| 0 | 0 | 182 | 182.00 | False |
| 330 | 330 | 30 | 195.00 | False |
| 330 | 330 | 31 | 196.00 | True |
| largest steady yearly stay below the test: 121 days |
Show the full program
# Chapter 5. p09: The weighted day count of the US substantial presence
# test. A person meets it in year t if present at least 31 days in t
# and D(t) + D(t-1) / 3 + D(t-2) / 6 is at least 183 (exceptions such
# as the closer-connection rule are not modelled). Exact fractions; no
# sampling. We print the weighted count for several three-year
# patterns and the largest steady number of days a year that stays
# below the line.
from fractions import Fraction as Fr
def weighted(d0, d1, d2):
return d0 + Fr(d1, 3) + Fr(d2, 6)
def meets(d0, d1, d2):
return d0 >= 31 and weighted(d0, d1, d2) >= 183
if __name__ == "__main__":
print(" days t-2 t-1 t weighted meets test")
for pat in ((121, 121, 121), (122, 122, 122), (90, 90, 150),
(150, 150, 120), (0, 0, 182), (330, 330, 30),
(330, 330, 31)):
d2, d1, d0 = pat
w = weighted(d0, d1, d2)
print(" {:8d} {:3d} {:3d} {:8.2f} {}".format(
d2, d1, d0, float(w), meets(d0, d1, d2)))
steady = max(d for d in range(366) if not meets(d, d, d))
print(" largest steady yearly stay below the test: {} days"
.format(steady))Single source and citation
Fan, Y. (2026). Multicurrency FX Spread Microstructure, Dynamic Currency Conversion Traps and Tax-Residency Day-Counting Thresholds (Version 1.0.0), Chapter 5: Counting Days: 183, Rolling Windows and a Weighted Formula. 5D Library. DOI pending
DOI pending · monograph page goes live after publication · 5DL-B-108 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026108,
author = {Fan, Yafu},
title = {Multicurrency FX Spread Microstructure, Dynamic Currency Conversion Traps and Tax-Residency Day-Counting Thresholds},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}Other chapter answers in this book
- Chapter 1 · Why the Airport Booth's Spread Is So Wide
- Chapter 2 · The Weekend Markup on Multicurrency Cards
- Chapter 3 · How Much to Take Out of the ATM: The Economic Order Quantity
- Chapter 4 · Dynamic Currency Conversion at the Till
- Chapter 6 · Planning a Year as a Knapsack
- Chapter 7 · The Rites of Zhou on Contracts and the Money Office, Tang Flying Cash and the Forward Discount
- Chapter 8 · Practice: A Year's Friction Budget and a Day Ledger