private void InitTransientFields() { baseSymbol = MarketEventSymbols.GetBaseSymbol(symbol); if (exchange == null) { exchange = CandleExchange.GetAttributeForSymbol(symbol); } if (price == null) { price = CandlePrice.GetAttributeForSymbol(symbol); } if (session == null) { session = CandleSession.GetAttributeForSymbol(symbol); } if (period == null) { period = CandlePeriod.GetAttributeForSymbol(symbol); } if (alignment == null) { alignment = CandleAlignment.GetAttributeForSymbol(symbol); } if (priceLevel == null) { priceLevel = CandlePriceLevel.GetAttributeForSymbol(symbol); } }
/// <summary> /// Returns candle symbol string with the normalized representation of the candle period attribute. /// </summary> /// <param name="symbol">candle symbol string.</param> /// <returns>candle symbol string with the normalized representation of the the candle period attribute.</returns> public static string NormalizeAttributeForSymbol(string symbol) { string a = MarketEventSymbols.GetAttributeStringByKey(symbol, ATTRIBUTE_KEY); if (a == null) { return(symbol); } try { CandlePeriod other = Parse(a); if (other.Equals(DEFAULT)) { MarketEventSymbols.RemoveAttributeStringByKey(symbol, ATTRIBUTE_KEY); } if (!a.Equals(other.ToString())) { return(MarketEventSymbols.ChangeAttributeStringByKey(symbol, ATTRIBUTE_KEY, other.ToString())); } return(symbol); } catch (ArgumentNullException) { return(symbol); } }
private static string Normalize(string symbol) { symbol = CandlePrice.NormalizeAttributeForSymbol(symbol); symbol = CandleSession.NormalizeAttributeForSymbol(symbol); symbol = CandlePeriod.NormalizeAttributeForSymbol(symbol); symbol = CandleAlignment.NormalizeAttributeForSymbol(symbol); symbol = CandlePriceLevel.NormalizeAttributeForSymbol(symbol); return(symbol); }
/// <summary> /// Indicates whether this aggregation period is the same as another one. /// The same aggregation period has the same {@link #GetValue() value} and /// {@link #GetCandleType() type}. /// </summary> /// <param name="o"></param> /// <returns>`true` if this aggregation period is the same as another one.</returns> public override bool Equals(object o) { if (this == o) { return(true); } if (!(o.GetType() == typeof(CandlePeriod))) { return(false); } CandlePeriod that = (CandlePeriod)o; return(value.CompareTo(that.value) == 0 && type == that.type); }