Exemple #1
0
        public VerifyResult CheckDailyMatch(int shareId, int tradingDate, string formula)
        {
            VerifyResult result = new VerifyResult();

            result.ShareId     = shareId;
            result.TradingDate = tradingDate;

            var loadStart = DateHelper.DateToInt(DateHelper.IntToDate(tradingDate).AddDays(OFFSET_DAY * (-1)));

            var indiArray = LoadIndicators(shareId, loadStart, tradingDate);

            if (indiArray.Length > 0)
            {
                ExpressionManager em = new ExpressionManager(indiArray, indiArray.Length - 1);

                try
                {
                    result.IsMatch   = ExpressionManager.CheckIndicatorExpression(formula);
                    result.IsSuccess = true;
                }
                catch (Exception ex)
                {
                    result.IsSuccess    = false;
                    result.ErrorMessage = ex.ToString();
                }
            }
            else
            {
                result.IsSuccess    = false;
                result.ErrorMessage = "no reecords returned";
            }

            return(result);
        }
Exemple #2
0
        public List <ScanResult> GetScanMatchList(int shareId, Scan scan)
        {
            List <ScanResult> matchList = new List <ScanResult>();

            //this.GetProfitSettings(scan, shareId);

            var loadStart = DateHelper.DateToInt(DateHelper.IntToDate(scan.StartDate).AddDays(OFFSET_DAY * (-1)));

            int?verifyEnd = null;

            if (scan.EndDate.HasValue)
            {
                verifyEnd = DateHelper.DateToInt(DateHelper.IntToDate(scan.EndDate.Value).AddDays(VERIFY_DAY));
            }

            LoadIndicators(shareId, loadStart, verifyEnd);

            ExpressionManager em = new ExpressionManager(this.Indicators, 0);

            for (int index = 0; index < this.Indicators.Length; index++)
            {
                if (this.Indicators[index].TradingDate >= scan.StartDate &&
                    (this.Indicators[index].TradingDate <= scan.EndDate.Value || !scan.EndDate.HasValue))
                {
                    ExpressionManager.CurrentIndex = index;
                    if (ExpressionManager.CheckIndicatorExpression(scan.Rule.Formula))
                    {
                        ScanResult result = new ScanResult();

                        result.MatchIndicator = this.Indicators[index];

                        result.Verification = GetVerification(index);

                        matchList.Add(result);
                    }
                }
            }

            return(matchList);
        }