ED_FUTYF
Updated 2023-10-13 12:45:03.417000
Syntax
SELECT [westclintech].[wct].[ED_FUTYF](
<@DeliveryCode, nvarchar(4000),>
,<@StartDate, datetime,>
,<@Basis, nvarchar(4000),>)
Description
Use the scalar function ED_FUTYF to calculate the amount of time (in years) from a start date to the delivery date of a futures contract.
Arguments
@DeliveryCode
the standard delivery codes for Eurodollar futures, consisting of a letter and a one- or two-digit number.
@Basis
the day-count convention used in the calculation of the year fraction.
{"columns":[{"field":"@Basis","width":139},{"field":"Day count basis","width":396}],"rows":[{"@Basis":"0 or omitted","Day count basis":"US (NASD) 30/360"},{"@Basis":"1","Day count basis":"Actual/Actual"},{"@Basis":"2","Day count basis":"Actual/360"},{"@Basis":"3","Day count basis":"Actual/365"},{"@Basis":"4","Day count basis":"European 30/360"}]}
@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.
Return Type
float
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.
Examples
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 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
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.
{"columns":[{"field":"dc"},{"field":"YF","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"dc":"M13","YF":"0.238888888888889"},{"dc":"U13","YF":"0.491666666666667"},{"dc":"Z13","YF":"0.744444444444444"},{"dc":"H14","YF":"0.997222222222222"},{"dc":"M14","YF":"1.25"},{"dc":"U14","YF":"1.50277777777778"},{"dc":"Z14","YF":"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.
{"columns":[{"field":"dc"},{"field":"YearFrac","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"YF","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"dc":"M3","YearFrac":"0.238888888888889","YF":"0.238888888888889"},{"dc":"U3","YearFrac":"0.491666666666667","YF":"0.491666666666667"},{"dc":"Z3","YearFrac":"0.744444444444444","YF":"0.744444444444444"},{"dc":"H4","YearFrac":"0.997222222222222","YF":"0.997222222222222"},{"dc":"M4","YearFrac":"1.25","YF":"1.25"},{"dc":"U4","YearFrac":"1.50277777777778","YF":"1.50277777777778"},{"dc":"Z4","YearFrac":"1.75555555555556","YF":"1.75555555555556"}]}