package net.woodyfolsom.cs6601.p3;

import java.util.Calendar;
import java.util.Date;

import net.woodyfolsom.cs6601.p3.domain.StockPrice;

public class StockUtil {
	public static Date getNextTradingDay(Date date) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		do {
			cal.add(Calendar.DATE, 1);
		} while (cal.get(Calendar.DAY_OF_WEEK) == 1 || cal.get(Calendar.DAY_OF_WEEK) == 7);
		return cal.getTime();
	}
	
	public static double getPercentChange(StockPrice stockPrice) {
		double close = stockPrice.getClose();
		double open = stockPrice.getOpen();
		//If close is 2x open, pct change is 1.0;
		//If close is 0.9 * open, pct change is -0.10;
		return 100.0 * ((close / open) - 1.00);
	}
}