user233051 notes that ^IRX is indeed the official discount rate of the US Treasury. So to answer his question we need to exactly understand how the Treasury computes the discount rate. My answer is based on www.treasury.gov pages here, here and here.
The official way of calculating the discount rate $d$ is $d = \frac{100-P}{100}\frac{360}{n}$ where $P$ is the price per \$100 of par (face) value and $n$ is the number of days until expiration. In order to get the $d$ of this formula we would divide the ^IRX by 100 because it is stated as a percent. Yes, it's a somewhat arbitrary way of compounding the return, but that's what they do. The Treasury says "The Bank Discount rate is the rate at which a Bill is quoted in the secondary market and is based on the par value, amount of the discount and a 360-day year." The missing 5 or 6 days are for bankers' holidays.
But we want instead $r = \frac{100}{P}^\frac{1}{n}$ where $r$ is the daily risk-free return ratio. So we have some simple algebra to do. We solve the first equation for $P$ and substitute that value in the equation for $r$ and get
$r = \frac{ 1 }{ 1 - \frac{dn}{360}}^{1/n}$ where $dn$ is the product of $d$ and $n$.
So we have our answer but we really need to know what $n$ is, for each day. The Treasury says that their discount rates are determined by prices in the secondary market--- for the most recently auctioned bill. New 13-wk bills are auctioned-off every Monday. So this means that at first $n$ is approximately 91 days, but it will decline to about 85 days before a new bill is auctioned. So unless our code is responsive to the days of the week (and we do some further research about the details) we may instead want to consider making an approximation.
To that end, we can do some simple algebra that shows that the quantity that we want to compute is rather insensitive to small differences in the assumed value of $n$, to such an extent that we almost don't really need to have any idea what the value of $n$ is (because it will always be fairly large, at least 85). Since $d$ is quite small and is also divided by $360$, $\frac{1}{1 - \frac{dn}{360}}\approx 1 + \frac{dn}{360}$. And we recognize $1 + \frac{dn}{360}$ to be the leading term in $d$ in $(1 + \frac{d}{360})^n$. Therefore $r\approx 1 + \frac{d}{360}$!
The following Python code explores which approximation is best. In the printout rf
is the annualized risk-free return ratio, annualized so as to magnify the differences over a respectable period of time.
for i in range(1,5):
d = ( float(i) * 0.5 ) / 100.0 # discount rate
nhi = 91.0 # days until maturity
nlow = 91.0 - 6.0
rhi = ( 1.0 / (1 - d * nhi/360.0) )**(1/nhi) # corresponding daily risk-free return ratio (exact)
rlow = ( 1.0 / (1 - d * nlow/360.0) )**(1/nlow)
print( 'discount rate, d = {}'.format(d, '') )
print( 'rf = {} {}'.format(rhi**365.0, 'exact: n = 91 days') ) # rf is the annualized risk-free return ratio
print( 'rf = {} {}'.format( (1+d/252.0)**252.0, '(1+d/252.0)**252.0' ) )
print( 'rf = {} {}'.format( (1+d/360.0)**365.0, '(1+d/360.0)**365.0' ) )
print( 'rf = {} {}'.format(rlow**365.0, 'exact: n = 85 days') )
print('')
discount rate, d = 0.005
rf = 1.00508553843 exact: n = 91 days
rf = 1.00501247101 (1+d/252.0)**252.0
rf = 1.00508228044 (1+d/360.0)**365.0
rf = 1.00508532578 exact: n = 85 days
discount rate, d = 0.01
rf = 1.01020342853 exact: n = 91 days
rf = 1.01004996668 (1+d/252.0)**252.0
rf = 1.01019031932 (1+d/360.0)**365.0
rf = 1.01020257221 exact: n = 85 days
discount rate, d = 0.015
rf = 1.01535391748 exact: n = 91 days
rf = 1.01511261146 (1+d/252.0)**252.0
rf = 1.01532424685 (1+d/360.0)**365.0
rf = 1.01535197778 exact: n = 85 days
discount rate, d = 0.02
rf = 1.02053725469 exact: n = 91 days
rf = 1.02020053039 (1+d/252.0)**252.0
rf = 1.02048419386 (1+d/360.0)**365.0
rf = 1.02053378305 exact: n = 85 days
Note that the calculated values that are exact for 91 days and 85 days are almost equal. Next to those the $1 + \frac{d}{360}$ estimate isn't too bad. Those possibilities should be used with code that pays interest over the weekend. If you're just doing bars without regard for the day of the week, you'd like to use $1 + \frac{d}{252}$ but it doesn't fare as well. All things considered, for those of us who do go so far as to give proper consideration to the weekend the most feasible thing to do would seem to be to approximate $n$ by, say, $88$.