//TECHNICAL
private static Reporter trade(String starting_date, final String ending_date, Portfolio portfolio, Reporter reporter, String order_file_name,boolean include_trading_fees,boolean pay_dividends) {
        int final_time = 0; //last day must also be included
        Strategy strategy = new Strategy(portfolio, portfolio.getDatabase(),include_trading_fees);
        Long starting_time = System.currentTimeMillis();
        System.out.println("Trading simulation starts: ");
        System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxx");
        //0. Write dividend dates to dividend array
        //todo: implement array
        List<String> dividend_dates = new ArrayList<>();
        if (pay_dividends){dividend_dates = dividend_dates(starting_date,ending_date);}
        while (final_time == 0) {
            //TECHNICAL
            if (starting_date.equals(ending_date)) {
                final_time++;
            }
            //Check if we have data about this day in the database? Maybe it's Christmas or maybe it's the weekend.
            if (portfolio.getDatabase().contains_day(starting_date)) {
                //1. Dividend payments to other parties
                portfolio.exercise_dividends(starting_date);
                //2. Do I have any rights or obligations (Options) / Obligations(Stocks)?
                portfolio.exercise_obligations(starting_date,strategy.isUse_trading_fees());
                //3. Strategy((1.)unemployment rate, (2.) P/E  (3) moving average (4) RSI)
                strategy.setPortfolio(strategy.trade_all(starting_date));
                //4. Pay dividends to the owners
                if (pay_dividends && dividend_dates.contains(starting_date)){portfolio.pay_dividends(starting_date);}
            }
            //TODO: remove the else part later
            else{
                portfolio.exercise_obligations(starting_date,strategy.isUse_trading_fees());
                portfolio.exercise_dividends(starting_date);
            }
            // todo: remove
           if(portfolio.get_cash_available(starting_date) < 0){System.out.println(portfolio.get_cash_available(starting_date));}
            reporter.report(portfolio,starting_date);
            starting_date = LocalDate.parse(starting_date).plusDays(1).toString();
        }
        portfolio.order_results_to_file(order_file_name,ending_date);
        Long ending_time = System.currentTimeMillis();
        System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxx");
        System.out.println("Trading simulation ended: ");
        System.out.println("Simulation took " + Math.round((ending_time - starting_time) * 0.001 * 1 / 60) + " minutes to complete");
        return reporter;
    }
if (pay_dividends){dividend_dates = dividend_dates(starting_date,ending_date);}
while (final_time == 0) {
//TECHNICAL
if (starting_date.equals(ending_date)) {
final_time++;
int final_time = 0; //last day must also be included
Strategy strategy = new Strategy(portfolio, portfolio.getDatabase(),include_trading_fees);
Long starting_time = System.currentTimeMillis();
System.out.println("Trading simulation starts: ");
System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxx");
//0. Write dividend dates to dividend array
//todo: implement array
List<String> dividend_dates = new ArrayList<>();
if (pay_dividends){dividend_dates = dividend_dates(starting_date,ending_date);}
while (final_time == 0) {
//TECHNICAL
if (starting_date.equals(ending_date)) {
final_time++;
}
//Check if we have data about this day in the database? Maybe it's Christmas or maybe it's the weekend.
if (portfolio.getDatabase().contains_day(starting_date)) {
//1. Dividend payments to other parties
portfolio.exercise_dividends(starting_date);
//2. Do I have any rights or obligations (Options) / Obligations(Stocks)?
portfolio.exercise_obligations(starting_date,strategy.isUse_trading_fees());
//3. Strategy((1.)unemployment rate, (2.) P/E (3) moving average (4) RSI)
private static Reporter trade(String starting_date, final String ending_date, Portfolio portfolio, Reporter reporter, String order_file_name,boolean include_trading_fees,boolean pay_dividends) {
int final_time = 0; //last day must also be included
Strategy strategy = new Strategy(portfolio, portfolio.getDatabase(),include_trading_fees);
Long starting_time = System.currentTimeMillis();
System.out.println("Trading simulation starts: ");
System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxx");
//0. Write dividend dates to dividend array
//todo: implement array
List<String> dividend_dates = new ArrayList<>();
if (pay_dividends){dividend_dates = dividend_dates(starting_date,ending_date);}
while (final_time == 0) {
//TECHNICAL
if (starting_date.equals(ending_date)) {
final_time++;
}
//Check if we have data about this day in the database? Maybe it's Christmas or maybe it's the weekend.
if (portfolio.getDatabase().contains_day(starting_date)) {
//1. Dividend payments to other parties
portfolio.exercise_dividends(starting_date);
//2. Do I have any rights or obligations (Options) / Obligations(Stocks)?
portfolio.exercise_obligations(starting_date,strategy.isUse_trading_fees());
//3. Strategy((1.)unemployment rate, (2.) P/E (3) moving average (4) RSI)
strategy.setPortfolio(strategy.trade_all(starting_date));
//4. Pay dividends to the owners
if (pay_dividends && dividend_dates.contains(starting_date)){portfolio.pay_dividends(starting_date);}
}
//TODO: remove the else part later
else{
portfolio.exercise_obligations(starting_date,strategy.isUse_trading_fees());
portfolio.exercise_dividends(starting_date);
}
// todo: remove