Login     Register

        Contact Us     Search

XLeratorDB/financial Documentation

SQL Server YEARFRAC function for Eurodollar futures


ED_FUTYF

Updated: 29 Mar 2013


Use ED_FUTYF to calculate the amount of time (in years) from a start date to the delivery date of a futures contract.
Syntax
SELECT [wctFinancial].[wct].[ED_FUTYF](
  <@DeliveryCode, nvarchar(4000),>
 ,<@StartDate, datetime,>
 ,<@Basis, nvarchar(4000),>)
Arguments
@DeliveryCode
the standard delivery codes for Eurodollar futures, consisting of a letter and a one- or two-digit number.
@StartDate
The date from which the delivery date is calculated. @StartDate is an expression of type datetime or of a type that can be implicitly converted to datetime.
@Basis
the day-count convention used in the calculation of the year fraction.
 

@Basis
Day count basis
 
0 or omitted
US (NASD) 30/360
1
Actual/Actual
2
Actual/360
3
Actual/365
4
European 30/360

 
Return Type
datetime
Remarks
·         If @StartDate is NULL, @StartDate =GETDATE()
·         Valid letters for @DeliveryCode are F, G, H, J, K, M, N, Q, U, V, X, and Z.
·         If @Basis is NULL, @Basis = 2
Example
In this example we calculate the fractions of a year associated with the Eurodollar Futures strip as of 2013-03-25.
SELECT dc
,wct.ED_FUTYF(
dc                --@DeliveryCode
,'2013-03-25'     --@StartDate
,2                --@Basis
) as YF
FROM (
      SELECT 'M3' UNION ALL
      SELECT 'U3' UNION ALL
      SELECT 'Z3' UNION ALL
      SELECT 'H4' UNION ALL
      SELECT 'M4' UNION ALL
      SELECT 'U4' UNION ALL
      SELECT 'Z4'
      )n(dc)

This produces the following result.
dc                       YF
---- ----------------------
M3        0.238888888888889
U3        0.491666666666667
Z3        0.744444444444444
H4        0.997222222222222
M4                     1.25
U4         1.50277777777778
Z4         1.75555555555556

The following SQL will produce exactly the same year fractions.
SELECT dc
,wct.ED_FUTYF(DC,'2013-03-25',2) as YF
FROM (
      SELECT 'M13' UNION ALL
      SELECT 'U13' UNION ALL
      SELECT 'Z13' UNION ALL
      SELECT 'H14' UNION ALL
      SELECT 'M14' UNION ALL
      SELECT 'U14' UNION ALL
      SELECT 'Z14'
      )n(dc)
This produces the following result.
dc                       YF
---- ----------------------
M13       0.238888888888889
U13       0.491666666666667
Z13       0.744444444444444
H14       0.997222222222222
M14                    1.25
U14        1.50277777777778
Z14        1.75555555555556

ED_FUTYF
produces the same results as if you used the YEARFRAC function.
SELECT dc
,wct.YEARFRAC('2013-03-25',wct.ED_FUT2DATE(DC,'2013-03-25'),2) YearFrac
,wct.ED_FUTYF(DC,'2013-03-25',2) as YF
FROM (
      SELECT 'M3' UNION ALL
      SELECT 'U3' UNION ALL
      SELECT 'Z3' UNION ALL
      SELECT 'H4' UNION ALL
      SELECT 'M4' UNION ALL
      SELECT 'U4' UNION ALL
      SELECT 'Z4'
      )n(dc)
This produces the following result.
dc                 YearFrac                     YF
---- ---------------------- ----------------------
M3        0.238888888888889      0.238888888888889
U3        0.491666666666667      0.491666666666667
Z3        0.744444444444444      0.744444444444444
H4        0.997222222222222      0.997222222222222
M4                     1.25                   1.25
U4         1.50277777777778       1.50277777777778
Z4         1.75555555555556       1.75555555555556
 


Copyright 2008-2024 Westclintech LLC         Privacy Policy        Terms of Service