private void CalculateDayPriceChangeDifference() { List<DayPrice> dayChangeRelativeCollection = new List<DayPrice>(); foreach (DayPrice dayPrice in DayChangeCollection) { DayPrice indexDayPrice = (from index in IndexChangeCollection where index.DayPriceDate == dayPrice.DayPriceDate select index).FirstOrDefault(); // Calculate change relative to market index DayPrice dayPriceChangeRelative = new DayPrice(); dayPriceChangeRelative.DayPriceDate = dayPrice.DayPriceDate; if (indexDayPrice!=null) dayPriceChangeRelative.DayPriceClose = dayPrice.DayPriceClose - indexDayPrice.DayPriceClose; dayChangeRelativeCollection.Add(dayPriceChangeRelative); } DayChangeDifferenceCollection = new ObservableCollection<DayPrice>(dayChangeRelativeCollection); ChangeCalculationIsBusy = false; }
private void CalculateIndexChange(string indexName, List<DayPrice> indexCollection) { List<DayPrice> dayChangeCollection = new List<DayPrice>(); DayPrice previous = null; foreach (DayPrice dayPrice in indexCollection) { if (previous != null) { // Calculate percentage change from previous day DayPrice dayPriceChange = new DayPrice(); dayPriceChange.DayPriceDate = dayPrice.DayPriceDate; //if (previous.DayPriceOpen > 0) dayPriceChange.DayPriceOpen = ((dayPrice.DayPriceOpen - previous.DayPriceOpen) / previous.DayPriceOpen) * 100.0M; //if (previous.DayPriceHigh > 0) dayPriceChange.DayPriceHigh = ((dayPrice.DayPriceHigh - previous.DayPriceHigh) / previous.DayPriceHigh) * 100.0M; //if (previous.DayPriceLow > 0) dayPriceChange.DayPriceLow = ((dayPrice.DayPriceLow - previous.DayPriceLow) / previous.DayPriceLow) * 100.0M; if (previous.DayPriceClose > 0) dayPriceChange.DayPriceClose = ((dayPrice.DayPriceClose - previous.DayPriceClose) / previous.DayPriceClose) * 100.0M; //if (previous.DayPriceAdjustedClose > 0) dayPriceChange.DayPriceAdjustedClose = ((dayPrice.DayPriceAdjustedClose - previous.DayPriceAdjustedClose) / previous.DayPriceAdjustedClose) * 100.0M; //if (previous.DayPriceVolume > 0) dayPriceChange.VolumeChange = ((double)((dayPrice.DayPriceVolume - previous.DayPriceVolume) / previous.DayPriceVolume)) * 100.0; dayChangeCollection.Add(dayPriceChange); } previous = dayPrice; } _IndexChangeCollectionDictionary.Add(indexName, new ObservableCollection<DayPrice>(dayChangeCollection)); }
private bool FilterDayPriceSet(DayPrice entity) { return (entity.SymbolName == this.SymbolName); }
private void DetachDayPriceSet(DayPrice entity) { entity.Symbol = null; }
private void AttachDayPriceSet(DayPrice entity) { entity.Symbol = this; }
/// <summary> /// Create a new DayPrice object. /// </summary> /// <param name="dayPriceId">Initial value of the DayPriceId property.</param> /// <param name="symbolName">Initial value of the SymbolName property.</param> /// <param name="dayPriceDate">Initial value of the DayPriceDate property.</param> /// <param name="dayPriceOpen">Initial value of the DayPriceOpen property.</param> /// <param name="dayPriceHigh">Initial value of the DayPriceHigh property.</param> /// <param name="dayPriceLow">Initial value of the DayPriceLow property.</param> /// <param name="dayPriceClose">Initial value of the DayPriceClose property.</param> /// <param name="dayPriceAdjustedClose">Initial value of the DayPriceAdjustedClose property.</param> /// <param name="dayPriceVolume">Initial value of the DayPriceVolume property.</param> public static DayPrice CreateDayPrice(global::System.Guid dayPriceId, global::System.String symbolName, global::System.DateTime dayPriceDate, global::System.Decimal dayPriceOpen, global::System.Decimal dayPriceHigh, global::System.Decimal dayPriceLow, global::System.Decimal dayPriceClose, global::System.Decimal dayPriceAdjustedClose, global::System.Int64 dayPriceVolume) { DayPrice dayPrice = new DayPrice(); dayPrice.DayPriceId = dayPriceId; dayPrice.SymbolName = symbolName; dayPrice.DayPriceDate = dayPriceDate; dayPrice.DayPriceOpen = dayPriceOpen; dayPrice.DayPriceHigh = dayPriceHigh; dayPrice.DayPriceLow = dayPriceLow; dayPrice.DayPriceClose = dayPriceClose; dayPrice.DayPriceAdjustedClose = dayPriceAdjustedClose; dayPrice.DayPriceVolume = dayPriceVolume; return dayPrice; }
/// <summary> /// Deprecated Method for adding a new object to the DayPriceSet EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToDayPriceSet(DayPrice dayPrice) { base.AddObject("DayPriceSet", dayPrice); }