public List <Signal> GenerateOnClose(DateTime ts, int leadingIndex, SystemState systemState)
        {
            List <Signal> result = new List <Signal>();

            BBTrendFundsDataCalculator.CalculateTrendsAndExpectations(_fundsData, ts, _dataRange, _dataLoader);
            ResetRebalanceCountersIfNeeded();
            //if (ExecuteRebalance())
            {
                var balance = CalculateBalance();
                result.Add(BBTrendFundsSignalFactory.CreateSignal(balance, _dataRange, _fundsData));
                LogData(ts, balance);
            }
            IncrementRebalanceCounters();

            return(result);
        }
        public List <Signal> GenerateOnClose(DateTime ts, int leadingIndex, SystemState systemState)
        {
            List <Signal> result = new List <Signal>();

            BBTrendFundsDataCalculator.CheckStops(_fundsData, ts, _dataRange, _dataLoader);
            BBTrendFundsDataCalculator.CalculateTrendsAndExpectations(_fundsData, ts, _dataRange, _dataLoader);
            BBTrendFundsDataCalculator.CalculateMaxValuesAndStops(_fundsData, AggressiveStopWidth, ts, _dataRange, _dataLoader);

            //var sortedFunds = OrderStocksByProfit(ts, ProfitBackDataLength);
            var sortedFunds = OrderStocksByUpTrendProfit(ts);

            //ResetRebalanceCountersIfNeeded();
            //if (ExecuteRebalance())
            float[] balance = CalculateBalance(sortedFunds, NumberOfAggressiveFundsTaken);
            result.Add(BBTrendFundsSignalFactory.CreateSignal(balance, _dataRange, _fundsData));
            //IncrementRebalanceCounters();

            LogData(ts, sortedFunds, balance);
            return(result);
        }