#include <ql/quantlib.hpp>

#include <boost/timer.hpp>
#include <iostream>
#include <iomanip>

using namespace QuantLib;

#if defined(QL_ENABLE_SESSIONS)
namespace QuantLib {

Integer sessionId() { return 0; }

}
#endif


int main(int, char* []) {

    try {

         /////////////////////////////////////////////////////////////////////////////
		 /////////////////////////////////////////////////////////////////////////////
		 //    calculate Yield to maturity of Fixed Rate Bond
		 /////////////////////////////////////////////////////////////////////////////
		 /////////////////////////////////////////////////////////////////////////////
	 
		
		
		 //////////BondSchedule Class Declarations//////////////////
		 Date bondDatedDate(15,June,2010);
		 Date SettlementDate(15,June,2011);
		 Date bondMaturityDate(15,June,2011);
		 Frequency bondCouponFrequency = Annual;
		 Calendar bondCalendar = NullCalendar();
		 BusinessDayConvention bondBusinessDayConvention = Unadjusted;
		 ////////////////////////////////////////////////////////////

		 std::cout << "New Change made .... \n\n\n\ ";
		 Settings::instance().evaluationDate()= bondDatedDate;

		 //////////FixedRateBond Class Declarations//////////////////
		 Integer bondSettlementDays = 0;
		 Real faceAmount = 100.0;
		 Real bondCoupon = 5; //interest rate
		 DayCounter bondDayCountConvention = Thirty360(Thirty360::BondBasis);
		 Real bondRedemption = 100.0;    //Change Made
		 Date bondIssueDate(15,June,2010);
		 ////////////////////////////////////////////////////////////

		
		 Schedule bondSchedule(bondDatedDate, bondMaturityDate,
								Period(bondCouponFrequency),
								bondCalendar,bondBusinessDayConvention,
								bondBusinessDayConvention,
								DateGeneration::Forward,false);
		 
		 
	
		 boost::shared_ptr<FixedRateBond> bond(
			 new FixedRateBond  (bondSettlementDays,
								faceAmount,
								bondSchedule,
								std::vector<Rate>(1,bondCoupon),
								bondDayCountConvention,
								bondBusinessDayConvention,
								bondRedemption,
								bondIssueDate));




		 Real Clean_Price = 90;
		 		 
		 std::cout << "----\n";
		 


		 
		 std::cout <<  bond->yield(Clean_Price,
						bondDayCountConvention,
						 Compounded,
						 bondCouponFrequency);  //output is 5.667 still not correct suppose to be 16.67
						 
		 std::cin.get();
		 return 0;
		 

		 //std::cout << 

    } catch (std::exception& e) {
        std::cerr << e.what() << std::endl;\
		std::cin.get();
        return 1;
    }
	    catch (...) 
		{
        std::cerr << "unknown error" << std::endl;
		std::cin.get();
        return 1;
    }
}