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); }
/// <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(); } } }
/// <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; }
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); } }