code: public static double price(
  			double timeToMaturity,
  			double coupon,
  			double yield,
  			double redemption,
  			int frequency)
  	{
  		double price = 0.0;
  
  		if(timeToMaturity > 0) {
  			price += redemption;
  		}
  
  		double paymentTime = timeToMaturity;
  		while(paymentTime > 0) {
  			price += coupon;
  
  			// Discount back
  			price = price / (1.0 + yield / frequency);
  			paymentTime -= 1.0 / frequency;
  		}
  
  		// Accrue running period
  		double accrualPeriod = 0.0- paymentTime;
  		price *= Math.pow(1.0 + yield / frequency, accrualPeriod);
  		price -= coupon * accrualPeriod;
  
  		return price;
  	}
docs: Re-implementation of the Excel PRICE function (a rather primitive bond price formula).
  The re-implementation is not exact, because this function does not consider daycount conventions.
  We assume we have (int)timeToMaturity/frequency future periods and the running period has
  an accrual period of timeToMaturity - frequency * ((int)timeToMaturity/frequency).
  
  @param timeToMaturity The time to maturity.
  @param coupon Coupon payment.
  @param yield Yield (discount factor, using frequency: 1/(1 + yield/frequency).
  @param redemption Redemption (notional repayment).
  @param frequency Frequency (1,2,4).
  @return price Clean price.