/// <summary> /// Disposes the object data /// </summary> public void Dispose() { if (mPeriods != null) { mPeriods.Clear(); mPeriods = null; } if (mController != null) { mController.OnPriceUpdate -= OnPriceUpdate; mController = null; } }
/// <summary> /// Constructor /// </summary> /// <param name="instrument">The instrument name</param> /// <param name="timeframe">The timeframe id (e.g. m1)</param> /// <param name="alive">The flag indicating whether the collection shall be subscribed for updates</param> /// <param name="controller">The price update controller</param> public PeriodCollection(string instrument, string timeframe, bool alive, IPriceUpdateController controller) { mInstrument = instrument; mTimeframe = timeframe; mAlive = alive; mFilled = false; if (alive) { // if collection is alive - we will need to calculate the date/time of the candle // to which each tick belongs to, so we need to parse the time frame name for // further usage if (!CandlePeriod.parsePeriod(timeframe, ref mTimeframeUnit, ref mTimeframeLength)) { throw new ArgumentException("Invalid timeframe", "timeframe"); } // and we need to subscribe to tick updates mWaitingUpdates = new Queue <IOffer>(); mTradingDayOffset = controller.TradingDayOffset; controller.OnPriceUpdate += OnPriceUpdate; mController = controller; } }