public IReadOnlyCollection <IOrderAnalysis> OpposingSentiment(
            IReadOnlyCollection <IOrderAnalysis> orders,
            PriceSentiment sentiment)
        {
            if (sentiment == PriceSentiment.Neutral || sentiment == PriceSentiment.Mixed)
            {
                return(new IOrderAnalysis[0]);
            }

            if (orders == null)
            {
                return(new IOrderAnalysis[0]);
            }

            if (sentiment == PriceSentiment.Positive)
            {
                return(orders.Where(i => this._negativeSentiments.Contains(i.Order.OrderDirection)).ToList());
            }

            if (sentiment == PriceSentiment.Negative)
            {
                return(orders.Where(i => this._positiveSentiments.Contains(i.Order.OrderDirection)).ToList());
            }

            throw new ArgumentOutOfRangeException(nameof(sentiment));
        }
Example #2
0
        /// <summary>
        /// The aligned sentiment portfolio.
        /// </summary>
        /// <param name="analyzedOrders">
        /// The analyzed orders.
        /// </param>
        /// <param name="lastTradeSentiment">
        /// The last trade sentiment.
        /// </param>
        /// <returns>
        /// The <see cref="IPortfolio"/>.
        /// </returns>
        private IPortfolio AlignedSentimentPortfolio(
            IReadOnlyCollection <IOrderAnalysis> analyzedOrders,
            PriceSentiment lastTradeSentiment)
        {
            var alignedSentiment          = analyzedOrders.Where(i => i.Sentiment == lastTradeSentiment).ToList();
            var alignedSentimentPortfolio = this.portfolioFactory.Build();

            alignedSentimentPortfolio.Add(alignedSentiment.Select(i => i.Order).ToList());

            return(alignedSentimentPortfolio);
        }
Example #3
0
        /// <summary>
        /// The unaligned sentiment portfolio.
        /// </summary>
        /// <param name="analyzedOrders">
        /// The analyzed orders.
        /// </param>
        /// <param name="lastTradeSentiment">
        /// The last trade sentiment.
        /// </param>
        /// <returns>
        /// The <see cref="IPortfolio"/>.
        /// </returns>
        private IPortfolio UnalignedSentimentPortfolio(
            IReadOnlyCollection <IOrderAnalysis> analyzedOrders,
            PriceSentiment lastTradeSentiment)
        {
            var opposingSentiment          = this.analysisService.OpposingSentiment(analyzedOrders, lastTradeSentiment);
            var opposingSentimentPortfolio = this.portfolioFactory.Build();

            opposingSentimentPortfolio.Add(opposingSentiment.Select(i => i.Order).ToList());

            return(opposingSentimentPortfolio);
        }
Example #4
0
 public Judgement(PriceSentiment sentiment)
 {
     this.Sentiment = sentiment;
 }
Example #5
0
 public OrderAnalysis(Order order, PriceSentiment sentiment)
 {
     this.Order     = order ?? throw new ArgumentNullException(nameof(order));
     this.Sentiment = sentiment;
 }