Esempio n. 1
0
        public static SymbolStatistics GetViewSymbolStatistics(this Core.Model.SymbolStats s)
        {
            if (s == null)
            {
                throw new ArgumentNullException(nameof(s));
            }

            return(new SymbolStatistics
            {
                Exchange = s.Exchange,
                FirstTradeId = s.FirstTradeId,
                CloseTime = s.CloseTime,
                OpenTime = s.OpenTime,
                QuoteVolume = s.QuoteVolume,
                Volume = Convert.ToInt64(s.Volume),
                LowPrice = s.LowPrice,
                HighPrice = s.HighPrice,
                OpenPrice = s.OpenPrice,
                AskQuantity = s.AskQuantity,
                AskPrice = s.AskPrice,
                BidQuantity = s.BidQuantity,
                BidPrice = s.BidPrice,
                LastQuantity = s.LastQuantity,
                LastPrice = s.LastPrice,
                PreviousClosePrice = s.PreviousClosePrice,
                WeightedAveragePrice = s.WeightedAveragePrice,
                PriceChangePercent = decimal.Round(s.PriceChangePercent, 2, MidpointRounding.AwayFromZero),
                PriceChange = s.PriceChange,
                Period = s.Period,
                Symbol = s.Symbol,
                LastTradeId = s.LastTradeId,
                TradeCount = s.TradeCount
            });
        }
Esempio n. 2
0
        public static Symbol UpdateStatistics(this Symbol sy, Core.Model.SymbolStats st)
        {
            if (sy == null)
            {
                throw new ArgumentNullException(nameof(sy));
            }

            if (st == null)
            {
                throw new ArgumentNullException(nameof(st));
            }

            sy.SymbolStatistics.PriceChangePercent = decimal.Round(st.PriceChangePercent, 2, MidpointRounding.AwayFromZero);
            sy.PriceChangePercentDirection         = sy.SymbolStatistics.PriceChangePercent > 0 ? 1 : sy.SymbolStatistics.PriceChangePercent < 0 ? -1 : 0;
            sy.LastPriceChangeDirection            = st.LastPrice > sy.SymbolStatistics.LastPrice ? 1 : st.LastPrice < sy.SymbolStatistics.LastPrice ? -1 : 0;
            sy.SymbolStatistics.LastPrice          = st.LastPrice.Trim(sy.PricePrecision);
            sy.SymbolStatistics.Volume             = Convert.ToInt64(st.Volume);

            sy.SymbolStatistics.FirstTradeId         = st.FirstTradeId;
            sy.SymbolStatistics.CloseTime            = st.CloseTime;
            sy.SymbolStatistics.OpenTime             = st.OpenTime;
            sy.SymbolStatistics.QuoteVolume          = st.QuoteVolume;
            sy.SymbolStatistics.LowPrice             = st.LowPrice;
            sy.SymbolStatistics.HighPrice            = st.HighPrice;
            sy.SymbolStatistics.OpenPrice            = st.OpenPrice;
            sy.SymbolStatistics.AskQuantity          = st.AskQuantity;
            sy.SymbolStatistics.AskPrice             = st.AskPrice;
            sy.SymbolStatistics.BidQuantity          = st.BidQuantity;
            sy.SymbolStatistics.BidPrice             = st.BidPrice;
            sy.SymbolStatistics.LastQuantity         = st.LastQuantity;
            sy.SymbolStatistics.PreviousClosePrice   = st.PreviousClosePrice;
            sy.SymbolStatistics.WeightedAveragePrice = st.WeightedAveragePrice;
            sy.SymbolStatistics.PriceChange          = st.PriceChange;
            sy.SymbolStatistics.Period      = st.Period;
            sy.SymbolStatistics.LastTradeId = st.LastTradeId;
            sy.SymbolStatistics.TradeCount  = st.TradeCount;

            return(sy);
        }
Esempio n. 3
0
 static Core.Model.Symbol f(Core.Model.Symbol s, Core.Model.SymbolStats ss)
 {
     s.SymbolStatistics = ss;
     return(s);
 };