package com.strategyquant.extend.MonteCarloValues;

import com.strategyquant.lib.fitness.FitnessFunction;
import com.strategyquant.lib.language.L;
import com.strategyquant.lib.snippets.MonteCarloSim.MCStatsConst;
import com.strategyquant.lib.snippets.MonteCarloSim.MCValueComputer;
import com.strategyquant.lib.snippets.MonteCarloSim.MonteCarloStatValues;
import com.strategyquant.lib.utils.SQUtils;

public class MCNetProfit extends MCValueComputer {

	public MCNetProfit() {
		super(MCStatsConst.NET_PROFIT, FitnessFunction.MAXIMIZE);
		
		setColumnName(L.t("Net Profit"));		
		setColumnWidth(100);
		setTooltip(L.t("Net Profit (higher is better)"));
	}

	@Override
	protected double compute(MonteCarloStatValues statValues, double initialCapital, double[] orders, double avgTradesPerMonth) throws Exception {
		double totalPL = 0;
		
		for(int i=0; i<orders.length; i++) {
			totalPL += orders[i];
		}
		
		return totalPL;
	}

	@Override
	public String formatValue(double value) {
		return "$ "+SQUtils.d2(value);
	}
}
