T Bill Rate Calculator

T-Bill Rate Calculator: Calculate Treasury Bill Yields Accurately :root { –primary-color: #004a99; –success-color: #28a745; –background-color: #f8f9fa; –text-color: #333; –border-color: #ccc; –card-background: #fff; –error-color: #dc3545; } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: var(–background-color); color: var(–text-color); line-height: 1.6; margin: 0; padding: 0; display: flex; flex-direction: column; align-items: center; padding-top: 20px; padding-bottom: 40px; } .container { width: 95%; max-width: 960px; background-color: var(–card-background); padding: 30px; border-radius: 8px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); margin: 0 auto; } h1, h2, h3 { color: var(–primary-color); text-align: center; margin-bottom: 20px; } h1 { font-size: 2.2em; margin-bottom: 30px; } h2 { font-size: 1.8em; border-bottom: 2px solid var(–primary-color); padding-bottom: 10px; margin-top: 40px; } h3 { font-size: 1.4em; margin-top: 30px; color: var(–primary-color); } .loan-calc-container { background-color: var(–card-background); padding: 25px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08); margin-bottom: 30px; } .input-group { margin-bottom: 20px; text-align: left; } .input-group label { display: block; margin-bottom: 8px; font-weight: bold; color: var(–primary-color); } .input-group input[type="number"], .input-group input[type="text"], .input-group select { width: calc(100% – 22px); padding: 12px; border: 1px solid var(–border-color); border-radius: 5px; font-size: 1em; box-sizing: border-box; transition: border-color 0.3s ease; } .input-group input[type="number"]:focus, .input-group input[type="text"]:focus, .input-group select:focus { border-color: var(–primary-color); outline: none; } .input-group .helper-text { font-size: 0.85em; color: #6c757d; margin-top: 5px; display: block; } .error-message { color: var(–error-color); font-size: 0.85em; margin-top: 5px; display: none; /* Hidden by default */ } .error-message.visible { display: block; } .button-group { display: flex; justify-content: space-between; margin-top: 25px; gap: 10px; } .button-group button { padding: 12px 20px; border: none; border-radius: 5px; cursor: pointer; font-size: 1em; font-weight: bold; transition: background-color 0.3s ease, transform 0.2s ease; flex-grow: 1; } .btn-calculate { background-color: var(–primary-color); color: white; } .btn-calculate:hover { background-color: #003366; transform: translateY(-2px); } .btn-reset { background-color: #6c757d; color: white; } .btn-reset:hover { background-color: #5a6268; transform: translateY(-2px); } .btn-copy { background-color: var(–success-color); color: white; margin-top: 10px; width: 100%; } .btn-copy:hover { background-color: #218838; transform: translateY(-2px); } #results { margin-top: 30px; padding: 25px; background-color: var(–primary-color); color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); text-align: center; } #results h3 { color: white; margin-top: 0; margin-bottom: 15px; font-size: 1.6em; } .result-item { margin-bottom: 15px; font-size: 1.1em; } .result-item strong { color: #e0e0e0; } .primary-result { font-size: 2em; font-weight: bold; margin-top: 10px; padding: 10px; background-color: rgba(255, 255, 255, 0.2); border-radius: 5px; display: inline-block; } .formula-explanation { font-size: 0.9em; color: #e0e0e0; margin-top: 20px; padding-top: 15px; border-top: 1px solid rgba(255, 255, 255, 0.3); } table { width: 100%; border-collapse: collapse; margin-top: 25px; margin-bottom: 30px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); } caption { font-size: 1.1em; font-weight: bold; color: var(–primary-color); margin-bottom: 15px; text-align: left; } th, td { padding: 12px 15px; text-align: left; border: 1px solid var(–border-color); } thead { background-color: var(–primary-color); color: white; } tbody tr:nth-child(even) { background-color: #f2f2f2; } tbody tr:hover { background-color: #e9ecef; } canvas { display: block; margin: 25px auto; background-color: var(–card-background); border-radius: 5px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); } .chart-container { text-align: center; margin-top: 30px; padding: 20px; background-color: var(–card-background); border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08); } .chart-container h3 { margin-top: 0; margin-bottom: 20px; } .article-content { margin-top: 40px; background-color: var(–card-background); padding: 30px; border-radius: 8px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); } .article-content p, .article-content ul, .article-content ol { margin-bottom: 20px; font-size: 1.05em; } .article-content ul { list-style-type: disc; padding-left: 40px; } .article-content ol { list-style-type: decimal; padding-left: 40px; } .article-content li { margin-bottom: 10px; } .article-content a { color: var(–primary-color); text-decoration: none; font-weight: bold; } .article-content a:hover { text-decoration: underline; } .faq-item { margin-bottom: 20px; padding: 15px; background-color: #f2f2f2; border-left: 4px solid var(–primary-color); border-radius: 4px; } .faq-item strong { display: block; margin-bottom: 5px; color: var(–primary-color); font-size: 1.1em; } .related-links ul { list-style: none; padding: 0; } .related-links li { margin-bottom: 15px; } .related-links a { font-weight: bold; } .related-links span { font-size: 0.9em; color: #6c757d; display: block; margin-top: 3px; } .highlighted-result { font-size: 2.5em; font-weight: bold; color: var(–success-color); margin: 10px 0; display: block; } .key-assumption { font-size: 0.9em; color: #e0e0e0; margin-top: 15px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, 0.3); } .variable-table { margin-top: 20px; margin-bottom: 30px; } .variable-table th, .variable-table td { padding: 10px 12px; } .variable-table th { background-color: #e9ecef; color: var(–text-color); } .variable-table td { border: 1px solid #dee2e6; } .variable-table tr:nth-child(even) { background-color: #f8f9fa; } .variable-table tr:hover { background-color: #e2e6ea; } .chart-legend { margin-top: 15px; font-size: 0.9em; color: #6c757d; } .chart-legend span { display: inline-block; margin: 0 10px; } .chart-legend .color-box { display: inline-block; width: 12px; height: 12px; margin-right: 5px; vertical-align: middle; border: 1px solid #ccc; } .color-yield { background-color: #1f77b4; } .color-discount { background-color: #ff7f0e; }

T-Bill Rate Calculator

Calculate the investment yield on U.S. Treasury Bills with ease. Understand the discount and coupon equivalent yields for your short-term government debt investments.

Treasury Bill Calculator

The price you paid for the T-bill.
The amount the T-bill will be worth at maturity.
The number of days remaining until the T-bill matures.

Your T-Bill Investment Results

Discount Rate: –.–%
Coupon Equivalent Yield (CEY): –.–%
Investment Gain ($): –.–
Annualized Yield (Simple): –.–%
Formula Used:

Discount Rate = ((Face Value – Purchase Price) / Face Value) * (360 / Days to Maturity) * 100
Coupon Equivalent Yield (CEY) = Discount Rate * (365 / 360) * (Face Value / Purchase Price)

Key Assumption: 360-day year convention for discount rate calculation, 365-day year for CEY.

Yield vs. Discount Over Time

Coupon Equivalent Yield (CEY) Discount Rate

What is a T-Bill Rate?

The T-bill rate, or Treasury Bill rate, refers to the yield an investor earns on U.S. Treasury Bills (T-bills). T-bills are short-term debt instruments issued by the U.S. Department of the Treasury with maturities ranging from a few days up to 52 weeks. They are considered one of the safest investments in the world because they are backed by the full faith and credit of the U.S. government. The t bill rate calculator helps investors quickly understand the potential return on these investments.

Unlike coupon-bearing bonds, T-bills are sold at a discount to their face value (par value) and the investor receives the face value at maturity. The difference between the purchase price and the face value represents the investor's profit. The t bill rate calculator is crucial for determining this profit and expressing it as an annualized yield.

Who should use a T-Bill Rate Calculator?

  • Short-term investors seeking safe havens for their capital.
  • Individuals and institutions managing cash reserves.
  • Portfolio managers looking to diversify with low-risk assets.
  • Anyone interested in understanding the current short-term interest rate environment.

Common Misconceptions about T-Bill Rates:

  • Misconception: T-bill rates are always the same as other interest rates. Reality: T-bill rates are influenced by short-term market conditions, monetary policy, and inflation expectations, and can differ significantly from longer-term bond yields or bank deposit rates.
  • Misconception: T-bills are complex to understand. Reality: While the calculation of their yield can seem tricky, tools like the t bill rate calculator simplify the process, making them accessible to most investors.
  • Misconception: T-bills offer no return. Reality: T-bills provide a return through the difference between their discounted purchase price and their face value at maturity, which is effectively an interest payment.

T-Bill Rate Formula and Mathematical Explanation

Calculating the yield on a T-bill involves understanding two primary metrics: the Discount Rate and the Coupon Equivalent Yield (CEY). The t bill rate calculator uses these formulas to provide a clear picture of your investment's return.

1. Treasury Bill Discount Rate: This is the most common way T-bill yields are quoted in the market. It represents the annualized return based on the discount from the face value, using a 360-day year convention.

Formula: Discount Rate = ((Face Value - Purchase Price) / Face Value) * (360 / Days to Maturity) * 100

2. Coupon Equivalent Yield (CEY): This metric converts the discount rate into a more comparable annual yield, similar to that of a coupon-bearing bond. It uses a 365-day year and adjusts for the actual purchase price. This is often referred to as the "investment yield."

Formula: CEY = Discount Rate * (365 / 360) * (Face Value / Purchase Price) Alternatively, a more direct calculation for CEY is: CEY = ((Face Value - Purchase Price) / Purchase Price) * (365 / Days to Maturity) * 100

The t bill rate calculator presented here uses the direct CEY calculation for simplicity and clarity of the actual investment return.

Variables Table

Variable Meaning Unit Typical Range
Purchase Price The amount paid to acquire the T-bill. USD ($) Slightly below Face Value (e.g., $980,000 – $999,000 for a $1M T-bill)
Face Value The amount the T-bill will be worth at maturity. USD ($) Standard denominations (e.g., $1,000, $10,000, $100,000, $1,000,000)
Days to Maturity The remaining time until the T-bill matures. Days 1 to 364 (for standard T-bills)
Discount Rate Annualized yield based on discount, using a 360-day year. % Typically 0% to 7% (fluctuates with market rates)
Coupon Equivalent Yield (CEY) Annualized yield comparable to coupon bonds, using a 365-day year. % Typically 0% to 7% (fluctuates with market rates)
Investment Gain The profit earned from holding the T-bill to maturity. USD ($) Positive value (Face Value – Purchase Price)

Practical Examples (Real-World Use Cases)

Understanding the t bill rate calculator is best done through practical examples.

Example 1: Short-Term Cash Management

A small business has $500,000 in excess cash they don't need for 13 weeks (91 days). They decide to invest it in a T-bill. They purchase a T-bill with a face value of $500,000 for $495,000.

Inputs:

  • Purchase Price: $495,000
  • Face Value: $500,000
  • Days to Maturity: 91

Using the T-Bill Rate Calculator:

  • Investment Gain: $500,000 – $495,000 = $5,000
  • Discount Rate: (($500,000 – $495,000) / $500,000) * (360 / 91) * 100 ≈ 1.978%
  • Coupon Equivalent Yield (CEY): (($500,000 – $495,000) / $495,000) * (365 / 91) * 100 ≈ 4.101%
  • Annualized Yield (Simple): (($500,000 – $495,000) / $495,000) * (365 / 91) * 100 ≈ 4.101% (Note: For simplicity, this calculator shows CEY as the annualized yield)

Interpretation: The business earns a safe return of approximately $5,000 over 13 weeks, translating to an annualized yield of about 4.10%. This is a good option for preserving capital while earning a modest return.

Example 2: Longer Maturity T-Bill Investment

An individual investor wants to invest $985,000 for approximately 6 months (180 days). They find a T-bill with a face value of $1,000,000 maturing in 180 days, which they can purchase for $985,000.

Inputs:

  • Purchase Price: $985,000
  • Face Value: $1,000,000
  • Days to Maturity: 180

Using the T-Bill Rate Calculator:

  • Investment Gain: $1,000,000 – $985,000 = $15,000
  • Discount Rate: (($1,000,000 – $985,000) / $1,000,000) * (360 / 180) * 100 = 3.00%
  • Coupon Equivalent Yield (CEY): (($1,000,000 – $985,000) / $985,000) * (365 / 180) * 100 ≈ 3.096%
  • Annualized Yield (Simple): (($1,000,000 – $985,000) / $985,000) * (365 / 180) * 100 ≈ 3.096%

Interpretation: The investor locks in a gain of $15,000 over 180 days. The annualized yield is approximately 3.10%. This demonstrates how the t bill rate calculator helps compare potential returns across different maturities and purchase prices. Notice how the CEY is slightly higher than the discount rate due to the 365-day year convention and the adjustment for the purchase price.

How to Use This T-Bill Rate Calculator

Our t bill rate calculator is designed for simplicity and accuracy. Follow these steps to get your T-bill yield:

  1. Enter Purchase Price: Input the exact amount you paid for the Treasury Bill.
  2. Enter Face Value: Input the amount the T-bill will be worth when it matures (this is its par value).
  3. Enter Days to Maturity: Specify the number of days remaining until the T-bill matures.
  4. Click 'Calculate': The calculator will instantly display your results.

How to Read Results:

  • Discount Rate: This is the standard market quote for T-bills, using a 360-day year.
  • Coupon Equivalent Yield (CEY): This is the most important figure for understanding your actual investment return. It's annualized using a 365-day year and reflects the return relative to your purchase price.
  • Investment Gain ($): This shows the total dollar profit you will receive at maturity.
  • Annualized Yield (Simple): This provides a straightforward annual percentage return based on your investment.

Decision-Making Guidance: Compare the CEY from this calculator to other short-term investment options (like money market funds or short-term CDs). The T-bill's primary advantage is its exceptional safety. If the CEY meets your return expectations for that level of risk, it's a strong candidate for your short-term cash. Use the 'Copy Results' button to easily share or record your findings.

Key Factors That Affect T-Bill Rate Results

Several economic factors influence the rates at which T-bills are issued and, consequently, the results you see on the t bill rate calculator:

  • Federal Reserve Monetary Policy: The Federal Reserve's target for the federal funds rate significantly impacts short-term interest rates. When the Fed raises rates, T-bill yields tend to rise, and vice versa.
  • Inflation Expectations: If investors anticipate higher inflation, they will demand higher yields on their investments to maintain their purchasing power. This pushes T-bill rates up.
  • Economic Growth Outlook: Strong economic growth can lead to higher demand for credit and potentially higher interest rates, including T-bill rates. Conversely, fears of a recession often lead to lower rates as investors seek safety.
  • Supply and Demand for Treasuries: As a safe-haven asset, demand for U.S. Treasuries can increase during times of global uncertainty, potentially driving prices up and yields down. Conversely, increased government borrowing (higher supply) can put upward pressure on yields.
  • Maturity Period: While T-bills are short-term, yields can vary slightly between different maturities (e.g., 4-week vs. 52-week bills). The yield curve reflects these differences. Shorter maturities are generally more sensitive to immediate Fed policy changes.
  • Market Liquidity: The ease with which a T-bill can be bought or sold in the secondary market can influence its price and yield. Highly liquid T-bills might trade at slightly different yields compared to less liquid ones.
  • Investor Sentiment and Risk Aversion: During periods of market stress, investors flock to perceived safe assets like T-bills, increasing demand and lowering yields.

Frequently Asked Questions (FAQ)

Q1: What is the difference between the Discount Rate and the Coupon Equivalent Yield (CEY)?

The Discount Rate is how T-bills are quoted in the market, using a 360-day year. The CEY is a more accurate representation of the investor's actual annualized return, using a 365-day year and adjusting for the purchase price. Our t bill rate calculator emphasizes the CEY for investment decisions.

Q2: Are T-bills truly risk-free?

T-bills are considered among the safest investments globally, backed by the U.S. government. The primary risks are minimal: reinvestment risk (if you need to reinvest at lower rates) and inflation risk (if inflation erodes the real return). There is virtually no default risk.

Q3: Can I sell a T-bill before maturity?

Yes, T-bills can be sold in the secondary market before they mature. However, their price in the secondary market will fluctuate based on prevailing interest rates. If rates have risen since you bought the T-bill, its price may have fallen, and vice versa.

Q4: How do T-bill rates compare to savings accounts?

T-bill rates are typically influenced by market conditions and can sometimes be higher than savings account rates, especially during periods of rising interest rates. However, savings accounts offer FDIC insurance up to $250,000 per depositor, per insured bank, for each account ownership category, while T-bills are backed by the U.S. government.

Q5: What does a 360-day year vs. a 365-day year mean for T-bill calculations?

The 360-day convention for the discount rate simplifies calculations and is a market convention. The 365-day year used for CEY provides a more accurate annualized return, aligning with how most other interest-bearing investments are measured.

Q6: What is the minimum investment for a T-bill?

T-bills can be purchased directly from TreasuryDirect.gov with a minimum of $100. In the secondary market, minimums can vary but are often higher, especially for institutional investors.

Q7: How are T-bill yields taxed?

Interest earned on T-bills is subject to federal income tax but is exempt from state and local income taxes. This tax advantage can make them particularly attractive for investors in high-tax states.

Q8: Can the T-bill rate calculator handle T-bills with odd days to maturity?

Yes, the calculator is designed to accept any number of days to maturity, allowing you to calculate yields for T-bills of any duration within the standard range (1-364 days).

© 2023 Your Financial Tools. All rights reserved.

function validateInput(id, min, max, errorMessageId, fieldName) { var input = document.getElementById(id); var errorElement = document.getElementById(errorMessageId); var value = parseFloat(input.value); errorElement.classList.remove('visible'); input.style.borderColor = '#ccc'; if (isNaN(value)) { errorElement.innerText = fieldName + " cannot be empty."; errorElement.classList.add('visible'); input.style.borderColor = 'var(–error-color)'; return false; } if (value max) { errorElement.innerText = fieldName + " cannot be greater than " + max + "."; errorElement.classList.add('visible'); input.style.borderColor = 'var(–error-color)'; return false; } return true; } function calculateTBillRate() { var purchasePriceValid = validateInput('purchasePrice', 0, null, 'purchasePriceError', 'Purchase Price'); var faceValueValid = validateInput('faceValue', 0, null, 'faceValueError', 'Face Value'); var daysToMaturityValid = validateInput('daysToMaturity', 1, 364, 'daysToMaturityError', 'Days to Maturity'); if (!purchasePriceValid || !faceValueValid || !daysToMaturityValid) { document.getElementById('discountRateResult').innerText = '–.–%'; document.getElementById('ceyResult').innerText = '–.–%'; document.getElementById('investmentGainResult').innerText = '–.–'; document.getElementById('annualizedYieldResult').innerText = '–.–%'; updateChart([], []); // Clear chart return; } var purchasePrice = parseFloat(document.getElementById('purchasePrice').value); var faceValue = parseFloat(document.getElementById('faceValue').value); var daysToMaturity = parseInt(document.getElementById('daysToMaturity').value); var investmentGain = faceValue – purchasePrice; var discountRate = 0; var cey = 0; var annualizedYield = 0; if (faceValue > 0 && daysToMaturity > 0) { discountRate = ((faceValue – purchasePrice) / faceValue) * (360 / daysToMaturity) * 100; } if (purchasePrice > 0 && daysToMaturity > 0) { cey = ((faceValue – purchasePrice) / purchasePrice) * (365 / daysToMaturity) * 100; annualizedYield = cey; // For simplicity, using CEY as annualized yield } document.getElementById('discountRateResult').innerText = discountRate.toFixed(2) + '%'; document.getElementById('ceyResult').innerText = cey.toFixed(2) + '%'; document.getElementById('investmentGainResult').innerText = investmentGain.toFixed(2); document.getElementById('annualizedYieldResult').innerText = annualizedYield.toFixed(2) + '%'; // Update Chart Data var chartData = generateChartData(purchasePrice, faceValue, daysToMaturity); updateChart(chartData.labels, chartData.yieldData, chartData.discountData); } function resetCalculator() { document.getElementById('purchasePrice').value = '980000'; document.getElementById('faceValue').value = '1000000'; document.getElementById('daysToMaturity').value = '182'; document.getElementById('purchasePriceError').innerText = "; document.getElementById('purchasePriceError').classList.remove('visible'); document.getElementById('purchasePrice').style.borderColor = '#ccc'; document.getElementById('faceValueError').innerText = "; document.getElementById('faceValueError').classList.remove('visible'); document.getElementById('faceValue').style.borderColor = '#ccc'; document.getElementById('daysToMaturityError').innerText = "; document.getElementById('daysToMaturityError').classList.remove('visible'); document.getElementById('daysToMaturity').style.borderColor = '#ccc'; document.getElementById('discountRateResult').innerText = '–.–%'; document.getElementById('ceyResult').innerText = '–.–%'; document.getElementById('investmentGainResult').innerText = '–.–'; document.getElementById('annualizedYieldResult').innerText = '–.–%'; updateChart([], []); // Clear chart } function copyResults() { var discountRate = document.getElementById('discountRateResult').innerText; var cey = document.getElementById('ceyResult').innerText; var investmentGain = document.getElementById('investmentGainResult').innerText; var annualizedYield = document.getElementById('annualizedYieldResult').innerText; var purchasePrice = document.getElementById('purchasePrice').value; var faceValue = document.getElementById('faceValue').value; var daysToMaturity = document.getElementById('daysToMaturity').value; var assumptions = "Key Assumptions: 360-day year for discount rate, 365-day year for CEY."; var resultsText = "T-Bill Investment Results:\n" + "Purchase Price: $" + purchasePrice + "\n" + "Face Value: $" + faceValue + "\n" + "Days to Maturity: " + daysToMaturity + "\n\n" + "Discount Rate: " + discountRate + "\n" + "Coupon Equivalent Yield (CEY): " + cey + "\n" + "Investment Gain: $" + investmentGain + "\n" + "Annualized Yield (Simple): " + annualizedYield + "\n\n" + assumptions; // Use a temporary textarea to copy text var textArea = document.createElement("textarea"); textArea.value = resultsText; textArea.style.position = "fixed"; textArea.style.left = "-9999px"; document.body.appendChild(textArea); textArea.focus(); textArea.select(); try { var successful = document.execCommand('copy'); var msg = successful ? 'Results copied!' : 'Copying failed!'; // Optionally show a temporary message to the user var tempMsg = document.createElement('div'); tempMsg.textContent = msg; tempMsg.style.cssText = 'position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: var(–primary-color); color: white; padding: 15px; border-radius: 5px; z-index: 1000;'; document.body.appendChild(tempMsg); setTimeout(function() { document.body.removeChild(tempMsg); }, 2000); } catch (err) { console.error('Fallback: Oops, unable to copy', err); } document.body.removeChild(textArea); } // Charting Logic var myChart = null; // Global variable to hold chart instance function generateChartData(purchasePrice, faceValue, daysToMaturity) { var labels = []; var yieldData = []; var discountData = []; var maxDays = 364; var step = Math.max(1, Math.floor(maxDays / 10)); // Aim for about 10 data points for (var d = step; d 0 && d > 0) { currentDiscountRate = ((faceValue – purchasePrice) / faceValue) * (360 / d) * 100; } if (purchasePrice > 0 && d > 0) { currentCEY = ((faceValue – purchasePrice) / purchasePrice) * (365 / d) * 100; } yieldData.push(currentCEY); discountData.push(currentDiscountRate); } // Ensure the actual days to maturity is included if not already if (daysToMaturity > 0 && daysToMaturity 0 && daysToMaturity > 0) { currentDiscountRate = ((faceValue – purchasePrice) / faceValue) * (360 / daysToMaturity) * 100; } if (purchasePrice > 0 && daysToMaturity > 0) { currentCEY = ((faceValue – purchasePrice) / purchasePrice) * (365 / daysToMaturity) * 100; } labels.push(daysToMaturity + " days"); yieldData.push(currentCEY); discountData.push(currentDiscountRate); } return { labels: labels, yieldData: yieldData, discountData: discountData }; } function updateChart(labels, yieldData, discountData) { var ctx = document.getElementById('tBillChart').getContext('2d'); // Destroy previous chart instance if it exists if (myChart) { myChart.destroy(); } // Create new chart myChart = new Chart(ctx, { type: 'line', data: { labels: labels, datasets: [{ label: 'Coupon Equivalent Yield (CEY)', data: yieldData, borderColor: '#1f77b4', // Muted blue backgroundColor: 'rgba(31, 119, 180, 0.1)', fill: false, tension: 0.1, pointRadius: 3, pointHoverRadius: 5, }, { label: 'Discount Rate', data: discountData, borderColor: '#ff7f0e', // Safety orange backgroundColor: 'rgba(255, 127, 14, 0.1)', fill: false, tension: 0.1, pointRadius: 3, pointHoverRadius: 5, }] }, options: { responsive: true, maintainAspectRatio: false, scales: { x: { title: { display: true, text: 'Days to Maturity' }, grid: { color: 'rgba(0, 0, 0, 0.05)' } }, y: { title: { display: true, text: 'Yield (%)' }, ticks: { callback: function(value) { return value.toFixed(1) + '%'; } }, grid: { color: 'rgba(0, 0, 0, 0.05)' } } }, plugins: { tooltip: { mode: 'index', intersect: false, }, legend: { display: false // Legend is shown via div below canvas } }, hover: { mode: 'nearest', intersect: true } } }); } // Initial calculation on page load document.addEventListener('DOMContentLoaded', function() { calculateTBillRate(); });

Leave a Comment