public AlgorithmSwitchingManager()
        {
            _stableHistory   = new Dictionary <AlgorithmType, AlgorithmHistory>();
            _unstableHistory = new Dictionary <AlgorithmType, AlgorithmHistory>();
            _lastLegitPaying = new Dictionary <AlgorithmType, double>();

            foreach (var kvp in NHSmaData.FilteredCurrentProfits(true))
            {
                _stableHistory[kvp.Key]   = new AlgorithmHistory(MaxHistory);
                _lastLegitPaying[kvp.Key] = kvp.Value;
            }
            foreach (var kvp in NHSmaData.FilteredCurrentProfits(false))
            {
                _unstableHistory[kvp.Key] = new AlgorithmHistory(MaxHistory);
                _lastLegitPaying[kvp.Key] = kvp.Value;
            }
        }
Exemple #2
0
        public void ForceUpdate()
        {
            var isAllZeroPaying = _lastLegitPaying.Values.Any(paying => paying == 0);

            if (isAllZeroPaying)
            {
                foreach (var kvp in NHSmaData.FilteredCurrentProfits(true))
                {
                    _stableHistory[kvp.Key]   = new AlgorithmHistory(MaxHistory);
                    _lastLegitPaying[kvp.Key] = kvp.Value;
                }
                foreach (var kvp in NHSmaData.FilteredCurrentProfits(false))
                {
                    _unstableHistory[kvp.Key] = new AlgorithmHistory(MaxHistory);
                    _lastLegitPaying[kvp.Key] = kvp.Value;
                }
            }
            var args = new SmaUpdateEventArgs(_lastLegitPaying);

            Stop();
            SmaCheck?.Invoke(this, args);
            Start();
        }