コード例 #1
0
        private void CalculateFiveBasicValues()
        {
            var sixtyEightLowLimit      = StdDevResults.Where(t => t.ZScore <= (Decimal)(-1.0) && t.ZScore > (Decimal)(-2.0)).OrderByDescending(t => t.ZScore).FirstOrDefault();
            var sixtyEightLowLimitPrice = sixtyEightLowLimit.StdDev * sixtyEightLowLimit.ZScore + sixtyEightLowLimit.Mean;

            var sixtyEightHighLimit      = StdDevResults.Where(t => t.ZScore <= (Decimal)1.0 && t.ZScore > (Decimal)(0)).OrderByDescending(t => t.ZScore).FirstOrDefault();
            var sixtyEightHighLimitPrice = sixtyEightHighLimit.StdDev * sixtyEightHighLimit.ZScore + sixtyEightHighLimit.Mean;

            var ninetyLowLimit      = StdDevResults.Where(t => t.ZScore > (Decimal)(-2.0) && t.ZScore < (Decimal)(-1.0)).OrderBy(t => t.ZScore).FirstOrDefault();
            var ninetyLowLimitPrice = ninetyLowLimit.StdDev * ninetyLowLimit.ZScore + ninetyLowLimit.Mean;

            var ninetyHighLimit          = StdDevResults.Where(t => t.ZScore <= (Decimal)2.0 && t.ZScore > (Decimal)1.0).OrderByDescending(t => t.ZScore).FirstOrDefault();
            var ninetynineHighLimitPrice = HistoricalQuotes.Max(q => q.Close);

            var mean      = StdDevResults.Where(t => t.ZScore <(Decimal)(0) && t.ZScore>(Decimal)(-1)).OrderByDescending(t => t.ZScore).FirstOrDefault();
            var meanPrice = mean.StdDev * mean.ZScore + mean.Mean;

            var List = new List <decimal> {
                sixtyEightLowLimitPrice.Value,
                sixtyEightHighLimitPrice.Value,
                meanPrice.Value,
                ninetynineHighLimitPrice,
                ninetyLowLimitPrice.Value
            };
            var sorted = List.OrderBy(t => t).ToList();

            FiveBasicNumber = new FiveBasicNumberValue
            {
                NinetyLow      = sorted[0],
                SixtyEightLow  = sorted[1],
                Mean           = sorted[2],
                SixtyEightHigh = sorted[3],
                NinetyNineHigh = sorted[4] * ((decimal)1.1)
            };
        }
コード例 #2
0
        private void CaculateLowLimitResult(AlertInfo stdLowAlertInfo)
        {
            var maxStickerQuote = HistoricalQuotes.Max(s => s.High);
            var minStickerQuote = HistoricalQuotes.Min(s => s.Low);
            var currentPrice    = HistoricalQuotes.OrderByDescending(q => q.Date).FirstOrDefault();

            CalculateHighAndLowLimitPriceForLowAlertInfo(stdLowAlertInfo, maxStickerQuote, minStickerQuote);
            if (currentPrice?.Close <= stdLowAlertInfo.HighLimit)
            {
                ToAlertToBuy = true;
            }
        }
コード例 #3
0
        private void CalculateSuggestionPrices(AlertInfo stdHighAlertInfo, AlertInfo stdLowAlertInfo)
        {
            var maxStickerQuote = HistoricalQuotes.Max(s => s.High);
            var minStickerQuote = HistoricalQuotes.Min(s => s.Low);

            CalculateHighAndLowLimitPriceForLowAlertInfo(stdLowAlertInfo,
                                                         maxStickerQuote, minStickerQuote);
            CalculateHighAndLowLimitPriceForHighRangeAlertInfo(stdHighAlertInfo,
                                                               maxStickerQuote, maxStickerQuote);
            if (stdHighAlertInfo.HighLimit > stdLowAlertInfo.HighLimit)
            {
                MakeSuggestions(stdHighAlertInfo, stdLowAlertInfo);
            }
            else
            {
                MakeSuggestions(stdLowAlertInfo, stdHighAlertInfo);
            }
        }