예제 #1
0
        public virtual CalanderEvent GetEvent(DateTime date)
        {
            CalanderEvent evt = null;

            if (_isIntitialized == false)
            {
                evt             = CalanderEvent.DAY_EVENT;
                _isIntitialized = true;
            }
            else
            {
                if (date.Year != _previousDate.Year)
                {
                    evt = CalanderEvent.YEAR_EVENT;
                }
                else if (date.Month != _previousDate.Month)
                {
                    evt = CalanderEvent.MONTH_EVENT;
                }
                else
                {
                    evt = CalanderEvent.DAY_EVENT;
                }
            }
            _previousDate = date;
            return(evt);
        }
예제 #2
0
 /// <summary>
 ///
 /// </summary>
 public virtual void Iterate()
 {
     _instrument.Next();
     if (_instrument.GetCurrent().Date >= _dateMarketStart)
     {
         if (_observer != null)
         {
             _currentDate = _instrument.Date;
             CalanderEvent evt = GetEvent(_currentDate);
             _observer.onUpdate(evt);
         }
         if (_instrument.GetCurrent().Date >= _dateTradeStart && _instrument.GetCurrent().Date <= _dateTradeEnd)
         {
             _trader.ProcessOrders();
         }
         else
         {
             _trader.ClearOrders();
         }
         if (_instrument.NextToLast())
         {
             _trader.ClosePosition();
         }
         else
         {
             _trader.UpdateTraders();
         }
     }
 }
예제 #3
0
 /// <summary>
 /// Stop engine
 /// </summary>
 public virtual void Stop()
 {
     if (_observer != null)
     {
         _currentDate = _instrument.Date;
         CalanderEvent evt = GetEvent(_currentDate);
         _observer.onUpdate(evt);
         _observer.onStopped();
     }
     _isRunning = false;
 }
예제 #4
0
 public void onUpdate(CalanderEvent evt)
 {
     if (_isInitialized == false)
     {
         _dateStart     = _instrument.Date;
         _isInitialized = true;
     }
     _dateCurrent = _instrument.Date;
     _year        = _dateCurrent.Year;
     UpdateStatistics();
     if (evt.YearEvent)
     {
         _reportAnnual.yearUpdate();
     }
     for (int i = 0; i < _observers.Count; i++)
     {
         ((Observer)_observers[i]).onUpdate(evt);
     }
 }