Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
        /// <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);
            }
        }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
        /// <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);
        }