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-2t-1tweightedmeets test
121121121181.50False
122122122183.00True
9090150195.00True
150150120195.00True
00182182.00False
33033030195.00False
33033031196.00True
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