PC Review


Reply
Thread Tools Rate Thread

How to calculate Yield using Yield Function by C#

 
 
Ali
Guest
Posts: n/a
 
      1st Dec 2009

Dear Excel Guruz..
I have to calculate Yield using excel yield function in my C# program.In
order to do that I have import
using Microsoft.Office.Core;
using Excel = Microsoft.Office.Interop.Excel;
and write yield calcuation function . My function work fine for office 2007
but onces I unistall 2007 , my code stopped wokring on any perivious version.

What I have observed my last line i.e used to calculate yield has problem
result = xl.Evaluate("YIELD(" + days + "," + days1 + "," + rate +
"," + par + "," + facevalue + "," + frequency + "," + basis + ")");

even though I change my dates arguments , though nothing happens in result.

Help me in this regards


// ***********************Code*********************************
Excel.Application xl = new Excel.Application();
Excel.WorksheetFunction wsf = xl.WorksheetFunction;
string satelmentdt = dtsatelment.Value.ToString();
string maturitydt = dtmaturity.Value.ToString();
dtobjectsatelemnt = DateTime.Parse(satelmentdt.ToString());
dtobjectmaturity = DateTime.Parse(maturitydt.ToString());
days = (dtobjectsatelemnt - startdt).Days;
days1 = (dtobjectmaturity - startdt).Days;
days = days + 2;
days1 = days1 + 2;
string rate = this.rate.Text;

double par = double.Parse(this.par.Text.ToString());

double redumptation =
double.Parse(this.redemption.Text.ToString());
string facevalue = "100";
string frequency = "2";
string basis = "1";
object result;

result = xl.Evaluate("YIELD(" + days + "," + days1 + "," + rate +
"," + par + "," + facevalue + "," + frequency + "," + basis + ")");

result.Text = result.ToString();

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Current Yield vs. Yield to Maturity at low prices beariebird Microsoft Excel Worksheet Functions 1 19th Nov 2009 08:50 PM
Calculate yield =?Utf-8?B?Sg==?= Microsoft Access Queries 3 19th Sep 2007 01:02 PM
How to calculate bond value and current yield =?Utf-8?B?R2FyeQ==?= Microsoft Excel Worksheet Functions 2 7th Jul 2007 11:32 PM
Does anyone know how to calculate Yield to Maturity using Exel? =?Utf-8?B?VEwxNTI1?= Microsoft Excel Worksheet Functions 1 23rd Jan 2006 11:46 PM
how do you calculate "dividend yield using Excel? =?Utf-8?B?RGVubmlz?= Microsoft Excel Misc 1 20th Jun 2005 02:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:43 PM.